akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//

using namespace std;

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

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0}; //次に行くところ
int dx[] = {0,1}; //上に同じ


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

  ll n,cnt = 0;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++){
    cin >> l[i];
  }
  for (int i = 0; i < n; i++){
    for (int j = i+1; j < n; j++){
      for (int k = j+1; k < n; k++){
        if (l[i] != l[j] && l[j] != l[k] && l[k] != l[i] && max({l[i],l[j],l[k]}) < (l[i]+l[j]+l[k])-max({l[i],l[j],l[k]})){
          cnt++;
        }   
      }
    }
  }
  
  cout << cnt << '\n';
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
  
  return 0;
}

Measured memory_bytes: 3672
*r,=c=[0]*9**6
_,*z=[[*map(int,t.split())]for t in open(0)]
for y,x in z:r[y]+=1;c[x]+=1
h,w=max(r),max(c)
print(h+w-(r.count(h)*c.count(w)==sum(h+w==r[y]+c[x]for y,x in z)))

Measured memory_bytes: 74344
#include <iostream>
#include <string>
#include <stack>

using namespace std;

int main(){
	int x, y, n, area;
	int d;
	y = 600;
	area = 0;
	while (cin >> d){
		n = y / d;
		for (int i = 1; i < n; i++){
			area += d * ((d * i) * (d * i));

		}
		cout << area << endl;
		area = 0;
	}
	return 0;
}


Measured memory_bytes: 3008
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W
// int binary_search(int key) {
//     int ng = -1;
//     int ok = (int)a.size();
//     while(abs(ok - ng) > 1) {
//         int mid = (ok + ng) / 2;
//         if(isOK(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }
bool docheck(vector<pair<int, bool> > s) {
    if((s[0].second && s[1].second && s[2].second) ||
    (s[3].second && s[4].second && s[5].second) ||
    (s[6].second && s[7].second && s[8].second) ||
    (s[0].second && s[3].second && s[6].second) ||
    (s[1].second && s[4].second && s[7].second) ||
    (s[2].second && s[5].second && s[8].second) ||
    (s[0].second && s[4].second && s[8].second) ||
    (s[2].second && s[4].second && s[6].second) ){
        return true;
    }
    return false;
}
int main() {
    vector<pair<int,bool> > sheet(9);
    for(size_t i = 0; i < 9; i++) {
        cin >> sheet[i].first;
        sheet[i].second = false;
    }
    int N;
    cin >> N;
    string ans =  "No";
    for(size_t i = 0; i < N; i++) {
        int b;cin >> b;
        for(size_t j = 0; j<9; j++){
            if(sheet[j].first == b){
                sheet[j].second = true;
                if(docheck(sheet)){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
        
    }
    cout << "No" << endl;
}

Measured memory_bytes: 888
n=int(input())
w=str(input())
a=[]
a.append(w)
for i in range(1,n):
  x=w[len(w)-1]
  w=str(input())
  if x!=w[0] or w in a:
    print("No")
    exit()
  a.append(w)

print("Yes")

Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
#define pii pair <int , int > 
#define pll pair < ll , ll >
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	string s ;
  	cin >> s ;
  sort(s.begin() , s.end());
  if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) cout << "Yes" ;
  else cout << "No" ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int BIG = 2e9 + 55;

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

    int x, y, a, b, c;

    cin >> x >> y >> a >> b >> c;

    vector<ll> r(a), g(b), no(c);

    for(auto &val : r) {
        cin >> val;
    }

    for(auto &val : g) {
        cin >> val;
    }

    for(auto &val : no) {
        cin >> val;
    }

    sort(r.begin(), r.end());
    sort(g.begin(), g.end());
    reverse(r.begin(), r.end());
    reverse(g.begin(), g.end());

    vector<pair<ll, int> > aa;

    for(int i = 0; i < x; i++) {
        aa.push_back(make_pair(r[i], 1));
    }

    for(int i = 0; i < y; i++) {
        aa.push_back(make_pair(g[i], 1));
    }

    for(auto val : no) {
        aa.push_back(make_pair(val, 0));
    }

    sort(aa.begin(), aa.end());
    reverse(aa.begin(), aa.end());

    ll res = 0;

    //cerr << "sz = " << (int)aa.size() << '\n';

    for(int i = 0, j = (int)aa.size() - 1; i < (int)aa.size(); i++) {
        if(aa[i].second) {
            continue;
        }

        while(i < j && (aa[j].second == 0)) {
            j--;
        }

        if(i >= j) {
            continue;
        }

        swap(aa[i].second, aa[j].second);
    }

    for(int i = 0; i < (int)aa.size(); i++) {
        if(aa[i].second) {
            res += aa[i].first;
        }
    }

    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 12396
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
	int a[20][20];
	for(int i = 0;i < 20;i++){
		for(int j = 0;j < 20;j++){
			a[i][j] = 1000;
		}
	}
	for(int i = 5;i < 15;i++){
		for(int j = 5;j < 15;j++){
			a[i][j] = 0;
		}
	}
	int x, y, size;
	char b, c;
	int count = 0, hold = 0;
	while(cin >> x >> b >> y >> c >> size){
		int X = x+5, Y = y+5;
		if(size == 1){
			a[Y][X]++;
			a[Y+1][X]++;
			a[Y][X+1]++;
			a[Y-1][X]++;
			a[Y][X-1]++;
		}
		else if(size == 2){
			a[Y][X]++;
			a[Y+1][X]++;
			a[Y][X+1]++;
			a[Y-1][X]++;
			a[Y][X-1]++;
			a[Y+1][X+1]++;
			a[Y-1][X+1]++;
			a[Y-1][X-1]++;
			a[Y+1][X-1]++;
		}
		else if(size == 3){
			a[Y][X]++;
			a[Y+1][X]++;
			a[Y][X+1]++;
			a[Y-1][X]++;
			a[Y][X-1]++;
			a[Y+1][X+1]++;
			a[Y-1][X+1]++;
			a[Y-1][X-1]++;
			a[Y+1][X-1]++;
			a[Y-2][X]++;
			a[Y][X-2]++;
			a[Y+2][X]++;
			a[Y][X+2]++;
		}
		/*for(int i = 5;i < 15;i++){
			for(int j = 5;j < 15;j++){
				cout << a[i][j];
			}
			cout << endl;
		}
		cout << endl;*/

		count = 0, hold = 0;
		for(int i = 5;i < 15;i++){
			for(int j = 5;j < 15;j++){
				if(a[i][j] == 0) count++;
				else if(hold < a[i][j]) hold = a[i][j];
			}
		}

	}
	cout << count << endl;
	cout << hold << endl;
	return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    int d,t,s;
    cin >> d >> t >> s;
    if(d <= s*t) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

typedef vector<double> vec;
typedef vector<vec> mat;
const double eps = 1e-8;

mat mul(const mat& A, const mat& B)
{
  mat C(A.size(), vec(B[0].size()));
  for(int i = 0; i < (int)A.size(); i++) {
    for(int j = 0; j < (int)B.size(); j++) {
      for(int k = 0; k < (int)B[0].size(); k++) {
	C[i][k] += A[i][j] * B[j][k];
      }
    }
  }
  return C;
}

mat pow(mat A, int n)
{
  mat B(A.size(), vec(A.size()));
  for(int i = 0; i < (int)A.size(); i++) B[i][i] = 1;
  while(n > 0) {
    if(n & 1) B = mul(B, A);
    A = mul(A, A);
    n >>= 1;
  }
  return B;
}

double det(mat A) {
  const int n = A.size();
  double D = 1;
  for(int i = 0; i < n; i++) {
    int pivot = i;
    for(int j = i+1; j < n; j++) {
      if(abs(A[j][i]) > abs(A[pivot][i])) pivot = j;
    }
    swap(A[pivot], A[i]);
    D *= A[i][i] * (i != pivot ? -1 : 1);
    if(abs(A[i][i]) < eps) break;
    for(int j = i+1; j < n; j++) {
      for(int k = n-1; k >= i; k--) {
	A[j][k] -= A[i][k]*A[j][i] / A[i][i];
      }
    }
  }
  return D;
}

int Rank(mat A) {
  const int n = A.size(), m = A[0].size();
  int r = 0, c = 0;
  for(int i = 0; i < n; i++) {
    int pivot = -1;
    while(c < m) {
      for(int j = i; j < n; j++) {
	if(abs(A[j][c]) > eps) { pivot = j; break; }
      }
      if(~pivot) break;
      c++;
    }
    if(c >= m) break;
    r++;
    swap(A[pivot], A[i]);
    double a = A[i][c];
    for(int j = 0; j < m; j++) A[i][j] /= a;
    for(int j = i+1; j < n; j++) {
      double aa = A[j][c];
      for(int k = 0; k < m; k++) A[j][k] -= aa*A[i][k];
    }
    c++;
  }
  return r;
}

int N, M;
mat A;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> M;
  A.resize(N, vec(M));
  rep(i, M) {
    int s, t;
    cin >> s >> t;
    --s, --t;
    A[s][i]++;
    A[t][i]--;
  }

  cout << M - Rank(A) << endl;

  return 0;
}

Measured memory_bytes: 26348
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N,M;
    cin >> N >> M;
    ll ans = min(N,M/2);
    if(N<=M/2){
        M-=N*2;
        ans+=M/4;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int n = Integer.parseInt(str);
		int answer = 0;
		answer = n*800 - (n/15)*200;
		System.out.println(answer);
	}

}


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

#define Debug(x) x
typedef int regular_int;
// #define int ll
typedef long long ll;

map <int, int > m;

regular_int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(12) << fixed;

	int n, N;
	cin >> n;
	N = 1 << n;
	for (int i = 0; i < N; ++i) {
        int x;
        cin >> x;
        m[x]++;

	}

	vector<int > y, cnt(m.size());
	for (auto x: m){
        y.push_back(x.second);
	}
	reverse(y.begin(), y.end());
	cnt[0]++;
	for (int i = 0; i < n; ++i) {
        int pos = 0, sum = 0;
        while (pos < (int )y.size()){
            int z = cnt[pos];
            cnt[pos] = min(y[pos], cnt[pos] + sum);
            sum -= cnt[pos] - z;
            sum += z;
            ++pos;
        }
        if (sum > 0){
        cout << "No" << endl;
        return 0;
        }

	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 14840
using System;

class Problem
{
  public static void Main()
  {
    var inputs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    int A = inputs[0], B = inputs[1];
    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) Console.WriteLine("Possible");
    else Console.WriteLine("Impossible");
  }
}


Measured memory_bytes: 11220
/**
 *    SATAR ALLAH
 *
**/
#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()


const int N=100;
int n,m;
string grid[N];
bool is_valid(int r,int c){

  return (r<n&&c<m&&r>=0&&c>=0);
 }

bool check(int r,int c){

    bool ok=false;
    if(is_valid(r+1,c))
        ok|=(grid[r+1][c]=='#');
    if(is_valid(r,c+1))
        ok|=(grid[r][c+1]=='#');
    if(is_valid(r-1,c))
        ok|=(grid[r-1][c]=='#');
    if(is_valid(r,c-1))
        ok|= (grid[r][c-1]=='#');


        return ok;
}
int main()
{


     cin>>n>>m;


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


        for(int i=0;i<n;i++){


             for(int j=0;j<m;j++){
                if(grid[i][j]=='#')
                 if(!check(i,j))
                    return cout<<"No",0;
             }
        }

        cout<<"Yes";

    return 0;
}


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

int i32_InputN = 0;

void dfs(char str_temp[11], char mx) {
    char str_ans[11];
    strcpy(str_ans, str_temp);
    if (strlen(str_ans) == i32_InputN) {
        printf("%s\n", str_ans);
    }
    else {
        char temp;
        int i32_Place = 0;
        for (temp = 'a'; temp <= mx; temp++) {
            //char *str_temp = str_ans;
            while (str_ans[i32_Place] != '\0') {
                i32_Place++;
            }
            str_ans[i32_Place] = temp;
            str_ans[i32_Place + 1] = '\0';
            dfs(str_ans, ((temp == mx) ? (char)(mx + 1) : mx));
            str_ans[i32_Place] = '\0';
        }
    }
}

int main() {
    
    /* Standard Input */
    (void)scanf("%d", &i32_InputN);

    dfs("", 'a');

    return 0;
}

Measured memory_bytes: 1408
def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input())-1)

    answer = -1
    counter = 0

    i = 0
    while True:
        counter += 1
        if i == a[i]:
            answer = -1
            break
        elif a[i] == 1:
            answer = counter
            break
        elif a[i] == 0:
            answer = -1
            break
        else:
            temp = a[i]
            a[i] = 0
            i = temp

    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 80404
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int n, k;
	cin >> n >> k;
 
	ll h[n];
	rep(i, n) cin >> h[i];
 
	ll INF = 1e13;
	ll c[n];
	rep(i, n) c[i] = INF;
	c[0] = 0;
 
	for(int i = 1; i < n; i++){
		for(int j = max(i-k, 0); j < i; j++){
			c[i] = min(c[i], c[j] + abs(h[j] - h[i]));
		}
	}
 
	cout << c[n-1] << endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int,input().split()))
A = [0] + A + [0]
for i in range(n+1):
  ans += abs(A[i+1]-A[i])

for i in range(1,n+1):
  print(ans-abs(A[i+1]-A[i])-abs(A[i]-A[i-1])+abs(A[i+1]-A[i-1]))



Measured memory_bytes: 62088
from operator import itemgetter
import sys
input = sys.stdin.readline
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]
ab = sorted(ab,key = itemgetter(1))
ab.insert(0,[0,0])
flag = 0
flag_2 = 0
for j in range(1,n+1):
  flag += (ab[j][1]-ab[j-1][1])-ab[j][0]
  if flag < 0:
    print("No")
    flag_2 = 1
    break
if flag_2 == 0:
  print("Yes")

Measured memory_bytes: 85596
#include<iostream>
using namespace std;
int main()
{
	int m,n,a[200005],sum=0;
	cin>>n;
	m=n%10;
	if(m==2||m==4||m==5||m==7||m==9)cout<<"hon";
	if(m==0||m==1||m==6||m==8)cout<<"pon";
	if(m==3)cout<<"bon";
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


// ----------------------------------------------------------------------------

vector<int> dice(vector<int> faces,char com){
  vector<int> temp(7);
  if(com == 'N'){
    temp[1] = faces[2];
    temp[2] = faces[6];
    temp[3] = faces[3];
    temp[4] = faces[4];
    temp[5] = faces[1];
    temp[6] = faces[5];
  }else if(com == 'W'){
    temp[1] = faces[3];
    temp[2] = faces[2];
    temp[3] = faces[6];
    temp[4] = faces[1];
    temp[5] = faces[5];
    temp[6] = faces[4];
  }else if(com == 'S'){
    temp[1] = faces[5];
    temp[2] = faces[1];
    temp[3] = faces[3];
    temp[4] = faces[4];
    temp[5] = faces[6];
    temp[6] = faces[2];
  }else if(com == 'E'){
    temp[1] = faces[4];
    temp[2] = faces[2];
    temp[3] = faces[1];
    temp[4] = faces[6];
    temp[5] = faces[5];
    temp[6] = faces[3];
  }else{
    temp[1] = faces[1];
    temp[2] = faces[4];
    temp[3] = faces[2];
    temp[4] = faces[5];
    temp[5] = faces[3];
    temp[6] = faces[6];
  }
  return temp;
}

bool issame(vector<int> a,vector<int> b){
  for(int i=1; i<=6; i++){
    if(a[i] != b[i]){
      return false;
    }
  }
  return true;
}


int main(){
  vector<int> D(7);
  for(int i=1; i<=6; i++){
    cin >> D[i];
  }
  string S;
  cin >> S;
  for(int i=0; i<S.size(); i++){
    D = dice(D,S[i]);
  }
  cout << D[1] << endl;
  return 0;
}



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

int const N = 100000;
ll const inf = 1e18;
int x[N + 1];
ll z[N + 1];

void no() { printf("-1\n"); exit(0); }

int main(){
	int n;
	scanf("%d", &n);
	f(i, 0, n + 1)scanf("%d", x + i);
	z[0] = 1;
	f(i, 1, n + 1)z[i] = min(z[i - 1] << 1, inf);
	ll t = 1;
	f(i, 0, n + 1){
		z[i] = min(z[i], t);
		t = min(t - x[i] << 1, inf);
	}
	t = 0;
	for (int i = n; i >= 0; --i){
		t = min(t + x[i], inf);
		z[i] = min(z[i], t);
	}
	f(i, 0, n)if (x[i] >= z[i])no();
	if (x[n] != z[n])no();
	ll an = 0;
	f(i, 0, n + 1)an += z[i];
	printf("%lld\n", an);
}

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

int main (void)
{
	int input1,input2;
	char op;
	
	do
	{
		scanf("%d %c %d",&input1,&op,&input2);
		if(op == '?')
		{
			break;
		}
		switch(op)
		{
		case '+':
			printf("%d\n",input1 + input2);
			break;
		case '-':
			printf("%d\n",input1 - input2);
			break;
		case '*':
			printf("%d\n",input1 * input2);
			break;
		case '/':
			printf("%d\n",input1 / input2);
			break;
		}
	}while(1);
	return 0;
}


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

int main()
{
    string s;
    cin>>s;

    string res;
    int size = s.size();

    for(int i=0; i<size; i++)
    {
        if(s[i] != 'B')
        {
            res.push_back(s[i]);
        }
        else
        {
            res = res.substr(0,res.size()-1);
        }
    }

    cout<<res<<endl;
}


Measured memory_bytes: 3620
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <functional>

const int INF = 1001001000;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

typedef pair<int,int> P;

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

int main(){

  int n;
  bool d[105];

  for( int i = 0; i < 105; ++i){
    d[i] = false;
  }

  cin >> n;
  for( int i = 0; i < n; ++i){
    int tmp;
    cin >> tmp;
    d[tmp] = true;
  }

  int ans = 0;
  for( int i = 0; i < 105; ++i){
    if( d[i]){
      ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N;
	int K, P;
	int i;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d%d", &K, &P);
		if( K%P == 0)
			printf("%d\n", P);
		else
			printf("%d\n", K%P);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt;
  int w[15],t[15];
  string s;
  while(1){
    cin>>n;
    if(n==0) break;
    cnt=0;
    for(int i=0;i<15;i++){
      w[i]=1;
      t[i]=0;
    }
    for(int i=0;i<n;i++){
      cin>>s;
      if(s[0]=='R'){
	t[0]=1;
	for(int j=1;j<8;j++){
	  w[j]=0;
	}
      }
      else if(s[0]=='F'){
	t[1]=1;
	for(int j=2;j<9;j++){
	  w[j]=0;
	}
      }
       else if(s[0]=='S'){
	 if(s[1]=='c'){
	   t[2]=1;
	   for(int j=3;j<10;j++){
	     w[j]=0;
	   }
	 }
	 else if(s[1]=='n'){
	   t[3]=1;
	   for(int j=4;j<11;j++){
	     w[j]=0;
	   }
	 }
	 else if(s[1]=='p'){
	   t[7]=1;
	   for(int j=8;j<15;j++){
	     w[j]=0;
	   }
	 }
       }
       else if(s[0]=='H'){
	 t[4]=1;
	 for(int j=5;j<12;j++){
	   w[j]=0;
	 }
       }
       else if(s[0]=='T'){
	 t[5]=1;
	 for(int j=6;j<13;j++){
	   w[j]=0;
	 }
       }
       else if(s[0]=='W'){
	 if(s[1]=='o'){
	   t[6]=1;
	   for(int j=7;j<14;j++){
	     w[j]=0;
	   }
	 }
	 else if(s[1]=='a'){
	   t[10]=1;
	   for(int j=11;j<15;j++){
	     w[j]=0;
	   }
	   for(int j=0;j<3;j++){
	     w[j]=0;
	   }
	 }
       }
       else if(s[0]=='P'){
	 t[8]=1;
	 w[0]=0;
	 for(int j=9;j<15;j++){
	   w[j]=0;
	 }
       }
      else if(s[0]=='A'){
	 t[9]=1;
	 w[0]=0;
	 w[1]=0;
	 for(int j=10;j<15;j++){
	   w[j]=0;
	 }
       }
      else if(s[0]=='D'){
	if(s[1]=='r'){
	  t[11]=1;
	  for(int j=12;j<15;j++){
	    w[j]=0;
	  }
	   for(int j=0;j<4;j++){
	    w[j]=0;
	  }
	}
	else if(s[1]=='e'){
	  t[12]=1;
	  for(int j=13;j<15;j++){
	    w[j]=0;
	  }
	   for(int j=0;j<5;j++){
	    w[j]=0;
	  }
	}
      }
      else if(s[0]=='L'){
	t[13]=1;
	w[14]=0;
	for(int j=0;j<6;j++){
	  w[j]=0;
	}
      }
      else if(s[0]=='G'){
	t[14]=1;
	for(int j=0;j<7;j++){
	  w[j]=0;
	}
      }
    }
    for(int i=0;i<15;i++){
      if(t[i]==1) cnt++;
    }
    if(cnt==1) cout<<"Draw"<<endl;
    else{
      for(int i=0;i<15;i++){
	if(t[i]==1){
	  if(w[i]==1){
	    if(i==0){
	      cout<<"Rock"<<endl;
	      break;
	    }
	    else if(i==1){
	      cout<<"Fire"<<endl;
	      break;
	    }
	    else if(i==2){
	      cout<<"Scissors"<<endl;
	      break;
	    }
	    else if(i==3){
	      cout<<"Snake"<<endl;
	      break;
	    }
	    else if(i==4){
	      cout<<"Human"<<endl;
	      break;
	    }
	    else if(i==5){
	      cout<<"Tree"<<endl;
	      break;
	    }
	    else if(i==6){
	      cout<<"Wolf"<<endl;
	      break;
	    }
	    else if(i==7){
	      cout<<"Sponge"<<endl;
	      break;
	    }
	    else if(i==8){
	      cout<<"Paper"<<endl;
	      break;
	    }
	    else if(i==9){
	      cout<<"Air"<<endl;
	      break;
	    }
	    else if(i==10){
	      cout<<"Water"<<endl;
	      break;
	    }
	    else if(i==11){
	      cout<<"Dragon"<<endl;
	      break;
	    }
	    else if(i==12){
	      cout<<"Devil"<<endl;
	      break;
	    }
	    else if(i==13){
	      cout<<"Lightning"<<endl;
	      break;
	    }
	    else if(i==14){
	      cout<<"Gun"<<endl;
	      break;
	    }
	  }
	}
	if(i==14) cout<<"Draw"<<endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod=1000000007;
constexpr ll INF=(1ll<<60);
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<typename T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}

int main(){
    ll a,b;cin>>a>>b;
    if(0<=a && a<=9 && 0<=b && b<=9) cout<<a*b<<endl;
    else cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 3592
H,W = map(int,input().split())
A = []
for h in range(H):
    a = input()
    if '#' in a:
        A.append(a)
A = [a for a in zip(*A) if '#' in a]
A = [a for a in zip(*A)]
for a in A:
    print(''.join(a))

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
const ll INF = LLONG_MAX / 2;
const int MOD = 1e9 + 7;

int N;
ll sz[2010], dp[2010][2010][2];
vector<int> G[2010];

void dfs_sz(int u) {
	sz[u] = 1;
	for (int v: G[u]) dfs_sz(v), sz[u] += sz[v];
}

void dfs(int u) {
	int n = 1;
	vector<vector<int> > a(n + 1, vector<int>(3));
	a[0][0] = 1;
	for (int v: G[u]) {
		dfs(v);
		vector<vector<int> > _a(n + sz[v] + 1, vector<int>(3));
		rep(x, n + 1) rep(y, 3) if (a[x][y])
			rep(dx, sz[v] + 1) rep(dy, 2) if (dp[v][dx][dy]) {
				int _x = x + dx, _y = y + dy;
				if (_x > n + sz[v]) continue;
				if (_y > 2) continue;
				_a[_x][_y] = (_a[_x][_y] + (ll)a[x][y] * dp[v][dx][dy]) % MOD;
			}
		a = _a;
		n += sz[v];
	}
	rep(x, n + 1) {
		dp[u][x][0] = (dp[u][x][0] + a[x][0]) % MOD;
		dp[u][x + 1][1] = (dp[u][x + 1][1] - a[x][0]) % MOD;
		dp[u][x][0] = (dp[u][x][0] + a[x][1] * 2) % MOD;
		dp[u][x + 1][1] = (dp[u][x + 1][1] - a[x][1]) % MOD;
		dp[u][x][0] = (dp[u][x][0] + a[x][2] * 2) % MOD;
	}
}

ll F[2010];

int main() {
	F[0] = 1;
	rep(x, 2001) F[x + 1] = F[x] * (x + 1) % MOD;
	cin >> N;
	for (int u = 1; u < N; u++) {
		int p; cin >> p, p--;
		G[p].pb(u);
	}
	dfs_sz(0), dfs(0);
	/*
	rep(u, N) {
		rep(x, N + 1) cout << u << ' ' << x << ' ' << dp[u][x][0] << endl;
	}
	rep(x, N + 1) cout << x << ' ' << dp[0][x][0] << endl;
	*/
	int ans = 0;
	rep(x, N + 1) {
		ans = (ans + (ll)dp[0][x][0] * F[N - x]) % MOD;
	}
	cout << (ans + MOD) % MOD << endl;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b + c || b == a + c || c == a + b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3608
S = input()
n = len(S)
k = 0
for i in range(1, n//2):
  T = S[:2*i]
  flag = 1
  for j in range(i):
    if T[j] != T[i+j]:
      flag = 0
  if flag == 1:
    k = 2*i
print(k)


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

int main(){
    int N; cin >> N;
    vector<int> P(N);
    for(int i=0;i<N;i++){
        cin >> P[i];
    }
    int cnt = 0;
    int min = P[0];
    for(int i=0;i<N;i++){
        if(min >= P[i]){
            cnt++;
        }
        if(min > P[i]){
            min = P[i];
        }
    }  
    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  int n; string s;
  int i;
  int ans = 1;

  cin >> n; cin >> s;

  rep(i,n-1){
      if(s[i] != s[i+1]){ans++;}
  }
  cout << ans << endl;

  return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,k,sum=0;
    cin>>a>>b>>c>>k;
    if(k>a) 
    {
        sum += a; k = k-a;
    }
    else
    {
        cout<<k; return 0;
    }
    if(k>0)
    {
        k = k-b;
    }
    if(k>c) 
    {
        sum -= c; k = k-c;
    }
    else
    {
        sum -= k ;
    }
    
    cout<<sum;
}

Measured memory_bytes: 3648
void main() {
  problem();
}

void problem() {
  auto N = scan!int;
  auto K = scan!int;

  void solve() {
    bool[int] snk;
    foreach(i; 1..N+1) {
      snk[i] = true;
    }

    foreach(_; 0..K) {
      auto d = scan!int;
      foreach(i; scan!int(d)) {
        snk[i] = false;
      }
    }

    int answer;
    foreach(key; snk.keys()) {
      if (snk[key] == true) answer++;
    }

    writeln(answer);
  }

  solve();
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

// -----------------------------------------------


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    ll n;

	cin >> n;

	ll a = n;
	ll b = 0;

	while (a) {
		b += a % 10;
		a /= 10;
	}

	if (n % b == 0) Out("Yes");
	else Out("No");
	
	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD!string;

	writeln(N[1] == N[2] && (N[0] == N[1] || N[2] == N[3]) ? "Yes" : "No");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define let const auto
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout<< (x) << '\n'

int main()
{
   cin.tie(0), ios::sync_with_stdio(false);
   long a;
   long b;
   cin >> a >> b;
   a -= 2;
   b -= 2;

   if (a < 0) {
      a = abs(a % 2);
   }
   if (b < 0) {
      b = abs(b % 2);
   }

   outl(a * b);
}



Measured memory_bytes: 256
#B
w = input()
dic = {chr(i+ord('a')): 0 for i in range(0, 26)}
for c in w:
    dic[c] += 1
#print(dic) #
result = 'No'
for i in range(26):
    if dic[chr(i+ord('a'))] % 2 != 0: break
else: result = 'Yes'
print(result)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define int long long
#define mod 1000000007
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
#define N 100005
int a[N];
int mul[N],inv[N];
int C(int x,int y)
{
	if(x<y) return 0;
	return mul[x]*inv[x-y]%mod*inv[y]%mod;
}
bool cmp(int x,int y)
{
	return x>y;
}
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n=read(),k=read();
	for(int i=1;i<=n;i++) a[i]=read();
	int ans=0;
	mul[0]=1;inv[1]=inv[0]=1;
	for(int i=1;i<=n;i++) mul[i]=mul[i-1]*i%mod;
	for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1;i<=n;i++) inv[i]=inv[i-1]*inv[i]%mod;
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		ans=(ans+C(i-1,k-1)*a[i])%mod;
	}
//	cout<<ans<<endl;
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		ans=(ans-C(i-1,k-1)*a[i])%mod;
	}
	ans=(ans+mod)%mod;
	cout<<ans<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



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

#define PI 3.141592653589793

int main()
{
	double a = 0, b = 0, c = 0, kakudo = 0, x = 0;
	double space, hight, length;

	scanf("%lf %lf %lf", &a, &b, &kakudo);

	kakudo = kakudo * PI / 180.0;
	hight = sin( kakudo ) * b;
	space = hight * a / 2;
	x = b * cos( kakudo );
	c = sqrt( hight * hight + ( a - x ) * ( a - x ) );
	length = a + b + c;
	printf("%f %f %f\n", space, length, hight);

	return 0;
}

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

typedef pair<int, int> pii;

const int MN = 200010;

int N, M;
vector<pii> seg;

struct BIT {
    vector<int> tree, lazy;
    void init() {
        tree = vector<int>(4*MN, 0);
        lazy = vector<int>(4*MN, 0);
    }
    void prop(int l, int r, int n) {
        if(l != r) {
            tree[2*n] += lazy[n];
            lazy[2*n] += lazy[n];
            tree[2*n + 1] += lazy[n];
            lazy[2*n + 1] += lazy[n];
            lazy[n] = 0;
        }
    }
    void upd(int a, int b, int d, int l, int r, int n) {
        if(b < l || r < a) return;
        if(a <= l && r <= b) {
            tree[n] += d;
            lazy[n] += d;
            return;
        }
        prop(l, r, n);
        int m = (l + r)>>1;
        upd(a, b, d, l, m, 2*n);
        upd(a, b, d, m + 1, r, 2*n + 1);
        tree[n] = min(tree[2*n], tree[2*n + 1]);
    }
    int quer(int a, int b, int l, int r, int n) {
        if(b < l || r < a) return 1e9;
        if(a <= l && r <= b) return tree[n];
        prop(l, r, n);
        int m = (l + r)>>1;
        int L = quer(a, b, l, m, 2*n);
        int R = quer(a, b, m + 1, r, 2*n + 1);
        return min(L, R);
    }
} bit;

int main() {
    scanf("%d %d", &N, &M);

    seg.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d %d", &seg[i].first, &seg[i].second);
        seg[i].first--;
        seg[i].second--;
    }

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

    bit.init();
    for(int i = M - 1; i >= 0; i--) {
        bit.upd(0, i, 1, 0, MN - 1, 1);
    }
    for(int i = 0; i < N; i++) {
        bit.upd(1, M, 1, 0, MN - 1, 1);
    }

    int pos = 0;
    while(pos < N && seg[pos].first == -1) {
        bit.upd(1, seg[pos].second, -1, 0, MN - 1, 1);
        pos++;
    }

    int ans = bit.quer(0, M, 0, MN - 1, 1);
    for(int i = 0; i < M; i++) {
        while(pos < N && seg[pos].first == i) {
            bit.upd(1, seg[pos].second, -1, 0, MN - 1, 1);
            pos++;
        }
        ans = min(ans, i + 1 + bit.quer(i + 1, M, 0, MN - 1, 1));
    }
    printf("%d", N - ans);
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  int A[100010], B[100010];
  for (int i = 0; i < N; i++)
    cin >> A[i];
  for (int i = 0; i < N; i++)
    cin >> B[i];
  int C[100010];
  for (int i = 0; i < N; i++)
    C[i] = A[i]-B[i];
  sort(C, C+N);
  int l = 0, r = N-1, ans = 0;
  ll diff = 0;
  while (C[l] < 0) {
    ans++;
    diff -= C[l];
    l++;
  }
  while (diff > 0 && r >= l) {
    ans++;
    diff -= C[r];
    r--;
  }
  if (diff <= 0)
    cout << ans << endl;
  else
    cout << -1 << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll a,b;
    cin>>a>>b;
    cout<<lcm(a,b)<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    for(int i=0; i<n; i++) {
      float x1 = sc.nextFloat();
      float y1 = sc.nextFloat();
      float x2 = sc.nextFloat();
      float y2 = sc.nextFloat();
      float x3 = sc.nextFloat();
      float y3 = sc.nextFloat();
      float a1 = 2*(x2-x1);
      float a2 = 2*(x3-x1);
      float b1 = 2*(y2-y1);
      float b2 = 2*(y3-y1);
      float c1 = x1*x1-x2*x2+y1*y1-y2*y2;
      float c2 = x1*x1-x3*x3+y1*y1-y3*y3;
      float xp = (b1*c2-b2*c1)/(a1*b2-a2*b1);
      float yp = (c1*a2-c2*a1)/(a1*b2-a2*b1);
      double r  = Math.sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1));
      System.out.println(String.format("%.3f %.3f %.3f", xp, yp, r));
    }
  }  
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = 0;
  if (c * 2 < a + b) {
    int t = min(x, y);
    ans += t * c * 2;
    x -= t;
    y -= t;
  }
  ans += min(x * a, x * c * 2) + min(y * b, y * c * 2);
  cout << ans << '\n';
}


Measured memory_bytes: 3572
s = int(input())


def func(n):
  if n % 2 == 0:
    return n / 2
  elif n % 2 == 1:
    return 3 * n + 1

candidate = [s]  
  
for i in range(2, 1000001):
  tmp = func(candidate[-1])
  if tmp in candidate:
    print(i)
    break
  else:
    candidate.append(tmp)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> Pp;

class UnionFind
{
    int *rank, *parent;
public:
    UnionFind(int n)
    {
        rank = new int[n];
        parent = new int[n];
        for(int i=0;i<n;++i){
            rank[i] = 0;
            parent[i] = i;
        }
    }

    int findSet(int x)
    {
        if(parent[x] != x)
        {
            parent[x] = findSet(parent[x]);
        }
        return parent[x];
    }

    bool same(int x, int y)
    {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y)
    {
        int root_x = findSet(x);
        int root_y = findSet(y);
        if(rank[root_x] < rank[root_y])
        {
            parent[root_x] = root_y;
        }
        else{
            if(rank[root_x] == rank[root_y])
            {
                ++rank[root_x];
            }
            parent[root_y] = root_x;
        }
    }
};

bool compareEdge(const Pp& e1, const Pp& e2)
{
    return e1.second < e2.second;
}

int craskal(const vector< Pp >& edges, int n)
{
    int count = 0, ans = 0;
    UnionFind UF(n);

    for(Pp e : edges)
    {
        if(!UF.same(e.first.first, e.first.second)){
            ans += e.second;
            UF.unite(e.first.first, e.first.second);
            ++count;
        }
        if(count >= n - 1) break;
    }
    return ans;
}

int main()
{
    int n, m, s, t, w;
    cin >> n >> m;
    vector<Pp> edges;
    for(int i=0;i<m;++i)
    {
        cin >> s >> t >> w;
        edges.push_back(make_pair(
            make_pair(s, t), w
        ));
        edges.push_back(make_pair(
            make_pair(t, s), w
        ));
    }
    sort(edges.begin(), edges.end(), compareEdge);
    cout << craskal(edges, n) << endl;
}



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

typedef long long ll;

int main(int argc, char* argv[])
{
  std::string s1, s2, s3;
  std::cin >> s1 >> s2 >> s3;

  std::cout << (char)(s1[0] - 32) << (char)(s2[0] - 32) << (char)(s3[0] - 32) << std::endl;

  return 0;
}


Measured memory_bytes: 512