akhauriyash/Code-Regression huggingface dataset:
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions
int bs_cnt_less(vi& A, const int X, bool equal) {
    if (equal) return upper_bound(A.begin(), A.end(), X) - A.begin();
    else return lower_bound(A.begin(), A.end(), X) - A.begin();
}

int bs_cnt_greater(vi& A, const int X, bool equal) {
    if (equal) return A.end() - lower_bound(A.begin(), A.end(), X);
    else return A.end() - upper_bound(A.begin(), A.end(), X);    
}
#endif


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

    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];
    vi B(N); REP(i, N) cin >> B[i];
    vi C(N); REP(i, N) cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    ll ans = 0;
    for(int i=0; i<N; i++) {
        ll na = bs_cnt_less(A, B[i], false);
        ll nc = bs_cnt_greater(C, B[i], false);

        ans += na * nc;
    }
    
    cout << ans << endl;

    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n;
    ll a,b,ans=0;
    cin>>n>>a>>b;
    vector<ll> x(n);
    
    for(int i = 0; i < n; i++)
    {
        cin>>x[i];
    }
    
    for(int i = 0; i < n-1; i++)
    {
        ans+=min(b,(x[i+1]-x[i])*a);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
import random
input = sys.stdin.readline

n = int(input())
s = input().rstrip()
a = [int(ch) for ch in s]
# a = [random.randrange(0,3) for _ in range(12)]

def naive(a):
    c = a[:]
    while len(c) > 1:
        b = []
        for c1, c2 in zip(c, c[1:]):
            b.append(abs(c1 - c2))
        c = b[:]
    return c[0]

def solve(a):
    c = a[:]
    while len(c) > 1:
        b = []
        if len(c) % 2 == 0:
            for c1, c2 in zip(c[::2], c[1::2]):
                b.append(abs(c1 - c2))
        else:
            for c1, c2 in zip(c, c[1:]):
                b.append(abs(c1 - c2))
        c = b[:]
    return c[0]

b = []
for a1, a2 in zip(a, a[1:]):
    b.append(abs(a1 - a2))
if 1 not in b:
    tmp = []
    for item in b:
        if item == 2:
            tmp.append(1)
        else:
            tmp.append(0)
    ret = solve(tmp)
    if ret == 1:
        print(2)
    else:
        print(0)
else:
    tmp = []
    for item in b:
        if item == 2:
            tmp.append(0)
        else:
            tmp.append(item)
    ret = solve(tmp)
    print(ret)

Measured memory_bytes: 147432
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1001001001
#define LINF (1LL << 62)
using namespace std;
using ll = long long;
using P = pair<int, int>;

void solv() {
    vector<vector<int>> A(3, vector<int>(3));
    vector<vector<bool>> Ans(3, vector<bool>(3));

    rep(i, 3) {
        rep(j, 3) {
            cin >> A.at(i).at(j);
            Ans.at(i).at(j) = false;
        }
    }

    int N;
    cin >> N;
    vector<int> b(N);
    rep(k, N) {
        cin >> b.at(k);
        rep(i, 3) {
            rep(j, 3) {
                if (A.at(i).at(j) == b.at(k)) {
                    Ans.at(i).at(j) = true;
                }
            }
        }
    }
    rep(i, 3) {
        if (Ans.at(i).at(0) == true && Ans.at(i).at(1) == true &&
            Ans.at(i).at(2) == true) {
            cout << "Yes" << endl;
            return;
        }
        if (Ans.at(0).at(i) == true && Ans.at(1).at(i) == true &&
            Ans.at(2).at(i) == true) {
            cout << "Yes" << endl;
            return;
        }
    }
    if (Ans[0][0] == true && Ans[1][1] == true && Ans[2][2] == true) {
        cout << "Yes" << endl;
        return;
    }
    if (Ans[0][2] == true && Ans[1][1] == true && Ans[0][2] == true) {
        cout << "Yes" << endl;
        return;
    }
    cout << "No" << endl;
}

int main() {
    solv();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,k,vis[10];
int check(int n){
	while(n){
		if(vis[n%10]==1)
		return 0;
		n/=10;
	}
    return 1;
	}
int main()
{
	cin>>n>>k;
	memset(vis,0,sizeof(vis));
	int a;
	for(int i=0;i<k;i++){
	cin>>a;
	vis[a]=1;
}
	int i=n;
	while(1){
		if(check(i)){
			cout<<i<<endl;
			break;
		}
		i++;
	}
	
	
 } 

Measured memory_bytes: 888
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [None]*(n-1)
from collections import defaultdict
c = defaultdict(list)
for i in range(n-1):
    num = int(input())
    c[num].append(i+2)

def sub(winner):
    l = len(c[winner])
    vs = []
    for p in c[winner]:
        vs.append(sub(p))
    vs.sort()
    ans = l
    for i,v in enumerate(vs):
        ans = max(ans, l-(i)+v)
#     print(winner, ans, l, vs)
    return ans
ans = sub(1)
print(ans)

Measured memory_bytes: 126328
#include <bits/stdc++.h>
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n,m;
int k,l;
int par[200010],rankh[200010];
void init(int n) {
	for(int i=0;i<=n;i++){
		par[i]=i;
		rankh[i]=0;
	}
}
int find(int x){
	if(par[x]==x)return x;
	else return par[x]=find(par[x]);
}
bool same(int x,int y){
	return find(x)==find(y);
}
void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(same(x,y))return;
	if(rankh[x]<rankh[y])par[x]=y;
	else{
		par[y]=x;
		if(rankh[x]==rankh[y])rankh[x]++;
	}
}
signed main(){
	cin>>n>>m;
	init(n+m+5);
	rep(i,n){
		cin>>k;
		rep(j,k){
			cin>>l;
			unite(i,n+l);
		}
	}
	rep(i,n){
		if(!same(i,n-1)){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
using namespace std;
 pair<int ,int> a[100005];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>a[i].second>>a[i].first;
    }
    int ans=0;
    sort(a,a+m);
    int l=a[0].first;
    for(int i=1;i<m;i++)
    {
        if(a[i].second>=l)
        {
            ans++;
            l=a[i].first;
        }
    }
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String O = sc.next();
        String E = sc.next();
        StringBuilder sb = new StringBuilder();
        for (int i = 0 ; i < E.length() ; i++) {
            sb.append(O.charAt(i));
            sb.append(E.charAt(i));
        }
        if (O.length() > E.length()) {
            sb.append(O.charAt(O.length() - 1));
        }
        System.out.println(sb);

    }

}


Measured memory_bytes: 20820
#include <iostream>
using namespace std;
#define int long long


int32_t main() {
    int n;
    cin>>n;
    int t = n%10;
    n = n/10;
    t+=10*(n%10);
    n = n/10;
    int t2 = n % 10;
    n = n / 10;
    t2 += 10 * (n % 10);

    if(t<=12 && t2<=12 && t>0 && t2>0) cout << "AMBIGUOUS";
    else if(t2<=12 && t2>0) cout<<"MMYY";
    else if (t <= 12 && t > 0) cout << "YYMM";
    else cout<<"NA";
}


Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Node
    {
        public int num = 0;
        public List<Node> children = new List<Node>();
        public void Write(Queue<int> C)
        {
            num = C.Dequeue();
            foreach (var child in children.Where(child => child.num == 0))
            {
                child.Write(C);
            }
        }
    }

    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int[] Solve(int N, Node[] nodes, int[] C)
        {
            nodes[0].Write(new Queue<int>(C));
            return nodes.Select(node => node.num).ToArray();
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            var nodes = new Node[N];
            for (int i = 0; i < N; ++i) { nodes[i] = new Node(); }
            for (int i = 0; i < N - 1; ++i)
            {
                var V = ReadInts();
                Node a = nodes[V[0] - 1];
                Node b = nodes[V[1] - 1];
                a.children.Add(b);
                b.children.Add(a);
            }
            var C = ReadInts();
            Array.Sort(C, (a, b) => b.CompareTo(a));
            Console.WriteLine(C.Sum() - C[0]);
            Console.WriteLine(string.Join(" ", Solve(N, nodes, C)));
        }
    }
}


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

using namespace std;

int main(int argc, char* argv[]){
    long N,H,next,count=0,max=0;
    cin >> N;
    cin >> H;
    for(long i=1;i<N;i++){
        cin >> next;
        if(H>=next) {
            count++;
            if(max<count) max=count;
        }
        else count=0;
        H = next;
    }
    cout << max << endl;
}

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

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

    int n;
    cin >> n;

    vector<pair<int, int>> A[n];
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        for(int j = 0; j < a; j++){
            int x, y;
            cin >> x >> y;
            A[i].push_back({x - 1, y});
        }
    }

    int ans = 0;
    for(int i = 0; i < (1 << n); i++){
        set<int> honest;
        for(int j = 0; j < n; j++){
            if((i >> j) & 1){
                honest.insert(j);
            }
        }

        bool f = true;
        for(auto x: honest){
            for(int j = 0; j < A[x].size(); j++){
                int x2 = A[x][j].first;
                int y2 = A[x][j].second;
                if(y2 == 1){
                    if(honest.count(x2));
                    else{
                        f = false;
                        break;
                    }
                }else{
                    if(honest.count(x2)){
                        f = false;
                        break;
                    }
                }
            }
            if(!f){
                break;
            }
        }

        if(f){
            ans = max(ans, (int)honest.size());
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<algorithm>
#include<math.h>
#include"boost/algorithm/string.hpp"
#include<array>

using namespace std;



int main(){
	/*Q3*/
	//std::array<string, 1000> str;


	/*Q2*/
	int r, g, b;//ハコの中の個数
	int n;
	int ret = 0;
	cin >> r >> g >> b >> n;
	int i_st = n / r, j_st = n / g, k_st = n / b;
	int i, j, k;
	int x, y, z;

	for (i = i_st; -1 < i; --i){
		x = r * i;
		for (j = j_st; -1 < j; --j){
			y = g * j;
		
			if (
				((n-x-y) > -1)
				&& ((n-x-y) % b == 0)
				){
				++ret;
			}
		}
	}

	cout << ret << endl;

	return 0;


	/*Q1*/
	/*
	int a, b;
	cin >> a >> b;

	cout << (int)(a - b + 1) << endl;
	
	return 0;
	*/
}

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

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
#define db double
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
const int maxn=100008;
char s[maxn];
int main()
{
	while(scanf("%s",s)!=EOF)
	{
		int n=strlen(s);
		REP(i,n-8)
			printf("%c",s[i]);printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] d = new int[N];
            for (int i = 0; i < N; i++) {
                d[i] = in.nextInt();
            }

            long sum = 0;
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    sum += d[i] * d[j];
                }
            }
            out.println(sum);
        }

    }
}



Measured memory_bytes: 21844
a,b,c,d=map(int,input().split())

from fractions import gcd
m=(c*d)//gcd(c,d)

A=b//c-(a-1)//c # a-bのうち、cの倍数のもの
B=b//d-(a-1)//d # a-bのうち、dの倍数のもの
C=b//m-(a-1)//m # a-bのうち、cとdの最小公倍数の倍数のもの
ans=(b-a+1)-(A+B-C)
print(ans)

Measured memory_bytes: 5048
//AcFreak

#include<bits/stdc++.h>
#define lint long long int 

using namespace std;

int main()
{
      lint d,n;
      cin>>d>>n;
      if(n==100)
            n=101;
      
      if(d==0)
      {
            
            cout<<n<<endl;
      }
      
      if(d==1)
      {
            cout<<n*100<<endl;
      }
      
      if(d==2)
      cout<<n*10000<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

/**
 * for (int i = 0; i < N; i++) {}
 * System.out.println();
 * HashMap<Integer, Integer> hm = new HashMap<>();
 * int[] s = new int[M];
 * ArrayDeque<Integer> deq = new ArrayDeque<>();
 *
 */
public class Main implements Runnable { //クラス名はMain1

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 1024 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	public void run() {
		FastScannerMain1 sc = new FastScannerMain1(System.in);

		try {
			String S = sc.nextLine().trim();
			ArrayList<String> arr = new ArrayList<String>();

			dfs(S, (String) S.subSequence(0, 1), Integer.valueOf((String) S.subSequence(0, 1)), 1, arr);
			System.out.println(arr.get(0));
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	public void dfs(String os, String news, long ans, int next, ArrayList<String> arr) {
		if (next == 4) {
			//System.out.println("news:" + news + " ans:" + ans);
			if (ans == 7) {
				arr.add(news + "=7");
			}
		} else {
			String news1 = news + "+" + (String) os.subSequence(next, next + 1);
			long ans1 = ans + Long.valueOf((String) os.subSequence(next, next + 1));

			dfs(os, news1, ans1, next + 1, arr);

			long ans2 = ans - Long.valueOf((String) os.subSequence(next, next + 1));

			String news2 = news + "-" + (String) os.subSequence(next, next + 1);
			dfs(os, news2, ans2, next + 1, arr);
		}
	}
}

//高速なScanner
class FastScannerMain1 {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMain1(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 30676
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <math.h>
#include <random>
using namespace std;
typedef long long int ll;

int solve(int l,int r,int d,int u,int x,int y,int cnt,int res){
    if(l<=x&&x<r&&d<=y&&y<u){
        return res;
    }
    if(cnt==0){
        r+=(u-d);
    }
    if(cnt==1){
        u+=(r-l);
    }
    if(cnt==2){
        l-=(u-d);
    }
    if(cnt==3){
        d-=(r-l);
    }
    return solve(l,r,d,u,x,y,(cnt+1)%4,(res+1)%3);
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int x,y; cin >> x >> y;
    cout << solve(0,1,0,1,x,y,0,0)+1 << endl;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define     debug       printf("\n<<CameHere<<\n")
#define     mem(x,y)    memset(x, y, sizeof(x))
#define     all(qz)     qz.begin(),qz.end()
#define     rall(qz)    qz.rbegin(),qz.rend()
#define     inf         LONG_LONG_MIN
#define     INF         LONG_LONG_MAX
#define     mod         1000000007
#define     Sqr(x)      ((x)*(x))
#define     ll          long long
#define     mk          make_pair
#define     pb          push_back
#define     pi          acos(-1.0)
#define     cos(a)      cos(a*pi/180)
#define     sin(a)      sin(a*pi/180)
#define     tan(a)      tan(a*pi/180)

ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}
/*---------AL ASAD NUR RIYAD------------*/


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}



















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

int hantei(int d, int s){
  int r = s % d;
  if(r == 0 || s / d == 0){
    return 1;
  }else{
    return 0;
  }
}

int main(){
  int A, B, C, D, E, F;
  double max = -1;
  int max_s;
  int max_sw;
  cin >> A >> B >> C >> D >> E >> F;
  //for(int f = 100*A; f <= F; f++){
    for(int a = 0; a <= F / 100 ; a++){
      for(int b = 0; b <= F / 100; b++){
        if(a == 0 && b == 0) continue;
        int w = 100 *( A * a + B * b);
        for(int c = 0; c * C <= F-w; c++){
          for(int d = 0; d * D <= F - w - c*C; d++){
            int s = c*C + d*D;
            double per = (100 * s) / (double)(s + w);
            if(max < per && s <= E * (A * a + b * B) ){
              max = per;
              max_s = s;
              max_sw = s + w;
            }
          }
        }
      }
    }
  //}
  cout << max_sw << " " << max_s << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int a, b; cin >> a >> b;
	vector<vi> v(a, vi(b));
	rep(i, a) rep(j, b) cin >> v[i][j];
	
	vector<vi> dist(101, vi(101));
	for(int i = 1; i <= a; i++) for(int j = 1; j <= b; j++){
		//x = i, y = jとしたとき
		//ki + lj + dist[k][l] >= v[i][j]
		rep(k, 101) rep(l, 101){
			dist[k][l] = max(dist[k][l], v[i-1][j-1] - k * i - l * j);
		}
	}
	for(int i = 1; i <= a; i++) for(int j = 1; j <= b; j++){
		int mn = inf;
		rep(k, 101) rep(l, 101){
			mn = min(mn, k * i + l * j + dist[k][l]);
		}
		if(mn != v[i-1][j-1]){
			dbg(i, j, mn, v[i-1][j-1]);
			dbg(dist[1][0]);
			cout << "Impossible" << endl;
			return 0;
		}
	}
	int m = 200 + 101 * 101;
	
	cout << "Possible" << endl;
	cout << 202 << " " << m << endl;
	rep(i, 100) cout << i+1 << " " << i+2 << " X" << endl;
	rep(i, 100) cout << i+102 << " " << i+103 << " Y" << endl;
	rep(i, 101) rep(j, 101){
		cout << i+1 << " " << 202-j << " " << dist[i][j] << endl;
	}
	cout << 1 << " " << 202 << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;
const int INF=1001001001;

bool f(int x){
  bool ok=true;
  for(int i=2;i*i<=x;i++){
    if(x%i==0){ok=false;}
  }
  return ok;
}
int main() {
  int Q;
  cin>>Q;
  vector<int>l(Q),r(Q);
  for(int i=0;i<Q;i++){
    cin>>l[i]>>r[i];
  }
  vector<int>prime(1e5+5);
  for(int i=2;i<=1e5;i++){
    if(i%2!=0&&f(i)&&f((i+1)/2)){prime[i]++;}
  }  
  for(int i=0;i<=1e5;i++){
    prime[i+1]+=prime[i];
  }
  for(int i=0;i<Q;i++){
    cout<<prime[r[i]]-prime[l[i]-1]<<endl;
  }
  return 0;  
}

Measured memory_bytes: 4560
n,v=[int(k) for k in input().split()]
li=[]
for i in range(n):
  li.append([int(k) for k in input().split()])
  
dp=[[0 for i in range(v+1)] for j in range(n+1)]
for a in range(1,n+1):
  for b in range(1,v+1):
    if(li[a-1][0]<=b):
      dp[a][b]=max(li[a-1][1]+dp[a-1][b-li[a-1][0]],dp[a-1][b])
    else:
      dp[a][b]=dp[a-1][b]
print(dp[n][v])      
      
  


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

int main(){
    int n;
    cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
    }
    if(n == 2){
        int a,b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm> // reverse

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, x, n) for (int i = x; i < (n); ++i)
using namespace std;

// using ll = long long;
// using P = pair<int, int>;

string divider[4] = { "dream", "dreamer", "erase", "eraser" };

int main() {
    string S;
    cin >> S;
    // 後ろから解く代わりにすべての文字を左右反転させる
    reverse(S.begin(), S.end());
    rep(i, 4) reverse(divider[i].begin(), divider[i].end());

    // 端から切っていく
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false; // 4 個の文字列たちどれかで divide（割り算できるか）
        rep(j, 4) {
            string d = divider[j];
            if (S.substr(i, d.size()) == d) { // i 番目から d.size() だけ抜き出す
                can2 = true;
                i += d.size(); // divide できたら i を進める．
            }
        }
        if (!can2) {
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

typedef long long ll;

ll dp[100005];
ll w[105], v[105];

int main(){
    int n, c; cin >> n >> c;
    for(int i = 1; i <= n; i++){
        cin >> w[i] >> v[i];
    }
    
    for(int j = 1; j <= n; j++){
        for(int i = c; i >= 1; i--){
            if(w[j] <= i){
                dp[i] = max(dp[i], dp[i - w[j]] + v[j]);
                // cout << i << ": " << dp[i] << " -> " << j << endl;
            } else dp[i] = max(dp[i], dp[i - 1]);
        }
    }
    cout << dp[c] << endl;
    
    return 0;
}

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

int main() {
	string o, e;
	cin >> o >> e;
	for (int i = 0; i < e.length(); i++) {
		cout << o[i] << e[i];
	}
	if (o.length() > e.length()) {
		cout << o[o.length() - 1];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string name,tab;
    getline(cin,name);
    getline(cin,tab);
    int sizen = name.size(),ans=0;
    for(int i =0;i<sizen;i++)
    {
        if(name[i]!=tab[i])
        {
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a<b) swap(a,b);
  if(b<c) swap(b,c);
  if(a<b) swap(a,b);
  
  int ans=(2*a-b-c)/2;
  if((a-b)%2==0 && (a-c)%2==1) ans+=2;
  else if((a-b)%2==1 && (a-c)%2==0) ans+=2;
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
d,g = map(int,input().split())
info = [list(map(int,input().split())) for i in range(d)]

complete=[None]*d
for i in range(d):
  complete[i] = info[i][0]*(100*i+100) + info[i][1]
  #print(complete[i])

ans = 1000

for i in range(2**(d)):
  bin_i = str("0"*(d+2-len(bin(i)))+str(bin(i))[2:])
  #print(bin_i)
  
  summation=0
  count=0
  index_0=-1
  
  for j in range(d):
    if bin_i[j]=="1":
      summation += complete[j]
      count +=info[j][0]
    else:
      index_0 = j
      
  if summation >= g:
    ans = min(ans,count)
  elif summation < g:
    tmp_g = g
    for j in range(info[index_0][0]):
      tmp_g = tmp_g-100*(index_0+1)
      count +=1
      if summation >= tmp_g:
        ans = min(ans,count)
        break
  #print(count)
  
print(ans)

        
  

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int num1 = scanner.nextInt();
		int num2 = scanner.nextInt();
		int num3 = scanner.nextInt();

		if (num1 < num2 && num2 < num3)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 17324
#include<stdio.h>
int main(){
  long long int N;
  scanf("%lld",&N);
  long long int B[N-1];
  int i;
  for(i=0;i<N-1;i++)
    scanf("%lld",&B[i]);
  long long int A[N];
  A[0] = B[0];
  for(i=1;i<N;i++)
    A[i]=B[i-1];
  for(i=0;i<N-1;i++){
    if(B[i]<A[i])
      A[i]=B[i];
    if(B[i]<A[i+1])
      A[i]=B[i+1];
  }
  long long int sum=0;
  for(i=0;i<N;i++)
    sum=sum+A[i];
  printf("%lld",sum);
  return 0;
}

Measured memory_bytes: 1724
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nk = Input.ar;
        var hei = Input.ar;
        var dp = Enumerable.Repeat((long)int.MaxValue, nk[0]).ToArray();
        dp[0] = 0;
        for (var i = 1; i < nk[0]; i++)
            for (var j = i - 1; j >= Max(0, i - nk[1]); j--)
                dp[i] = Min(dp[i], dp[j] + Abs(hei[i] - hei[j]));
        WriteLine(dp[nk[0] - 1]);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 21600
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define all(c) begin(c),end(c)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//最大公約数
ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}
//最小公倍数
ll lcm(ll x, ll y) {
  return x/gcd(x, y)*y;
}
//素因数分解
vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}
 
 
 ll mod=100000007;
 
int main() {
  string s;
  cin>>s;
  int s3=s.find("RRR");
  int s2=s.find("RR");
  int s1=s.find('R');
  if(s3==0){
    cout<<3;
    return 0;
  }else if(s2==0||s2==1){
    cout<<2;
    return 0;
  }else if(s1==0||s1==1||s1==2){
    cout<<1;
    return 0;
  }else{
    cout<<0;
  }
  
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=n1;i<(int)(n2);i++)
using namespace std;

signed main()
{
	int N, K, Q;
	cin >> N;
	cin >> K;
	cin >> Q;

	vector<int> P(N, K-Q);

	Rep(i, Q){
		int x;
		cin >> x;
		P[x-1]++;
	}

	std::string y, n;
	y = "Yes";
	n = "No";

	Rep(i, N){
		if(P[i] > 0){
			cout << y << endl;
		}else{
			cout << n << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 1024
A, B, C, D, E, F = map(int, input().strip().split())

X = set([])
Y = set([])

ans = (-1, 0, 0)
for w1 in range(0, F+1, 100*A):
    for w2 in range(0, F-w1+1, 100*B):
      w = w1+w2  # 水
      for s1 in range(0, min(F-w+1, w//100*E+1), C):
        for s2 in range(0, min(F-w-s1+1, w//100*E-s1+1), D):
          s = s1+s2  # 砂糖
          a = w+s
          ans = max(ans, (s/a if a!=0 else -1, a, s))
print(ans[1], ans[2])


Measured memory_bytes: 3064
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    h,w,m=map(int, readline().rstrip().split())
    cntH=[0]*h
    cntW=[0]*w

    ys=[0]*m
    xs=[0]*m

    for i in range(m):
        y,x = map(int, readline().rstrip().split())
        y-=1
        x-=1
        cntH[y]+=1
        cntW[x]+=1
        ys[i]=y
        xs[i]=x
    maxX = max(cntW)
    maxY = max(cntH)
    cntMaxX=cntW.count(maxX)
    cntMaxY=cntH.count(maxY)
    cntMax=cntMaxX*cntMaxY

    for i in range(m):
        y=ys[i]
        x=xs[i]
        maxPtn=False
        if cntH[y]==maxY and cntW[x]==maxX:
            cntMax-=1
    if cntMax > 0:
        print(maxX+maxY)
    else:
        print(maxX+maxY-1)
    return


if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 44468
#include<stdio.h>

int main(){
  int a,b,i,j,x[10000];
  char op;
  for(i=0;i<10000;i++){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='+'){
      x[i]=a+b;
    }
    else if(op=='-'){
      x[i]=a-b;
    }
    else if(op=='*'){
      x[i]=a*b;
    }
    else if(op=='/'){
      x[i]=a/b;
    }
    else{
      break;
    }
  }
  for(j=0;j<i;j++){
    printf("%d\n",x[j]);
  }
  return 0;
}

Measured memory_bytes: 2684
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in); 
		int n = as.nextInt();
		int a = as.nextInt();
		int b = as.nextInt();
		if(a+n<b||b+n<a){
			System.out.println(-1*Math.min(b-a+n, a-b+n));
		}else{
			System.out.println("0");
		}
	}
}

Measured memory_bytes: 23380
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;

int main(){
 
  vector<int> a(5);
  for(int i=0;i<5;i++){
    cin>>a[i];
  }
  sort(all(a),greater<int>());
  for(int i=0;i<5;i++){
    cout<<a[i]<<((i!=4)?' ':'\n');
  }
  return 0;
}

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


import sys

sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
INF=float('inf')

# Union-Find木
class UnionFind:
    def __init__(self, n):
        self.n = n
        # 親要素のノード番号を格納。par[x] == xの時そのノードは根
        # 1-indexedのままでOK、その場合は[0]は未使用
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0）
        self.rank = [0] * (n+1)
        # あるノードを根とする集合に属するノード数
        self.size = [1] * (n+1)
        # あるノードを根とする集合が木かどうか
        self.tree = [True] * (n+1)

    # 根の検索(グループ番号と言えなくもない)
    def find(self, x):
        # 根ならその番号を返す
        if self.par[x] == x:
            return x
        else:
            # 走査していく過程で親を書き換える
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)

        # 木かどうかの判定用
        if x == y:
            self.tree[x] = False
            return
        if not self.tree[x] or not self.tree[y]:
            self.tree[x] = self.tree[y] = False

        # 木の高さを比較し、低いほうから高いほうに辺を張る
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            # 木の高さが同じなら片方を1増やす
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # あるノードの属する集合のノード数
    def get_size(self, x):
        return self.size[self.find(x)]

    # 木かどうかの判定
    def is_tree(self, x):
        return self.tree[self.find(x)]

    # 集合の数
    def len(self):
        res = set()
        for i in range(self.n+1):
            res.add(self.find(i))
        # グループ0の分を引いて返却
        return len(res) - 1

N,M=MAP()
edges=[None]*M 
for i in range(M):
    s,t,w=MAP()
    edges[i]=(w, s, t)

# クラスカル法
edges.sort()
uf=UnionFind(N)
ans=0
for cost, u, v in edges:
    if not uf.same(u, v):
        uf.union(u, v)
        ans+=cost
print(ans)



Measured memory_bytes: 23448
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<set>
#include<cctype>
#include<stack>
using namespace std;
const int N = 110;
const int inf = (int)1e9;
int d[N][N],cntl;
char s[N];
int dfs(int i,int j)
{
    if(i>j) return d[i][j] = 0;
    if(i==j) return d[i][j] = 1;
    int &ans = d[i][j];
    if(ans != -1) return ans;
    ans = inf;
    if(s[i]=='('&&s[j]==')') ans = min(ans,dfs(i+1,j-1));
    for(int k = i; k+1<=j; k++) ans = min(ans,dfs(i,k)+dfs(k+1,j));
    return d[i][j] = ans;
}
void print(int i,int j)
{
    // cout<<i<<" "<<j<<endl;
    if(i > j) return ;
    if(i == j)
    {
        if(s[i] == ')') cntl++;
        return ;
    }
    int ans = d[i][j];
    if(s[i]=='(' && s[j] == ')' && ans==d[i+1][j-1])
    {
        print(i+1,j-1);
    }
    else
    {
        for(int k = i ; k  < j; k++)
        {
            if(ans == d[i][k] + d[k+1][j])
            {
                print(i,k);
                print(k+1,j);
                return ;
            }
        }
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    scanf("%s",s);
    memset(d,-1,sizeof(d));
    int ans = dfs(0,n-1);
    cntl = 0;
    print(0,n-1);
    for(int i = 0;i < cntl;i++) printf("(");
    printf("%s",s);
    for(int i = 0;i < ans - cntl;i++) printf(")");
    printf("\n");
    return   0;
}


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

#define rep(i,min,sup) for(int i=min;i<sup;i++)
#define per(i,min,sup) for(int i=(sup-1);i>=min;i--)
#define swap(a,b) {a+=b;b=a-b;a-=b;}
#define ll long long

using namespace std;

main(){
  int N,M;
  scanf("%d %d",&N,&M);
  int ans[N]={};
  rep(i,0,M){
    int s,c;
    scanf("%d %d",&s,&c);
    s--;c++;
    if(ans[s]&&ans[s]!=c){printf("-1");return 0;}
    ans[s]=c;
  }
  if(N>1&&!ans[0])ans[0]=2;
  if(N>1&&ans[0]==1){printf("-1");return 0;}
  rep(i,0,N)if(ans[i])ans[i]--;
  rep(i,0,N)printf("%d",ans[i]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 2000;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(auto &t:a)cin>>t;return i;}
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T> void prArr(T a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  bitset<N*N> bit;
  
  int n;
  cin>>n;
  vector<int>A(n);
  cin>>A;
  int sum = 0;
  for(int i:A) sum += i;
  
  bit |= 1;
  for(int a:A) bit |= bit << a;
  
  
  int ans = ceil(sum/2.0);
  while(bit[ans] == 0) ans++;
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    
    ll ans = 0;
    ll h;
    cin >> h;
    ll i=1;
    while(h > 0){
        ans += i;
        h /= 2;
        i *= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

using ll =  long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

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


}


int main() {

	int k, x;
	std::cin >> k >> x;

	int sum = k * 500;

	if (sum >= x) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
using namespace std;
using ll = long long;

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

    int n = s.size();
    int cntb = 0;
    ll ans = 0;
    rep (i, n) {
        if (s[i] == 'B') {
            cntb++;
        }
        else if (s[i] == 'W') ans += cntb;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main()
{
    long long int k;
    int n;
    scanf("%lld%d", &k, &n);
    long long int array[n];
    for(int i =0;i<n;i++)
        scanf("%lld", &array[i]);
    long long int differences[n];
    long long int i;
    for( i = 0;i<n-1;i++)
    {
        differences[i] = array[i+1]- array[i];
    }
    differences[i] = (k-array[n-1])+array[0];
    long long int max = 0;
    for(long long int j = 0;j<n;j++)
    {
        if(differences[j]>max)
        {
            max = differences[j];
        }
    }
    printf("%lld", k-max);
    return 0;

}

Measured memory_bytes: 3328
// 2015/06/30 Tazoe

#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

class State{
public:
	int p[31];	// p[0]は使わない
	int n;		// 操作回数

	bool is_over()
	{
		return p[1]==p[2] && p[2]==p[3] && p[3]==p[4] && p[4]==p[5]
		    && p[5]==p[6] && p[6]==p[7] && p[7]==p[8] && p[8]==p[9]
		    && p[10]==p[11] && p[11]==p[12]
		    && p[13]==p[14] && p[14]==p[15]
		    && p[16]==p[17] && p[17]==p[18]
		    && p[19]==p[20] && p[20]==p[21];
	}

	void rot1()
	{
		swap(p[ 7], p[22]);  swap(p[ 8], p[23]);  swap(p[ 9], p[24]);
		swap(p[10], p[12]);  swap(p[13], p[18]);
	}

	void rot2()
	{
		swap(p[ 1], p[28]);  swap(p[ 2], p[29]);  swap(p[ 3], p[30]);
		swap(p[19], p[21]);  swap(p[15], p[16]);
	}

	void rot3()
	{
		swap(p[ 1], p[24]);  swap(p[ 4], p[27]);  swap(p[ 7], p[30]);
		swap(p[16], p[18]);  swap(p[10], p[21]);
	}

	void rot4()
	{
		swap(p[ 3], p[22]);  swap(p[ 6], p[25]);  swap(p[ 9], p[28]);
		swap(p[13], p[15]);  swap(p[12], p[19]);
	}
};

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

	for(int i=0; i<N; i++){
		State now;
		for(int j=1; j<=30; j++){
			cin >> now.p[j];
		}
		now.n = 0;

		queue<State> que;
		que.push(now);

		while(!que.empty()){
			now = que.front();
			que.pop();

			if(now.is_over()){
				cout << now.n << endl;
				break;
			}

			State nex1 = now;  nex1.rot1();  nex1.n++;  que.push(nex1);
			State nex2 = now;  nex2.rot2();  nex2.n++;  que.push(nex2);
			State nex3 = now;  nex3.rot3();  nex3.n++;  que.push(nex3);
			State nex4 = now;  nex4.rot4();  nex4.n++;  que.push(nex4);
		}
	}

	return 0;
}

Measured memory_bytes: 12172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define speed ios_base::sync_with_stdio(0); cin.tie(0);
#define FL(i,a,n) for(ll i=a;i<n;i++)
#define even(x) (((x)%(2))==(0))
#define odd(x) (((x)%(2))==(1))
#define meme(x) memset(x, 0, sizeof(x))

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
	
int main()
{
    speed;
    int n,x,t;
    cin>>n>>x>>t;
    int xx=n/x;
    int yy=n%x;

    if(yy==0)
    cout<<xx*t<<endl;
    else 
    cout<<(xx+1)*t<<endl;

}
	
	


Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std;
int main(void){
 int N,K;
 long long int a;
 long long int sum=0;
 long long int ans=0;
 long long int bit=1;
 vector<long long int>A;
 vector<long long int>B;

 cin>>N;
 cin>>K;
 for(int i=0; i<N;i++){
	 cin>>a;
     A.push_back(a);
 }

 for(int i=0; i<N; i++){
  sum=0;
  sum+=A[i];
  B.push_back(sum);
  for(int j=i+1; j<N; j++){
   sum+=A[j];
   B.push_back(sum);
  }
 } 
 /*
 for(int i=0; i<B.size(); i++){
  std::cout<<"B size "<<B[i]<<std::endl;
 }
 */ 
 for(int i=60; i>=0; i--){
    vector<long long int> C;	
	//std::cout<<"(1<<i)"<< (1<<i) <<std::endl;
    for(int j=0; j<B.size();j++){
		if((B[j] & (bit<<i) )){
			C.push_back(B[j]);
			//std::cout<<" i B[j] "<<i<<" "<<B[j]<<std::endl;
		}
	}
	if(C.size()>=K){
	 //std::cout<<" i "<<i<<std::endl;
	 ans+=(bit<<i);
     B=C;
	}
 }
 std::cout<<ans<<std::endl; 
}

Measured memory_bytes: 6524
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(ll i = 0; i < (ll)c; i++)
#define ll long long
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;
const int inf = 1000000000; // 10^9

int main(){
    ll n, h[110000], dp[110000];

    cin >> n;

    rep(i, n) cin >> h[i];

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for(int i = 2; i < n; i++){
        dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]));
    }

    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    int n; cin >> n;
    vector<int> d(n); rep(i, n) cin >> d[i];
    sort(all(d));
    int ans = 1;
    rep(i, n-1) if(d[i] != d[i+1]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3608