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

using namespace std;
using ll = long long;

#define gc getchar
int getint() { unsigned int c; int x = 0; while (((c = gc()) - '0') >= 10) { if (c == '-') return -getint(); if (!~c) exit(0); } do { x = (x << 3) + (x << 1) + (c - '0'); } while (((c = gc()) - '0') < 10); return x; }
int getstr(char *s) { int c, n = 0; while ((c = gc()) <= ' ') { if (!~c) exit(0); } do { s[n++] = c; } while ((c = gc()) > ' ' ); s[n] = 0; return n; }
template<class T> inline bool chmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<class T> inline bool chmax(T &a, T b) { return a < b ? a = b, 1 : 0; }

int as[100011];

int main () {
    int n = getint();
    for (auto i = 0; i < n; ++i) as[i] = getint() - 1;
    auto now = 0;

    for (auto step = 0; step < n; ++step) {
        now = as[now];
        if (now == 1) {
            cout << step + 1 << endl;
            return 0;
        }
    }
    puts("-1");
    return 0;
}



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

vector<ll> A;
bool ok(int m)
{
    ll tmp = 0;
    for (int i = 0; i <= m; i++)
        tmp += A[i];
    for (int i = m + 1; i < A.size(); i++)
    {
        if (tmp * 2 < A[i])
            return false;
        tmp += A[i];
    }
    return true;
}

int main()
{
    ll n;
    cin >> n;
    A.resize(n);
    rep(i, n) cin >> A[i];
    sort(A.begin(), A.end());

    //にぶたん
    int l = -1;
    int r = n;
    while (r - l > 1)
    {
        int m = l + (r - l) / 2;
        if (ok(m))
            r = m;
        else
            l = m;
    }

    cout << n - r << endl;
}

Measured memory_bytes: 3924
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  int n, i;
  scanf("%d", &n);
  for (i = 1; ; ++i) {
    n -= i;
    if (n <= 0) break;
  }
  for (int j = 1; j <= i; ++j) {
    if (j + n == 0) continue;
    printf("%d\n", j);
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    string S;
    cin >> S;
    ll cnt = 0;
    vector<ll>ans(S.size(), 0);
    rep(rp, 0, 2){
        rep(j, 0, S.size()){
               if(S[j] == 'R')cnt++;
               else {
                   ans[j] += cnt/2;
                   ans[j-1] += (cnt+1)/2;
                   cnt=0;
               }
        }
        
        reverse(S.begin(), S.end());
        reverse(ans.begin(), ans.end());
        rep(i, 0, S.size()){
            if(S[i] == 'R')S[i]='L';
            else S[i]='R';
        }
    }
    rep(i, 0, S.size()){
        cout << ans[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 4268
Module Program
  Sub Main
    Dim s = GetInts()
    Dim a=s(0),b=a\2
    Dim ans=If(a Mod 2=0,b*b,b*(b+1))
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

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

int main() {
  int a,b;
  cin >> a >> b;
  
  if ( (a * b) % 2 == 0 ) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}  
  

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long x = scan.nextLong();
        long a = x / 11;
        long b = x % 11;
        long answer = a * 2;
        if (b != 0) {
            answer += (b <= 6 ? 1 : 2);
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
long long n, ans; 
string s;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> s; ans=1;
for (int i=1; i<n; i++){
	if (s[i]!=s[i-1]) ans++;
}
cout << ans;
return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if (s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n;i>s;i--)
#define repe_r(i,s,n)for(ll i=n;i>=s;i--)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll x[100001] = {};
ll v[100001] = {};
ll r[100001] = {};
ll r_max[100001] = {};
ll l[100001] = {};
ll l_max[100001] = {};
int main() {
	ll n, c; cin >> n >> c;
	repe(i, 1, n)cin >> x[i] >> v[i];

	ll maxE = 0;
	ll sumX = 0;
	repe(i, 1, n) {
		sumX = x[i] - x[i - 1];
		r[i] += v[i] + r[i - 1] - sumX;
		r_max[i] = max(r[i], r_max[i - 1]);
		maxE = max(maxE, r_max[i]);
	}

	repe_r(i, 1, n) {
		sumX = (c - x[i]) - ((i != n) ? (c - x[i + 1]) : 0);
		l[i] += v[i] + l[i + 1] - sumX;
		l_max[i] = max(l[i], l_max[i + 1]);
		maxE = max(maxE, l_max[i]);
	}

	rep(i, 1, n) {
		ll v = r[i] - x[i] + l_max[i + 1];
		maxE = max(maxE, v);
	}

	rep_r(i, 1, n) {
		ll v = l[i] - (c - x[i]) + r_max[i - 1];
		maxE = max(maxE, v);
	}

	cout << maxE << endl;

	return 0;
}

Measured memory_bytes: 4992
n = int(input())
h = list(map(int, input().split()))

ans = 0
cnt = 0

for i in range(n-1):
    if h[i] >=  h[i+1]:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0

ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 14252
n = gets.to_i
list = []
n.times do
  c, n = gets.split
  case c
  when 'insert'
    list.unshift(n)
  when 'delete'
    idx = list.index(n)
    list.delete_at(idx) if idx
  when 'deleteFirst'
    list.shift
  when 'deleteLast'
    list.pop
  else
  end
end
puts list.join(' ')


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

int main(){
    int N,count;
    cin>>N;
    vector<int>su(N);
    for(int i=0;i<N;i++)cin>>su.at(i);
    
    count=0;
    bool flag = false;
    for (int i=0;;i++) {
        for (int j=0;j<N;j++) { 
            // チェックの処理＋２で割る処理
            
            // もし奇数なら、フラグを立てて内側、外側両方のfor文をbreakする。
            if(su.at(j)%2==1)flag=true;
            if(flag)break;
            su.at(j)=su.at(j)/2;
        }
        if(flag)break;
        count++;
    }

    cout<<count<<endl;
}

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

int main(){
    int A,B,C,X,S,count;
    cin >> A >> B >> C >> X;

    for(int i = 0;i < A + 1;i++){
        for(int j = 0;j < B + 1;j++){
            for(int k = 0;k < C + 1;k++){
                S = 500  * i + 100 * j + 50 * k;
                if(S == X){
                    count++;
                }
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void){

 int w, h, x, y, r;

 scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

 if(0 <=  x - r && x - r <= w && 0 <= x + r && x + r <= w && 0 <= y - r && y - r <= h && 0 <= y + r && y + r <= h){
    puts("Yes");
 }else{
    puts("No");
 }
  return 0;

}

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

int main() {
	int N;
   	cin >> N;
  	
  	vector<int> top(N),bottom(N);
  
  	for(int i = 0; i < N; i++) {
    cin >> top.at(i);
    }
  
  	for(int i = 0; i < N; i++) {
    cin >> bottom.at(i);
    }
  
  	int k = 0,maxi = 0;
  	while(k < N) {
      int sum = 0;
  	for(int i = 0; i <= k; i++) {
    	sum += top.at(i);
      }
      
    for(int i = k; i < N; i++) {
    	sum += bottom.at(i);
    }
      maxi = max(sum,maxi);
      k++;
    }
  
  	cout << maxi << endl;
  
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

go = ""
back = ""

if sx <= tx:
    for i in range(tx-sx):
        go += "R"
        back += "L"
else:
    for i in range(sx-tx):
        go += "L"
        back += "R"
        
if sy <= ty:
    for i in range(ty-sy):
        go += "U"
        back += "D"
else:
    for i in range(ty-sy):
        go += "D"
        back += "U"

go_2nd = ""
back_2nd = ""

if sx <= tx:
    if sy <= ty:
        go_2nd += "D"
        go_2nd += "R"
        go_2nd += go
        go_2nd += "U"
        go_2nd += "L"
        back_2nd += "U"
        back_2nd += "L"
        back_2nd += back
        back_2nd += "D"
        back_2nd += "R"
    else:
        go_2nd += "U"
        go_2nd += "R"
        go_2nd += go
        go_2nd += "D"
        go_2nd += "L"
        back_2nd += "D"
        back_2nd += "L"
        back_2nd += back
        back_2nd += "U"
        back_2nd += "R"
else:
    if sy <= ty:
        go_2nd += "D"
        go_2nd += "L"
        go_2nd += go
        go_2nd += "U"
        go_2nd += "R"
        back_2nd += "U"
        back_2nd += "R"
        back_2nd += back
        back_2nd += "D"
        back_2nd += "L"
    else:
        go_2nd += "U"
        go_2nd += "L"
        go_2nd += go
        go_2nd += "D"
        go_2nd += "R"
        back_2nd += "D"
        back_2nd += "R"
        back_2nd += back
        back_2nd += "U"
        back_2nd += "L"


print(go + back + go_2nd + back_2nd)

Measured memory_bytes: 3188
#include <iostream>
#include <sstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <set>
#include <memory>

struct TestData
{
  int testNum;
  std::string input;
  std::string expectedOutput;
};

struct TestResult
{
  std::string expectedOutput;
  std::string testOutput;
  bool testPassed;
};

void testSolution();
TestResult runTestCase(const TestData& testData);
std::string formatResult(int testNum, const TestResult& testResult);
std::string formatOverallResult(const std::vector<TestResult>& testResult);
void testHelpers();
void solution(std::istream& is, std::ostream& os);

static const bool IS_TESTING = false;

// define test data
static const std::vector<TestData> testDatas = {
  {1, "2\n", "1\n"},
  {2, "13\n", "78\n"},
  {3, "1\n", "0\n"},
};
static const std::vector<TestResult (*)()> helpers = {
  
};

int main()
{
  if (IS_TESTING) {
    testSolution();
    testHelpers();
  }
  else
    solution(std::cin, std::cout);

  return 0;
}

void testSolution()
{
  std::cout << "Testing solution..." << std::endl;
  
  auto results = std::vector<TestResult>();
  for (const auto& testData : testDatas) {
    auto testResult = runTestCase(testData);
    results.push_back(testResult);

    std::cout << formatResult(testData.testNum, testResult);
  }
  std::cout << formatOverallResult(results);
}

TestResult runTestCase(const TestData& testData)
{
    std::istringstream iss {testData.input};
    std::ostringstream oss {};

    solution(iss, oss);

    auto testOutput = oss.str();
    auto testPassed = testData.expectedOutput.compare(testOutput) == 0;
    
    return {testData.expectedOutput, testOutput, testPassed};
}

std::string formatResult(int testNum, const TestResult& testResult)
{
  std::ostringstream oss {};

  oss << "Test " << std::setw(2) << testNum << ": "
    << (testResult.testPassed ? "Passed!" : "Failed!") << std::endl;
  
  oss << "\tExpected: " << testResult.expectedOutput << "\tActual  : " << testResult.testOutput << std::endl;

  return oss.str();
}

std::string formatOverallResult(const std::vector<TestResult>& testResults)
{
  std::ostringstream oss {};

  int passedTestCount = 0;
  for (const auto& result : testResults) {
    if (result.testPassed) passedTestCount++;
  }

  oss << passedTestCount << "/" << testResults.size()
    << " tests passed" << std::endl;

  return oss.str();
}

void testHelpers()
{
  std::cout << "Testing helpers..." << std::endl;

  std::vector<TestResult> testResults;
  for (auto i = 0; i < helpers.size(); ++i) {
    auto result = helpers[i]();
    testResults.push_back(result);
    std::cout << formatResult(i, result);
  }

  std::cout << formatOverallResult(testResults);
}

// solution to the problem
void solution(std::istream& is, std::ostream& os)
{
  // read from input
  unsigned long long numCount; is >> numCount;
  
  os << (((numCount - 1) * numCount) / 2) << std::endl;
}

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

int tmp[26];

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

	for (int i = 0; i < S.length(); ++i) {
		++tmp[S[i] - 97];
		if (tmp[S[i] - 97] > 1) {
			cout << "no" << endl;
			return 0;
		}
	}

	cout << "yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<ctype.h>
using namespace std;

int main() {
	string str;
	char check;
	getline(cin, str);
	for (int i = 0; i < str.size(); i++) {
		if (isalpha(str[i]) != 0) {
			check =str[i];
			str[i] = tolower(str[i]);
			if (check == str[i])
				str[i] = toupper(str[i]);
		}
		cout << str[i];
	}
	cout << endl;
	return 0;
}


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

using namespace std;
#define ll long long

ll sumA[100000000];

ll cut(ll *A, ll i, ll j, ll precut) {
	ll sum=0, medium=0;
	ll cutpoint;
	ll min;
	ll cur;
	ll temp;
	if(i==0) cur=0;
	else cur=sumA[i-1];
	for(int k=precut-1;k<j-1;k++) {
		if(k!=precut-1 && temp < llabs((sumA[k]-cur) - (sumA[j-1]-sumA[k])))
			break;
		temp=llabs((sumA[k]-cur) - (sumA[j-1]-sumA[k]));
		if(k==precut-1){
			min=temp;
			cutpoint=k;
		}else if(min>temp){
			min=temp;
			cutpoint=k;
		}
	}
	return cutpoint+1;
}

ll F(ll N,ll i,ll j,ll k){
	ll sum[4];
	for(int m=0;m<4;m++) sum[m]=0;
	sum[0]=sumA[i-1];
	sum[1]=sumA[j-1]-sumA[i-1];
	sum[2]=sumA[k-1]-sumA[j-1];
	sum[3]=sumA[N-1]-sumA[k-1];
	ll min=sum[0],max=sum[0];
	for(int m=1;m<4;m++) {
		if(min>sum[m]) min=sum[m];
		if(max<sum[m]) max=sum[m];
	}
	return max-min;
	
}

int main(){
	ll N;
	ll *A;
	ll sum=0;
	cin >> N;
	A = (ll*) malloc(N*sizeof(*A));
	for(ll i=0;i<N;i++){
		cin >> A[i];
		if(i==0) sumA[i]+=A[i];
		else sumA[i]+=A[i]+sumA[i-1];
	}
	ll medium=sumA[N-1]/4;
	ll s=0;
	ll P[2]={1,3};
	ll min=0, temp;
	for(int i=2;i<=N-2;i++) {
		P[0]=cut(A,0,i,P[0]);
		P[1]=cut(A,i,N,P[1]);
		ll temp = F(N,P[0],i,P[1]);
		if(i==2) min = temp;
		else if(min>temp) min = temp;
	}
	cout << min << "\n";
	return 0;
}


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

void main_()
{
    int N, L;
    vector<string> Ss;
    cin >> N >> L;
    copy_n(istream_iterator<string>(cin), N, back_inserter(Ss));
    sort(begin(Ss), end(Ss));
    for (auto&& s : Ss) {
        cout << s;
    }
    cout << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n,i,j,num;
  char card[5][14]={0},mark;
  //s=1,h=2,c=3,d=4
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf(" %c %d",&mark,&num);
    if(mark=='S')card[1][num]=1;
    if(mark=='H')card[2][num]=1;
    if(mark=='C')card[3][num]=1;
    if(mark=='D')card[4][num]=1;
  }
  for(i=1;i<=4;i++){
    for(j=1;j<=13;j++){
      if(card[i][j]==0){
	if(i==1)printf("S %d\n",j);
	if(i==2)printf("H %d\n",j);
	if(i==3)printf("C %d\n",j);
	if(i==4)printf("D %d\n",j);
      }
    }
  }
  return 0;
}
	

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

using namespace std;
using ll = long long;

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

int main() {
  int n = 5;
  int sum = 0;
  rep(i, n) {
    int x;
    cin >> x;
    sum += x;
  }
  cout << 15 - sum << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.

using namespace std;
typedef long long ll;

int main() {
	ll S;
	cin >> S;

	ll X1=0, Y1=0, X2=0, Y2=0, X3=0, Y3=0;

	if(S<=1000000000) {
		X2 = S;
		Y2 = 0;
		X3 = 0;
		Y3 = 1;
		cout << X1 << ' ' << Y1 << ' ' << X2 << ' ' << Y2 << ' ' << X3 << ' ' << Y3 << endl;
		return 0;
	}

	X2 = 1000000000;
	Y2 = 1;

	Y3 = dup(S, X2);
	X3 = X2 * Y3 - S;

	cout << X1 << ' ' << Y1 << ' ' << X2 << ' ' << Y2 << ' ' << X3 << ' ' << Y3 << endl;
	//cout << X2*Y3-X3*Y2 << endl;
  return 0;
}


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

int main()
{
	/*
	cout << '0' - 48 << endl;
	cout << '1' - 48 << endl;
	cout << '2' - 48 << endl;
	cout << '9' - 48 << endl;
	*/
	string s;
	cin >> s;
	int num;
	long long int sum = 0;
	for (char c : s)
	{
		num = c - 48;
		sum = sum + num;
	}
	if (sum % 9 == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    int a[110000];
    int num = 0;

    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        if(a[i]%2 != 0) num++;
    }
    if (num%2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int n,m;
	int a[1002],b[1002];
	int temp,c=0,ans=0;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<m;i++){
		for(int j=m-1;j>i;j--){
			if(a[i]<a[j]){
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
		}
	}
	for(int i=0;i<m;i++){
		if(c>=m-1){
			cout<<ans<<endl;
		}
		if(a[i]>=n){
			c++;
		}
		else{
			ans+=n-a[i];
			c++;
		}
	}
}

Measured memory_bytes: 3076
n = int(input())
A = list(map(int, input().split()))

minus = 0
for a in A:
    if a < 0:
        minus += 1

min_abs = 10**9 + 1
for a in A:
    min_abs = min(min_abs, abs(a))

abs_sum = 0
for a in A:
    abs_sum += abs(a)

if minus % 2 == 0:
    print(abs_sum)
else:
    print(abs_sum - 2 * min_abs)

Measured memory_bytes: 64752
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = ll(1e18) + 1;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    int n; ll k;
    cin >> n >> k;
    vector <ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    ll l=-INF, r=INF;
    while(l+1 < r){
        ll x=(l+r)/2;
        
        bool ok =[&]{
            ll tot=0;
            rep(i,n){
                if (a[i]<0){
                    int l=-1, r=n;
                    while(l+1<r){
                        int c=(l+r)/2;
                        if (a[c]*a[i]<x) r=c;
                        else l=c;
                    }
                    tot += n-r;
                }else{
                    int l=-1, r=n;
                    while(l+1<r){
                        int c=(l+r)/2;
                        if (a[c]*a[i]<x) l=c;
                        else r=c;
                    }
                    tot += r;
                }
                if (a[i]*a[i]<x) tot--;
            }
            tot/=2;
            return tot<k;
        }();
        if (ok) l=x; else r=x;
    }
    cout << l << endl;
    return 0;
}



Measured memory_bytes: 1792
from sys import stdin
readline = stdin.readline


def main():
    v, e = map(int, readline().split())
    from collections import defaultdict
    g = defaultdict(list)

    for _ in range(e):
        s, t = map(int, readline().split())
        g[s].append(t)
        g[t].append(s)

    visited = set()
    lowest = [None] * v
    parent = [None] * v
    prenum = [None] * v
    child = defaultdict(list)
    root = 0

    # dfs??§tree?????????
    stack = [(root, None)]
    while stack:
        u, prev = stack.pop()
        if u not in visited:
            parent[u] = prev
            if prev is not None:
                child[prev].append(u)
            visited |= {u}
            prenum[u] = lowest[u] = len(visited)

        stack.extend([(v, u) for v in g[u] if v not in visited])

    # lowest????¨????
    from collections import Counter
    leaf = [i for i in range(v) if not child[i]]
    unfinished = Counter()
    for li in leaf:
        while li is not None:
            candidate = [prenum[li]] + [prenum[i] for i in g[li] if i != parent[li]] + [lowest[i] for i in child[li]]
            lowest[li] = min(candidate)
            li = parent[li]
            if li is not None and 1 < len(child[li]):
                unfinished[li] += 1
                if unfinished[li] < len(child[li]):
                    break

    # ??£???????????????
    if 2 <= len(child[root]):
        print(root)
    for i in range(1, v):
        if child[i] and any(prenum[i] <= lowest[j] for j in child[i]):
            print(i)
main()

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


int main()
{
  int N;
  cin>>N;
  int A[1000000];
  int B[20];

  for(int i=0;i<=N;i++){
    B[i]=pow(2,i);
  }
  for(int i=1;i<=B[N];i++){
    cin>>A[i];
  }


  for(int i=0;i<=N;i++){
    for(int j=2;j<=B[N-i];j+=2){
      if(A[j]!=A[j-1]){
      A[j/2]=abs(A[j]-A[j-1]);
      }
      else A[j-2]=A[j];
    }
  }

  cout<<A[1]<<endl;

  return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		for (int T = sc.nextInt(); 0 < T; T--) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			
			a *= a;
			b *= b;
			c *= c;
			if (a + b == c || a + c == b || b + c == a) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}

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

Measured memory_bytes: 23396
require 'scanf'

def check(str)
    keys=["this","the","that"]
    for i in keys do
        return true if str.index(i) != nil
    end
    return false
end

while str = STDIN.gets
    while not check(str)
        for i in 0..str.length do
            if /[a-y]/ =~ str[i] then
                str[i] = str[i].succ
            elsif /[z]/ =~ str[i] then
                str[i] = 'a'
            end
        end
    end
    print str
end

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

#define bolt ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double ld;

const ld pi=3.1415926535897932384626433;
const int mod = 1000000007;
const ll inf=3e18;
// 90DTG
ll dp[101][100001];
ll w[101];
ll v[101];
ll n;
ll W;
ll god(ll ind, ll avlw)
{
   //cerr<<ind<<" "<<avlw<<" "<<endl;
   if (ind==n)
      return 0;

   if (dp[ind][avlw]!=-1)
      return dp[ind][avlw];

   if (w[ind]>avlw)
      return dp[ind][avlw]=god(ind+1,avlw);

   ll ans=0;
   return dp[ind][avlw]=max(god(ind+1,avlw),v[ind]+god(ind+1,avlw-w[ind]));
}
int main ()
{
   bolt;
   memset (dp,-1,sizeof(dp));
   cin>>n>>W;
   for (ll i=0;i<n;i++)
   {
      cin>>w[i]>>v[i];
   }
   cout<<god(0,W);

}


Measured memory_bytes: 79232
#include<iostream>
#include<vector>

using namespace std;

int main()
{
    int N, K;  cin >> N;
    long long ans;
    K = (N+1)/2;
    vector<int> v(K,0), A(N);
    if(N%2==0){
        for(int i=0; i<N; i++){
            cin >> A[i];
            if(A[i]%2==0){
                cout << 0;
                return 0;
            }
            v[(A[i]-1)/2]++;
        }
    }else{
        for(int i=0; i<N; i++){
            cin >> A[i];
            if(A[i]%2==1){
                cout << 0;
                return 0;
            }
            v[(A[i]+1)/2]++;
        }
    }
    for(int i=0; i<K; i++){
        if(i == 0){
            if(v[i] != 1 && N%2==1){
                cout << 0;
                return 0;
            }else if(v[i] != 2 && N%2==0){
                cout << 0;
                return 0;                
            }
        }else{
            if(v[i] != 2){
                cout << 0;
                return 0;
            }
        }
    }
    ans = 1;
    for(int i=0; i<N/2; i++)  ans = ans*2%1000000007;
    cout << ans;
}

Measured memory_bytes: 3716
//In the Name of God
//Ya Ali

#include <bits/stdc++.h>

#define int long long

#define err(A) cout << #A << " = " << (A) << endl

using namespace std;

const int maxn = 256;

int n;

int d[maxn][maxn];
vector<int> g[maxn];

int vis[maxn];

int ans;

void dfs(int v, int c = 1)
{
  vis[v] = c;
  for (int u: g[v])
    if (!vis[u])
      dfs(u, -c);
    else if (c == vis[u])
      {
	cout << -1 << endl;
	exit(0);
      }
}

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

  memset(d, 30, sizeof d);
  int inf = d[0][0];

  cin >> n;
  for (int i = 0; i < n; i ++)
    {
      d[i][i] = 0;
      string s;
      cin >> s;
      for (int j = 0; j < n; j ++)
	if (s[j] == '1')
	  {
	    d[i][j] = 1;
	    g[i].push_back(j);
	  }
    }

  for (int i = 0; i < n; i ++)
    if (!vis[i])
      dfs(i);

  for (int k = 0; k < n; k ++)
    for (int i = 0; i < n; i ++)
      for (int j = 0; j < n; j ++)
	d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

  for (int i = 0; i < n; i ++)
    for (int j = 0; j < n; j ++)
      if (d[i][j] < inf)
	ans = max(ans, d[i][j] + 1);

  cout << ans << endl;
    

  return 0;
}


Measured memory_bytes: 1152
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val L = readLine()!!.split(" ").map { it.toInt() }.sorted().toTypedArray()
  var cnt = 0
  for (i in 0 until n - 2) {
    for (j in i + 1 until n - 1) {
      val index = lowerBound(L, L[i] + L[j])
      val found = index - 1 - j
      cnt += found
//      println("($i $j): ${L[i]} + ${L[j]} = ${L[i] + L[j]}, index: $index, found: $found")
    }
  }
  println(cnt)
}

fun lowerBound(array: Array<Int>, value: Int, first: Int = 0, last: Int = array.size): Int {
  var first = first - 1
  var last = last
  while (last - first > 1) {
    val middle = first + (last - first) / 2
    if (array[middle] < value) {
      first = middle
    } else {
      last = middle
    }
  }
  return last
}

fun upperBound(array: Array<Int>, value: Int, first: Int = 0, last: Int = array.size): Int {
  var first = first - 1
  var last = last
  while (last - first > 1) {
    val middle = first + (last - first) / 2
    if (array[middle] <= value) {
      first = middle
    } else {
      last = middle
    }
  }
  return last
}


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int x,y,z;
  x = c;
  y = a;
  z = b;
  cout<<x<<' '<<y<<' '<<z<<endl;
}
  
  
  


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define mset(a,x) memset(a,x,sizeof(a))
#define OUT(x) cout<<(x)<<"\n"
#define SZ(x) (int)(x).size()
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)

int n, p;


int main() {
    FASTIO;
    cin >> n >> p;
    vector<int> a(n);
    for (auto&& i : a) cin >> i;

    static ll dp[55][5050];
    mset(dp, 0);
    dp[0][0] = 1;
    FOR(i, 1, n + 1) {
        FOR(j, 0, 50 * 100 + 1) {
            dp[i][j] += dp[i - 1][j];
            if (j - a[i - 1] >= 0) dp[i][j] += dp[i - 1][j - a[i - 1]];
        }
    }

    ll ans = 0;
    rep(j, 50 * 100 + 1) {
        if (dp[n][j] == 0) continue;
        if (j % 2 != p) continue;
        ans += dp[n][j];
    }

    OUT(ans);

    return 0;
}

Measured memory_bytes: 2432
#include <cstdio>

int main()
{
    int S;
    scanf("%d", &S);
    int h = S / 3600;
    int m = (S % 3600) / 60;
    int s = (S % 3600) % 60;
    printf("%d:%d:%d\n", h, m, s);
}


Measured memory_bytes: 2744
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    while(n--){
        double x1,x2,x3,y1,y2,y3;
        scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
        double a1,a2,b1,b2,c1,c2;
        a1=2*(x2-x1);b1=2*(y2-y1);
        a2=2*(x3-x1);b2=2*(y3-y1);
        c1=x1*x1-x2*x2+y1*y1-y2*y2;
        c2=x1*x1-x3*x3+y1*y1-y3*y3;
        double x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
        double y=(c1*a2-c2*a1)/(a1*b2-a2*b1);

        double a=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
        double b=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
        double c=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
        double s=(a+b+c)/2;
        double r=(a*b*c)/(4*sqrt(s*(s-a)*(s-b)*(s-c)));
        printf("%.3f %.3f %.3f\n",x,y,r);
    }
}

Measured memory_bytes: 1092
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	string S;
	cin >> S;
	long long no;
	for (no = 0; no < S.size(); no++) {
		if (S.at(no) != '1') {
			break;
		}
	}

	long long  K;
	cin >> K;

	if (K - 1 < no) {
		cout << 1 << endl;
	}
	else {
		cout << S.at(no) << endl;
	}
}

Measured memory_bytes: 256
n = input()
nlis = list(n)

if nlis[-1] == '2' or nlis[-1] == '4' or nlis[-1] == '5' or nlis[-1] == '7' or nlis[-1] == '9':
    print('hon')
elif nlis[-1] == '0' or nlis[-1] == '1' or nlis[-1] == '6' or nlis[-1] == '8':
    print('pon')
else:
    print('bon')


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, H, W;
  cin >> N >> H >> W;
  cout << (N - H + 1) * (N - W + 1) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 300005
#define LL long long
#define INF (1LL<<60)
using namespace std;
int n,q,Q[N],lq,rq; double Y[N];
LL f[N],g[N],wl[N],wr[N],w[N],S[N],T[N];
LL upd(int j,int i){ return f[j]-S[i]+S[j]+1LL*(i-j+1)*(i-j)/2;}
double K(int i,int j){ return 1.0*(Y[j]-Y[i])/(j-i);}
void dp()
{
	int i; Q[lq=rq=1]=0;
	for(i=1;i<=n;i++) S[i]=S[i-1]+T[i];
	for(i=1;i<=n;i++){
		f[i]=f[i-1];
		while(lq>1&&K(Q[lq],Q[lq-1])<i) lq--;
		if(lq<=rq) f[i]=max(f[i],upd(Q[lq],i));
		Y[i]=f[i]+1LL*(i-1)*i/2+S[i];
		while(rq>1&&K(i,Q[rq-1])>K(Q[rq],Q[rq-1])) rq--;
		Q[++rq]=i,lq=min(lq+1,rq);
	  }
}
void sol(int l,int r,LL *w,int o)
{
	int i,mid=(l+r-o)>>1; LL x;
	if(l==r){
		w[l]=max(w[l],f[l-1]+1-T[l]+g[l+1]); 
		return ;
	  }
	sol(l,mid,w,o),sol(mid+1,r,w,o);
	lq=1,rq=0;
	for(i=l-1;i<=mid;i++){
		Y[i]=f[i]+1LL*(i-1)*i/2+S[i];
		while(lq<rq&&K(i,Q[rq-1])>K(Q[rq],Q[rq-1])) rq--;
		Q[++rq]=i;
	  }
	x=-INF;
	for(i=r;i>mid;i--){
		while(lq<rq&&K(Q[rq-1],Q[rq])<i) rq--;
		x=max(x,upd(Q[rq],i)+g[i+1]);
		w[i]=max(w[i],x);
	  }
}
int main()
{
	int i,p,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%lld",&T[i]);
	dp();
	for(i=1;i<=n/2;i++)
		swap(T[i],T[n-i+1]);
	for(i=1;i<=n;i++) g[i]=f[i];
	dp();
	for(i=1;i<=n;i++) swap(f[i],g[i]);
	for(i=1;i<=n/2;i++){
		swap(T[i],T[n-i+1]);
		swap(g[i],g[n-i+1]);
	  }
	for(i=1;i<=n;i++) wl[i]=wr[i]=-INF;
	for(i=1;i<=n;i++) S[i]=S[i-1]+T[i];
	sol(1,n,wl,0);
	for(i=1;i<=n;i++) swap(f[i],g[i]);
	for(i=1;i<=n/2;i++){
		swap(T[i],T[n-i+1]);
		swap(f[i],f[n-i+1]);
		swap(g[i],g[n-i+1]);
	  }
	for(i=1;i<=n;i++) S[i]=S[i-1]+T[i];
	sol(1,n,wr,1);
	for(i=1;i<=n/2;i++){
		swap(f[i],f[n-i+1]);
		swap(g[i],g[n-i+1]);
		swap(T[i],T[n-i+1]);
		swap(wr[i],wr[n-i+1]);
	  }
	for(i=1;i<=n;i++)
		w[i]=max(wl[i],wr[i]);
	for(i=1;i<=n;i++) swap(f[i],g[i]);
	scanf("%d",&q);
	while(q--){
		scanf("%d %d",&p,&x);
		printf("%lld\n",max(f[p-1]+g[p+1],w[p]+T[p]-x));
	  }
	return 0;
}


Measured memory_bytes: 21376
import java.util.Scanner;
import java.math.*;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		double a = scan.nextDouble();
		BigDecimal x = new BigDecimal(a*a*Math.PI);
		x = x.setScale(6, BigDecimal.ROUND_HALF_UP);
		BigDecimal y = new BigDecimal(2*a*Math.PI);
		y = y.setScale(6, BigDecimal.ROUND_HALF_UP);
		System.out.println(x +" "+ y);
	}
}

Measured memory_bytes: 19120
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<cstdlib>
using namespace std;
long long n,m;
int main(){
	cin>>n>>m;
	cout<<min(n%m,m-n%m)<<endl;
	return 0;
}

Measured memory_bytes: 256
a=input()
c=int(a)
b=len(a)
ans=0
if b==1:
    print(c)
elif b==2:
    print(9)
elif b==3:
    print(9+c-99)
elif b==4:
    print(9+900)
elif b==5:
    print(9+900+c-9999)
elif b==6:
    print(9+900+90000)
    


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n,d;
  cin >> n >> d;
  cout << (n+(2*d))/(2*d+1);
 return 0;
}


Measured memory_bytes: 256
program answer
  implicit none

  integer(8) :: N, A, B, i

  read(*,*) N, A, B
  if(A==0) then
     write(*,*) '0'
     stop
  else if(B==0) then
     write(*,*) N
     stop
  end if

  if(mod(N,(A+B))==0) then
     write(*,*) N/(A+B)*A
     stop
  end if

  if(mod(N,(A+B))<=A) then
     write(*,*) N/(A+B)*A + mod(N,(A+B))
  else
     write(*,*) N/(A+B)*A +A
  end if

  stop
 end program answer

Measured memory_bytes: 2768
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  string SA,SB,SC;
  cin>>SA>>SB>>SC;
  queue<char> A,B,C;
  for(auto&& e: SA) 
  {
    A.push(e);
  }
  for(auto&& e: SB) 
  {
    B.push(e);
  }
  for(auto&& e: SC) 
  {
    C.push(e);
  }
  char t='a';
  while(true)
  {

    if(t=='a')
    {
      if(A.empty())
      {
        cout<<"A"<<endl;
        return 0;
      }
      t=A.front();
      A.pop();
    }
    else if(t=='b') 
    {
      if(B.empty())
      {
        cout<<"B"<<endl;
        return 0;
      }
      t=B.front();
      B.pop();
    }
    else
    {
      if(C.empty())
      {
        cout<<"C"<<endl;
        return 0;
      }
      t=C.front();
      C.pop();
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;
using ll = long long;

int main(){
    ll c=0,d=0,e,m,n,k,o=0,p,l,q,x1,y1,z,max1=0,s=0,ans,r,i1=-1,x,w,h,y,j1;
    string t,u;
    
    cin>>n>>l;
    o=max(l,-l);
    for(ll i=2;i<n+1;i++){
    if(max(i+l-1,-i-l+1)<max(o,-o))o=i+l-1;
    
    }
    
    cout<<n*(n+1)/2+(l-1)*n-o<<endl;
}




Measured memory_bytes: 888
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,m;
    int i,j;
    scanf("%d %d",&n,&m);
    int a[n][m];
    int b[m];
    int out[n];
    for(i=0;i<n;i++){
        out[i]=0;
        for((j=0);j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }for(j=0;j<m;j++){
        scanf("%d",&b[j]);
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            out[i]+=a[i][j]*b[j];
        }
    }for(i=0;i<n;i++){
        printf("%d\n",out[i]);
    }
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e5+5;

#define endl '\n'

struct node{
	int idx,cp;
}a[N];

bool cmp(const node&x,const node&y){
	return x.cp<y.cp;
}

int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i].cp;
		a[i].idx=i+1;
	}
	sort(a,a+n,cmp);
	for(int i=0;i<n;i++)
	cout<<a[i].idx<<(i<(n-1)?' ':'\n');
	return 0;
}

Measured memory_bytes: 1664
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
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();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iterator i=(c).begin();i!=(c).end();++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS=1e-10;
const double PI=acos(-1.0);
#define EQ(a,b) abs((a)-(b))<EPS

#include<math.h>
int main(){
	int N;
	cin>>N;
	REP(i,N){
		int nowX=0,nowY=0;
		int maxX=0,maxY=0;
		double root=0;
		double maxRoot=0;
		int X,Y;
		while(1){
			cin>>X>>Y;
			if(X==0&&Y==0)	break;
			nowX=nowX+X;
			nowY=nowY+Y;
			root=sqrt((double)nowX*nowX+nowY*nowY);
			if(root>maxRoot||(EQ(root,maxRoot)&&nowX>maxX)){
				maxRoot=root;
				maxX=nowX;
				maxY=nowY;
			}
		}
		cout<<maxX<<" "<<maxY<<endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

const long long mod = 1E9 + 7;

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

	vector<vector<long long>> dp(S.size()+1, vector<long long>(4, 0));
	dp[0][0] = 1;
	for(int i=0; i<S.size(); i++){
		for(int j=0; j<4; j++){
			if(S[i] != '?')
				dp[i+1][j] += dp[i][j];
			else{
				dp[i+1][j] += 3*dp[i][j];
				dp[i+1][j] %= mod;
			}
		}

		if(S[i] == 'A' || S[i] == '?'){
			dp[i+1][1] += dp[i][0];
			dp[i+1][1] %= mod;
		}
		if(S[i] == 'B' || S[i] == '?'){
			dp[i+1][2] += dp[i][1];
			dp[i+1][2] %= mod;
		}
		if(S[i] == 'C' || S[i] == '?'){
			dp[i+1][3] += dp[i][2];
			dp[i+1][3] %= mod;
		}
	}

	cout << dp[S.size()][3]%mod << endl;

	return 0;
}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n; cin >> n;
    V<pii> data;
    for(int i=0; i<n; i++) {
        int a, b; cin >> a >> b;
        data.push_back({a-b, a+b});
    }
    sort(data.begin(), data.end());
    int end = data[0].second;
    int res = 0;
    for(int i=1; i<data.size(); i++) {
        if(data[i].first < end) {
            res++;
            end = min(data[i].second, end);
        } else {
            end = data[i].second;
        }
    }
    cout << n - res << endl;
}


Measured memory_bytes: 1400
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

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

	vector<int> A(N);
	for(int i=0; i<N; i++)
		cin >> A[i];

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

	vector<int> M(N), W(N);
	for(int i=0; i<N; i++){
		if(i%2 == 0){
			M[i] = -2;
			W[i] = 2;
		}
		else{
			M[i] = 2;
			W[i] = -2;
		}
	}
	M[0] -= M[0]/2;
	M[N-1] -= M[N-1]/2;
	W[0] -= W[0]/2;
	W[N-1] -= W[N-1]/2;

	sort(M.begin(), M.end());
	sort(W.begin(), W.end());

	long long sumM, sumW;
	sumM = sumW = 0;
	for(int i=0; i<N; i++){
		sumM += 1LL * A[i] * M[i];
		sumW += 1LL * A[i] * W[i];
	}

	cout << max(sumM, sumW) << endl;

	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void pr(){
    cout << -1 << endl;
    exit(0);
}

// 隣接リスト
const ll MAX_V = 210;
vvll g(MAX_V, vll());
vi visited(MAX_V, 0);

// グラフに対する幅優先探索
ll bfs(ll start){
    queue<pll> q;
    visited[start] = 1;
    ll depth = 1;
    ll now = start;
    q.emplace(now, depth);
    while(!q.empty()){
        now = q.front().first;
        depth = q.front().second;
        q.pop();
        for(auto to: g[now]){
            if(!visited[to]){
                visited[to] = depth+1;
                q.emplace(to, depth+1);
            }else if(visited[to] == depth+1 || visited[to] == depth-1){
                
            }else{
                cout << -1 << endl;
                exit(0);
            }
        }
    }
    return depth;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vs s(n);
    rep(i, n){
        cin >> s[i];
    }
    rep(i, n){
        rep(j, n){
            if(s[i][j] == '1'){
                g[i].emplace_back(j);
                g[j].emplace_back(i);
            }
        }
    }
    vll ans(n);
    rep(i, n){
        fill(ALL(visited), 0);
        ans[i] = bfs(i);
    }
    dump(ans);
    cout << *max_element(ALL(ans)) << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;

int main(void)
{
    int N, A;
    cin >> N >> A;

    int rest = N % 500;
    if (rest <= A)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return (0);
}

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

int main(){
    int a;
    
    cin>>a;
    if(a==25){cout<<"Christmas"<<endl;}
    else if(a==24){cout<<"Christmas Eve"<<endl;}
    else if(a==23){cout<<"Christmas Eve Eve"<<endl;}
    else{cout<<"Christmas Eve Eve Eve"<<endl;}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vec vector<int>
#define vecll vector<ll>

using namespace std;
///////////////////////////////////////////////////////////



int main() {
    int h, n;
    cin >> h >> n;
    vec a;
    int x;
    rep(i, n) {
        cin >> x;
        a.push_back(x);
    }

    if (accumulate(a.begin(), a.end(), 0) >= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;



    return 0;
}

Measured memory_bytes: 892
#include<stdio.h>
long long gys(long long x,long long y)
{
	if(x!=y&&x>y)
	{
		x^=y;
		y^=x;
		x^=y;
	}
	  
	
	while(y%x!=0)
	{
		long long r=y%x;
		y=x;
		x=r;
		
	}
	return x;
	
}


int main()
{
	int x,y;
	long long a[105];
	scanf("%d",&x);
//	scanf("%d%d",&x,&y);
//	printf("%d",gys(x,y));
for(int i=0;i<x;i++)
scanf("%lld",&a[i]);


	long long first=a[0];
	for(int i=1;i<x;i++)
	{
	     first=a[i]/gys(first,a[i])*first;
	
    }
	printf("%lld\n",first);		
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

int main() {
    string S; cin >> S;
    bool f = true;
    int N = S.length();
    for (int i = 0; i < N; i++) {
        if (S[i] != S[N-1-i]) f = false;
    }
    for (int i = 0; i < (N-1)/2; i++) {
        if (S[i] != S[(N-1)/2 - 1 - i]) f = false;
    }
    for (int i = 0; i < (N-1)/2; i++) {
        if (S[i+(N-1)/2+1] != S[i]) f = false;
    }
    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;

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

    int res = 0;
    int t = 1;
    for (int i = b.size() - 1; i >= 0; i--)
    {
        res += t * (b[i] - '0');
        t *= 10;
    }

    for (int i = a.size() - 1; i >= 0; i--)
    {
        res += t * (a[i] - '0');
        t *= 10;
    }

    if ((int)sqrt(res) * (int)sqrt(res) == (res))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
    string s;
    cin >> s;
    bool k=false;
    if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])k=true;
    if(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1])k=true;
    if(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1])k=true;
    if(k)cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    int n;cin>>n;
    int a;
    map<int,int> m;
    
    rep(i,n){
        cin>>a;
        m[a]++;
    }
    
    int ans = 0;
    
    for(auto p: m){
        if(p.second%2==1)ans++;
    }
    
    cout << ans <<endl;
    
    return 0;
}

Measured memory_bytes: 4992