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

int n, a[55], b[55];
bool num[55][55];
long long ans = (1LL << 51) - 2;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++) {
        scanf("%d", &b[i]);
    }
    auto chk = [&]() {
        memset(num, 0, sizeof(num));
        for (int i = 1; i <= 50; i++) if (ans >> i & 1) {
            for (int j = 0; j <= 50; j++) num[j][j % i] = 1;
        }
        for (int i = 0; i <= 50; i++) {
            num[i][i] = 1;
        }
       for (int i = 0; i <= 50; i++) {
            for (int j = 0; j <= 50; j++) {
                for (int k = 0; k <= 50; k++) {
                    num[j][k] |= num[j][i] & num[i][k];
                }
            }
        }
        for (int i = 0; i < n; i++) {
            if (!num[a[i]][b[i]]) return 0;
        }
        return 1;
    };
    if (!chk()) {
        printf("-1\n"); return 0;
    }
    for (int i = 50; i; i--) {
        ans ^= 1LL << i;
        if (!chk()) ans |= 1LL << i;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <string>
#include <functional>
#include <math.h>
#include <utility>
using namespace std;
int a,b,n;
bool road[16][16];
int dp[16][16];
int main()
{
	while(true){
		cin>>a>>b;if(a==0&&b==0)break;
		cin>>n;
		fill(road[0],road[16],false);
		for(int i=0;i<a;i++)dp[i][0]=1;
		for(int j=0;j<b;j++)dp[0][j]=1;
		for(int i=0;i<n;i++){
			int x,y;cin>>x>>y;
			x--;y--;
			road[x][y]=true;
			dp[x][y]=0;
			if(x==0)for(int s=y;s<b;s++)dp[0][s]=0;
			if(y==0)for(int s=x;s<a;s++)dp[s][0]=0;
		}
		for(int i=1;i<a;i++)
			for(int j=1;j<b;j++)
				if(!road[i][j])dp[i][j]=dp[i-1][j]+dp[i][j-1];
		cout<<dp[a-1][b-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int n;
	cin >> n;
	vector<ll> a(n);
	for (size_t i = 0; i < n; i++) {
		cin >> a[i];
	}

	multiset<ll> s;

	for (ll i = 0; i < n; ++i) {
		ll now = a[i];
		auto itr = s.lower_bound(now);
		if (itr != s.begin()) {
			--itr;
			s.erase(itr);
		}
		s.insert(now);
	}
	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 5760
#include <cstdio>
    #include <cstdlib>
    #include <cmath>
    #include <climits>
    #include <cfloat>
    #include <map>
    #include <utility>
    #include <set>
    #include <iostream>
    #include <memory>
    #include <string>
    #include <vector>
    #include <algorithm>
    #include <functional>
    #include <sstream>
    #include <complex>
    #include <stack>
    #include <queue>
    #include <iomanip>
    #include <array>
    #include <numeric>
    #include <regex>
    #include <bitset>
    #include <deque>

    using namespace std;
    typedef long long ll;
    typedef pair<int, int> p_ii;

    const int INF = 1e9;
    const double PI = acos(-1.0);
    const ll MOD = 1e9 + 7;

    int x[101], y[101], h[101];

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

        int rx, ry;
        ll res=-1;
        for (int i = 0; i <= 100; i++) {
            for (int j = 0; j <= 100; j++) {
                ll H=-1;

                for (int k = 0; k < n; k++) {
                    int tx=abs(x[k]-j);
                    int ty=abs(y[k]-i);
                    if(h[k]>0){
                        if(H==-1){
                            H=(ll)h[k]+ty+tx;
                        }
                        if(H!=(ll)h[k]+ty+tx){
                            H=-2;
                            break;
                        }
                    }
                }
                if(H==-2)continue;

                for (int k = 0; k < n; k++) {
                    if(h[k]==0){
                        int tx=abs(x[k]-j);
                        int ty=abs(y[k]-i);
                        ll dist=(ll)ty+tx;
                        if(H>dist){
                            H=-2;
                            break;
                        }
                    }
                }
                if(H==-2)continue;

                cout<<j<<" "<<i<<" "<<H<<endl;
                return 0;
            }
        }

        return 0;
    }

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

using namespace std;

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

  // left_b := i文字目よりも左にある黒の個数
  int left_b = 0;
  // right_b:= i文字目およびそれより右にある白の個数
  int right_w = count(s.begin(), s.end(), '.');
  int ans = left_b + right_w;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '.') {
      right_w--;
    } else {
      left_b++;
    }
    ans = min(ans, right_w+left_b);
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	int n, k;
	string s;
	cin >> n >> k >> s;

	int a[3] = { 0 };
	for (int i = 0; i < n - 1; i++) {
		if (s[i] == s[i + 1]) {
			a[0]++;
		}
		else if (s[i] == 'R') {
			a[1]++;
		}
		else {
			a[2]++;
		}
	}

	for (int i = 0; i < k; i++) {
		if ((a[1] > 0) && (a[2] > 0)) {
			a[1]--;
			a[2]--;
			a[0] += 2;
		}
		else if ((a[1] > 0) || (a[2] > 0)) {
			a[1]--;
			a[2]--;
			a[0]++;
		}
		else
		{
			break;
		}
	}
	cout << a[0] << endl;
	return 0;
}

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

using namespace std;

int const maxn = 1e5 + 5;
int nxt[maxn], lst[maxn];

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < (int)s.size(); ++i) {
        nxt[i] = i + 1, lst[i] = i - 1;
    }
    int i = 1;
    while (1) {
        if (lst[i] == -1) i = nxt[i];
        if (nxt[i] == (int)s.size()) break;
        if (s[lst[i]] != s[nxt[i]]) {
            ans++;
            nxt[lst[i]] = nxt[i];
            lst[nxt[i]] = lst[i];
            i = lst[i];
        }
        else i = nxt[i];
    }
    if (ans % 2 == 0) cout << "Second";
    else cout << "First";
    return 0;
}


Measured memory_bytes: 4560
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
#include<utility>
#include<set>
using namespace std;

vector<long int>r;
vector<long int>a;
vector<long int>b;
vector<long int>size;
vector<long int>ans;

long int n,m;

long int root(long int x){
  if(r.at(x)==x)return x;
  else{
    long int p=root(r.at(x));
    r.at(x)=p;
    return p;
  }
}

long int getsize(long int x){
  return size.at(root(x));
}

void conect(long int x, long int y){
  long int p=root(x);
  long int q=root(y);
  if(p==q)return;
  if(size.at(q)<size.at(p))swap(p,q);
  size.at(q)+=size.at(p);
  r.at(p)=q;
  size.at(p)=0;
  return;
}

bool notsame(long int x,long int y){
  if(root(x)!=root(y))return true;
  else return false;
}

int main(void){
  int i;
  cin >> n >> m;
  r=vector<long int>(n);
  a=vector<long int>(m);
  b=vector<long int>(m);
  size=vector<long int>(n,1);
  ans=vector<long int>(m+1,0);
  ans.at(m)=n*(n-1)/2;
  for(i=0;i<m;i++)cin >> a.at(i) >> b.at(i);
  for(i=0;i<n;i++)r.at(i)=i;
  for(i=m-1;i>-1;i--){
    if(notsame(a.at(i)-1,b.at(i)-1)){
      ans.at(i)=ans.at(i+1)-getsize(a.at(i)-1)*getsize(b.at(i)-1);
      conect(a.at(i)-1,b.at(i)-1);
    }else{
      ans.at(i)=ans.at(i+1);
    }
  }
  for(i=1;i<=m;i++)cout << ans.at(i) << endl;
}

Measured memory_bytes: 5248
#include <iostream>
#include <cstdio>
#include <string>
#include <map>
using namespace std;

map<char, string> convert_table;

void init() {
    convert_table['1'] = ".,!? ";
    convert_table['2'] = "abc";
    convert_table['3'] = "def";
    convert_table['4'] = "ghi";
    convert_table['5'] = "jkl";
    convert_table['6'] = "mno";
    convert_table['7'] = "pqrs";
    convert_table['8'] = "tuv";
    convert_table['9'] = "wxyz";
}

char convert(char c, int n) {
    n = (n-1) % convert_table[c].size();
    return convert_table[c][n];
}

int main() {
    init();
    int n;
    cin >> n; getchar();
    for (int i = 0; i < n; i++) {
        string s, t;
        getline(cin, s);
        char prev = s[0];
        int count = 1;
        for (int j = 1; j < s.size(); j++) {
            if (s[j] == prev) {
                count++;
            } else if (s[j] == '0') {
                if (prev == '0') {
                    continue;
                } else {
                    t.push_back(convert(prev, count));
                    prev = s[j];
                    count = 0;
                } 
            } else {
                prev = s[j];
                count = 1;
            }
        }
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<queue>

using namespace std;

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

class L{
	public:
	int a,c,t;
	L(int a,int c,int t):a(a),c(c),t(t){}
};

class S{
	public:
	int now;
	int p;
	S(int now,int p):now(now),p(p){}
	bool operator<(const S&a)const{
		return p>a.p;
	}
};

int main(){
	
	while(1){
		int n,m;
		cin>>n>>m;
		
		if(n==0)break;
		
		vector<L> load[111];
		
		rep(i,n){
			int a,b,c,t;
			cin>>a>>b>>c>>t;
			
			load[a].push_back(L(b,c,t));
			load[b].push_back(L(a,c,t));
		}
		
		
		int k;
		cin>>k;
		
		rep(pp,k){
			int aa,bb,cc;
			cin>>aa>>bb>>cc;
			
			priority_queue<S> que;
			que.push(S(aa,0));
			
			int visit[111]={0};
			while(1){
				if(que.empty())break;
				
				S u = que.top();
				que.pop();
				
				//printf("%d %d\n",u.now,u.p);
				
				if(u.now==bb){
					printf("%d\n",u.p);
					break;
				}
				
				if(visit[u.now]==1)continue;
				visit[u.now]=1;
				
				rep(i,load[u.now].size()){
					
					L e = load[u.now][i];
					
					if(cc==0){
						que.push(S(e.a, u.p+e.c));
					}else{
						que.push(S(e.a, u.p+e.t));
					}
				}
			}
		}
	}
}

Measured memory_bytes: 1104
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<list>
using namespace std;

int n;
bool my_search(int key, vector<int> v) {
	int up = n;
	int down = 0;
	while (down < up) {
		int mid = (up + down) / 2;
		if (v[mid] > key) {
			up = mid;
		}
		else if (v[mid] == key) {
			return true;
		}
		else {
			down = mid + 1;
		}
	}
	return false;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	sort(v.begin(), v.end());

	int q;
	cin >> q;
	int t;
	int cnt = 0;
	for (int i = 0; i < q; i++) {
		cin >> t;
		if (my_search(t, v)) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
char grid[1001][1001];
int solve(int n,int m)
{
    int dp[n+1][m+1];
    dp[n][m]=1;
    for(int i=n;i>=1;i--)
    {
        for(int j=m;j>=1;j--)
        {
            if(i==n && j==m)
            {
                continue;
            }
            if(grid[i][j]=='#')
            {
                dp[i][j]=0;
            }
            else dp[i][j] = (((i==n)?0:dp[i+1][j])+((j==m)?0:dp[i][j+1]))%mod;

        }
    }
    return dp[1][1];
}
int main() {
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>grid[i][j];
        }
    }
    cout<<solve(n,m);
}


Measured memory_bytes: 8472
-- | Main entry point to the application.
module Main where

import Control.Applicative
import Control.Monad
import Data.List
import Debug.Trace
import Text.Printf

rInt :: String -> Int
rInt str = read str :: Int

-- | The main entry point.
main :: IO ()
main = do
    [a, b] <- (map rInt . words) <$> getLine
    printf "%d %d\n" (a * b) (a * 2 + b * 2)

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

void nope()
{
    printf("0\n");
    exit(0);
}

int n;

long long lew[1000007];
long long pra[1000007];

long long mod=1000000007;

long long dol[1000007];
long long gor[1000007];

long long wyn=1;

int main()
{
    scanf("%d", &n);
    for (int i=1; i<=n; i++)
        scanf("%lld", &lew[i]);
    for (int i=1; i<=n; i++)
        scanf("%lld", &pra[i]);
    lew[0]=0;
    pra[n+1]=0;
    for (int i=1; i<=n; i++)
        if (lew[i]<lew[i-1])
            nope();
    for (int i=n; i; i--)
        if (pra[i]<pra[i+1])
            nope();
    for (int i=1; i<=n; i++)
    {
        dol[i]=1;
        gor[i]=1000000000;
    }
    for (int i=1; i<=n; i++)
    {
        if (lew[i]>lew[i-1])
        {
            dol[i]=max(dol[i], lew[i]);
            gor[i]=min(gor[i], lew[i]);
        }
        else
        {
            gor[i]=min(gor[i], lew[i]);
        }
    }
    for (int i=n; i; i--)
    {
        if (pra[i]>pra[i+1])
        {
            dol[i]=max(dol[i], pra[i]);
            gor[i]=min(gor[i], pra[i]);
        }
        else
        {
            gor[i]=min(gor[i], pra[i]);
        }
    }
    for (int i=1; i<=n; i++)
        if(gor[i]<dol[i])
            nope();
    for (int i=1; i<=n; i++)
        wyn=((gor[i]-dol[i]+1)*wyn)%mod;
    printf("%lld\n", wyn);
    return 0;
}


Measured memory_bytes: 3328
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int P = sc.nextInt(), Q = sc.nextInt(), R = sc.nextInt();
    System.out.println(P + Q + R - Math.max(Math.max(P, Q), R));
  }
}

Measured memory_bytes: 21844
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

h, w, k = ril()
ls = rss(h)
res = []
count = 0
first = -1
for i, s in enumerate(ls):
    if '#' in s:
        row = []
        l = 0
        for j in range(w):
            l += 1
            if s[j] == '#':
                count += 1
                row += [count] * l
                l = 0
        row += [count] * (w - len(row))
        if first == -1:
            first = i
    else:
        if len(res) > 0:
            row = res[-1]
        else:
            row = None
    res.append(row)
for i in range(h):
    if res[i] is None:
        res[i] = res[first]
for row in res:
    print(*row)

Measured memory_bytes: 45932
n = int(input())
s = list(input())

tmplist = ['A', 'B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
result = ''

for i in range(len(s)):
    tmp = tmplist.index(s[i])
    if tmp + n < 26:
        result += tmplist[tmp + n]
    else:
        result += tmplist[tmp + n - 26]

print(result)

Measured memory_bytes: 3064
n,m=map(int,input().split())
i=0
listA=[]
listb=[]
for i in range(n):
    listA.append(list(map(int,input().split())))
for i in range(m):
	listb.append(int(input()))
for i in range(n):
  sum=0
  for j in range(m):
    sum += listA[i][j]*listb[j]
  print(sum)




Measured memory_bytes: 6008
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    vector<int> color(3);
    for (int i = 0; i < 3; i++)
    {
        cin >> color[i];
    }
    sort(color.begin(), color.end());
    int cnt = 0;
    for (int i = 0; i < 3 - 1; i++)
    {
        if (color[i] != color[i + 1])
        {
            cnt++;
        }
    }
    cout << cnt + 1 << endl;
    return (0);
}

Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let hist = Array.make 100002 0 in
    for i = 1 to n do
        Scanf.scanf " %d" (fun a ->
            hist.(a    ) <- hist.(a    ) + 1;
            hist.(a + 1) <- hist.(a + 1) + 1;
            hist.(a + 2) <- hist.(a + 2) + 1;
       )
    done;
    Array.fold_left max 0 hist |> Printf.printf "%d\n"
)

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

using namespace std;

string s;
unordered_map <char, int> m;

int main() {
  cin >> s;
  int n = s.length();
  long long ans = n * 1LL * (n - 1) / 2 + 1;
  for (auto z : s) {
    ans -= m[z];
    m[z]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i <= max_i; i++)
using namespace std;
typedef long long ll;

int main() {
  int N; cin >> N;
  int A[N+1]; REP(i,N+1) cin >> A[i];
  int B[N]; REP(i,N) cin >> B[i];
  ll ans = 0;
  REP(i, N) {
    int left = min(A[i], B[i]);
    ans += left;
    A[i] -= left;
    B[i] -= left;

    int right = min(A[i + 1], B[i]);
    ans += right;
    A[i + 1] -= right;
    B[i] -= right;
  }
  cout << ans << endl;
  return 0;
}


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

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

    int A, B;
    cin >> A >> B;

    int ans = 0;
    for(int i = A; i <= B; ++i){
        int s = i % 10 , t = i / 10000 % 10;
        int u = i / 10 % 10 , v = i / 1000 % 10;
        if ( s == t && u == v ) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P ,ll> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9)+7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(5e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, a, cnt = 0;
    cin >> n;
    REP(i,n){
        cin >> a;
        while(a % 2 == 0){
            cnt++;
            a /= 2;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
        FastIO

        int s,w;
        cin>>s>>w;
        if(w>=s)
        	cout<<"unsafe";
        else
        	cout<<"safe";
        return 0;

    }

Measured memory_bytes: 3668
// code author: Dhruva Mahajan
 
// Ideas are cheap, execution is everything.
 
#include<bits/stdc++.h> 
using namespace std;
 
#define ll long long  
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define testcase(t) int t;cin>>t;while(t--)
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))

int main(){
	
	fastio;

	ll h, cnt=1;
	cin>>h;

	while(h!=1){
		h/=2;
		cnt++;
	}

	cout<<(ll)pow(2, cnt)-1<<endl;

	
	
	return 0;
}

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

using namespace std;
using ll = long long;
using p = pair<int,int>;
int main() {
  int a; cin >> a;
  int ans = 0;
  ans = a + a * a + a * a * a;
  cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int p, q, r; cin >> p >> q >> r;
    int max_flight = max(p, max(q, r));
    
    cout << p + q + r - max_flight << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.lang.management.MemoryUsage

fun main(){
    val n = readLine()!!.split(" ")[0].toInt()
    val l = readLine()!!.split(" ").map { it.toInt() }.sorted()
    val ll = mutableListOf<Int>()
    val kaisuu = mutableListOf<Int>()
    ll.add(l[0])
    kaisuu.add(1)
    for (i in 1 until n){
        if (l[i] == l[i-1]){
            val size = ll.size - 1
            kaisuu[size]++
        } else {
            ll.add(l[i])
            kaisuu.add(1)
        }
    }
    val m = ll.size
    var ans = 0
    for (i in 0 until m){
        for (j in i+1 until m){
            val total = ll[i] + ll[j]
            for (k in j+1 until m){
                if (total > ll[k]) {
                    ans += kaisuu[i] * kaisuu[j] * kaisuu[k]
                }
            }
        }
    }
    println(ans)
}

Measured memory_bytes: 41132
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <bitset>  
using namespace std;

//======================================================
#define for1(i,n)  for (int i = 0; i < (int)(n); ++i)
#define for2(i,n)  for (int i = 1; i <=(int)(n); ++i)
#define forr1(i,n)  for (int i = n - 1 ;i <= 0; --i)
#define forr2(i,n)  for (int i = n  ;i < 0; --i)
#define all(v)	   ((v).begin()), ((v).end())
#define allr(v)	   ((v).rbegin()), ((v).rend())
#define clr(v,d)   memset(v, d, sizeof(v))
#define ull        unsigned long long
#define MP(a,b)	   make_pair(a,b)
#define S          second
#define F          first
#define PI         3.14159265359
#define ll         long long
#define sz(v)	   v.size()
#define pb         push_back
#define pp         pop_back
#define bgn        begin
#define N          100000+5
#define	MOD        1e9+7
#define inf        1e18
//======================================================
int dx[] = { 0,  0, 1, -1 ,  1,  -1,  1,  -1 };
int dy[] = { 1, -1, 0,  0 , -1,   1,  1,  -1 };
//======================================================
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ull a, ull b, ull ret = 1LL) {
	while (b--) ret = (ret * a);
	return ret;
}
//======================================================



int weights[100+9];
long long benefit[100+9];
int n , kpWeight;
long long dp[100 + 9][100000 + 9];

long long  knapSack(int index , int reminderWeight)
{
	if (index == n)
		return 0;

	if (dp[index][reminderWeight] != -1)
	{
		return dp[index][reminderWeight];
	}

	long long leave = knapSack(index + 1, reminderWeight);

	long long take = 0;
	if (reminderWeight >= weights[index])
	{
		take = benefit[index] + knapSack(index + 1, reminderWeight - weights[index]);
	}
	return dp[index][reminderWeight] = max(leave, take);
}

int main()
{
	
	cin >> n >> kpWeight;
	for (int i = 0; i < n; i++)
	{
		int a;
		long long b;
		cin >> a >> b;
		weights[i] = a;
		benefit[i] = b;
	}
	for (int i1 = n - 1; i1 >= 0; i1--)
	{
		for (int i2 = 0; i2 <= kpWeight; i2++)
		{
			if (i2 >= weights[i1])
			{
				dp[i1][i2] = max(benefit[i1] + dp[i1 + 1][i2 - weights[i1]], dp[i1 + 1][i2]);

			}
			else
			{
				dp[i1][i2] = dp[i1 + 1][i2];

			}
		}
	}
	cout << dp[0][kpWeight];
}



Measured memory_bytes: 81272
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
bool isprime(int n){
	for(int i=2;i*i<=n;i++){
		if(n%i==0){
			return false;
		}
	}
	return true;
}

signed main(){
	int n,k,r,s,p;
	string t;
	cin>>n>>k>>r>>s>>p>>t;

	int ans=0;

	for(int i=0;i<k;i++){
		char tmp='7';
		int f=0;
		for(int j=i;j<n;j+=k){
			// cout<<j<<' '<<ans<<endl;

			if(tmp==t[j]){
				f=1-f;
				tmp=t[j];
				if(f)continue;
			}else{
				f=0;
			}
			
			if(t[j]=='r') ans+=p;
			else if(t[j]=='s') ans+=r;
			else if(t[j]=='p') ans+=s;

			tmp=t[j];
			
		}
	}
	cout<<ans<<endl;



	return 0;
}



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n, m, k;
const int N = 2e5 + 5;
int a[N], b[N];
int ai, bi, cnt;

int main() {
    cin >> n >> m >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }
    while (ai < n && k >= a[ai]) {
        k -= a[ai];
        ++ai;
        ++cnt;
    }
    while (bi < m && k >= b[bi]) {
        k -= b[bi];
        ++bi;
        ++cnt;
    }
    int res = cnt;
    --ai;
    while (bi < m && ai >= 0) {
        k += a[ai];
        --cnt;
        --ai;
        while (bi < m && k >= b[bi]) {
            k -= b[bi];
            ++cnt;
            ++bi;
        }
        res = max(res, cnt);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5136
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
  else cout << "Yes" << endl;
return 0;
}

Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("test.txt","r",stdin);
	ll inf=1ll<<60;
	ll n,W;
	cin>>n>>W;
	ll w[n+1],v[n+1];
	for(ll i=1;i<=n;i++){
		cin>>w[i]>>v[i];
	}
	ll dp[n+1][100005];
	for(ll i=0;i<=n;i++)
	{
		for(ll j=0;j<=100005;j++)
			dp[i][j]=inf;
	}
	dp[0][0]=0;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=0;j<=100005;j++)
		{
			dp[i][j]=min(dp[i][j],dp[i-1][j]);
			if(v[i]<=j)
				dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i][j]);
		}
	}
	ll ans=0;
	for(ll i=0;i<=100002;i++)
	{
		//cout<<dp[n][i]<<" ";
		if(dp[n][i]<=W)
			ans=i;
	}
	//cout<<endl;
	//cout<<dp[n][17]<<endl;
	cout<<ans<<endl;




}

Measured memory_bytes: 79232
N,K=map(int,input().split())
p=list(map(int,input().split()))

res=0
s=sum(p[:K])
for i in range(N-K+1):
    res=max(res,(s+K)/2)
    if i!=N-K:
        s=s+p[i+K]-p[i]
print(res)

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

int t[100005];

int main()
{
	int n, c, k;
	scanf("%d%d%d", &n, &c, &k);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &t[i]);
	}

	sort(t, t + n);

	int ans = 0;

	for (int i = 0, r; i < n; i = r)
	{
		for (r = i + 1; r < n && r - i < c && t[r] <= t[i] + k; r++)
			;
		++ans;
	}
	printf("%d\n", ans);
}

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

string s;
int countx=0;

int main()
{
    cin>>s;
    char k=s[0];
    for(int i=1; i<s.length(); i++)
    {
        if(s[i]!=k)  countx++;
        k=s[i];
    }
    printf("%d\n",countx);
    return 0;
}

Measured memory_bytes: 512
def inpl(): return [int(i) for i in input().split()]
N = int(input())
A, B =[], [] 
for _ in range(N):
    a, b = inpl()
    A.append(a)
    B.append(b)
A = list(reversed(A))
B = list(reversed(B))
ans = 0
for i in range(N):
    ans += -(-(A[i]+ans)//B[i])*B[i]-(A[i]+ans)
print(ans)

Measured memory_bytes: 11844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <queue>

using namespace std;

#define MAX_W 30
#define MAX_H 60

int inf = 1<<29;

int W, H;
char s[MAX_H+1][MAX_W+1];
int dist[MAX_H+1][MAX_W+1][2];

struct state{
	int dist, y, x, foot;
	state(int a, int b, int c, int d):dist(a),y(b),x(c),foot(d){}
};

bool operator<(const state& a, const state& b){ return a.dist > b.dist; }

int solve(){
	for (int k = 0; k < 2; k++)
	{
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W ; j++)
			{
				dist[i][j][k] = inf;
			}
		}
	}
	priority_queue<state> Q;
	for (int j = 0; j < W; j++)
	{
		if(s[H-1][j] == 'S'){
			Q.push(state(0, H-1, j, 1));
			Q.push(state(0, H-1, j, 0));
		}
	}
	while(!Q.empty()){
		state tp = Q.top(); Q.pop();
		if(s[tp.y][tp.x] == 'T') return tp.dist;
		if(dist[tp.y][tp.x][tp.foot] != inf) continue;
		dist[tp.y][tp.x][tp.foot] = tp.dist;
		for (int dx = 1; dx <= 3; dx++)
		{
			for (int dy = -2; dy <= 2 ; dy++)
			{
				if(dx + abs(dy) <= 3){
					int ny= tp.y + dy;
					int nx= tp.x + (tp.foot?dx:-dx);
					int nf = 1-tp.foot;
					if(0 <= ny && ny < H && 0 <= nx && nx < W && s[ny][nx] != 'X' && dist[ny][nx][nf] == inf){
						int d;
						if(s[ny][nx] >= '0' && s[ny][nx] <= '9'){
							d = tp.dist + (s[ny][nx] - '0');
						}else{
							d = tp.dist;
						}
						Q.push(state(d, ny, nx, nf));
					}
				}
			}
		}
	}
	return -1;
}

int main(int argc, char const *argv[])
{
	while(1){
		cin >> W >> H;
		if(W == 0) break;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cin >> s[i][j];
			}
		}
		cout << solve() << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b,c;
    cin >> a >> b;
    for(int i=0;i<a.size();i++){
        if(a==b){
            cout << "Yes" << endl;
            return 0;
        }
        a=a[a.size()-1]+a.substr(0,a.size()-1);
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

#include <bits/stdc++.h>
using namespace std;


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define MN                           INT_MIN
#define MX                           INT_MAX

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

int32_t main()
{
	
	int n;
	cin >> n;
	int x[n],y[n];
	for(int i = 0;i<n;i++)
		cin >> x[i] >> y[i];
	int fact = 1;
	for(int i= 2;i<= n;i++)
		fact*= i;
	map<pair<int,int>,double> m;
	for(int i = 0;i< n-1;i++)
	{
		for(int j = i+1;j<n;j++)
		{
			double curlen = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
			m[{i, j}] = curlen;
		}
	}
	long double allsum = 0;
	for(auto x : m)
		allsum += x.second;
	long double ans =  (allsum * 2) / n;
	cout << std::setprecision(12) << ans << '\n';
}
	

Measured memory_bytes: 3852
using System;

namespace abc156_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NR = Console.ReadLine().Split(' ');
            int N = Convert.ToInt32(NR[0]);
            int R = Convert.ToInt32(NR[1]);
            if (N >= 10)
            {
                Console.WriteLine(R); 
            }
            else
            {
                Console.WriteLine(R+(100 * (10 - N)));
            }
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b;
  c = a * b;
  if (c % 2 == 0){
    cout << "Even" << endl;
  }
   else {
     cout << "Odd" << endl;
   }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

bool M(int a){
	return 1<=a&&a<=12;
}
signed main(){
	string S;cin>>S;
	int u=(S[0]-'0')*10+S[1]-'0';
	int d=(S[2]-'0')*10+S[3]-'0';
	
	if(M(u)&&M(d))cout<<"AMBIGUOUS"<<endl;
	else if(M(u))cout<<"MMYY"<<endl;
	else if(M(d))cout<<"YYMM"<<endl;
	else cout<<"NA"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <string>

using namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    string s;
    cin >> s;
    int segment = 1;
    for(int i =0; i < N - 1; i++){
        if(s.at(i) != s.at(i + 1)) segment ++;
    }
    // cout << segment << endl;
    int temp = segment/2;
    segment = max(1, segment - 2*K);
    cout << N - segment << endl;
}

Measured memory_bytes: 512
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Card{
    string suit;
    int value;
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    int K, N;
    int a;
    vector<int> h;
    
    cin >> N >> K;
    for (int i=0;i<N;i++) {
        cin >> a;
        h.push_back(a);
    }
    
    sort(h.begin(), h.end());
    
    int min = h[K-1] - h[0];
    for (int i=0;i<N-K+1;i++) {
        int temp = h[i+K-1] - h[i];
        if (temp<min) min = temp;
    }
    cout << min << endl;
    
    return 0;
}


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

int main() {
  char b;
  cin>>b;
  if(b=='A') cout<<'T'<<endl;
  if(b=='T') cout<<'A'<<endl;
  if(b=='C') cout<<'G'<<endl;
  if(b=='G') cout<<'C'<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int m=0,f=0,r=0,sum;
        String s="F";
        while(true) {
        	m=scan.nextInt();
        	f=scan.nextInt();
        	r=scan.nextInt();
        	if(m==-1 && f==-1 && r==-1) {
        		break;
        	}
        	sum=m+f;
        	if(m==-1 || f==-1 || sum<30) {
        		System.out.println("F");
        	}
        	else if(sum>=80) {
        		System.out.println("A");
        	}
        	else if(sum<80 && sum>=65) {
        		System.out.println("B");
        	}
        	else if(sum<65 && sum>=50) {
        		System.out.println("C");
        	}
        	else if(sum<50 && sum>=30) {
        		if(r>=50) {
        			System.out.println("C");
        		}
        		else{
        			System.out.println("D");
        		}
        	}
        }
    }
}



Measured memory_bytes: 26156
# F(a,b) = a xor (a+1) ,,, (b-1) xor b
# F(a,b) = F(0,a-1) xor F(0,b)
# 偶数nについて、 n xor (n+1) = 1

# f(n) == F(0,n)
def f(n):
	num = (n+1)//2	# n xor (n+1) の個数
	if num%2==0:
		if n%2==1:
			return 0
		else:
			return n
	else:
		if n%2==1:
			return 1
		else:
			return 1^n

a,b= list(map(int,input().split()))
print(f(a-1)^f(b))

Measured memory_bytes: 3060
'use strict'
function main(input) {
  input = input.trim()
  if (input.match(/^10+$/)) {
    console.log(10)
  } else {
    console.log(input.split('').reduce((r, c) => Number(r) + Number(c), 0))
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

typedef long long ll;


int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    string str;

    cin>>str;

    int len = str.size(), ans = 0;
    set<int> s;

    int i = 0, j = 1;
    while(true){
        if(i >= len || j >= len)
            break;
        if(str[i] == str[j] || i < 0){
            if(i >= 0)
                s.insert(i);
            i = j;
            j = j + 1;
        }
        else{
            if(s.count(i)){
                s.erase(i);
            }
            if(!s.empty()){
                i = *s.rbegin();
            }
            else
                i = -1;
            j++;
            ans += 2;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 5072
#include <bits/stdc++.h>
using namespace std;
const int mx = 112345;
int v[mx], dp[mx];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 1; i < n; i++) {
    dp[i] = abs(v[i]-v[i-1]) + dp[i-1];
    if (i > 1) dp[i] = min(dp[i], abs(v[i]-v[i-2]) + dp[i-2]);
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
vector<vector<int> >mark[8];
int main(){
    vector<pair<pair<string,int>,int> > a;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        string s;
        cin>>s;
        int p;
        cin>>p;
        a.push_back({{s,-p},i});
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        cout<<a[i].second<<endl;//' '<<a[i].first.first<<endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef struct node
{
  int key;
  node *prev, *next;
};

class list
{
private:
  node *nil;
  
public:
  void insert(int key);
  node* listSearch(int key);
  void deleteNode(node *t);
  void deleteFirst();
  void deleteLast();
  void deleteKey(int key);
  void init();
  void print();
};

void list::insert(int key){
  node *x = (node *)malloc(sizeof(node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

node* list::listSearch(int key){
  node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void list::deleteNode(node *t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void list::deleteFirst(){
  deleteNode(nil->next);
}

void list::deleteLast(){
  deleteNode(nil->prev);
}

void list::deleteKey(int key){
  deleteNode(listSearch(key));
}

void list::init(){
  nil = (node *)malloc(sizeof(node));
  nil->next = nil;
  nil->prev = nil;
}

void list::print(){
  node *cur = nil->next;
  int isf = 0;
  while(1){
    if(cur == nil){ break; }
    if(isf++ > 0){ printf(" "); }
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

int main(){
  int n, key;
  char com[20];
  list L;

  scanf("%d", &n);
  L.init();
  for(int i = 0; i < n; i++){
    scanf("%s%d", com, &key);
    if(com[0] == 'i'){ L.insert(key); }
    else if(com[6] == 'F'){ L.deleteFirst(); }
    else if(com[6] == 'L'){ L.deleteLast(); }
    else{ L.deleteKey(key); }      
  }
  L.print();
  
  return 0;
}



Measured memory_bytes: 33964
a,b = map(int, input().split())
#a,bの高さを求める
#b-aがbが何本目だったか示してる～
point_b = b-a
#bの本来の長さを出す
true_length_b = 0
for i in range (1,point_b+1):
        true_length_b += i
length_snow = true_length_b - b
print(length_snow)

Measured memory_bytes: 3316
from statistics import median

A, B, C = [int(x) for x in input().split()]

min_num = min(A, B, C)
mid_num = median([A, B, C])
high_num = max(A, B, C)

print(min_num * mid_num * -(-high_num // 2) -
      min_num * mid_num * (high_num - -(-high_num // 2)))


Measured memory_bytes: 10876
// Problem: A - Plural Form
// Contest: AtCoder - AtCoder Beginner Contest 179
// URL: https://atcoder.jp/contests/abc179/tasks/abc179_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable" 
//#pragma GCC diagnostic ignored "-Wformat"

using namespace std ;

#define   Pi     2*acos(0.0)
#define   LINF   1LL<<63
#define   ll     long long
#define   ull    unsigned long long
#define   pb     push_back
#define   mp     make_pair
#define   MAX    500006
#define   MAX1   10000008
#define   mem(a,v)   memset(a,v,sizeof(a))
#define   all(x) x.begin(),x.end()
#define   lcm(a, b)        ((a)*((b)/gcd(a,b)))
#define yes   cout<<"YES"<<endl
#define no   cout<<"NO"<<endl
#define buga  cout<<1<<endl
#define bugb  cout<<2<<endl
#define bugc  cout<<3<<endl
#define bugd  cout<<4<<endl
#define buge  cout<<5<<endl

void fastIO (){ios_base::sync_with_stdio(false);cin.tie(0); cout.precision(20);}

ll A[MAX];
ll B[MAX];
ll C[MAX];
vector< ll >V;
vector< ll >Ans;
vector< pair<ll,ll> >VP;
map< ll,ll >M;
vector<ll>prime;
bool mark[MAX1];
ll N=1e7;
void seive (){int limit = sqrt(N*1.0)+2;mark[1]=1;for (int i=4;i<=N;i+=2)mark[i]=1;prime.push_back(2);for (int i=3;i<=N;i+=2){if(!mark[i]){prime.push_back(i);if(i<=limit){for (int j=i*i;j<=N;j+=i*2)mark[j]=1;}}}}

/*
ll bin_pow(ll o, ll s) {
    if (s == 0) return 1;
    if (s == 1) return o % mod;
    ll d = bin_pow(o, s/2);
    d = (d * 1ll * d) % mod;
    if (s % 2 == 1)
        d = (d * 1ll * o) % mod;
    return d;
}
*/

int main ()
{
    fastIO();
    ll a,b,c,d,n,m,k,l,p,q,r,t,x,y;
    ll cnt=0,cntr=0,sum=0,ans=1,check=0;
    ll Max= 0,Max1=-1e18+1,Min=LINF;
    string s,s1,s3,s4;

    //cin>>n;
    cin>>s;
    a = s.size() - 1;
    if(s[a]== 115)s+="es";
    else s+='s';
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;

    int x = 0, y = 0;
    rep(i, n) {
        if (s[i] == 'a') {
            if (x < a + b) {
                cout << "Yes" << endl;
                x++;
            } else {
                cout << "No" << endl;
            }
        } else if (s[i] == 'b') {
            if (x < a + b && y < b) {
                cout << "Yes" << endl;
                x++; y++;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>

int main() {
    char s[4];
        scanf("%s", &s);
    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3])printf("Yes\n");
    else if(s[0] == s[2] && s[2] != s[1] && s[1] == s[3])printf("Yes\n");
    else if(s[0] == s[3] && s[3] != s[1] && s[1] == s[2])printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 128
N,M=map(int,input().split())
H=list(map(int,input().split()))
L=[0]*N
for i in range(M):
 A,B=map(int,input().split())
 if H[A-1]<=H[B-1]:
  L[A-1]+=1
 if H[B-1]<=H[A-1]:
  L[B-1]+=1
b=0
for i in L:
 if i==0:
  b+=1
print(b)

Measured memory_bytes: 84988
#include <stdio.h>
int main() {
	int n, d, x, a;
	scanf("%d%d%d", &n, &d, &x);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		x += (d - 1) / a + 1;
	}
	printf("%d\n", x);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
using namespace std;


#define abs(N) ((N>0)?N:-1*N)
#define lt(A,B) ((A>B)?B:A)
#define gt(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

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

	int el[n];
	for (int i = 0; i < n; ++i) {
		cin >> el[i];
	}
	int cnt=0;
	for (int i = 0; i < n; ++i) {
		for (int j = n-1; j >= i+1; --j) {
			if( el[j] < el[j-1]){
				int c;
				c = el[j];
				el[j] = el[j-1];
				el[j-1] = c;
				cnt++;
			}
		}
	}

	for (int i = 0; i < n; ++i) {
		if(i > 0) cout << " ";
		cout << el[i];
	}
	cout << endl;
	println(cnt);


	return 0;
}



Measured memory_bytes: 3056
#include <cstdio>
#include <cstring>
#include <cstdlib>
//#include <cmath>
//#include <string>
#include <algorithm>
//#include <vector>
#define INF (2000000000)
using namespace std;

//typedef vector<int> VI;
//typedef vector<int>::iterator VII;
//typedef vector<double> VD;
//typedef vector<double>::iterator VDI;

char map[2048][2048];
int dp[2048][2048];

int main()
{
	int n;
	while (scanf("%d", &n), n){
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < 1024; i++){
			for (int j = 0; j < 1024; j++){
				map[i][j] = '\0';
			}
		}
		
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				scanf(" %c", &map[i][j]);
			}
		}
		
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				if (map[i][j] == '.'){
					dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
				}
	//			printf("%d", dp[i][j]);
			}
	//		printf("\n");
		}
		
		int maxi = 0;
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				maxi = max(maxi, dp[i][j]);
			}
		}
		
		printf("%d\n", maxi);
	}
	
	return 0;
}

Measured memory_bytes: 21512