akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
struct objects{
    int weight,value;
};
ll solve(){
   int n,w;
   cin>>n>>w;
   objects object[n];
   int totalvalue=0;
   for(int i=0;i<n;i++){
       cin>>object[i].weight>>object[i].value;
       totalvalue+=object[i].value;
   }
   ll dp[n+1][totalvalue+1];
    //dp[i][j] denotes the least weight to get a value of
   // j from the first i objects
   dp[0][0]=0;//It takes 0 weight here
   int ans=0;
   for(int i=1;i<=totalvalue;i++){
       dp[0][i]=1e18;
      // Just set it arbitrarily large
       //because it's not possible 
   }
   for(int i=0;i<n;i++){
       for(int j=0;j<=totalvalue;j++){
           if(j>=object[i].value){
                dp[i+1][j]=min(dp[i][j],dp[i][j-object[i].value]+object[i].weight);
                //Either don't choose this object(dp[i][j]) or choose this object
                //The value without it would be j-object[i].value
                //the minimum weight would be the minimum weight needed to
                //get a value of j- object[i].value and add the weight of this object.
           }
           else{
               //If I choose this object the value will go over j
               dp[i+1][j]=dp[i][j];
           }
           if(dp[i+1][j]<=w){//Is it possible to get value of j in less than w weight
               ans=max(ans,j);//Find maximum such j
           }
       }
   }
   return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<solve();
}

Measured memory_bytes: 82500
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret

def extgcd(a, b):
    if b:
        d, y, x = extgcd(b, a%b)
        y -= (a//b)*x
        return d, x, y
    else:
        return a, 1, 0

ans = float("inf")
n = int(input())
n = 2*n
P = primeFactor(n)
K = P.keys()
l = len(K)
for i in range(1<<l):
    temp = 1
    for j, k in enumerate(K):
        if i>>j & 1:
            temp *= k**P[k]
    if temp == 1 or temp == n:
        continue
    other = n // temp
    S = extgcd(temp, other)[1:]
    p, q = S
    if p > q:
        p, q = q, p
        temp, other = other, temp
    ans = min(ans, p*temp*(-1))
if ans == float("inf"):
    ans = n//2
print(ans)

Measured memory_bytes: 71300
#!/usr/bin/env python
import bisect
from collections import defaultdict

def main():
    P, Q, R = map(int, input().split())
    max_edge = max([P, Q, R])
    min_path = sum([P, Q, R]) - max_edge
    
    print(min_path)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int m=sc.nextInt();
    int a=sc.nextInt();
    int b=sc.nextInt();
    if(a<=b){
      for(int s=a;s<=b;s++){
        if(s%m==0){
          System.out.println("OK");
          break;
        }
        if((s==b)&&!(b%m==0)){
          System.out.println("NG");
        }
      }
    }
  }
}


Measured memory_bytes: 35676
n=int(input())
s=[list(input()) for i in range(n)]
for i in range(n):
    s[i].sort()
word="abcdefghijklmnopqrstuvwxyz"
l=len(word)
data=[[0]*n for i in range(l)]
for i in range(n):
    k=0
    for j in range(l):
        while s[i][k]==word[j]:
            data[j][i]+=1
            k+=1
            if k==len(s[i]):
                break
        else:
            continue
        break
ans=""
for i in range(l):
    ans+=word[i]*min(data[i])
print(ans)

Measured memory_bytes: 3064
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
const int mx = 1000 * 100 + 5;
int v[mx];
int32_t main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, ans = 0, s = 0, a, b;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a >> b;
		s += b;
		v[i] = a + b;
	}
	sort(v , v + n);
	for(int i = n - 1; i >= 0; i -= 2)
		ans += v[i];
	cout << ans - s << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
using namespace std;
#define ll long long int
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)


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

ll lcm(ll a, ll b) {
	return a /gcd(a, b) *b;
}
typedef pair<int,int> pii;
const int mod = 1e9+7;
int main() {

   string s;
   cin>>s;

   int n=  s.size();
     int ct = 0;
     int maxx = 0;
   fo(i,n){
       if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
        ct++;
        maxx = max(maxx,ct);

       }
       else{
        ct=0;
       }
   }

   //cout<<ans;
    cout<<maxx;




























    return 0;

      }


Measured memory_bytes: 256
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

def solve(N, M, A):
    while A[0] % 2 == 0:
        for idx, a in enumerate(A):
            if a % 2 != 0:
                return 0
            A[idx] //= 2
        M //= 2

    for a in A:
        if a % 2 == 0:
            return 0

    cur_lcm = 1
    for a in A:
        cur_lcm = lcm(cur_lcm, a)
        if M < cur_lcm:
            return 0
    return (M // cur_lcm + 1) // 2

if __name__ == '__main__':
    N, M = map(int, input().split())
    A = list((map(int, input().split())))
    A = [a // 2 for a in A]
    print(solve(N, M, A))

Measured memory_bytes: 89580
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vi p(n);
	REP(i, n) {
		cin >> p[i];
		p[i]--;
	}
	ll ans = 0;
	vi pos(n);
	REP(i, n)pos[p[i]] = i;
	set<pii> st;
	st.emplace(0, n);
	RREP(i, n - 1) {
		auto c = st.lower_bound(pii{ pos[i + 1],INF });
		c--;
		auto tmp = *c;
		st.erase(c);
		st.emplace(tmp.first, pos[i + 1]);
		st.emplace(pos[i + 1] + 1, tmp.second);

		auto mid = st.lower_bound(pii{ pos[i],INF });
		mid--;
		ll f = pos[i] - (*mid).first + 1, s = (*mid).second - pos[i];
		mid++;
		if (mid != st.end())ans += (i + 1) * f * ((*mid).second - (*mid).first + 1);
		mid--;
		if (mid != st.begin()) {
			mid--;
			ans += (i + 1) * s * ((*mid).second - (*mid).first + 1);
			mid++;
		}
	}
	cout << ans << endl;
}

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

int main()
{
  string s;
  int s_count = 0;
  cin >> s;
  for (int i = 0; i < 3; i++)
  {
    if (s[i] == 'o')
      s_count++;
  }
  cout << 700 + s_count * 100 << endl;
}

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

int main()
{
    int H, W;
    std::cin >> H >> W;
    std::vector<std::string> S(H);
    for (int i = 0; i < H; i++) {
        std::cin >> S[i];
    }

    std::vector<std::vector<int>> count(H, std::vector<int>(W, 0));
    int di[] = {-1, -1, -1, +0, +0, +1, +1, +1};
    int dj[] = {-1, +0, +1, -1, +1, -1, +0, +1};

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#') {
                for (int k = 0; k < 8; k++) {
                    int ni = i + di[k];
                    int nj = j + dj[k];
                    if (0 <= ni && ni < H && 0 <= nj && nj < W) {
                        count[ni][nj]++;
                    }
                }
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#') {
                std::cout << S[i][j];
            } else {
                std::cout << count[i][j];
            }
        }
        std::cout << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
lli gcd(lli a, lli b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
//qsort�֐��Ɏg��compare�֐�,(long long int, int, double�^)
int compare_lli(const void *a, const void *b)
{
    return *(lli*)a - *(lli*)b;
}
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int compare_double(const void *a, const void *b)
{
    return *(double*)a - *(double*)b;
}/****************<Data�\���̂̐錾>*********************/
typedef struct data{
	int x;
	char c[2];
}Data;
/*******************************************************/
int compare_struct(const void *a, const void *b){
  Data *A = (Data *)a;
  Data *B = (Data *)b;
  return ((A->x) - (B->x));
}
/*qsort(array, 10, sizeof(int/lli/double/struct data), compare_int/double/lli/struct);*/
/*qsort(�z��/�\���̔z��), �v�f��, sizeof(�z��̌^), compare_�֐��̖��O);*/


//2�̔z�񂪈�v���邩�̔���_(return��v��0,�s��v���P)
int chek(int *tmp1, int *tmp2, int n){
	int i;
	for(i=0; i<n; i++){
		if(tmp1[i] != tmp2[i]){
			return 1;
		}
	}
	return 0;
}
/*��Βl��Ԃ�(Abs)�֐�*/
int Abs(int a){
	if(a>=0) return a;
	else return -1*a;
}
/**********************************************************************/

lli n;
lli ans(lli x, lli *a, lli i){
	x = gcd(x, a[i]);
	if(x == 1) return (i+1);
	i++;
	if(i >= n) return x;
	return ans(x, a, i);
}
int main(void)
{
	long long int k, i, j, m, sum=0, ans;
	scanf("%lld", &k);
	loop(i, 1, k+1){
		loop(j, 1, k+1){
			loop(m, 1, k+1){
				ans = gcd(gcd(i,j), m);
				sum += ans;
			}
		}
	}
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 1732
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	string s;
	long long a,b;
	bool ac=false;
	cin >> s;
	for(long long i=0;i<s.length();i++){
		if(s[i]=='A' && ac==false){
			a=i;
			ac=true;
		}
		if(s[i]=='Z'){
			b=i;
		}
	}
	cout << b-a+1 << endl;


	return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    string a;
    cin >> a ;
    int ans = 0;
    if (a[0] == '1') {
        ans++;
    }
    if (a[1] == '1') {
        ans++;
    }
    if (a[2] == '1') {
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int num,a,b,c,d[10001],i,j,temp,cal,price;
	scanf("%d%d%d%d",&num,&a,&b,&c);
	for (i=0; i<num; i++){
		scanf("%d",&d[i]);
	}
	for (i=0; i<num-1; i++) {
		for (j=0; j<num-1-i; j++) {
			if(d[j]<d[j+1]){
                temp=d[j];
                d[j]=d[j+1];
                d[j+1]=temp;
            }
        }
    }
    cal=c;
    price=a;
    for (i=0; i<num; i++) {
        if (1.0*cal/price<1.0*(cal+d[i])/(price+b)) {
            cal+=d[i];
            price+=b;
        } else {
            break;
        }
    }
    printf("%d\n",cal/price);
    return 0;
}

Measured memory_bytes: 2708
# input
n = int(input())
a = [0 for i in range(n)]
b = [int(i) for i in input().split()]

# main
a[0] = b[0]
for i in range(1, n-1):
  a[i] = min(b[i-1], b[i])
a[n-1] = b[n-2]

# output
print(sum(a))


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> hw(H);
    const int inf = 1e8;
    int xmi = inf, xma = -inf, ymi = inf, yma = -inf;
    rep(i, H) {
        cin >> hw[i];
        rep(j, W) {
            if (hw[i][j] == 'B') {
                xmi = min(xmi, j);
                xma = max(xma, j);
                ymi = min(ymi, i);
                yma = max(yma, i);
            }
        }
    }

    // 列挙
    vector<P> pos;
    rep(r, H) rep(c, W) {
        if (hw[r][c] == 'B' and (r == ymi or r == yma or c == xmi or c == xma)) pos.emplace_back(r, c);
    }

    int ans = -inf;
    rep(i, pos.size()) rep(j, pos.size()) {
        ans = max(ans, abs(pos[i].first-pos[j].first) + abs(pos[i].second-pos[j].second));
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3812
fun main(args:Array<String>) {
	val n=readLine()!!.toInt()
	val l=mutableListOf<Pair<Int,Int>>()

	val f=if(n%2==0) n+1 else n
	for(i in 1..n)
		for(j in i+1..n)
			if(i+j!=f)
				l.add(i to j)

	println(l.size)
	for((a,b) in l)
		println("$a $b")
}


Measured memory_bytes: 33784
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;



int main(){
 ll a,b,c,x,y; cin>>a>>b>>c>>x>>y;
 ll p=a+b;
 ll res=0;
 if(p<=2*c)res+=a*x+b*y;
 else{
 res=min(x,y)*2*c;
 res+=(x-min(x,y))*min(a,2*c);
 res+=(y-min(x,y))*min(b,2*c);
 }
 cout<<res<<endl;
 
}

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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)


void func(long long N, long long K){
    int digits = 0;
    long long q = N;
    while (true) {
        q = q/K;
        digits += 1;
        if (q == 0) break;
    }

    cout << digits << endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    func(N, K);
    return 0;
}


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

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

    int a[n];
    for(int i = 0; i < n; i++)  cin >> a[i];

    int q;
    cin >> q;

    int b, e;
    for(int i = 0; i < q; i++){
        cin >> b >> e;
        reverse(a+b, a+e);
    }

    for(int i = 0; i < n; i++)  cout << a[i] << " \n"[i == n-1];

    return 0;
}


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

int main() {
    int a,b;
    cin >> a >> b;
    if(a>b){
        for(int i=0;i<a;i++){
            cout << b;
        }
    } 
    else if(a<b){
        for(int i=0;i<b;i++){
            cout << a;
        }
    }
    else for(int i=0;i<a;i++){
            cout << a;
        }
    cout << endl;
}

Measured memory_bytes: 384
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var b = Array.ConvertAll(line, int.Parse);
        var a = new int[n + 2];
        long t = Math.Abs(b[0]) + Math.Abs(b[n - 1]);
        for (int i = 1; i <n; i++)
        {
            t += Math.Abs(b[i] - b[i - 1]);
            a[i + 1] = b[i];
        }
        a[n + 1] = a[0];  a[1] = b[0];
        for (int i = 1; i <= n; i++)
        {
            //if ((a[i - 1] <= a[i] && a[i] <= a[i + 1]) | (a[i - 1] >= a[i] && a[i] >= a[i + 1])) Console.WriteLine(t);
            //else
            //{
                var ret = t - Math.Abs(a[i - 1] - a[i]) - Math.Abs(a[i] - a[i + 1]) + Math.Abs(a[i - 1] - a[i + 1]);
                Console.WriteLine(ret);
            //}
        }
    }
}


Measured memory_bytes: 26332
from fractions import gcd

a,b,c,d=map(int,input().split())
lcm=int(c*d/gcd(c,d))
A=a-1
x1=A-A//c-A//d+A//lcm
x2=b-b//c-b//d+b//lcm
print(x2-x1)

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

int check( vector< int >& vec, int p )
{
	for( int i = 0; i < (int)vec.size(); ++i ){
		if( p == vec[ i ] ){
			return i;
		}
	}
	return -1;
}

int main()
{
	int p, q;
	while( cin >> p >> q ){
		string answer;
		vector< int > covered;
		int loop = -1;

		while( p != 0 ){
			while( 1 ){
				p *= 10;
				loop = check( covered, p );
				if( loop != -1 ){
					break;
				}
				covered.push_back( p );
				if( p >= q ){
					break;
				}
				answer += '0';
			}
			if( loop != -1 ) break;

			int div = p / q;
			answer += (char)( div + '0' );
			p %= q;
		}

		cout << answer << endl;
		if( loop != -1 ){
			for( int i = 0; i < loop; ++i ){
				cout << ' ';
			}
			for( int i = loop; i < (int)answer.size(); ++i ){
				cout << '^';
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1220
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
//use std::collections::HashMap;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: i32 = sc.read();
    let i = n / 111 +
        if n % 111 == 0 { 0 } else { 1 };
    println!("{}", i * 111);
}


Measured memory_bytes: 4352
import           Control.Monad

comb :: Int -> [a] -> [[a]]
comb 0 xs     = [[]]
comb _ []     = []
comb n (x:xs) = [x:y | y <- comb (n-1) xs] ++ comb n xs

norm :: (Integral a, Floating b) => [a] -> [a] -> b
norm i j = sqrt . fromIntegral . sum $ zipWith (\a b -> (a - b) ^ 2) i j

isInteger :: RealFrac a => a -> Bool
isInteger x = x == fromInteger (round x)

main = do
    [n,_] <- map read . words <$> getLine :: IO [Int]
    x <- replicateM n (map read . words <$> getLine) :: IO [[Int]]
    print $ length . filter isInteger . map (\[i, j] -> norm i j) $ comb 2 x


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

using namespace std;
#define REP(i, n) for(int i=0; i < (int)(n); ++i)
#define REPR(i, n) for(int i=n; i>= 0; --i)
#define FOR(i, m, n) for(int i=m; i<(n); ++i)

using ll = long long;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N), sum(N+1, 0);
    REP(i, N){
        cin >> A[i];
        sum[i+1] = sum[i] + A[i];
    }
    ll ans = (ll) 1 << 62;
    FOR(i, 1, N){
        ans = min(ans, abs((sum[N]-sum[i]) - sum[i]));
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
n, m = map(int, input().split())

lac = [0] * n
lwa = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if lac[p] == 0:
        if s == 'WA':
            lwa[p] += 1
        if s == 'AC':
            lac[p] = 1

print(sum(lac), sum(x * y for x, y in zip(lac, lwa)))

Measured memory_bytes: 4596
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
using namespace std;



int main() {
	cout << fixed << setprecision(10);
	long long int a, b, c, n, m;
	double t,x;
	cin >>t >>x;
	cout <<t/x ;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * ABC111A
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        String[] chars = n.split("");
        
        int before = Integer.valueOf(chars[0]);
        int now = 0;
        
        boolean bad = false;
        
        for(int i=1;i<chars.length;i++) {
        	now = Integer.valueOf(chars[i]);
        	if(before==now) {
        		bad = true;
        	}
        	before = now;
        }
        
        if(bad) {
        	System.out.println("Bad");
    	}else {
    		System.out.println("Good");
    	}
        
        sc.close();
    }
}

Measured memory_bytes: 21844
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)
function hsort(a::Array{Int,1})
	h = heap(a)
	b = Array{Int}(n)
	for i in 1:n
		b[i] = hpop(h)
	end
	b
end

function heap(a::Array{Int,1})
	h = [a[1]]
	for i in 2:length(a)
		hpush(h,a[i])
	end
	h
end

function hpush(h,x)
	push!(h,x)
	l = length(h)
	k = div(l,2)
	while h[k]>x&&k>=1
		tmp = h[k]
		h[k] = x
		h[l] = tmp
		k = div(k,2)
		l = div(l,2)
	end
	h
end

function hpop(h)
	x = h[1]
	z = pop!(h)
	h[1] = z
	k = 1
	l = length(h)
	while k <= l
		if 2*k>=l
			break
		elseif 2*k+1>=l
			if h[2*k]>=z
				break
			else
				tmp = h[2*k]
				h[2*k] = z
				h[k] = tmp
				k = 2*k
			end
		else
			if h[2*k]>=z&&h[2*k+1]>=z
				break
			elseif h[2*k]<z
				tmp = h[2*k]
				h[2*k] = z
				h[k] = tmp
				k = 2*k
			else
				tmp = h[2*k+1]
				h[2*k+1] = z
				h[k] = tmp
				k = 2*k+1
			end
		end
	end
	x
end
function main()
	n,m = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	a = sort(a)
	x = Array{Int}(2,m)
	for i in 1:m
		x[:,i] = readline() |> split |> parseMap
	end
	x = sortcols(x,by=x->x[2],rev=true)
	b = zeros(Int,n)
	now = 0
	for i in 1:m
		if now+x[1,i]>=n
			b[now+1:n] .+= x[2,i]
			now = n
			break
		else
			b[now+1:now+x[1,i]] .+= x[2,i]
			now += x[1,i]
		end
	end
	m = 0
	for i in 1:n
		m += max(a[i],b[i])
	end
	println(m)
end
main()


Measured memory_bytes: 159776
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::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...);
}
#else
#define trace(...)
#endif
 

#define M 1000010
 
ll f(ll n){
	if(n==1)return 1;
	return 2*f(n/2)+1;
}
int main(){
	IOS;
	tihs;
	
	ll h;cin>>h;
	cout<<f(h);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <time.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
	ll s;
	if(k > 1){
		s = k*facctorialMethod(k-1);
	} else {
		s = 1;
	}
	return s;
}

map< int64_t, ll > prime_factor(int64_t n) {
  map< int64_t, ll > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
const ll mod = 1000000007;
const ll INF = 1e9;

// 変数定義start(vectorはresizeしようね)
ll A, B;
// 変数定義end

void solve(){
	cin >> A >> B;
	ll abgcd = gcd(A, B);
	ll tmp = 1;
	ll ans = 1;
	for(auto p : prime_factor(abgcd)){
		while(p.second--){
			if(p.first != tmp){
				ans++;
				tmp = p.first;
			}
		}
	}
	cout << ans << endl;
}

int main(){

    //clock_t start = clock();

    cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	//clock_t end = clock();

    //const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    //printf("time %lf[ms]\n", time);
}


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

int main() {
	list<int> l;
	int n,s;
	cin>>n;
		for(int i=0;i<n;i++){
			cin>>s;
			if(i%2==n%2){
				l.push_back(s);
			}
			else{
				l.push_front(s);
			}
		}
	for(list<int>::iterator it=l.begin();it!=l.end();it++){
		cout<< *it <<" ";
	}
	
	return 0;
}

Measured memory_bytes: 8448
import java.util.Scanner;

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

	public void run() {

		while (true) {
			int[] val = new int[] { sc.nextInt(), sc.nextInt() };
			if(val[0]==0 &&val[1]==0)break;
			if(val[0]>val[1])swap(val);
			ln(val[0] + " " + val[1]);
		}
	}

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

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}

	public static int[] swap(int[] vals) {
		int tmp = vals[0];
		vals[0] = vals[1];
		vals[1] = tmp;
		return vals;
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
int main()
{
  char op[20000];
  int i,a[20000],b[20000],c[20000];
  for(i=1;i<=20000;i++){
    scanf("%d %c %d",&a[i],&op[i],&b[i]);
    if(op[i]=='?')
      {
        break;
      }
    switch(op[i])
    {
    case '+':
      c[i]=a[i]+b[i];
    break;
    case '-':
      c[i]=a[i]-b[i];
    break;
    case '/':
      c[i]=a[i]/b[i];
    break;
    case '*':
      c[i]=a[i]*b[i];
    break;
    }
  }
  for(i=1;i<=20000;i++){
    if(op[i]=='?'){
      break;
    }
    printf("%d\n",c[i]);
  }
  return 0;
}



Measured memory_bytes: 2088
-- Math Functions - Standard Deviation

import Control.Monad
import Control.Applicative

main :: IO()
main = do
  n <- readLn
  when (n > 0) $ do
    xs <- map read . words <$> getLine
    putStrLn . show $ sd n xs
    main

sd :: Double -> [Double] -> Double
sd n xs = sqrt . (/ n) . sum . map ((^2) . (subtract m)) $ xs
  where m = sum xs / n



Measured memory_bytes: 4956
d = dict()

N = int(input())
A = [int(_) for _ in input().split()]
Q = int(input())

val = sum(A)
ans = []
for a in A:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

for q in range(Q):
    b, c = [int(_) for _ in input().split()]
    if b not in d:
        ans.append(val)
        continue
    x = d.pop(b)
    if c in d:
        d[c] += x
    else:
        d[c] = x
    val += (c-b) * x    
    ans.append(val)

for v in ans:
    print(v)


Measured memory_bytes: 21356
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int cnt = 0;
  string w = "CF";
  cin >> s;
  for(int i = 0;i < s.size() && cnt < 2;i++){
    if(w[cnt] == s[i])cnt++;
  }
  if(cnt == 2)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 384
/**
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
ll mod=1e9+7;
int main()
{
IOS
int n;
cin>>n;
int a=n*n;
n+=a+(a*n);
cout<<n;
return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

struct Union_Find {
	vector<int> par;
	vector<int> rank;

	void init( int n ) {
		for ( int i = 0; i < n; ++i ) {
			par.push_back( i );
			rank.push_back( 0 );
		}
	}

	int find( int s ) {
		if ( par[ s ] == s ) {
			return s;
		}
		return par[ s ] = find( par[ s ] );
	}

	void unite( int x, int y ) {
		int a = find( x ), b = find( y );
		if ( a == b ) {
			return;
		}
		if ( rank[ x ] < rank[ y ] ) {
			par[ x ] = y;
		}
		else {
			par[ y ] = x;
			if ( rank[ x ] == rank[ y ] ) {
				++rank[ x ];
			}
		}
	}

	bool same( int x, int y ) {
		return find( x ) == find( y );
	}
};

int main() {
	int n, m;
	while ( ~scanf( "%d", &n ) && n ) {
		scanf( "%d", &m );
		VVI root( n, VI( n, INF ) );
		for ( int i = 0; i < m; i++ ) {
			int a, b, c;
			scanf( "%d,%d,%d", &a, &b, &c );
			root[ a ][ b ] = root[ b ][ a ] = c / 100 - 1;
		}
		Union_Find u;
		u.init( n );
		int ans = 0;
		for ( int i = 1; i < n; i++ ) {
			int _min = INF, add;
			for ( int j = 0; j < n; j++ ) {
				if ( !u.same( 0, j ) ) {
					continue;
				}
				for ( int k = 1; k < n; k++ ) {
					if ( !u.same( 0, k ) && _min >= root[ j ][ k ] ) {
						add = k;
						_min = root[ j ][ k ];
					}
				}
			}
			u.unite( 0, add );
			ans += _min;
		}
		printf( "%d\n", ans );
	}
	return 0;
}

Measured memory_bytes: 1256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;

int N[4];
vector<int> P;

int main() {
	for (int i = 0; i < 4; i++)
	{
		int n;
		cin >> n;
		N[i] = n;
	}
	vector<bool> is_1974(4, false);
	for (int i = 0; i < 4; i++)
	{
		switch (N[i])
		{
		case 1:
			is_1974[0] = true;
			break;
		case 9:
			is_1974[1] = true;
			break;
		case 7:
			is_1974[2] = true;
			break;
		case 4:
			is_1974[3] = true;
			break;
		default:
			break;
		}
	}
	string ans = "YES";
	for (int i = 0; i < 4; i++)
	{
		if (is_1974[i] == false) {
			ans = "NO";
			break;
		}
	}
	cout << ans << endl;
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int res = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			res += i;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3652
n = gets.to_i
a = gets.split.map(&:to_i)
sum = a[0].abs
(n-1).times do |i|
  sum += (a[i+1] - a[i]).abs
end
sum += a[n-1].abs
p sum - a[0].abs - (a[1]-a[0]).abs + a[1].abs
(n-2).times do |i|
  ans = sum + (a[i+2]-a[i]).abs - (a[i+1]-a[i]).abs - (a[i+2]-a[i+1]).abs
  p ans
end
p sum - a[n-1].abs - (a[n-1]-a[n-2]).abs + a[n-2].abs


Measured memory_bytes: 17576
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-10;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 2e5+10;
const int sigma_size = (int) 26;

///--------------------START-------------------------
int n;
int a[MAXN];
int x;

void work(){
    scanf("%d%d",&n,&x);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    int ans=0;
    for(int i=1;i<=n;i++){
        if(a[i]>x) break;
        x-=a[i];
        ans++;
    }
    if(x>0&&ans==n) ans--;
    printf("%d\n",ans);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}






Measured memory_bytes: 256
/*         
               JAI SHREE RAM    */
 
 
 
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define int             long long
#define mp              make_pair
#define pr              pair<long long,long long>
#define vr              vector<long long>
#define mod            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)
#define fill(a,b)       memset(a, b, sizeof(a))
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
 int k;
const int N = 1000001;
  vector <int> a;
int power(int x, unsigned int y) 
{ 
    int res = 1;     
   
    while (y > 0) 
    { 
        
        if (y & 1) 
            res = res*x%1000000007; 
        y = y>>1; // y = y/2 
        x = x*x % 1000000007;  // Change x to x^2 
    } 
    return res; 
}
 
long long maxSubArray(long long a[], int sze)
{
   long long max_so_far = 0, max_ending = 0;
   for (int i = 0; i < sze; i++)
   {
       max_ending = max_ending + a[i];
       if (max_ending < 0)
           max_ending = 0;
       else if (max_so_far < max_ending)
           max_so_far = max_ending;
   }
   return max_so_far;
}
 
 
 
ll factorialNumInverse[N + 1]; 
ll naturalNumInverse[N + 1]; 
ll fact[N + 1]; 
  
 
void InverseofNumber(ll p) 
{ 
    naturalNumInverse[0] = naturalNumInverse[1] = 1; 
    for (int i = 2; i <= N; i++) 
        naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p; 
} 
void InverseofFactorial(ll p) 
{ 
    factorialNumInverse[0] = factorialNumInverse[1] = 1; 
  
    
    for (int i = 2; i <= N; i++) 
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p; 
} 
void factorial(ll p) 
{ 
    fact[0] = 1; 
  
    // precompute factorials 
    for (int i = 1; i <= N; i++) { 
        fact[i] = (fact[i - 1] * i) % p; 
    } 
} 
  
ll Binomial(ll N, ll R, ll p) 
{ 
    // n C r = n!*inverse(r!)*inverse((n-r)!) 
    ll ans = ((fact[N] * factorialNumInverse[R]) 
              % p * factorialNumInverse[N - R]) 
             % p; 
    return ans; 
} 

 
void solve()
{
    int n;
    cin>>n;
    
    if(n)
    cout<<0<<"\n";
    else
    cout<<1<<"\n";
}

 
int32_t main()
{ 
      
      ios;
      int test;
      
      
      test=1;
     // cin>>test;
    
      while(test--)
      {
          solve();
          
      }
       
    
    return 0;
	}

Measured memory_bytes: 3644
#include <cstdio>

int main()
{
  int k, s;
  scanf("%d %d", &k, &s);
  int ans = 0;
  for (int x = 0; x <= k; ++x)
  {
    for (int y = 0; y <= k; ++y)
    {
      if (0 <= s - x - y && s - x - y <= k)
      {
        ++ans;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main(){
	long long n, m;
	cin >> n >> m;
	int ans = 0;
	for (int i = 1; i * i <= m; i++) {
		if (m % i == 0) {
			if (i * n <= m) {
				if (ans < i) {
					ans = i;
				}
			}
			if ((m / i) * n <= m) {
				if (ans < (m / i)) {
					ans = (m / i);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;

const ll INF = 10000000000000000;

template <typename T>
struct Edge
{
    int to;
    T cost;
};

template <typename T>
struct WeightedGraph
{
    int n;
    vector<vector<Edge<T>>> g;
    
    WeightedGraph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to, T cost){
        g[from].push_back((Edge<T>){to, cost});
    }
};

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

template <typename T>
vector<T> Dijkstra(WeightedGraph<T> &g, int s){
    typedef pair<T, int> P;
    int n = g.n;
    vector<T> d(n);
    fill(d.begin(), d.end(), INF);
    priority_queue<P, vector<P>, greater<P>> que;
    d[s] = 0;
    que.push(P(0, s));
    while(que.size()){
        P nowp = que.top();
        que.pop();
        if(d[nowp.second] < nowp.first) continue;
        for(Edge<T> e : g.g[nowp.second]){
            if(d[e.to] > d[nowp.second] + e.cost){
                d[e.to] = d[nowp.second] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
    return d;
}

int main()
{
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    WeightedGraph<ll> gy(n), gs(n);
    for(int i = 0; i < m; i++){
        ll v, w, a, b;
        cin >> v >> w >> a >> b;
        v--; w--;
        gy.add_edge(v, w, a);
        gy.add_edge(w, v, a);
        gs.add_edge(v, w, b);
        gs.add_edge(w, v, b);
    }
    vector<ll> dy = Dijkstra(gy, s);
    vector<ll> ds = Dijkstra(gs, t);
    ll ans[100002];
    for(int i = n - 1; i >= 0; i--){
        ans[i] = 1000000000000000 - (dy[i] + ds[i]);
        if(i < n - 1) ans[i] = max(ans[i], ans[i + 1]);
    }
    for(int i = 0; i < n; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 19068
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int n;
int a[maxn];

int main(){
	scanf("%d",&n);
	int ans=0,res=0;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=2;i<=n;i++){
		if(a[i-1]>=a[i])res++;
		else ans=max(ans,res),res=0;
	}
	ans=max(ans,res);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
n = int(input())
ansc = 0
ans = 0
if n == 1:
    print(1)
    exit()
for i in range(1,n+1):
    x = i
    cnt = 0
    while x % 2 == 0:
        cnt += 1
        x /= 2
        if cnt > ansc:
            ansc = cnt
            ans = i
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MOD 1000000007
//for(int i=0; i<n; ++i)
using namespace std;
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define ll long long

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

    int x, n, f = 1;
    cin >> n;

    for (int i = 0; i < n; ++i)
    {
        cin >> x;
        if (f)
        {
            if (x % 2 == 0)
                if (x % 3 != 0 && x % 5 != 0)
                    f = 0;
        }
    }
    if (f)
        cout << "APPROVED";
    else
        cout << "DENIED";

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
///#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

/*
    zet:
        find_by_order(k): k-stat [k > 0]
        order_of_key(k) : {el < k}

    gp_hash_table<key, val, custom_hash>

    rope<T>:
        iterators: mutable_begin, ..
        methods  : erase, insert, substr, ..
*/

#define all(x) (x).begin(), (x).end()
#define size(x) (int)((x).size())
#define em_back emplace_back

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

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

template<typename T>
using zet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

mt19937 eng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e5 + 4;
const int LGN = 20;

int n, l, x[N];

void read() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x[i];
    }
    cin >> l;
}

int to[N][LGN];

int myUpper(int val) {
    int tl = 1, tr = n + 1;
    while (tl + 1 < tr) {
        int m = (tl + tr) >> 1;
        if (x[m] <= val) {
            tl = m;
        } else {
            tr = m;
        }
    }

    return tl;
}

void prepare() {
    for (int i = 1; i < n; ++i) {
        to[i][0] = myUpper(x[i] + l);
    }
    to[n][0] = -1;
    for (int pw = 1; pw < LGN; ++pw) {
        for (int j = 1; j <= n; ++j) {
            if (j + (1 << pw) <= n && to[j][pw - 1] != -1) {
                to[j][pw] = to[to[j][pw - 1]][pw - 1];
            } else {
                to[j][pw] = -1;
            }
        }
    }
}

int calc(int a, int b) {
    if (a == b) {
        return 0;
    }
    if (x[b] - x[a] <= l) {
        return 1;
    }
    for (int pw = LGN - 1; pw >= 0; --pw) {
        int c = to[a][pw];
        if (c > b || c == -1) {
            continue;
        }
        return (1 << pw) + calc(c, b);
    }
}

void solve() {
    read();
    prepare();

    int q;
    cin >> q;
    while (q--) {
        int a, b;
        cin >> a >> b;
        if (a > b) {
            swap(a, b);
        }
        cout << calc(a, b) << "\n";
    }
}

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

    int z = 1;
    /// cin >> z;

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

    return 0;
}


Measured memory_bytes: 11860