akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> PP;
int n,C;
int s[100001],t[100001],c[100001];
PP p[100001];
int fr[31];
int ch[31];
bool check(int v){
	memset(fr,0,sizeof(fr));
	memset(ch,0,sizeof(ch));
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<v;j++){
			if(fr[j]<=p[i].first.first && ch[j]==p[i].second){
				flag=true;
				fr[j]=p[i].first.second;
				break;
			}
		}
		if(!flag){
			for(int j=0;j<v;j++){
				if(fr[j]<p[i].first.first){
					flag=true;
					fr[j]=p[i].first.second;
					ch[j]=p[i].second;
					flag=true;
					break;
				}
			}
		}
		if(!flag)return false;
	}
	return true;
}

int main(void){
	scanf("%d%d",&n,&C);
	for(int i=0;i<n;i++){
		scanf("%d%d%d",&s[i],&t[i],&c[i]);
		p[i]=PP(P(s[i],t[i]),c[i]);
	}
	sort(p,p+n);
	int lb=0,rb=C;
	while(lb+1<rb){
		int mid=(lb+rb)/2;
		if(check(mid))rb=mid;
		else lb=mid;
	}
	printf("%d\n",rb);
	return 0;
}

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

using namespace std;

int n, m, x, y;
set < int > graph[200200];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        scanf("%d %d", &x, &y);
        graph[x].insert(y);
        graph[y].insert(x);
    }

    bool possible = false;
    for (auto v : graph[1]) {
        if (graph[v].count(n))
            possible = true;
    }

    if (possible) printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");

    return 0;
}


Measured memory_bytes: 28416
#include <bits/stdc++.h>
using namespace std;
int main()
{
  	int n;
    cin>>n;
    int ans=0;
    if(n==1)
        cout<<1<<endl;
    else{
        for(int i=2;pow(i,2)<=n;i++){
            for(int j=2;pow(i,j)<=n;j++){
                ans=max(ans,(int)pow(i,j));
            }
        }
        cout<<ans<<endl;
    }
}


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

int pow(int m){
    int ret = 1;
    while(m > 0){
        ret *= 2;
        m--;
    }
    return ret;
}

int main(){
    int n, m;
    std::cin >> n >> m;
    int base = 100 * (n - m);
    int r = pow(m);
    std::cout << (1900 * m + base) * r << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    /*
    cin.tie(0);
    ios::sync_with_stdio(false);
    //*/
    int n; 
    cin >> n;
    while (n != 0) {
        int flag = 1;
        int p[n];
        rep(i, n) {
            cin >> p[i];
        }
        int count = 0;
        int q[101] = {0};
        fill(q, q+101, 0);
        while (flag == 1){
            flag = 0;
            fill(q, q+101, 0);
            rep(i, n) q[p[i]]++;
            //rep(i, n) cout << q[p[i]] << " ";
            for (int i = 0; i < n; i++) {
                if (p[i] != q[p[i]]) flag = 1;
            }
            rep(i ,n) p[i] = q[p[i]];
            count++;
        }
        cout << count-1 << endl;
        rep(i, n-1) cout << q[p[i]] << " ";
        cout << q[p[n-1]] << endl;
        cin >> n;
    }

    return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//-------------------------↓↓↓↓↓↓------------------------

map<ll,ll> ac;
ll bit[1000000 + 10], n, a[100000 + 10];

ll summ(ll i){
    ll s = 0;
    while(i > 0){
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(ll i,ll x){
    while(i <= n){
        bit[i] += x;
        i += i & -i;
    }
}

bool check(ll res){
    ll sum[n + 2] = {}, b[n + 2] = {};
    ll cnt = 0, pos;

    for(int i = 0; i < n; i++){
        if(a[i] < res)sum[i + 1] = -1;
        else sum[i + 1] = 1;
    }
    sum[0] = n;

    for(int i = 0; i < n; i++){
        sum[i + 1] += sum[i];
    }
    for(int i = 0; i < n + 1; i++){
        b[i] = sum[i];
    }
    sort(b, b + n + 1);

    ll tmp = 1;
    for(int i = 0; i < n + 1; i++){
        ac[b[i]] = tmp;
        if(b[i] != b[i + 1])tmp++;
    }
    for(int i = 0; i < n + 1; i++){
        sum[i] = ac[sum[i]];
    }
    
    fill(bit, bit + 100000 + 10, 0LL);
    add(sum[0], 1LL);
    for(int i = 1; i < n + 1; i++){
        cnt += summ(sum[i]);
        add(sum[i], 1LL);
    }

    pos = n * (n + 1) / 4;
    if((n * (n + 1) / 2) % 2 == 1)pos++;
    
    if(cnt >= pos)return true;
    else return false;
}

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

    ll c[100000 + 10];
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        c[i] = a[i];
    }
    sort(c, c + n);

    ll le = 0, ri = n - 1, mid;
    while(ri - le > 1){
        mid = (le + ri) / 2;
        if(check(c[mid])){
            le = mid;
        }
        else{
            ri = mid;
        }
    }

    if(n == 1)cout << a[0] << "\n";
    else{
        for(ll i = min(ri + 10, n - 1); i >= max(le - 10, 0LL); i--){
            if(check(c[i])){
                cout << c[i] << "\n";
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 10368
nn = int(input())
ss = input()

ans = 0

for i in range(nn-1):
  n = nn-i
  s = ss[i:]
  a = [0]*n
  a[0] = n
  i, j = 1, 0
  while i < n:
    while i+j < n and s[j] == s[i+j]:
      j += 1
    a[i] = j
    if j == 0:
      i += 1
      continue
    k = 1
    while i+k < n and k+a[k] < j:
      a[i+k] = a[k]
      k += 1
    i += k
    j -= k
  for p in range(1, n-1):
    a[p] = min([p, a[p]])
  sub = max(a[1:])
  if ans < sub:
    ans = sub
print(ans)

Measured memory_bytes: 70236
import java.io.*;
import java.util.*;

public class Main{
    public static void main (String args[]){
         Scanner sc = new Scanner(System.in); 
         int a = sc.nextInt();
         int b = sc.nextInt();
         
         if ((a*b) % 2 == 0)
            System.out.println("Even");
        
        else
            System.out.println("Odd");
    }
        
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
//#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

const int MAX_N = 2050;
const int MAX_Q = 200000;
int N, M, Q;

char S[MAX_N][MAX_N];
int x1[MAX_Q], y1[MAX_Q], x2[MAX_Q], y2[MAX_Q];

int ac_node[MAX_N][MAX_N] = {};
int ac_edge_hor[MAX_N][MAX_N] = {};
int ac_edge_ver[MAX_N][MAX_N] = {};

int main(int argc, char **argv) {
    std::cin >> N >> M >> Q;

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            std::cin >> S[i][j];
        }
    }

    for (int i = 1; i <= Q; i++) {
        std::cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
    }

    for (int i = 1; i <= N; i++) {
        int ac_tmp = 0;
        for (int j = 1; j <= M; j++) {
            if (S[i][j] == '1') {
                ac_tmp++;
            }
            ac_node[i][j] = ac_node[i-1][j] + ac_tmp;
        }

        int ac_tmp_edge_hor = 0;
        int ac_tmp_edge_ver = 0;
        for (int j = 1; j <= M; j++) {
            if (S[i][j] == '1' && S[i][j-1] == '1') {
                ac_tmp_edge_ver++;
            }
            if (S[i][j] == '1' && S[i-1][j] == '1') {
                ac_tmp_edge_hor++;
            }
            ac_edge_ver[i][j] = ac_edge_ver[i-1][j] + ac_tmp_edge_ver;
            ac_edge_hor[i][j] = ac_edge_hor[i-1][j] + ac_tmp_edge_hor;
        }
    }

    for (int i = 1; i <= Q; i++) {
        int node_num = ac_node[x2[i]][y2[i]] - ac_node[x2[i]][y1[i] - 1] - ac_node[x1[i] - 1][y2[i]] + ac_node[x1[i] - 1][y1[i] - 1];
        int edge_num_hor = ac_edge_hor[x2[i]][y2[i]] - ac_edge_hor[x2[i]][y1[i] - 1] - ac_edge_hor[x1[i]][y2[i]] + ac_edge_hor[x1[i]][y1[i] - 1];
        int edge_num_ver = ac_edge_ver[x2[i]][y2[i]] - ac_edge_ver[x2[i]][y1[i]] - ac_edge_ver[x1[i] - 1][y2[i]] + ac_edge_ver[x1[i] - 1][y1[i]];

        //std::cout << "check:" << node_num << " " << edge_num << std::endl;

        std::cout << node_num - edge_num_hor - edge_num_ver << std::endl;
    }

    return 0;
}

Measured memory_bytes: 58240
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
typedef long long ll;
using namespace std;
#define N 100001
int main(void){
    int n;
    cin>>n;
    vector<int>a(n+2,0);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int sum=0;
    for(int i=0;i<=n;i++){
        sum+=abs(a[i+1]-a[i]);
    }
    for(int i=1;i<=n;i++){
        int ans=sum-(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))+abs(a[i+1]-a[i-1]);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

int main() {

	int n;
	cin >> n;

	int ans = 0;

	while (n > 0) {
		if (n % 10 != 0) {
			ans++;
		}
		n /= 10;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;


int main() {

    int r;
    cin >> r;

    cout << (r * r) << endl;
    return 0;

}

Measured memory_bytes: 256
import sys
from bisect import bisect_left
a,b,q = map(int, sys.stdin.readline().split())
S = []
for _ in range(a):
  S.append(int(sys.stdin.readline()))
T = []
for _ in range(b):
  T.append(int(sys.stdin.readline()))
X = []
for _ in range(q):
  X.append(int(sys.stdin.readline()))

INF = 10 ** 11
def dfs(direction, tors, pos, count):
  if tors == 1:
    L = T
  elif tors == -1:
    L = S
  i = bisect_left(L, pos)
  if i == len(L):
    if direction == 1:
      return INF
    elif direction == -1:
      res = abs(L[i-1]-pos)
      next_pos = L[i-1]
  elif L[i] == pos:
    res = 0
    next_pos = pos
  else:
    if direction == 1:
      res = abs(L[i]-pos)
      next_pos = L[i]
    elif direction == -1:
      if i == 0:
        return INF

      res = abs(L[i-1]-pos)
      next_pos = L[i-1]

  if count == 1:
    return res

  res0 = res + dfs(direction, tors*(-1), next_pos, count-1)
  res1 = res + dfs(direction*(-1), tors*(-1), next_pos, count-1)

  return min(res0, res1)

for x in X:
  res0 = dfs(1, 1, x, 2)
  res1 = dfs(-1, 1, x, 2)
  res2 = dfs(1, -1, x, 2)
  res3 = dfs(-1, -1, x, 2)

  sys.stdout.write('{}\n'.format(min(res0, res1, res2, res3)))

Measured memory_bytes: 16168
#include <iostream>
#include<string>
#include <cmath>

using namespace std;
typedef long long ll;
const int N =1e7+5;
bool good[N];

void check(ll checkNumber)
{
    while(good[checkNumber]==false)
    {
        checkNumber++;
    }
    cout<<checkNumber;
}

int main()
{
    ll checkNuber,i,j;
    cin>>checkNuber;
    for(i=1;i<N;i++)
    {
        good[i]=true;
    }
    good[1]=false;
        for(i=2;i<N;i++)
        {
            if(good[i])
            {
               for(j=i*i;j<N;j+=i)
               {
                   good[j]=false;
               }
            }
        }
        if(good[checkNuber]==true)
            {cout<<checkNuber;return 0;}
        else
            check(checkNuber);
    return 0;
}

Measured memory_bytes: 13380
from collections import deque

S = input().rstrip()
Q = int(input())


rev = False
out = deque(S)
for i in range(Q):
    args = input().split()
    if args[0] == '1':
        rev = not rev
    else:
        t, f, c = args
        assert t == '2'
        if f == '1':
            if rev:
                out.append(c)
            else:
                out.appendleft(c)
        else:
            assert f == '2'
            if rev:
                out.appendleft(c)
            else:
                out.append(c)

if rev:
    out = reversed(out)
print(''.join(out))
 


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int> >;
using vii = vector<pair<int, int> >;

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 GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

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

	rep(i, s.size()) {
		if ((i + 1) % 2 == 1) {
			ans.push_back(s[i]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int n;
int a[100000];

long long int min(long long int a, long long int b) {
	return a < b ? a : b;
}

long long int count(int sf) {
	int i;
	long long int sum = 0, count = 0;

	for (i = 0; i < n; i++) {
		sum += a[i];
		if (!sf) {
			if (sum >= 0) {
				count += sum + 1;
				sum = -1;
			}
		}
		else {
			if (sum <= 0) {
				count += -sum + 1;
				sum = 1;
			}
		}
		sf = !sf;
	}
	return count;
}

int main(void) {
	int i;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);

	printf("%lld\n", min(count(0), count(1)));
	return 0;
}


Measured memory_bytes: 512
import sys

stdin = sys.stdin

ni = lambda: int(ns()) #int
na = lambda: list(map(int, stdin.readline().split())) #int,list
ns = lambda: stdin.readline().rstrip()  # str

n=ni()
b=na()
ans=[]
def solve(li):

	for i in range(1,len(li)+1):
		if li[len(li)-i]==len(li)-i+1:
			a=li.pop(len(li)-i)
			ans.append(a)
			return solve(li)

solve(b)
if len(ans)==n:
	for i in range(n):
		print(ans[n-i-1])
else:
	print(-1)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int A = s.nextInt();
			final int B = s.nextInt();

			int max = A + B;
			{
				int work = A - B;
				if(max < work) {
					max = work;
				}
			}
			{
				int work = A * B;
				if(max < work) {
					max = work;
				}
			}
			System.out.println(max);
		}
	}
}


Measured memory_bytes: 21844
N = int(input())
S = input()
Q = int(input())
*k, = map(int, input().split())

acd = [0]*(N+1)
acm = [0]*(N+1)
acc = [0]*(N+1)
acmc = [0]*(N+2)

for i in range(1, N+1):
    acd[i] = acd[i-1] + (S[i-1]=="D")
    acm[i] = acm[i-1] + (S[i-1]=="M")
    acc[i] = acc[i-1] + (S[i-1]=="C")

ans = 0
for i in range(1, N+1):
    if S[i-1]=="M":
        ans += acd[i-1]*(acc[N]-acc[i])

for i in range(1, N)[::-1]:
    acmc[i] += acmc[i+1]
    if S[i-1]=="M":
        acmc[i] += acc[N]-acc[i]

for i in k:
    v = 0
    for j in range(1, N+1):
        if S[j-1]=="D":
            v += (acm[min(N, i+j-1)]-acm[j]) * (acc[N]-acc[min(N, i+j-1)]) + acmc[min(i+j, N)]
    print(ans-v)

Measured memory_bytes: 86108
// Problem : A - Registration
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    string s, t;
    cin >> s >> t;
    
    t.pop_back();
    
    cout << (s == t ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define SZ(x) ((int)(x).size())
#define TC(tc) while (tc--)
#define VI vector<int>
#define PII pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int mn = INT_MAX;
	int n; cin >> n;
	int c = 0;
	FOR(i, 0, n)
	{
		int a; cin >> a;
		if (a < mn)
		{
			mn = a;
			c++;
		}
	}
	cout << c;
	return 0;
}



Measured memory_bytes: 3576
R, C, K = map(int, input().split())
# = int(input())
p = []
for k in range(K):
  p.append(list(map(int, input().split())))

maps = [[0 for _ in range(C)] for _ in range(R)]
for k in range(K):
  maps[p[k][0]-1][p[k][1]-1] += p[k][2]

point1 = [[0 for _ in range(C)] for _ in range(R)]
point2 = [[0 for _ in range(C)] for _ in range(R)]
point3 = [[0 for _ in range(C)] for _ in range(R)]

point1[0][0] = maps[0][0]

for r in range(R):
  for c in range(C):
    a, b, d = point1[r][c], point2[r][c], point3[r][c]  
    if c < C - 1:
      x = maps[r][c+1]
      point1[r][c+1] = max(point1[r][c+1], x, a)
      point2[r][c+1] = max(point2[r][c+1], a + x, b)
      point3[r][c+1] = max(point3[r][c+1], b + x, d)
    if r < R - 1:
      point1[r+1][c] = maps[r+1][c] + max(a, b, d)


print(max(point1[-1][-1], point2[-1][-1], point3[-1][-1]))

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

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

int main() {
    ll n; cin >> n;
    vector<ll> t(n);
    for(ll i = 0; i < n; i++) cin >> t[i];
    ll m; cin >> m;
    vector<pair<ll, ll> > px(m);
    for(ll i = 0; i < m; i++){
        ll p, x; cin >> p >> x;
        px[i] = make_pair(p, x);
    }

    for(ll i = 0; i < m; i++){
        ll sum = px[i].second;
        for(ll j = 0; j < n; j++){
            if(px[i].first - 1 == j) continue;
            sum += t[j];
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 256
N = int(input())
d_ok = []
ans = 0
for _ in range(N):
    x = int(input())
    if x % 10:
        d_ok += [x]
    ans += x
d_ok.sort()
if ans % 10 == 0:
    if len(d_ok):
        ans -= d_ok[0]
    else:
        ans = 0
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>


#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  ll N;
  cin >> N;
  cout << 500 * (N / 500) << endl;
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> vec(M);

    for (int i = 0; i < M; i++)
    {
        int k; cin >> k;
        vec[i].resize(k);
        for (int j = 0; j < k; j++)
        {
            cin >> vec[i][j];
            --vec[i][j];
        }
    }
    
    vector<int> p(M);
    for (int i = 0; i < M; i++)
    {
        cin >> p[i];
    }
    
    int ans = 0;
    for (int i = 0; i < (1 << N); i++)
    {
        bool ok = true;
        for (int j = 0; j < M; j++)
        {
            int c = 0;
            for (int id : vec[j])
            {
                if((i >> id) & 1){
                    ++c;
                }
            }
            c %= 2;
            if(c != p[j]){
                ok = false;
            }
        }
        if(ok) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int x=0;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(x==1&&s[i]=='C'){
            cout<<"Yes"<<endl;
            return 0;
        }
        if(s[i]=='A') x=1;
        else x=0;
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
#define PI 3.1415926535
using namespace std;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, ans=-1;

	cin>>n;

	vector<int> a(n), b(n), asum(n+1, 0), bsum(n+1, 0);

	rep(i, n) cin>>a[i];
	rep(i, n) cin>>b[i];

	reverse(all(b));

	repr(i, 1, n+1){
		asum[i]=asum[i-1]+a[i-1];
	}
	repr(i, 1, n+1){
		bsum[i]=bsum[i-1]+b[i-1];
	}
	repr(i, 1, n+1){
		if(ans<asum[i]+bsum[n-i+1]) ans=asum[i]+bsum[n-i+1];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

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

    if (N % 10 == 9){
        cout << "Yes";
        return 0;
    }
    N /= 10;
    if (N % 10 == 9){
        cout << "Yes";
        return 0;
    }

    cout << "No"  << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue> 
#include<stack>
#include<vector>
#include<map>
#include<set>

#define ll long long
#define pb push_back
#define ff first
#define ss second

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> v[m];
    int k;
    int p[m];
    for(int i=0;i<m;i++){
        cin>>k;
        int a;
        for(int j=0;j<k;j++){
            cin>>a;
            v[i].pb(a);
        }
    }
    for(int i=0;i<m;i++)
    cin>>p[i];
    
    int ans = 0;
    for(int i=0;i<(1<<n);i++){
        int flg =0;
        for(int j=0;j<m;j++){
            int c =0;
            for(int k=0;k<v[j].size();k++){
                if(i&(1<<(v[j][k]-1))){
                    c++;
                }
            }
            if(c%2!=p[j]){
                flg = 1;
            }
        }
        if(!flg)
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define nmod         -1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define xxx         exit(0);
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x)/log(base));
}
ll n,m,dp[100005]; vec v[100005]; bool vis[100005];
void dfs(ll x)
{
	vis[x]=true;
	ll y,z,mx;
	y=v[x].size();
	mx=0;
	rep(i,0,y)
	{
		z=v[x][i];
		if(!vis[z]) dfs(z);
		mx=max(mx,dp[z]);
	}
	dp[x]=mx+1;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS; 
    while(TESTS--)
    {
    	ll i,l,j,x1,y1,x,y,z,q,h;
    	cin>>n>>m;
    	rep(i,0,m)
    	{
    		cin>>x>>y;
    		v[x].pb(y);
		}
		repi(i,1,n) dp[i]=0, vis[i]=false;
		repi(i,1,n)
		if(!vis[i]) dfs(i);
		x=0;
		repi(i,1,n) x=max(x,dp[i]);
		cout<<x-1;
	}
	return 0;
}


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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int t; cin >> t; for(int cs = 1; cs <= t; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";

//input space ---> scanf("%[^\n]%*c",s);

ll dp[10005][105][2],d,n;
string s;

ll f(ll cur, ll sum, ll flag) {
	if(cur == n) {
		return !sum;
	}
	if(dp[cur][sum][flag] != -1)
		return dp[cur][sum][flag];
	ll ret = 0;
	if(flag) {
		int rem = s[cur]-'0';
		fori(i,0,rem-1,1) {
			ret = (ret+f(cur+1,(sum+i)%d,0))%mod;
		}
		ret = (ret+f(cur+1,(sum+rem)%d,1))%mod;
	} else {
		fori(i,0,9,1) {
			ret = (ret+f(cur+1,(sum+i)%d,0))%mod;
		}
	}
	return dp[cur][sum][flag] = ret;
}

int main() {
	IOS
	reset(dp,-1);
	cin >> s >> d;
	n = sz(s);
	ll ans = f(0,0,1)-1;
	cout << (ans+mod)%mod << endl;
}


Measured memory_bytes: 17664
#include<iostream>
#define rep(i, a, b) for (int i = a; i < b; ++i)
using namespace std;
int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int c = 0;
    rep (i, 1, n) if (s[i] == 'E') c++;
    int res = c;
    rep (i, 1, n) {
        if (s[i] == 'E') c--;
        if (s[i-1] == 'W') c++;
        if (res > c) res = c;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 900
A = list(map(int, input()))

dic = {1: "+", 0: "-"}

for i in range(2 ** 3):
    t = A[0]
    s = str(A[0])
    for j in range(3):
        if (i >> j) & 1:
            t += A[j + 1]
            s += dic[1] + str(A[j + 1])
        else:
            t -= A[j + 1]
            s += dic[0] + str(A[j + 1])
            
    if t == 7:
        print(s + "=7")
        exit()


Measured memory_bytes: 9196
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;

/**
 * https://beta.atcoder.jp/contests/abc070/tasks/abc070_d
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		Node[] nodes = new Node[N];
		for(int i=0; i<N; i++) nodes[i] = new Node(i);
		for(int i=0; i<N-1; i++){
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			int c = sc.nextInt();
			nodes[a].edge.put(nodes[b], c);
			nodes[b].edge.put(nodes[a], c);
		}
		final int Q = sc.nextInt();
		final int K = sc.nextInt()-1;
		int[] x = new int[Q];
		int[] y = new int[Q];
		for(int i=0; i<Q; i++){
			x[i]=sc.nextInt()-1;
			y[i]=sc.nextInt()-1;
		}
		sc.close();
		
		calcDepth(nodes[K], new HashSet<Integer>());
		
		for(int i=0; i<Q; i++){
			System.out.println(nodes[x[i]].depth+nodes[y[i]].depth);
		}
		
	}
	
	static void calcDepth(Node n, Set<Integer> parents){
		parents.add(n.id);
		for(Entry<Node, Integer> c: n.edge.entrySet()){
			if(parents.contains(c.getKey().id)) continue;
			c.getKey().depth = n.depth + c.getValue();
			calcDepth(c.getKey(), parents);
		}
	}
	
	static class Node{
		int id;
		long depth = 0;
		Map<Node, Integer> edge = new HashMap<>();	
		Node(int id){
			this.id = id;
		}
	}

}

Measured memory_bytes: 207728
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll x,y;
ll concatenate(ll x, ll y) {
    ll pow = 10;
    while(y >= pow)
        pow *= 10;
    return x * pow + y;        
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin>>x>>y;
    ll k,n=concatenate(x,y);
    k=sqrt(n);
    if(k*k==n) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

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


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

def main():
    # # 整数の入力
    # a = int(input())
    # # スペース区切りの整数の入力
    # b, c = map(int, input().split())
    # # 文字列の入力
    # s = input()
    # # 出力
    # print("{} {}".format(a+b+c, s))
    N = int(input())
    d_list = list(map(int, input().split()))
    sorted_d = sorted(d_list)
    print(sorted_d[N//2]-sorted_d[N//2-1])



if __name__=='__main__':
    main()


Measured memory_bytes: 14428
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
#define MK make_pair
const ll E=1e18+7;
const ll MOD=1000000007;






int main(){
    ll n,k;
    cin>>n>>k;
    if(n%k!=0){cout<<1<<endl;}
    else{cout<<0<<endl;}
    
    
    return 0;
}

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

int main()
{
	int a, b;
	char c;
	while (cin>>a>>c>>b) {
		if (c !='?') {
			switch (c)
			{
			case '+':
				cout << a + b << endl; break;
			case'-':
				cout << a - b << endl; break;
			case'/':
				cout << a / b << endl; break;
			case'*':
				cout << a*b << endl; break;
			}
		}
		else { return 0; }
	}
	return 0;
}

Measured memory_bytes: 3004
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<typeinfo>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



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


Measured memory_bytes: 256
n,k = map(int, input().split())
t = [1 for i in range(n)]
for i in range(0,k):
    m = int(input())
    a = list(map(int, input().split()))
    for j in range(0,m):
        c = a[j]-1
        t[c] = 0
print(sum(t))

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    map<ll,int> mp;
    ll ans = 0;
    rep(i,n) {
      ll js = i-a[i];
      ll is = i+a[i];
      if (mp.count(js)) ans += mp[js];
      mp[is]++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int a, b, c, k;
  cin>>a>>b>>c>>k;
  if (k <= a) {
    cout<<k<<endl;
  } else if (k <= a + b) {
    cout<<a<<endl;
  } else {
    cout<<a-k+(a+b)<<endl;
  }
}

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

int main() {
  int n,m;
  cin >> n >> m;
  priority_queue<int> q;
  rep(i,n){
    int a;
    cin >> a;
    q.push(a);
  }
  rep(i,m){
    int a=q.top(); q.pop();
    q.push(a/2);
  }
  ll ans;
  rep(i,n){
    int a=q.top();q.pop();
    ans+=a;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
function Main(input) {
	input = input.trim().split("\n");
  input[0] = input[0].split("");
  input[1] = input[1].split("");
  input[2] = input[2].split("");
  console.log(input[0][0] + input[1][1] + input[2][2]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#include <bits/stdc++.h>


using namespace std;

#define INPUT_INT(valName) int valName; cin >> valName
#define INPUT_LLINT(valName) long long int valName; cin >> valName;
#define INPUT_STR(valName) string valName; cin >> valName;
#define INPUT_LINE(valName) string valName; getline(cin,s);
#define INPUT_VECTOR_INT(valName, N) vector<int> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }
#define INPUT_VECTOR_DOUBLE(valName, N) vector<double> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }

#define OUTPUT(A) cout << (A) << endl;
#define OUTPUT2(A, B) cout << (A) << " " << (B) << endl;
#define OUTPUT3(A, B, C) cout << (A) << " " << (B) << " " << (C) << endl;

#define REP(valName, N) for(int valName = 0; valName < N; ++valName)

vector<string> split(const string& str, char delimiter) {
	vector<string> ret;
	string tmp = "";
	for (auto c : str) {
		if (c != delimiter) {
			tmp.push_back(c);
		} else {
			ret.push_back(tmp);
			tmp = "";
		}
	}
	ret.push_back(tmp);
	return ret;
}

template <typename T> void sortAsc(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> void sortDesc(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }

template <typename T> void insert(vector<T>& dest, const vector<T>& src) { copy(src.begin(), src.end(), back_inserter(dest)); }

template <long long int MOD> long long int mod_inv(long long int a) {
	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;
	return u;
}

template <long long int MOD> long long int mod_add(long long int a, long long int b) {
	return (a + b) % MOD;
}

template <long long int MOD> long long int mod_sum(long long int a, long long int b) {
	return (a - b) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b) {
	return (a % MOD) * (b % MOD) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b, long long int c) {
	return mod_mul<MOD>(a, mod_mul<MOD>(b, c));
}

template <long long int MOD> long long int mod_div(long long int a, long long int b) {
	return (a % MOD) * mod_inv<MOD>(b) % MOD;
}

int sign(long long int a) {
	return a >= 0 ? 1 : -1;
}


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



int main() {

	// TODO: streamやめる

	cin.tie(0); ios::sync_with_stdio(false);

	INPUT_LLINT(a);
	INPUT_LLINT(b);
	INPUT_LLINT(c);

	OUTPUT(a + b + 2 * sqrtl(a * b) < c ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines 
MOD = 10**9+7

S = inpS()
N = len(S)
dp = [0]*13

dp[0] = 1
mul = 1
for i in range(N-1, -1, -1):
  nextDP = [0]*13
  s = S[i]
  if s == "?":
    for dgt in range(10):
      for mo in range(13):
        ind = (dgt*mul+mo)%13
        nextDP[ind] += dp[mo]
        nextDP[ind] %= MOD        
  else:
    dgt = int(S[i])
    for mo in range(13):
      ind = (dgt*mul+mo)%13
      nextDP[ind] += dp[mo]
      nextDP[ind] %= MOD    
  mul *= 10
  mul %= 13
  dp = nextDP
print(dp[5])    
      

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

int main(void){
   long long N,W;
   cin>>N>>W;
   vector<long long> w(N),v(N);
   for(int i=0;i<N;i++){
      cin>>w[i]>>v[i];
   }
   vector<vector<long long>> dp(N+1,vector<long long>(100007));
   for(int i=0;i<=N;i++){
      for(int j=0;j<100007;j++){
         dp[i][j]=1000000009;
      }
   }
   dp[0][0]=0;
   for(int i=0;i<N;i++){
      for(int value=0;value<=100000;value++){
         if(value>=v[i]){
            dp[i+1][value]=min(dp[i+1][value],dp[i][value-v[i]]+w[i]);
         }
         dp[i+1][value]=min(dp[i+1][value],dp[i][value]);
      }
   }
   long long ans=0;
   for(long long value=0;value<=100000;value++){
      if(dp[N][value]<=W) ans=value;
   }
   cout<<ans<<endl;
   return 0;
}


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

pair<int, int> intersection(pair<int, int> x, pair<int, int> y) {
	int l = max(x.first, y.first);
	int r = min(x.second, y.second);
	if (l > r) return {2, 1};
	return {l, r};
}
int len(pair<int, int> p) {
	return p.second - p.first + 1;
}

int main()
{
	int n;
	ignore = scanf("%d", &n);
		
	vector<pair<int, int>> A;
	
	for (int i = 0; i < n; i++) {
		int L, R;
		ignore = scanf("%d %d", &L, &R);		
		A.emplace_back(L, R);
	}
	
	int ans = 0;
	{
		vector<pair<int, int>> B;
		for (int i = 0; i < n; i++) {
			if (i == 0) B.push_back(A[0]);
			else B.push_back(intersection(B.back(), A[i]));
		}
		pair<int, int> x = {1, 1000000000};
		for (int i = n - 1; i >= 0; i--) {
			int tmp = len(A[i]) + len(i == 0 ? x : intersection(x, B[i - 1]));
			ans = max(ans, tmp);
			x = intersection(x, A[i]);
		}
	}
	
	int j = -1;
	for (int i = 0; i < n; i++) {
		if (j == -1 || A[i].second < A[j].second) j = i;
	}
	
	pair<int, int> x = {1, 1000000000};
	int cnt = 0;
	
	vector<pair<int, int>> B;
	
	for (int i = 0; i < n; i++) {
		if (i == j || A[i].first <= A[j].first) continue;
		if (A[i].first <= A[j].second) B.push_back(A[i]);
		else {
			cnt++;
			x = intersection(x, A[i]);
		}
	}
	
	sort(B.begin(), B.end());
	
	while (!B.empty()) {
		if (cnt > 0) ans = max(ans, len(x) + A[j].second - B.back().first + 1);
		cnt++;
		x = intersection(x, B.back());
		B.pop_back();
	}
	
	if (cnt > 0) ans = max(ans, len(x) + len(A[j]));
	
	printf("%d\n", ans);
}


Measured memory_bytes: 2824
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    ll x;
    cin>>x;
    cout<<(x^1)<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3820
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N;
  cin >> S;
  int top = 0;
  int depth = 0;
  for (int i = 0; i < N; ++i) {
    if (S[i] == '(') {
      depth++;
    } else {
      if (depth > 0) {
        depth--;
      } else {
        top++;
      }
    }
  }
  string ret = "";
  for (int i = 0; i < top; ++i) {
    ret+='(';
  }
  ret+= S;
  for (int i = 0; i < depth; ++i) {
    ret+=')';
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
while True:
	try:
		a,b,c,d,e,f=map(int,raw_input().split())
		y=round( float(c*d-f*a)/(b*d-a*e) ,3)
		x=round( float(c-b*y)/a , 3)
		print("{:.3f}".format(x)),("{:.3f}".format(y))
	except EOFError:
		break


Measured memory_bytes: 4672
#include<stdio.h>
#include<stdlib.h>


#define MAX 100


int main()
{
	int i=0,j,k,n,b,m=0,a=0,cnt=0,flag=1;
	int num[MAX] = {0};
	int arr[MAX];

	while (scanf("%d", &n) != EOF)
	{
		num[cnt] = n;
		++cnt;
	}
	
	while (i != cnt)
	{
		if (num[i] == 0)
		{
			k = i+1;
			j = i - 1;
			arr[m] = j;  //printf("%d\n", num[j]);
			++m;
			while (k<cnt && num[k] == 0)
			{
				--j;
				if (num[j] == 0)
				{
					--j;
				}
				else
				{
					for (a = 0; a < m; a++)
					{
						if (arr[a] == j)
						{
							--j;
							flag = 0;
							break;
						}
					}
					if (flag)
					{
						arr[m] = j;  //printf("%d\n", num[j]);
						++m;
						++k;
					}
					flag = 1;
				}
			}
			i = k;
		}
		else
		{
			++i;
		}
		
	}

	for (i = 0; i < m; i++)
	{
		printf("%d\n",num[arr[i]]);
	}

	return 0;
}


Measured memory_bytes: 600
from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))

if len(set(A)) <= K:
  print(0)
else:
  c = Counter(A).most_common()[::-1]
  ans = 0
  for i in range(len(set(A)) - K):
    ans += c[i][1]
    
  print(ans)
  

Measured memory_bytes: 49944
#include<stdio.h>

int main(void)
{
    int A, B;
    int answer = 1;
    int a, b;
    scanf("%d %d", &A, &B);

    for (int i = 1; i < 1001; i++)
    {
        a = answer * 8 / 100;
        b = answer / 10;
        if (a == A && b == B)
        {
            printf("%d", answer);
            return 0;
        }

        answer++;
        
    }

    printf("-1");
    
    return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define f(i, a, b) for (int i = (a); i <=(b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s;
	cin >> s;
	ll ans = 0;
	f(i, 0, 2) {
		ll cur = 0;
		f(j, i, 2) {
			if (s[j] == 'S')
				break;
			cur++;
		}
		ans = max(ans, cur);
	}
	cout << ans << endl;
	// read the stuff at the bottom
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* use int when constraints limits are tight
	* Time taken : global variable < pass by refernce < pass by value
	* It takes significant amt. of time in pass by value
*/





























Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    int c1,c2,c3,cnt=0;
    while(cin>>c1>>c2>>c3){
        cnt=0;
        for(int i=1;i<=10;i++){
            if(i!=c1&&i!=c2&&i!=c3&&i+c1+c2<21)cnt++;
        }
        if(cnt>3)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    long long a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    // sum of factors of 2s
    int r = 0;
    for (auto &i : a) {
        while (i % 2 == 0) {
            r++;
            i /= 2;
        }
    }
    cout << r << endl;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


Measured memory_bytes: 384