akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;


void solve()
{
    ll n;
    cin>>n;
    ll i,j,k;
    ll res=0;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                res+=gcd(i,gcd(j,k));
            }
        }
    }
    cout<<res<<"\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class ABlackjack
    {
        static void Main(string[] args)
        {
            var aList = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            Console.WriteLine(aList.Sum() >= 22 ? "bust" : "win");
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <string>
#include <map>
using namespace std;
#define REP(i, a, n) for (int i = ((int)a); i < ((int)n); i++)
#define lli long long int

#define MAX 100000000
//#define DEBUG

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int main()
{
#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
#else
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
#endif
    string s;
    cin>>s;
    int f0=0;//0はじまり
    int f1=0;//1はじまり
    for(int i=0;i<s.length();i++){
        if(((int)s[i])-(int('0'))==i%2){
            f1++;
        }else{
            f0++;
        }
    }
    cout<<min(f0,f1)<<endl;
    return 0;
}
/* 注意すべき点
グローバル以外の配列は初期化すべし
*/

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
string a,b;
long long l,l2;
int main()
{
	cin>>a>>b;
	l=a.size();
	l2=b.size();
	if(l!=l2)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	else
	{
		for(int i=0;i<l;i++)
		{
			if(a[i]!=b[l-i-1])
			{
				cout<<"NO"<<endl;
				return 0;
			}
		}cout<<"YES"<<endl;
	}
	return 0;
}

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

int main(){
  string S; cin>>S;
  if(S[1]=='B') cout<<"ARC\n";
  else cout<<"ABC\n";
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans1 = a * c;
    ll ans2 = a * d;
    ll ans3 = b * c;
    ll ans4 = b * d;
    ll Ansa, Ansb;
    if (ans1 > ans2)
    {
        Ansa = ans1;
    }
    else
    {
        Ansa = ans2;
    }
    if (ans3 > ans4)
    {
        Ansb = ans3;
    }
    else
    {
        Ansb = ans4;
    }
    if (Ansa > Ansb)
    {

        cout << Ansa << endl;
    }
    else
    {

        cout << Ansb << endl;
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <cstdio>
#include <deque>
#include <algorithm>
#include <string>
#include <cstring>
#include <list>
#include <stack>

using namespace std;
int a[31];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		for (int j = 0; j < x; j++) {
			int y; cin >> y;
			a[y] += 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= m; i++) {
		if (a[i] == n)ans += 1;
	}
	cout << ans << '\n';



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
    string S;
    cin>>S;
    int cnt=0;
    int len=S.size();
    bool AC=true;
  
    if(S[0]!='A'){
        AC=false;
    }
    for(int i=2;i<len-1;i++){
        if(S[i]=='C'){
            cnt++;
            
        }
    }
    if(cnt!=1){
        AC=false;
    }
    rep(i,len-1){
        
        if(S[i+1]<'a'&&S[i+1]!='C'){
            AC=false;
            break;
        }
    }
    if(AC==true){
        cout<<"AC"<<endl;
    }
    else{
        cout<<"WA"<<endl;
    }
    
}

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
using ll = long long;
using ull = unsigned long long;

int main() {
    int n, d, x;
    cin >> n >> d >> x;

    int choco = x, c = 0;
    int a;
    rep(i, n){
        cin >> a;

        if(d % a == 0){
            choco += (d / a);
        }else{
            choco += (d / a) + 1;
        }
    }

    println(choco);
}

Measured memory_bytes: 256
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	int count = 0;
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < w; j++) {
			if (s.substr(j, 1) == "#") {
				count++;
			}
		}
	}
	if (count == h + w - 1) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
main() {
	int n=read();
	cout<<(n)*(n-1)/2;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  int H[100010];
  for(int i = 1; i <= N; i++){
    cin >> H[i];
  }
  
  bool is_highest[100010];
  for(int i = 0; i< 100010; i++){
    is_highest[i] = true;
  }
  for(int i = 0; i < M; i++){
    int a,b;
    cin >> a >> b;
    if(H[a] <= H[b])is_highest[a-1] = false;
    if(H[b] <= H[a])is_highest[b-1] = false;
  }
  
  int count = 0;
  
  for(int i = 0; i<N; i++){
    if(is_highest[i])count++;
  }
  
  
  cout << count << endl;
}

Measured memory_bytes: 4072
MOD = 10**9+7

N,M = map(int,input().split())
is_broken = [0]*(N+1)#1-broken 0-not
for i in range(0,M,1):
    a = int(input())
    is_broken[a]=1

method = [0]*(N+1)
method[0]=1
method[1]=1-is_broken[1]
for i in range(2,N+1,1):
    if is_broken[i]== 0:
        method[i]= (method[i-1]+method[i-2])%MOD
    else:
        method[i]=0
print(method[N])

Measured memory_bytes: 45016
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

#define int long long

const int MOD = 1e9 + 9;
const int BASE = 239;

int mul(int a, int b) {
    return (a * b) % MOD;
}

int add(int a, int b) {
    return (a + b) % MOD;
}

vector<int> h;
vector<int> p;

void init(int n, string s) {
    h.resize(n + 1);
    p.resize(n + 1);
    p[0] = 1;
    for (int i = 0; i < n; i++) {
        h[i + 1] = add(mul(h[i], BASE), s[i]);
        p[i + 1] = mul(p[i], BASE);
    }
}


int get(int l, int r) {
    return (h[r] - mul(h[l], p[r - l]) + MOD * MOD) % MOD;
}

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

    int n;
    string s;
    cin >> n >> s;
    init(n, s);
    auto can = [&](int x) {
        set<int> l;
        vector<int> vals;
        for (int i = 0; i + x <= n; i++) {
            int t = get(i, i + x);
            if (l.count(t)) {
                return true;
            }
            vals.push_back(t);
            if (i - x + 1 >= 0) {
                l.insert(vals[i - x + 1]);
            }
        }
        return false;
    };
    int l = 0;
    int r = n + 1;
    while (r - l > 1) {
        int m = (r + l) >> 1;
        if (can(m)) {
            l = m;
        } else {
            r = m;
        }
    }
    cout << l << endl;
}

Measured memory_bytes: 784
#include<stdio.h>
int main()
{
    int  M=-1000;
    int A,B;
    scanf("%d%d",&A,&B);
    if(A+B>M)M=A+B;
    if(A*B>M)M=A*B;
    if(A-B>M)M=A-B;
    printf("%d",M);
    return 0;
}


Measured memory_bytes: 128
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define mp make_pair

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
    return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
    return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
    int sign = 1;
    T ret = 0;
    char c;

    do{
        c = getc();
    }while(c == ' ' || c == '\n');
    if(c == '-')sign = -1;
    else ret = c-'0';
    while(1){
        c = getc();
        if(c < '0' || c > '9')break;
        ret = 10*ret + c-'0';
    }
    return sign * ret;
}

inline void ini(int& x){
    x = getnum<int>();
}

inline void scani(int& x){
    scanf("%d",&x);
}

//end of macro


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    string str;
    cin>>str;
    bool bad = false;
    for(int i=1; i<str.size(); i++){
        if(str[i] == str[i-1]){
            bad = true;
        }
    }
    cout << (bad ? "Bad" : "Good") << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int x = scanner.nextInt();
		
		if(a+b>=x&&x>=a)System.out.println("YES");
		else System.out.println("NO");
	}

}


Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i = 0; i < (n); i++)

int main(void) 
{
    int h, w;
    while(1) {
        cin >> h >> w;
        if(h == 0 && w == 0) return 0;
        REP(i, h) {
            REP(j, w) {
                cout << "#" ;
            }
            cout << endl;
        }
        cout << endl;
    }
}



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
    int N, M; cin >> N >> M;
    vector<ll> A(N); REP(i, N) cin >> A[i];
    vector<pair<ll, ll>> CB(M);
    REP(i, M) {
        int b, c;
        cin >> b >> c;
        CB[i] = make_pair(c, b);
    }
    sort(all(A));
    sort(all(CB));
    int cnt = CB.size() - 1;
    int tmp = 0;
    REP(i, N) {
        if(A[i] < CB[cnt].first) {
            A[i] = CB[cnt].first;
            tmp++;
        }
        if(tmp == CB[cnt].second) {
            cnt--;
            tmp = 0;
        }
    }
    ll ans = accumulate(all(A), 0LL);
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int R, G;
  cin >> R >> G;
  cout << R + 2*(G-R) << endl;

  return 0;
}


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

void merge(vector<int> &A, int left, int mid, int right, long long int& count){
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L, R;
	L.resize(n1 + 1);
	R.resize(n2 + 1);
	for(int i = 0; i < n1; i++){
		L[i] = A[left + i];
	}
	for(int i = 0; i < n2; i++){
		R[i] = A[mid + i];
	}
	L[n1] = numeric_limits<int>::max();
	R[n2] = numeric_limits<int>::max();
	int i = 0;
	int j = 0;
	for(int k = left; k < right; k++){
		if(L[i] <= R[j]){
			A[k] = L[i];
			i = i + 1;
		}else{
			count += n1 - i;
			A[k] = R[j];
			j = j + 1;
		}
	}
}

void mergeSort(vector<int> &A, int left, int right, long long int &count){
	if(left+1 < right){
	    int mid = (left + right)/2;
	    mergeSort(A, left, mid, count);
	    mergeSort(A, mid, right, count);
		merge(A, left, mid, right, count);
	}
}

int main()
{
	int n;
	long long int count = 0;
	cin >> n;
	vector<int> S;
	S.resize(n);
	for(int i = 0; i < n; i++){
		cin >> S[i];
	}
	mergeSort(S, 0, n, count);
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 4320
#include <stdio.h> 

long long int sum (long long int n) {
    return n*(n+1)/2;
}

int main() {
    long long int N;
    scanf("%lld", &N);

    long long int ans;
    ans=sum(N)-3*sum(N/3)-5*sum(N/5)+15*sum(N/15);
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 1696
#include <iostream>
using namespace std;
int main()
{
     int a,b,s,m;
     cin>>a>>b;

     s=a+b;
     m=a*b;
     if(s==15){
        cout<<"+"<<endl;

     }else if(m==15){
         cout<<"*"<<endl;

     }else{
         cout<<"x"<<endl;

     }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        int x = int.Parse(Console.ReadLine());
        int a = int.Parse(Console.ReadLine());
        int b = int.Parse(Console.ReadLine());
        Console.WriteLine((x - a) % b);
    }
}

Measured memory_bytes: 13140
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# library
# -------------------------------------------------------------



# -------------------------------------------------------------
# main
# -------------------------------------------------------------

N,M = map(int,input().split())
LR = [tuple(map(int,input().split())) for _ in range(M)]

maxL,minR = 0,10**5+1
for l,r in LR:
    maxL = max(maxL,l)
    minR = min(minR,r)

print(max(0, minR - maxL + 1))

Measured memory_bytes: 16600
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
vector<int> f,g;

void yes(){
    cout << "Yes"<<endl;
    exit(0);
}
void no(){
    cout << "No"<<endl;
    exit(0);
}
int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    map<int,int> m,fuga;
    rep(i,n){
        cin >> a[i];
        fuga[a[i]]++;
    }
    if(n%3==0){
       int k = n/3;
       for(auto s:fuga)f.push_back(s.second);

       for(auto s:fuga)g.push_back(s.first);

       if(fuga.size() > 3){
           no();
       }
       if(fuga.size() == 3){
          if(f[0] == f[1] && f[1] == f[2]){
              rep(i,3)if(g[i] != (g[(i+1)%3] ^ g[(i+2)%3])) no(); 
              yes();
          }
          no();
       }
       if(fuga.size() == 2){
          if(f[0] == 2 * f[1] || f[1] == 2 * f[0]){
              if(fuga[0] <= n/2){
                  yes();
              }
              no();
          }
          no();
       }
       if(fuga[0] > 0) yes(); else no();
    }else{
        if(fuga.size()==1 && fuga[0] > 0){
            yes();
        }else {
            no();
        }
    }
}


Measured memory_bytes: 5244
import copy
n=int(input())
a=list(map(int,input().split()))
q=int(input())
l=[0]*10**5

for i in a:
    l[i-1]+=1

ans=sum(a)

for i in range(q):
    b,c=map(int,input().split())
    temp=copy.deepcopy(l[b-1])
    ans-=temp*(b-c)
    #print(l)
    print(ans)
    l[b-1]=0
    l[c-1]+=temp

Measured memory_bytes: 80388
while True:
    n = int(input())
    if n == 0:
        break
    
    a = 1
    for i in range(1,n+1):
        a *= i
    
    count = 0
    while(a % 10 == 0):
        count += 1
        a //= 10
    
    print(count)
    


Measured memory_bytes: 5628
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))
    print(A[-1] - A[0])


if __name__ == '__main__':
    resolve()


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

int main(void) {
   ll N;
   cin>>N;
   if (N%2 == 0) {
      ll M = N*(N-1)/2;
      M-= N/2;
      cout<<M<<endl;
      for(int i = 1; i <= N;i++) {
         for(int j = i+1; j <= N;j++) {
            if (j+i == N+1) continue;
            cout<<i<<" "<<j<<endl;
         }
      }
   } else {
      ll M = N*(N-1)/2;
      M -= (N-1)/2;
      cout<<M<<endl;
      for(int i = 1; i <= N;i++) {
         for(int j = i+1; j <= N;j++) {
            if (j+i == N) continue;
            cout<<i<<" "<<j<<endl;
         }
      }

   }




   return 0;
}

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

using namespace std;

int main()
{
    long N, M;
    long L, R;

    long min, max;
    min = LONG_MIN;
    max = LONG_MAX;

    cin >> N >> M;
    for (long i=0; i < M; i++) {
        cin >> L >> R;
        if (min < L) {
            min = L;
        }
        if (max > R) {
            max = R;
        }
        if (max < L || min > R) {
            cout << 0 << endl;
            return 0;
        }
    }

    //cout << min << max << endl;
    cout << max-min+1 << endl;
   return 0;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctime>
#include <cstdlib>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()
{
    int A, B;
    cin >> A >> B;
    int ans = 1, count = 0;
    while (1)
    {
        if (ans >= B)
        {
            break;
        }
        ans += A - 1;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
s = input()
x, y = map(int, input().split())
command = s.split("T")

command_length = len(command)

x_command = []
y_command = []
for i in range(command_length):
    c = len(command[i])
    if i % 2 == 0:
        x_command.append(c)

    else:
        y_command.append(c)
x -= x_command.pop(0)
x_command.sort(reverse=True)
y_command.sort(reverse=True)

c_x = 0
c_y = 0
for c in x_command:
    if x - c_x >= 0:
        c_x += c
    else:
        c_x -= c

for c in y_command:
    if y - c_y > 0:
        c_y += c
    else:
        c_y -= c
if c_x == x and c_y == y:
    print("Yes")
else:
    print("No")


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

#define ll long long
#define f first
#define s second
#define pb push_back

using namespace std;

int main() {
    int n;
    cin >> n;
    ll a[n], b[n];
    for (int i = 1; i <= n; ++i) {
        scanf("%lld %lld", &a[i], &b[i]);
    }
    ll ans = 0;
    for (int i = n; i >= 1; --i) {
        a[i] += ans;
        if (a[i] % b[i] != 0)
            ans += (b[i] - a[i] % b[i]);
    }
    cout << ans << endl;
    return 0;
}

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

int n, k;

int get_ck(vector<int> c){
	int p = 0;
	for(int i=0 ; i+k <= c.size() ; i++ ){
		int s = 1;
		for(int j = 0 ; j < k ; j++ ){
			s *= c[i+j];
		}
		p = max( s , p );
	}
	return p;
}

int main(){
	while( cin >> n >> k , n || k ){
		vector<int> c;
		for(int i=0 ; i < n ; i++ ){
			int e;
			cin >> e;
			c.push_back( e );
		}
	
		int ck = get_ck( c );
		int ans = -1;
		for(int i=0 ; i < n ; i++ ){
			for(int j=i+1 ; j < n ; j++ ){
				swap( c[i] , c[j] );
				int next_ck = get_ck( c );
				swap( c[i] , c[j] );
				ans = max( ans , next_ck - ck );
			}
		}
		if( ans < 0 )
			cout << "NO GAME" << endl;
		else
			cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pa;
typedef long long LL;
const int maxn=1e4+7;
const int mod=1e9+7;
int n,t,m;
LL quick_mod(LL a, LL b)
{
    LL ans = 1;
    a %= mod;
    while(b)
    {
        if(b & 1)
        {
            ans = ans * a % mod;
            b--;
        }
        b >>= 1;
        a = a * a % mod;
    }
    return ans;
}
LL C(LL n, LL m)
{
    if(m > n) return 0;
    LL ans = 1;
    for(int i=1; i<=m; i++)
    {
        LL a = (n + i - m) % mod;
        LL b = i % mod;
        ans = ans * (a * quick_mod(b, mod-2) % mod) % mod;
    }
    return ans;
}

LL Lucas(LL n, LL m)
{
    if(m == 0) return 1;
    return C(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}
int main()
{
    LL a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    LL g=quick_mod(2,n);
    printf("%lld\n",(g+mod+mod-Lucas(n,a)-Lucas(n,b)-1)%mod);
    return 0;
}


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

using namespace std;

int main()
{
    char a[5], b[5];

    scanf("%s%s", a, b);
    if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) {
        puts("YES");
    } else puts("NO");
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m;
int D[200010],T[200010];
int main()
{
	int i,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&D[i]);
	scanf("%d",&m);
	for(i=1;i<=m;i++)
		scanf("%d",&T[i]);
	sort(D+1,D+n+1);
	sort(T+1,T+m+1);
	j=1;
	for(i=1;i<=m;i++){
		while(T[i]!=D[j]&&j<=n)
			j++;
		if(j>n){
			printf("NO\n");return 0;
		}
		if(T[i]==D[j])j++;
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

int ans = 0, n, m;
int k[10], p[10], s[10][10];

void isok(vector<int>& v){
  int i;
  for(i = 0; i < m; i++){
    int sum = 0;
    for(int j = 0; j < k[i]; j++){
      sum += v[s[i][j] - 1];
    }
    if(sum % 2 != p[i]) break;
  }
  if(i == m) ans++;
  return;
}

void func(vector<int>& v){
  if(v.size() >= n){
    //for(int i = 0; i < v.size(); i++) cout << v[i]; cout << endl;
    isok(v);
    return;
  }
  v.push_back(0);
  func(v);
  v.pop_back();
  v.push_back(1);
  func(v);
  v.pop_back();
  return;
}

void solve(){
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    cin >> k[i];
    for(int j = 0; j < k[i]; j++) cin >> s[i][j];
  }
  for(int i = 0; i < m; i++) cin >> p[i];

  vector<int> v;
  func(v);
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 256
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    string s, t;
    cin >> s >> t;
    ll result = 0;
    rep(i, s.length()) {
        if (s[i] != t[i]) {
            ++result;
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>

using namespace std;

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

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

int main() {
	int h, w, n;
	cin >> h >> w >> n;
	vector<int> a(n), b(n);
	
	REP(i, n) scanf("%d %d", &a[i], &b[i]);
	
	set<pii> s, done;
	REP(i, n) s.insert(pii(a[i], b[i]));
	
	ll ans[10] = {};
	REP(i, n) {
		FOR(j, -1, 2) FOR(k, -1, 2) {
			int x = b[i] + j;
			int y = a[i] + k;
			if (!(x > 1 && x < w && y > 1 && y < h)) continue;
			if (done.find(pii(y, x)) != done.end()) continue;
			done.insert(pii(y, x));
			
			int cnt = 0;
			for (int ny = y - 1; ny <= y + 1; ny++) {
				for (int nx = x - 1; nx <= x + 1; nx++) {
					if (s.find(pii(ny, nx)) != s.end()) cnt++;
				}
			}
			ans[cnt]++;
		}
	}
	ll tmp = 0;
	FOR(i, 1, 10) tmp += ans[i];
	ans[0] = (ll)(h - 2) * (w - 2) - tmp;
	
	REP(i, 10) cout << ans[i] << endl;
	
	return 0;
}

Measured memory_bytes: 47872
use proconio::input;

fn main() {
    input! {
        sx: i32,
        sy: i32,
        tx: i32,
        ty: i32,
    }

    let start = [(sx, sy + 1), (tx, ty + 1), (sx, sy - 1), (tx, ty - 1)];
    let goal  = [(tx - 1, ty), (sx - 1, sy), (tx + 1, ty), (sx + 1, sy)];

    for i in 0..4 {
        // 進行方向の+-を制御する、行きは+1, 帰りは-1
        let m = if i == 2 || i == 0 { 1 } else { -1 };

        match i {
            0..=1 => print!("U"),
            2..=3 => print!("D"),
            _ => unreachable!(),
        }


        let y = goal[i].1 - start[i].1;
        let x = goal[i].0 - start[i].0;

        if i == 0 || i == 3 {
            for _ in 0..y.abs() {
                if m > 0 { print!("U"); } else { print!("D"); }
            }
            for _ in 0..x.abs() {
                if m > 0 { print!("R"); } else { print!("L"); }
            }
        } else {
            for _ in 0..x.abs() {
                if m > 0 { print!("R"); } else { print!("L"); }
            }
            for _ in 0..y.abs() {
                if m > 0 { print!("U"); } else { print!("D"); }
            }
        }

        match i {
            0..=1 => print!("R"),
            2..=3 => print!("L"),
            _ => unreachable!(),
        }
    }
    println!("");
}

Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S[N];
  map<string,int> value;
  int max=0;
  for (int i=0;i<N;i++) {
    cin >> S[i];
    value[S[i]]++;
    if (value[S[i]]>max){
      max = value[S[i]];
    }
  }
  vector<string> que;
  for(map<string,int>::iterator e=value.begin();e!=value.end();e++){
    if (e->second==max){
      que.push_back(e->first);
    }
//    pair<int,string> p;
//    p.first=e->second;
//    p.second=e->first;
//    que.push(p);
  }
//  while(!que.empty()){
//    cout << que.top().first << " " << que.top().second << endl;
//    que.pop();
//  }
  sort(que.begin(),que.end());
  for(vector<string>::iterator e=que.begin();e!=que.end();e++){
    cout << *e << endl;
  }
}


Measured memory_bytes: 28404
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize,
        p: [u64; n]
    }

    let mut cnt = 0;
    for i in 1..n-1 {
        if p[i-1]<=p[i] && p[i]<=p[i+1] || p[i-1]>=p[i] && p[i]>=p[i+1] {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}

Measured memory_bytes: 4352
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=150;

int b[N];

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

    int n;
    cin>>n;
    for(int i=1;i<=n-1;i++)
        cin>>b[i];
    b[0]=b[n]=1e6;
    int ans=0;
    for(int i=1;i<=n;i++)
        ans+=min(b[i-1],b[i]);
    cout<<ans;
}


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

int main(){
  string array[101];
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  for(int i=0;i<n-1;i++){
    if(array[i].at(array[i].size()-1)!=array[i+1].at(0)){
      cout<<"No"<<endl;
      return 0;
    }
  }
  sort(array,array+n);
  for(int i=0;i<n-1;i++){
    if(array[i]==array[i+1]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int cnt = 0;
		while (n != 0) {
			if (n%10 == 2) cnt++;
			n /= 10;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 20688
#include <bits/stdc++.h>
using namespace std;
const int N=2050;
int n,k,ans=1e9,tot,a[N],b[N],vis[N],dep[N];
vector<int> g[N];
void dfs(int u,int f){
	dep[u]=dep[f]+1;
	if(dep[u]>k/2) tot ++;
	for(auto v:g[u]){
		if(v==f||vis[v]) continue;
		dfs(v,u);
	}
}
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++) {
		scanf("%d%d",a+i,b+i);
		g[a[i]].push_back(b[i]), g[b[i]].push_back(a[i]);
	}
	dep[0]=-1;
	if(k&1){
		for(int i=1;i<n;i++){
			vis[a[i]]=vis[b[i]]=1;
			tot=0,dfs(a[i],0),dfs(b[i],0);
			ans=min(ans, tot);
			vis[a[i]]=vis[b[i]] = 0;
		}
	} else{
		for(int i=1;i<=n;i++) {
			tot=0,dfs(i,0);
			ans=min(ans,tot);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 

int main(){
  ll a,b,x;
  cin >> a >> b >> x;
  ll m=b/x;
  ll n;
  if(a!=0){
    n=(a-1)/x;
  }
  if(a==0){
    n=-1;
  }
  ll o=m-n;
  cout << o << endl;
}

Measured memory_bytes: 256
/*
 © 2020-08-22 12:40:23 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  lli n, x, t; cin >> n >> x >> t;
  cout << (n % x ? (n / x + 1) * t : (n / x) * t ) << ENDL;
  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
using namespace std;
#define MAX 10000
#define NIL -1

struct Node { int parent, left, right;};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
    if(u==NIL) return;
    D[u]=d;
    setDepth(T[u].left, d+1);
    setDepth(T[u].right, d+1);
}

int setHeight(int u){
    int h1=0, h2=0;
    if(T[u].left!=NIL)
        h1 = setHeight(T[u].left) + 1;
    if(T[u].right!=NIL)
        h2 = setHeight(T[u].right) + 1;
    return H[u] = (h1 > h2 ? h1:h2);
}

int getSibling(int u){
    if(T[u].parent==NIL) return NIL;
    if(T[T[u].parent].left!=u && T[T[u].parent].left!=NIL)
        return T[T[u].parent].left;
    if(T[T[u].parent].right!=u && T[T[u].parent].right!=NIL)
        return T[T[u].parent].right;
    return NIL;
}

void print(int u){
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "sibling = " << getSibling(u) << ", ";
    int deg=0;
    if(T[u].left != NIL) deg++;
    if(T[u].right != NIL) deg++;
    cout << "degree = " << deg << ", ";
    cout << "depth = " << D[u] << ", ";
    cout << "height = " << H[u] << ", ";
    
    if(T[u].parent == NIL){
        cout << "root" << endl;
    }else if(T[u].left==NIL && T[u].right==NIL){
        cout << "leaf" << endl;
    }else{
        cout << "internal node" << endl;
    }
}

int main(){
    int v,l,r,root = 0;
    cin >> n;
    
    for(int i=0; i<n; i++) T[i].parent = NIL;
    
    for(int i=0; i<n; i++){
        cin >> v >> l >> r;
        T[v].left = l;
        T[v].right = r;
        if(l!=NIL) T[l].parent = v;
        if(r!=NIL) T[r].parent = v;
    }
    
    for(int i=0; i<n; i++)
        if(T[i].parent==NIL)
            root = i;
    
    setDepth(root,0);
    setHeight(root);
    
    for(int i=0; i<n; i++)
        print(i);
    
    return 0;
}

Measured memory_bytes: 3100
#include<stdio.h>
#define Max 44


void fivonacci(int n){
	int i;
	int F[Max];
	F[0] = 1;
	F[1] = 1;
	for(i = 2; i <= n; i++){
		F[i] = F[i - 2] + F[i - 1]; 
	}
	printf("%d\n", F[n]);
}

	int main(){
		int n;
		
		scanf("%d", &n);
		fivonacci(n);
		return 0;
	}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
int n;
int a[nax], s = 0;
int main () {
    scanf("%d", &n);

    for (int i = 1 ; i <= n ; ++ i) {
        scanf("%d", a + i);
        s ^= a[i];
    }

    for (int i = 1 ; i <= n ; ++ i)
        printf("%d ", s ^ a[i]);
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans = min(abs(a-b)+abs(b-c),min(abs(b-c)+abs(c-a), abs(c-a)+abs(a-b)));
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
                };
    ll k;
    cin>>k;
    cout<<arr[k-1];
}


Measured memory_bytes: 256
while True:
    a = [];
    n = int(input());
    if n == 0:
        break;
    for i in range(0,n):
        b = int(input());
        a.append(b);

    for i in range(0,10):
        c = a.count(i);
        if c == 0:
            print('-');
        else:
            for j in range(0,c):
                print('*',end = '');
            print();


Measured memory_bytes: 7688
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) (((a) >> (b)) & 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, X;
int f[100], num[100];

int rec(int n, int pos) {
  if (pos == 0) return 0;
  if (n == 0) return 1;

  if (pos >= 2 * num[n - 1] + 2) {
    return f[n];
  } else if (pos >= num[n - 1] + 2) {
    int tmp = pos - (num[n - 1] + 2);
    int res = f[n - 1] + 1 + rec(n - 1, tmp);
    return res;
  } else {
    int tmp = pos - 1;
    return rec(n - 1, tmp);
  }
}

signed main() {
  cin >> N >> X;

  f[0] = num[0] = 1;
  for (int i = 0; i < 50; i++) {
    f[i + 1] = 2 * f[i] + 1;
    num[i + 1] = 2 * num[i] + 3;
  }

  cout << rec(N, X) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int mod = 1000000007;
const int tmpMod = 998244353;

int main() {
 
  int64_t a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  //vector<int64_t> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  
  cout << (c*60+d)-(a*60+b)-e << endl;
}
 

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>

using namespace std;
int main(){
  long n;
  cin >> n;

  int min_f = 100;
  for(long i = 1L; i <= sqrt(n); i++) {
    if(n%i == 0) {
      long tmp_max = max(i, n/i);
      int tmp_f = 1;
      while(tmp_max != 0) {
        tmp_max = tmp_max/10;
        if(tmp_max != 0) {
          tmp_f++;
        }
      }
      min_f = min(min_f, tmp_f);
    }
  }

  cout << min_f << endl;
  return 0;
}


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

int gcd2(int a, int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    if (a == b) 
        return a; 
   
    if (a > b) 
        return gcd2(a%b, b); 
    return gcd2(a, b%a); 
} 

int gcd(int a, int b, int c){
    return gcd2(a,gcd2(b,c));
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    long long ans = 0;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                ans = ans + gcd(i,j,k);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

using namespace std;

typedef long long ll;

int V[20];
int C[20];

int dfs(int i) {
    if (i == -1) return 0;

    int t = dfs(i - 1);
    return max(t, t + V[i] - C[i]);
}

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

    for (int i = 0; i < N; ++i) {
        cin >> V[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> C[i];
    }

    cout << dfs(N - 1) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[100003];
int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		int t;
		cin>>t;
		a[t]++;
		a[t+1]++;
		a[t+2]++;
	}
	cout<<*max_element(a,a+100000)<<endl;
	return 0; 
}

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

using namespace std;



int main(){
string s;
cin>>s;
int a = s.length();
a--;
if(s[a]== '2' || s[a]== '4' || s[a]== '5' || s[a]== '7' || s[a]== '9'){cout<<"hon\n";}
else if(s[a]== '0' || s[a]== '1' || s[a]== '6' || s[a]== '8'){cout<<"pon\n";}
else if(s[a]=='3'){cout<<"bon\n";}
return 0;
}



Measured memory_bytes: 3592
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long A = sc.nextLong();
		long B = sc.nextLong();
		long N = sc.nextLong();
		
		System.out.println(Math.min(B-1, N)*A/B);
		sc.close();
	}
}


Measured memory_bytes: 27096
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>

using namespace std;


int main() {
	int i, j, k;
	int n;
	int a, b;

	cin >> n;

	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		cin >> a;
		cin >> b;

		cout << a + b << endl;
	}


















	getchar();
	getchar();
	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.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int m = in.nextInt();
            out.println(48 - m);
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460