akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

int main() {
    LL n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    b -= a;
    a = 0;
    if (b < 0) b = -b;
    --n;
    //int bc = (b + c - 1) / c;
    //int bd = (b + d - 1) / d;
    for (int i = 0; i < n; i += 2) {
        //if ((b <= (LL)(n - i) * d && b >= (LL)(n - i) * c) || (n % 2 == 0 && b <= c - d)) {
        if ((b <= (LL)(n - i) * d + (d-c) * i / 2 && b >= (LL)(n - i) * c  - (d-c) * i / 2) || (n % 2 == 0 && b <= c - d)) {
            cerr << b << " " << (n - i) * c << " " << (n - i) * d << endl;
            cout << "YES" << endl;
            return 0;
        }
        if ((LL)(n - i) * d < 0) cerr << (LL)(n - i) * d << endl;
        if ((LL)(n - i) * c < 0) cerr << (LL)(n - i) * c << endl;
    }
    cout << "NO" << endl;

     return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repn(i, j, k) for (int i = (j); i < (k); i++)
#define all(v) v.begin(), v.end()
#define INF 1e9
using namespace std;
using ll = long long;

int main()
{
  int dp[1000000];
  int N;
  cin >> N;
  rep(i, N+1) dp[i] = INF;
  dp[0] = 0;
  rep(i, N+1) {
    rep(j, 8) {
      int pow6 = pow(6, j);
      int res = dp[i+pow6];
      dp[i+pow6] = min(res, dp[i]+1);
    }
    rep(j, 7) {
      int pow9 = pow(9, j);
      int res = dp[i+pow9];
      dp[i+pow9] = min(res, dp[i]+1);
    }
  }
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#define _USE_MATH_DEFINES
#include<math.h>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<unordered_map>
#include<set>
#include <algorithm>
#include <utility>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::set;
using std::vector;
using std::pair;
using std::make_pair;
using std::priority_queue;

typedef unsigned long long ull;
typedef long long ll;

#define Prime1 1000000007
#define Prime2 9999973

#define INF 0x7fffffffffffffff

#define MAX 300

ull i, j, k, l, m, n;
ull H, W, Q;
ull a, b, c, x, y;
ull K, L, N, M;
string str;
ull A[MAX][MAX];
ull Road[MAX][MAX];

int main()
{
	cin >> N;
	for (i = 0; i < N; ++i) {
		for (j = 0; j < N; ++j) {
			cin >> A[i][j];
			Road[i][j] = 1;
	} }
	for (i = 0; i < N - 2; ++i) {
		for (j = i + 1; j < N - 1; ++j) {
			for (k = j + 1; k < N; ++k) {
				M = std::max(A[i][j], std::max(A[j][k], A[i][k]));
				if (M > A[i][j] + A[j][k] + A[i][k] - M)
				{
					cout << "-1\n";
					return 0;
				}
				if (M == A[i][j] + A[j][k] + A[i][k] - M)
				{
					if (M == A[i][j])
					{
						Road[i][j] = 0;
					}
					else if (M == A[i][k])
					{
						Road[i][k] = 0;
					}
					else
					{
						Road[j][k] = 0;
					}
				}
	} } }
	ull S = 0;
	for (i = 0; i < N - 1; ++i) {
		for (j = i + 1; j < N; ++j) {
			if (Road[i][j])
			{
				S += A[i][j];
			}
	} }
	cout << S << '\n';
	return 0;
}


Measured memory_bytes: 1664
N, A, B = map(int, input().split())

if A > B:
    print(0)
elif N == 1 and A != B:
    print(0)
elif N == 1 and A == B:
    print(1)
elif N == 2 and A != B:
    print(1)
else:
    min_tmp = A*(N-1) + B
    max_tmp = B*(N-1) + A
    print(max_tmp-min_tmp+1)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main () {

    int K, X;
    cin >> K >> X;
    
    int min_candidate = X - (K - 1);
    int max_candidate = X + (K - 1);

    for (int i = min_candidate; i <= max_candidate; i++) {
        if ((-1000000 <= i) & (i <= 1000000)) {
            cout << i << " ";
        }
    }

    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;
ll N;
ll p[13],s[13];
void solve() {
	int i,j,k,l,r,x,y;
	
	p[0]=1;
	FOR(i,12) {
		p[i+1]=p[i]*26;
		s[i+1]=s[i]+p[i+1];
	}
	cin>>N;
	for(i=1;i<=12;i++) {
		if(N<=s[i]) {
			N--;
			N-=s[i-1];
			for(j=i;j>=1;j--) {
				S.push_back((char)('a'+(N/p[j-1])));
				N%=p[j-1];
			}
			break;
		}
	}
	
	
	cout<<S<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

ll c[6];
int main(){
    int n;
    cin>>n;
    ll cnt=0;
    string s;
    rep(i,n){
        cin>>s;
        if(s[0]=='M')++cnt,++c[0];
        else if(s[0]=='A') ++cnt,++c[1];
        else if(s[0]=='R') ++cnt,++c[2];
        else if(s[0]=='C') ++cnt,++c[3];
        else if(s[0]=='H') ++cnt,++c[4];
    }
    if(cnt<3) cout<<0<<endl;
    else{
        ll ans=0;
        rep(i,1<<5){
            ll mul=1; 
            if(__builtin_popcount(i)!=3) continue;
            rep(j,5)if((i>>j)&1) mul*=c[j];
            ans+=mul;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define int long long
#define endl '\n'
#define inf 0x3f3f3f3f
#define lb lower_bound
#define db(x) {cout <<"#db " << x << endl;}
#define here() {cout <<"here \n";}
#define mod 1000000007

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int n,m;
const int N = 1e5 + 5;
vector<int> link[N];
bool vis[N];
bool rep = 0;
int c[2];
int t[N];
queue <pair<int,int> > q;
void dfs(int u,int st){
	if(t[u] > 0){
		if(t[u] == st){
			cout << n*(n-1)/2 - m;
			exit(0);
		}
		return;
	}
	t[u] = 3-st;
	c[st-1] ++ ;
	for(int i = 0 ; i < link[u].size() ; i ++){
		int v = link[u][i];
		dfs(v,3 - st);
	}
}
signed main(){
	cin >> n >> m;
	for(int i = 1 ; i <= m ; i ++){
		int u , v; cin >> u >> v;
		link[u].pb(v);link[v].pb(u);
	}
	dfs(1,1);
	cout <<c[0]*c[1]-m;
	return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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



int main()
{
    llong n,k;
    cin>>n>>k;
    vector<llong> x(n,0);
    REP(i,n) cin>>x[i];
    llong ans=INF;
    for(auto i = 0; i < n - k + 1; ++i){
        if(x[i + k - 1] <= 0){
            ans = min(ans, -x[i]);
        }else if(x[i] >= 0){
            ans = min(ans, x[i + k - 1]);
        }else{
            ans = min({ans, x[i + k - 1] * 2 - x[i], x[i + k - 1] - x[i] * 2});
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD =1000000007;
int p=200003;
// Cooley–Tukey FFT algorithm O(N log N)
vector<complex<double>> fft(vector<complex<double>> a, bool inverse = false) {
    int n = a.size();
    int h = 0; // h = log_2(n)
    for (int i = 0; 1 << i < n; i++) h++;
    // バタフライ演算用の配置入れ替え
    for (int i = 0; i < n; i++) {
        int j = 0;
        for (int k = 0; k < h; k++) j |= (i >> k & 1) << (h - 1 - k);
        if (i < j) swap(a[i], a[j]);
    }
    // バタフライ演算
    for (int b = 1; b < n; b *= 2) {
        // 第 log_2(b) + 1 段
        // ブロックサイズ = b * 2
        for (int j = 0; j < b; j++) {
            // ブロック内 j 個目
            // 重み w = (1 の原始 2b 乗根の j 乗)
            complex<double> w =
                polar(1.0, (2 * M_PI) / (2 * b) * j * (inverse ? 1 : -1));
            for (int k = 0; k < n; k += b * 2) {
                // k を先頭とするブロック
                complex<double> s = a[j + k];         // 前
                complex<double> t = a[j + k + b] * w; // 後
                a[j + k] = s + t;                     // 前の更新
                a[j + k + b] = s - t;                 // 後の更新
            }
        }
    }
    // 逆変換時にサイズで割る調整
    if (inverse)
        for (int i = 0; i < n; i++) a[i] /= n;
    return a;
}
// Cooley–Tukey FFT algorithm O(N log N)
vector<complex<double>> fft(vector<double> a, bool inverse = false) {
    vector<complex<double>> a_complex(a.size());
    for (int i = 0; i < a.size(); i++) a_complex[i] = complex<double>(a[i], 0);
    return fft(a_complex, inverse);
}
 
// FFT による畳み込み O(N log N)
vector<double> convolve(vector<double> a, vector<double> b) {
    int s = a.size() + b.size() - 1; // 畳み込み結果のサイズ
    int t = 1; // FFT に使う配列のサイズ（2 の累乗）
    while (t < s) t *= 2;
    a.resize(t); // FFT するためにリサイズ
    b.resize(t); // FFT するためにリサイズ
    vector<complex<double>> A = fft(a);
    vector<complex<double>> B = fft(b);
    for (int i = 0; i < t; i++) {
        A[i] *= B[i]; // 畳み込み結果の FFT 結果を得る
    }
    A = fft(A, true); // IFFT で畳み込み結果を得る
    a.resize(s);      // 畳み込み結果を入れるためにリサイズ
    for (int i = 0; i < s; i++) a[i] = A[i].real(); // 実部が答え
    return a;
}

     signed main(){

int x[p];
int t=1;
for(int i=0;i<p-1;i++){
    x[t]=i;
    t=(2*t)%p;
}
vector<double> b(2*p+5,0);
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]!=0)b[x[a[i]]]++;
}
vector<double> ans=convolve(b,b);
int ans2=0;
t=1;
for(int i=0;i<ans.size();i++){
  //  if((int)(ans[i]+0.5)!=0)cerr<<i<<' '<<(int)(ans[i]+0.5)<<endl;
    ans2+=((int)(ans[i]+0.5) )*t;
    t=(t*2)%p;
}
for(int i=0;i<n;i++)ans2-=(a[i]*a[i])%p;
cout<<ans2/2<<endl;

     }


 


 






    





      

        


Measured memory_bytes: 83704
import sys
import math
input = sys.stdin.readline
 
a, b, x = map(int, input().split())
 
m = a ** 2 * b
if x <= m / 2:
    c = (x * 2) / (a * b)
    ans = math.degrees(math.atan(b / c))
else:
    c = 2 * (m - x) / (a ** 2)
    ans = math.degrees(math.atan(c / a))
 
print(ans)

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//
#include<cmath>
#include<iomanip>

using namespace std;

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

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0}; //次に行くところ
int dx[] = {0,1,0,-1}; //s上に同じ

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,ans = 0;
  cin >> n;
  vector<char> s(n);
  map<char,int> cnt;
  
  for (int i = 0; i < n; i++){
    cin >> s[i];
    if (cnt[s[i]] == 0){
      ans++;
    }
    cnt[s[i]]++;
  }
  
  if (ans == 3){
    cout << "Three\n";
  }else{
    cout << "Four\n";
  }

  return 0;
}

Measured memory_bytes: 3612
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	int[][] A = new int[50][50];
	int[][] B = new int[50][50];
	int[][] T = new int[50][50];
	int n, mod;
	
	void mult(int[][] C, int[][] D) {
		for (int i = 0; i < n; i++)
			Arrays.fill(T[i], 0);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					T[i][j] = (T[i][j] + C[i][k]*D[k][j]) % mod;
				}
			}
		}
	}
	
	void subst(int[][] C, int[][] D) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				C[i][j] = D[i][j];
			}
		}
	}
	
	void pow(int t) {
		for (int i = 0; i < n; i++) {
			Arrays.fill(B[i], 0);
			B[i][i] = 1;
		}
		while (t > 0) {
			if ((t & 1) == 1) {
				mult(A, B);
				subst(B, T);
			}
			mult(A, A);
			subst(A, T);
			t >>= 1;
		}
	}
	
	void run() {
		int[] stat = new int[50];
		while (true) {
			n = sc.nextInt();
			mod = sc.nextInt();
			int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
			int t = sc.nextInt();
			if (n == 0) break;

			for (int i = 0; i < n; i++)
				stat[i] = sc.nextInt();
			
			Arrays.fill(A[0], 0);
			A[0][0] = b; A[0][1] = c;
			for (int i = 1; i < n-1; i++) {
				Arrays.fill(A[i], 0);
				A[i][i-1] = a;
				A[i][i] = b;
				A[i][i+1] = c;
			}
			Arrays.fill(A[n-1], 0);
			A[n-1][n-2] = a;
			A[n-1][n-1] = b;
			
			pow(t);
			
			int res = 0;
			for (int i = 0; i < n; i++) {
				res = (res + B[0][i]*stat[i]) % mod;
			}
			out.print(res);
			for (int i = 1; i < n; i++) {
				res = 0;
				for (int j = 0; j < n; j++) {
					res = (res + B[i][j]*stat[j]) % mod;
				}
				out.printf(" %d", res);
			}
			out.println();
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 34064
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut now = 0;
    let mut ans: usize = 0;
    let mut r: usize = 0;
    for l in 0..n {
        while r < n && a[r] & now == 0 {
            now ^= a[r];
            r += 1;
        }
        ans += r - l;
        if r == l {
            r += 1;
        }
        now ^= a[l];
    }
    println!("{}", ans);
}


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

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  r(i,n)cin>>v.at(i);
  cout << *max_element(v.begin(),v.end())-*min_element(v.begin(),v.end()) <<endl;
}

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

int main(){
	int a;
	while(cin>>a,a){
		int x=INF;
		int y=INF;
		int z=INF;
		
		for(int i=0;i*i*i<=a;i++){
			int d,e,f;
			int b=a;
			b-=(i*i*i);
			d=i;
			int c=sqrt(b);
			e=c;
			b-=(c*c);
			f=b;
			if(d+e+f<x+y+z){
				z=d;
				y=e;
				x=f;
				}
			}
			cout<<x+y+z<<endl;
		}
		return 0;
	}

Measured memory_bytes: 3036
import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()

def main():
    def bfs():
        

        inf = 1e7

        dist = [[inf]*w for _ in range(h)]
        dist[xs][ys] = 0
        que = deque([(xs, ys)])
        dx = [-1, 0, 1, 0]
        dy = [0, 1, 0, -1]
        while que:
            x, y = que.popleft()
            for i in range(4):
                nx, ny = x, y
                for _ in range(k):
                    nx += dx[i]
                    ny += dy[i]
                    if nx < 0 or nx >= h or ny < 0 or ny >= w: break
                    if field[nx][ny] == '@' or dist[nx][ny] <= dist[x][y]: break
                    if dist[nx][ny] > dist[x][y] + 1:
                        dist[nx][ny] = dist[x][y] + 1
                        que.append((nx, ny))
            
        if dist[xg][yg] == inf:
            print(-1)
        else:
            print(dist[xg][yg])

    h, w, k = map(int, input().split())
    xs, ys, xg, yg = map(lambda x: int(x)-1, input().split())
    field = [input() for _ in range(h)]
    bfs()
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 38264
<?php
  fscanf(STDIN, "%d%d", $n,$k);
  $h = explode(" " , trim(fgets(STDIN)));
  $count=0;
  for($i=0; $i<$n; $i++){
      if($h[$i] >= $k){
          $count++;
      }
  }
  echo $count;

Measured memory_bytes: 12792
def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a

k = int(input())
sum = 0
for a in range(k):
    for b in range(k):
        gcd_ab = gcd(a + 1, b + 1)
        for c in range(k):
            sum += gcd(gcd_ab, c + 1)
print(sum)

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

const int MAXN = 3e5+5;
const int MAXNN = 20;
const int INF = 1e9+7;
#define ll long long
#define pb push_back
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define mp make_pair

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll MOD(ll a){
    return ((a%INF)+INF)%INF;
}

ll inv(ll a){
    return poww(a,INF-2,INF);
}

ll a[MAXNN][MAXNN],dp[(1<<MAXNN)],cost[(1<<MAXNN)];

int main()
{
    fast_io;
    //cout << fixed << setprecision(15);

    int n;cin >> n;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            cin >> a[i][j];
        }
    }

    for(int i=0;i<(1<<n);++i){
        for(int j=1;j<=n;++j){
            for(int f=j+1;f<=n;++f){
                if((i & (1<<(f-1))) && (i & (1<<(j-1)))){
                    cost[i] += a[j][f];
                }
            }
        }
    }

    dp[0] = 0;
    for(int i=0;i<(1<<n);++i){
        for(int prev = i;prev >0;prev = (prev - 1) & i){
            dp[i] = max(dp[i],dp[i ^ prev] + cost[prev]);
        }
    }
    cout << dp[(1<<n)-1];
}


Measured memory_bytes: 2816
#include <stdio.h>

#define N 1000

int main()
{
  int i,j,num,A[N],key;

  scanf("%d",&num);
  for(i=1; i<=num; i++){
    scanf("%d",&A[i]);
  }


  for(i=1; i <= num; i++){
    key = A[i];
    j = i-1;

    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
      A[j+1] = key;
    }

    for(j=1; j<num; j++){
      printf("%d ",A[j]);
    }
    printf("%d\n",A[num]); 

  }

  return 0;

}

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

#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 1005;

vector<int>graph[maxn];

vector<int>ans;
int n,m;
int vis[maxn];
void dfs(int u, int target)
{
  vis[u] = 1;
  for(const auto &v: graph[u])
  {
    if(vis[v] == 1)
    {
      if(v == target)
      {
        vector<int>cycle;
        for(int i = 1; i <= n ; i++)
          if(vis[i] == 1)
            cycle.push_back(i);
        if(ans.size() == 0 || cycle.size() < ans.size())
          ans = cycle;
      }
    }
    else if(vis[v] == 0)
    {
      dfs(v, target);
    }
  }
  vis[u] = 2;
}


int main()
{
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for(int i = 0 ; i < m ; i++)
  {
    int u,v;
    cin >> u >> v;
    graph[u].push_back(v);
  }
  for(int i = 1 ; i <= n ; i++)
  {
    MSET(vis, 0);
    dfs(i, i);
  }

  if(ans.size() == 0)
    cout << "-1\n";
  else
  {
    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++)
    {
      cout << ans[i] << endl; 
    }
  }
  return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()

int n;
const int maxn = 1e5 + 5;
vector<int> g[maxn];

int col[maxn];

bool dfs(int u, int f){
    bool flag = true;
    for(auto v : g[u]){
        if(v == f)
            continue;
        flag &= dfs(v, u);
    }
    if(col[u] == 0){
        col[u] = 1; //black
    }
    if(col[u] == 1){
        if(col[f] != 0)
            return false;
        else{
            col[f] = 2;
        }
    }
    return flag;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 1;i < n;i++){
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    } 
    if(n == 2){
        cout << "Second" << endl;
    }else{
        int rt = 0;
        for(int i = 1;i <= n;i++){
            if(g[i].size() > 1)
                rt = i;
        }
        if(dfs(rt, 0)){
            cout << "Second" << endl;
        }else{
            cout << "First" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6272
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
	int r, d;
	ll x;
	cin >> r >> d >> x;
	REP(i, 10) {
		x = r * x - d;
		cout << x << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#include <iomanip>
using namespace std;
#define inf 100000007

int main(void){
    long long int n;
    cin >> n;
    long long int ans = 0;
    ans = (n*(n-1))/2;
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    int N = S.size();
    int ans = 1;
    int now = 0;
    string temp = "";
    temp += S.at(0);
    for(int i = 1; i < N; i++) {
        if(i == N - 1 && temp.size() == 1) {
            if(temp.at(0) == S.at(N - 1)) {
                break;
            }
            ans++;
            break;
        }
        if(temp == S.substr(i, 1)) {
            temp = S.substr(i, 2);
            i++;
        } else {
            temp = S.substr(i, 1);
        }
        //cout << i << ':' << temp << endl;
        ans++;
    }
    cout << ans << endl;
    

    return 0;
}

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

// 複素数雨セット
typedef complex<double> C;
// 内積
double dot(C a, C b){
    return a.real() * b.real() + a.imag() * b.imag();
}
double round(double a){
    if(abs(a) < 0.00000000001){
        return 0;
    }
    else{
        return a;
    }
}

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

    // input
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    C p1(x1, y1);
    C p2(x2, y2);
    C v = p2 - p1;
    C n = v / abs(v);
        
    ll Q; cin >> Q;
    while(Q--){
        ll x, y;
        cin >> x >> y;
        C p(x, y);

        auto v = p - p1;
        auto p_proj = p1 + dot(v, n) * n;
        auto w = p_proj - p;
        auto ans = p_proj + w;

        // cout << round(ans.real()) << ' ' << round(ans.imag()) << endl;
        printf("%.8lf %.8lf\n", ans.real(), ans.imag());
    }
    
    return 0;
}


Measured memory_bytes: 3288
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

int first_num(int a) {
	
	while (a >= 10) {
		a /= 10;
	}

	return a;

}

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

	vector<vector<int>> cnt(10, vector<int>(10));


	for (int i = 1; i <=min(9,n);i++) {
		cnt[i][i]++;
	}

	for (int i = 10; i <= n; i++) {
		int b = i % 10;
		int a = first_num(i);
		if (b != 0) {
			cnt[a][b]++;
		}
	}

	ll ans = 0;

	for (int i = 1; i < 10;i++) {
		for (int j = i; j < 10; j++) {
			if (i != j) {
				ans += 2 * cnt[i][j] * cnt[j][i];
			}
			else {
				ans += cnt[i][j] * cnt[j][i];
			}

		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	int a;
	cin >> a;
	cout << a + pow(a, 2) + pow(a, 3) << endl;
}


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

using namespace std;
typedef pair<int, int> pii;

int n;
vector<int> a;

int f(int si, int c) {
  int l = si, r = si;
  while (l >= 1 && a[l - 1] == c) l--;
  while (r <= n && a[r + 1] == c) r++;
  if (r - l + 1 < 4) return 0;

  int res = r - l + 1;
  l--, r++;
  while (a[l] == a[r]) {
    int suml = 1, sumr = 1;
    while (l >= 1 && a[l - 1] == a[l]) l--, suml++;
    while (r <= n && a[r + 1] == a[r]) r++, sumr++;
    if (suml + sumr < 4) return res;
    res += suml + sumr;
    l--, r++;
  }
  return res;
}

int main(void) {
  while (cin >> n, n) {
    a.resize(n + 2, 0);
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }

    int ans = n;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= 3; j++) {
        ans = min(ans, n - f(i, j));
      }
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3052
import math
t,a,k = map(int,input().split())

for i in range(k):
    if i%2 ==0:
        if t % 2 == 1:
            t -= 1
        a += t/2
        t /= 2
    
    else:
        if a % 2 == 1:
            a -= 1
        t += a/2
        a /= 2
t = math.floor(t)
a =math.floor(a)

print(str(t)+" "+str(a))

Measured memory_bytes: 3060
DP = {}

def solve(n, a, b, c, d):
    if n <= 0: 
        return 0
    if n == 1:
        return d
    if n in DP:
        return DP[n]
    ans = float('inf')
    for i in range(-3, 4):
        num = n + i
        trash = abs(i)*d
        if num < 0:
            continue
        if num%5 == 0 and num // 5 < n:
            ans = min(ans, solve(num//5, a, b, c, d) + min(c, d*(num-(num//5))) + trash)
        if num%3 == 0 and num // 3 < n:
            ans = min(ans, solve(num//3, a, b, c, d) + min(b, d*(num-(num//3))) + trash)
        if num%2 == 0 and num // 2 < n:
            ans = min(ans, solve(num//2, a, b, c, d) + min(a, d*(num-(num//2))) + trash)
        # print(str(n) + ' ' + str(ans) + ' ' + str(num) + ' ' + str(i))
    DP[n] = int(ans)

    return int(ans)

def solve2():
    DP.clear()
    ans = float('inf')
    n, a, b, c, d = map(int, input().split())
    # for i in range(0, 65):
    #     for j in range(0, 30):
    #             for k in range(0, 10):
    #                 val = pow(2, i)*pow(3, j)*pow(5, k)
    #                 ans = min(ans, a*i + b*j + c*k + abs(n - val)*(d))
    # print(ans)
                    
    print(solve(n, a, b, c,d))
    
t = int(input())
for _ in range(t):
    solve2()


Measured memory_bytes: 14080
#include <iostream>
#include <string>
using namespace std;
int main() {
	int Anum=-1, Znum=-1;
	bool flg = false;
	string S;
	cin >> S;
	for (int i = 0; i < (int)S.size(); i++)
	{
		if (Anum == -1 && S[i] == 'A') {
			Anum = i;
			flg = true;
		}
		if (flg && S[i] == 'Z') {
			Znum = i;
		}
	}

	cout << Znum - Anum + 1 << endl;

	return 0;
}

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

#define all(A) begin(A), end(A)
#define sz(A) int(A.size())

using namespace std;

typedef long long ll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  char ch;
  cin >> ch;
  if (ch == 'A') cout << 'T' << endl;
  if (ch == 'T') cout << 'A' << endl;
  if (ch == 'C') cout << 'G' << endl;
  if (ch == 'G') cout << 'C' << endl;
  return (0);
}


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

ll mod = 998244353;
class SegmentTree {
private:
    int n;
    vector<ll> node, lazy;
public:
    SegmentTree(int N) {
        n = 1;
        while (n < N) n *= 2;
        node.resize(2 * n - 1, 0);
        lazy.resize(2 * n - 1, 0);
    }

    void update(int i, int l, int r) {
        node[i] += lazy[i];
        node[i] %= mod;
        if (r - l > 1) {
            lazy[2 * i + 1] += lazy[i] / 2;
            lazy[2 * i + 2] += lazy[i] / 2;
        }
        lazy[i] = 0;
    }

    void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return;
        
        if (a <= l && r <= b) {
            lazy[k] += (r - l) * (x);
            update(k, l, r);
        } else {
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = (node[2 * k + 1] + node[2 * k + 2]) % mod;
        }
    }

    ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return 0;        
        if (a <= l && r <= b) return node[k] % mod;

        ll sum_l = query(a, b, 2 * k + 1, l, (l + r) / 2);
        ll sum_r = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return (sum_l + sum_r) % mod;
    }

    void disp() {
        for (int i : node) {
            cout << i << " ";
        }
        cout << "\n";
    }

};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int L[K], R[K];
    for (int i = 0; i < K; i++) {
        cin >> L[i] >> R[i];
    }

    SegmentTree st(N + 1);
    st.add(1, 2, 1);
    
    for (int i = 1; i < N; i++) {
        ll x = st.query(i, i + 1);
        for (int j = 0; j < K; j++) {
            int l = i + L[j];
            int r = i + R[j] + 1;
            
            st.add(min(l, N + 1), min(r, N + 1), x);
            //st.add(l, r, x);
        }
        //cout << x << "\n";
    }

    cout << st.query(N, N + 1) << "\n";

    return 0;
}

Measured memory_bytes: 11368
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a = sorted(a)

b = []
cnt = 0
for i in range(n):
    for j in range(i+1, n):
        if cnt == 3:
            break
        if i == j: continue
        b.append(int(str(a[i]) + str(a[j])))
        b.append(int(str(a[j]) + str(a[i])))
        cnt += 1
b = sorted(b)
print(b[2])



Measured memory_bytes: 5960
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int mod=1e9+7,N=5005;
int C[N][N],s,ans;

signed main(){
	read(s);
	for(int i=0;i<=5000;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for(int n=1,base=3;base<=s;n++,base+=3) ans=(ans+C[s-base+n-1][n-1])%mod;
	write(ans);
}

Measured memory_bytes: 70376
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 100005;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

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

ll my_pow(ll x, ll y)
{
    ll res = 1;

    while(y)
    {
        if(y&1)
        {
            res = mul(res,x);
        }
        x = mul(x,x);
        y>>=1;
    }

    return res;
}

ll my_inv(ll x)
{
    return my_pow(x, MOD-2);
}

ll fac[NMAX*3];

void calculate_fac()
{
    fac[0] = fac[1] = 1;
    for(int i = 2; i< NMAX*3; ++i)
    {
        fac[i] = mul(fac[i-1],i);
    }
}

ll combinations(ll n, ll k)
{
    if(n < k)
        return 0;
    if(n == k)
        return 1;

    return mul(fac[n], my_inv(mul(fac[n-k],fac[k])));
}

void sub_self(ll &x, ll y)
{
    x = x - y;
    if(x < 0)
    {
        x+= MOD;
    }  
}

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

    int n,k;
    cin >> n >> k;

    calculate_fac();

    vector<int> v(n);
    for(int i =0; i< n; ++i)
    {
        cin >> v[i];
    }
    sort(v.begin(),v.end());

    ll ans = 0;

    
    
    for(int i = 0; i < n -1 ; ++i)
    {
        ll diff = (v[i+1] - v[i]) % MOD;
        ll ways = combinations(n,k);
        sub_self(ways, combinations(i+1, k));
        sub_self(ways, combinations(n-i -1, k));
        ans = (ans + mul(diff,ways)) % MOD;
    }


    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 2944
eval"N,*A,i=#{`tr ' 
' ,`}j=0
b=A.pop N
c=:Yes,*(b+b)[A.map{j+=1while b[j]&.<=_1
j-~i-=1}.max,N]
puts A.any?{_1==c[$.+=1]}?:No:c"

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

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007
#define INF (1<<28)
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)

#define int long long


signed main(){
	int n;
	cin>>n;
	int a[100],sum=0;
	lp(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	double av=(double)sum/n;
	//cout<<av<<endl;
	double d=INF,ans=0;
	lp(i,n){
		if(d>abs(a[i]-av)){
			ans=i;
			d=abs(a[i]-av);
		}
	}
	cout<<ans<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return rand()%x;
}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=205,mod=998244353;
int n,ans,ycl[N],x[N],y[N];
int main(){
	n=read(); ycl[0]=1;
	for(int i=1;i<=n;i++)ycl[i]=(ycl[i-1]<<1)%mod;
	for(int i=1;i<=n;i++){
		x[i]=read(); y[i]=read();
	}
	ans=ycl[n]-n-1;
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++){
		int sum=0;
		for(int k=j+1;k<=n;k++)if((x[i]-x[j])*(y[i]-y[k])==(x[i]-x[k])*(y[i]-y[j]))sum++;
		ans=(ans-ycl[sum])%mod;
	}
	cout<<(ans+mod)%mod<<endl;
}

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

int main(){
    int n, q, a, b, c;
    cin >> n >> q;

    vector<stack<int>> s(n);
    for(int i = 0; i < q; i++){
        cin >> a;
        if(a == 0){
            cin >> b >> c;
            s[b].push(c);
        }else if(a == 1){
            cin >> b;
            if(!s[b].empty()){
                cout << s[b].top() << endl;
            }
        }else if(a == 2){
            cin >> b;
            if(!s[b].empty())   s[b].pop();
        }
    }
    
    return 0;
}


Measured memory_bytes: 4364
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;



int main() {

    long long int n;
    cin >> n;

    vector<long long int> h(10000001, 0);

    long long int temp;

    for (int i = 1; i < 10000001; i++) {
        temp = 1;
        while (true)
        {
            h[i * temp]++;
            temp++;
            if (i * temp > 10000000)break;
        }
        //cout << "end";
    }

    long long int ans = 0;
    for (long long int i = 0; i < n; i++) {
        ans += (i + 1) * h[i + 1];
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 81392
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;
 
const ll INF = 1e18;
const int MOD = 1e9+7;

int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	int n;
	cin >> n;
	if(n == 1) cout << '0' << endl;
	else cout << '1' << endl;
	
	return 0;
}


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


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

int main(){

	ll a,b,c,d;
	cin>>a>>b>>c>>d;

	ll ca = (b)/c - (a-1)/c;
	ll cb = (b)/d - (a-1)/d;
	ll lcm = (c*d)/gcd(c,d);
	ll dup = (b)/lcm - (a-1)/lcm;
	//cout<<ca<<" "<<cb<<" "<<"\n";
	cout<<(b-a+1)-(ca+cb-dup);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>

using namespace std;

typedef long long ll;


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

	int w = A * 7 + B;
	int tmp = C / w * 7;
	int ans = tmp;
	ans += C%w / A;
	if (C%w%A) ans++;
	ans = min(ans, tmp + 7);

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 3080
h,w,d=map(int,input().split())
a=[list(map(int, input().split())) for _ in range(h)]
q=int(input())
lr=[list(map(int, input().split())) for _ in range(q)]

nums={}
for i in range(h):
    for j in range(w):
        nums[a[i][j]]=(i,j)

acc=[0]*(h*w)
for i in range(h*w):
    if i>=d:
        _to=nums[i+1]
        _from=nums[i+1-d]
        acc[i]+=acc[i-d]+abs(_from[0]-_to[0])+abs(_from[1]-_to[1])

for l,r in lr:
    print(acc[r-1]-acc[l-1])




Measured memory_bytes: 45504
N, K = map(int, input().split())
ans = 0
for b in range(K+1,N+1):
    ans += (b-K)*(N//b)
    if N//b*b+K <= N:
        ans += N - (N//b*b+K) +1 
if K == 0:
    ans -= N
print(ans)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
const int N = 10, M = 1e7 + 5;
ll d, g, p[N], c[N], dp[N][M];
ll solve(int i, ll rem)
{
    if(i == d)          return (!rem ? 0 : 1e18);
    if(~dp[i][rem])     return dp[i][rem];
    ll ans = solve(i + 1, max(rem - c[i] - p[i] * (i + 1), 0LL)) + p[i];
    for(int j = 0;j < p[i];++j)
        ans = min(ans, solve(i + 1, max(rem - j * (i + 1), 0LL)) + j);
    return dp[i][rem] = ans;
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> d >> g;
    g /= 100;
    for(int i = 0;i < d;++i)
    {
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }
    memset(dp, -1, sizeof dp);
    cout << solve(0, g);
    return 0;
}


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

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }

    class Program
    {
        private char[] S;
        private void Scan()
        {
            var sc = new Scanner();
            S = sc.Next().ToArray();
        }

        public void Solve()
        {
            Scan();
            S[3] = '8';
            Console.WriteLine(new string(S));
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        //文字列を取得
        Scanner scanner = new Scanner(System.in);
        String s1 = scanner.next();
        String s2 = scanner.next();

        //文字列の0番目の文字を取得
        char c1 = s1.charAt(0);
        char c2 = s2.charAt(0);

        if(c1 > c2){
            System.out.println(">");
        }else if(c1 < c2){
            System.out.println("<");
        }else{
            System.out.println("=");
        }
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll H1, M1, H2, M2, K, ans = 0;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    ll m1 = H1 * 60 + M1;
    ll m2;
    if(H1 > H2){
        m2 = H2 * 60 + M2 + 1440;
    }else{
        m2 = H2 * 60 + M2;
    }

    for(ll i = m1; i < m2 - K; i++){
        ans++;
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
	string S;
	cin >> S;
	int n, s, e, w, ns, ew;
	n = s = e = w = ns = ew = 0;
	for (int i = 0; i < S.size(); i++) {
		switch (S[i]) {
		case 'N': n++; ns++; break;
		case 'S': s++; ns++; break;
		case 'E': e++; ew++; break;
		case 'W': w++; ew++; break;
		}
	}
	if (ns == 0) {
		if (e * w == 0) cout << "No\n";
		else cout << "Yes\n";
	}
	else if (ew == 0) {
		if(n * s == 0) cout << "No\n";
		else cout << "Yes\n";
	}
	else {
		if (n * s * e * w == 0) cout << "No\n";
		else cout << "Yes\n";
	}
	return 0;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    for (int i = 1; i < 10; i++)
    {
        for (int j = i; j < 10; j++)
        {
            if (N == i * j)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int A[] = new int[N];
        int count = 0;

        boolean end_flag = true;

        for (int i = 0; i < N; i++){
            A[i] = Integer.parseInt(sc.next());
        }

        while(end_flag) {
            for (int i = 0; i < N; i++) {
                if ((A[i] & 1) == 0) {
                    A[i] = A[i] >> 1;
                }
                else {
                    end_flag = false;
                }
            }
            count++;
        }
        System.out.println(count-1);
    }
}


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

void solve(long long A, long long B){
    if (B % A) cout << B - A << '\n';
    else cout << A + B << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_n

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%lld%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%lld%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 400;
const int A_I_MAX = 1e9;
const ll INF = 1e18;

int N;
int a[N_MAX];

ll acc[N_MAX + 1];
ll dp[N_MAX][N_MAX + 1];

void solve() {
  fill(dp[0], dp[N], INF);
  REP(i, N) {
    dp[i][i + 1] = 0;
    acc[i + 1] = acc[i] + a[i];
  }
  FOR(k, 2, N) FOR(i, 0, N - k) {
    ll cost = acc[i + k] - acc[i];
    FOR(j, i + 1, i + k - 1) {
      dp[i][i + k] = min(dp[i][i + k], dp[i][j] + dp[j][i + k] + cost);
    }
  }
  // DUMP2D(dp, N, N + 1);
  printf("%lld\n", dp[0][N]);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", a + i);
}

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


Measured memory_bytes: 1536