akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)



template<int um> class UF { // from kmjp
public:
	vector<int> par;
	UF() { par = vector<int>(um, 0); rep(i, 0, um) par[i] = i; }
	int operator[](int x) { return par[x] == x ? x : par[x] = operator[](par[x]); }
	void operator()(int x, int y)
	{
		x = operator[](x); y = operator[](y);
		if (x != y) par[x] = y;
	}
};
//-----------------------------------------------------------------
int N, M;
UF<101010> uf;
int idx[101010];
//-----------------------------------------------------------------
int main() {
	cin >> N >> M;

	rep(i, 1, M + 1) idx[i] = -1;

	rep(i, 0, N) {
		int K; scanf("%d", &K);
		rep(j, 0, K) {
			int L; scanf("%d", &L);
			if (idx[L] < 0)
				idx[L] = i;
			else
				uf(i, idx[L]);
		}
	}

	bool ok = true;
	rep(i, 0, N) if (uf[0] != uf[i]) ok = false;

	if (ok)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    public static void Main( )
    {
        var NK = Console.ReadLine( ).Split( ).Select( int.Parse ).ToArray( );
        int N = NK[ 0 ];
        int K = NK[ 1 ];
        var RSP = Console.ReadLine( ).Split( ).Select( int.Parse ).ToArray( );
        int R = RSP[ 0 ];
        int S = RSP[ 1 ];
        int P = RSP[ 2 ];
        string T = Console.ReadLine( );

        var hand_point = new Dictionary<char, int>( )
            {
                {'r', P }, {'s', R },  {'p', S }
            };
        var win = new Dictionary<char, bool[]>( ) {
                {'r',  Enumerable.Repeat( true, T.Length ).ToArray( ) },
                {'s',  Enumerable.Repeat( true, T.Length ).ToArray( ) },
                {'p',  Enumerable.Repeat( true, T.Length ).ToArray( ) },
            };

        long ans = 0;
        for ( int i = 0; i < T.Length; i++ )
        {
            char yourHand = T[ i ];
            if ( i < K )
            {
                ans += hand_point[ yourHand ];
            }
            else
            {
                int point = hand_point[ yourHand ];
                char KagoHand = T[ i - K ];
                if ( yourHand == KagoHand )
                {
                    // K回前と一致したとき、そこで勝っていたら今回は勝てない
                    bool loose = win[ yourHand ][ i - K ];
                    if ( loose ) point = 0;
                    win[ yourHand ][ i ] = !loose;
                }
                ans += point;
            }

        }
        Console.WriteLine( ans );

    }

}

Measured memory_bytes: 29048
#include<bits/stdc++.h>
#define N 2005
#define LL long long
using namespace std;
const int mo=1e9+7;
int n,m,f[N][N],fc[N*N],xf[N*N];
LL fpm(LL x,LL y){ LL s=1; while(y){ if(y&1) s=(s*x)%mo; y>>=1,x=(x*x)%mo;} return s;}
LL C(int n,int m){ return 1LL*fc[n]*xf[m]%mo*xf[n-m]%mo;}
int main()
{
	int i,j;
	cin>>n>>m;
	if(m==1){ printf("1"); return 0;}
	f[0][0]=1;
	fc[0]=xf[0]=1;
	for(i=1;i<N*N;i++)
		fc[i]=(1LL*fc[i-1]*i)%mo;
	xf[N*N-1]=fpm(fc[N*N-1],mo-2);
	for(i=N*N-2;i>=0;i--)
		xf[i]=(1LL*xf[i+1]*(i+1))%mo;
	for(i=0;i<=n;i++)
		for(j=i;j<=n;j++){
			if(i<j) (f[i+1][j]+=f[i][j])%=mo;
			f[i][j+1]=(f[i][j+1]+f[i][j]*C(i-1+(m-1)*(j+1),m-2))%mo;
		  }
	printf("%lld\n",1LL*f[n][n]*fc[n]%mo);
	return 0;
}


Measured memory_bytes: 47360
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-9
#define M_PI 3.141592653589793
#define bsize 1024

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 200031;

string st;
long long k;

bool all_same(string st){
	for (int i=1;i<st.size();i++)
		if(st[i]!=st[i-1])
			return false;
	return true;
}

long long ans;

long long solver(long long x){
	if (x%2==0)
		return x/2;
	return (x-1)/2;
}

long long special_case(){
	return solver(st.size()*1ll*k);
}

vector<pair<int,int> > decouple(string st){
	vector<pair<int,int > > ret;
	int cnt=0;
	for (int i=0;i<st.size();i++){
		if (i>0&&st[i]!=st[i-1]){
			ret.push_back(make_pair(st[i-1],cnt));
			cnt=0;
		}
		++cnt;
	}
	ret.push_back(make_pair(st[st.size()-1],cnt));
	return ret;
}

int main(){
//    freopen("apache.in","r",stdin);
//    freopen("apache.out","w",stdout);
 //   freopen("input.txt", "r", stdin);
 //   freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
 //   cin.tie(0);

    cin>>st>>k;

    if (all_same(st)){
    	cout<<special_case()<<endl;
    	return 0;
    }

    vector<pair<int,int> > V=decouple(st);

    for (int i=1;i+1<V.size();i++){
    	ans+=solver(V[i].second)*k;
    }

    ans+=solver(V[0].second);
    ans+=solver(V.back().second);

    if (V[0].first==V.back().first)
    	ans+=solver(V[0].second+V.back().second)*(k-1);
    else
    {
    	ans+=solver(V[0].second)*(k-1);
    	ans+=solver(V.back().second)*(k-1);
    }

    cout<<ans<<endl;

//    cin.get(); cin.get();
    return 0;
}


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

int main(void){
    long long int N,D,ans=0;
    cin>>N>>D;
    for(int i=0;i<N;i++){
        long long int X,Y;
        cin>>X>>Y;
        if(X*X+Y*Y<=D*D) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
using System;
class p
{
  static void Main()
  {
    string s = Console.ReadLine();
    string output = string.Empty;
    for (int i = 0; i < s.Length; i++) {
      output += (s[i] == '1' ? '9' : '1');
    }
    Console.WriteLine(output);
  }
}

Measured memory_bytes: 11092
import collections

n = int(input())
s = input()
max_number = 0

for i in range(n-1):
  front = collections.Counter(s[:i+1])
  back = collections.Counter(s[i+1:])
  number = len(front.keys() & back.keys())
  if number > max_number:
    max_number = number

print(max_number)


Measured memory_bytes: 3444
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 50+10
//typedef std::pair<int,int> P;


    bool F=true;
    ll N,X[100010],Y[100010],T[100010];
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N)cin>>T[i]>>X[i]>>Y[i];
    ll t=0,x=0,y=0;
    REP(i,N){
        ll temp=((T[i]-t)-abs(X[i]-x)-abs(Y[i]-y));
        DEB(T[i])DEB(X[i])DEB(x)DEB(Y[i])DEB(y)DEB(temp)END

        if(temp%2!=0||temp<0){
            F=false;
            break;
        }
        t=T[i],x=X[i],y=Y[i];

    }
    cout<<(F?"Yes":"No")<<endl;
    return 0;
}




Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	string s; cin >> s;
	cout << (s[1] == s[2] && (s[0] == s[1] || s[2] == s[3]) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
//221 
int main(void){
  int n;
  long long int ans;
  int h[100];
  int dif[100];
  
  int i;

  scanf("%d",&n);
  for (i=0; i<n; i++){
    scanf("%d", &h[i]);
  }
  
  ans=h[0];
  for(i=1;i<n;i++){
    dif[i]=h[i]-h[i-1];
    if(dif[i]>0){
      ans=dif[i]+ans;
    }
  }
  
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner


object Main {

  def read(): (Int, String) = {
    val sc: Scanner = new Scanner(System.in)
    val a = sc.nextInt
    val s = sc.next
    sc.close()
    (a, s)
  }


  def solve(a: Int, s: String): String = {
    if(a < 3200) "red" else s
  }


  def main(args: Array[String]): Unit = {
    val (a, s) = read()
    println(solve(a, s))
  }

}


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

typedef long long ll;
typedef unsigned long long ull;

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

  for (ll i = 0; i < s.size(); ++i) {
    if (s[i] == '1') cout << '9';
    else if (s[i] == '9') cout << '1';
    else cout << s[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#include <memory>
#include <map>

using namespace std;

#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))
#define FILL(m,v)           memset(m, v, sizeof(m))

int b[1001], x[1001], y[1001];
double wf[1001][1001];
int rt[1001][1001];

const double inf = 1e12;
map<int,int> id, rid;

void trace(int s, int g){
    int r = rt[s][g];
    if(g == r){
        cout << " " << b[g];
        return;
    }
    trace(s,r);
    trace(r,g);
}

int main(){
    int n, m;
    while(cin >> n && n){
        FILL(x, 0);
        FILL(y, 0);
        FILL(rt, 0);
        REP(i,1001) REP(j,1001) wf[i][j] = inf;
        REP(i,n){
            cin >> b[i] >> x[i] >> y[i];
            id[b[i]] = i;
        }
        REP(i,n) REP(j,n){
            if(i == j){
                wf[i][j] = 0;
                continue;
            }
            int dist = (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
            if(dist <= 50*50){
                wf[i][j] = sqrt((double)dist);
                rt[i][j] = j;
            }
        }
        REP(k,n) REP(i,n) REP(j,n) {
            if(wf[i][j] > wf[i][k] + wf[k][j]){
                wf[i][j] = wf[i][k] + wf[k][j];
                rt[i][j] = k;
            }
        }

        cin >> m;
        int s,g;
        REP(i,m){
            cin >> s >> g;
            s = id[s], g = id[g];
            if(wf[s][g] == inf){
                cout << "NA" << endl;
                continue;
            }
            cout << b[s]; trace(s,g); cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 12960
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
	int n, i, j;
	int c[9];

	for (i = 0; i < 9; i++) {
		c[i] = 0;
	}

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> j;
		if (3600 <= j)
			c[8]++;
		else 
			c[j / 400]++;
	}

	j = 0;
	for (i = 0; i < 8; i++) {
		if (c[i] != 0)
			j++;
	}
	if (j == 0) {
		if (c[8] != 0) {
			cout << 1 << " ";
		}
	}
	else {
		cout << j << " ";
	}
	j += c[8];
	cout << j;

	return 0;
}

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

int main(){
  int n;
  cin >> n;
  if (n%2 == 0){
    cout << pow(n/2,2.0) << endl;
  }
  else {
    int k;
    k = (n-1)/2;
    cout << (n-k)*k << endl;
  }
}

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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

const int N = 2e5 + 2137;
int ile[N];
int tab[N];

int Find(int a) {
	if(tab[a] == a)
		return tab[a];
	tab[a] = Find(tab[a]);
	return tab[a];
}

void Union(int a, int b) {
	int fa = Find(a);
	int fb = Find(b);
	if(fa == fb)
		return;
	if(ile[fa] <= ile[fb]) {
		tab[fa] = fb;
		ile[fb] += ile[fa];
	}
	else {
		tab[fb] = fa;
		ile[fa] += ile[fb];
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin>>n>>m;
	for(int i=1; i<=n; i++) {
		tab[i] = i;
		ile[i] = 1;
	}
	int a, b;
	for(int i=0; i<m; i++) {
		cin>>a>>b;
		Union(a, b);
	}
	int ans = 0;
	for(int i=1; i<=n; i++) {
		ans = max(ans, ile[Find(i)]);
	}
	cout<<ans;
}


Measured memory_bytes: 5204
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        scanner.nextLine();
        String[] paramsA = scanner.nextLine().split(" ");
        scanner.close();

        double denominator = 0;
        
        for (String a: paramsA) {
            denominator += (double)1 / (double)(Integer.parseInt(a));
        }

        System.out.println(String.valueOf(((double)1 / denominator)));
    }
}

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

using namespace std;

int main() {

	string s,t;

	cin >> s >> t;

	vector<vector<long>> dp(s.size() + 2, vector<long>(t.size()+2));

	for (long i = 0; i < s.size(); i++) {
		for (long j = 0; j < t.size(); j++) {

			if (s[i]==t[j]) {
				dp[i+1][j+1] = max(dp[i ][j]+1, max(dp[i][j + 1], dp[i + 1][j]));
			}
			else {
				dp[i+1][j+1] = max(dp[i ][j+1],dp[i+1][j]);
			}
		}
	}
	/*
	for (long i = 0; i <= s.size() + 1; i++) {
		for (long j = 0; j <= t.size() + 1; j++) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	*/
	deque<char> ans;
	long i;
	i= s.size() - 1;
	long j;
	j = t.size() - 1;

	while (i >= 0 && j >= 0) {
		if (s[i] == t[j]) {
			ans.push_front(s[i]);
			i--;
			j--;
		}
		else if (dp[i + 1][j + 1] == dp[i][j + 1]) {
			i--;
		}
		else {
			j--;
		}

	}
	while(ans.size()>0){
		cout << ans.front() ;
		ans.pop_front();
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 70784
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;



int main() {
	int N, M, S, T; cin >> N >> M;
	vector<vector<int>> x(N);
	for (int i = 0; i < M; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		x[a].push_back(b);
	}
	cin >> S >> T; S--; T--;
	queue<pair<int,int>> y;
	y.push({S,0});
	vector<bool> c0(N,0),c1(N,0),c2(N,0);
	while (y.size() > 0) {
		pair<int,int> d = y.front();
		int a = d.first, b = d.second;
		y.pop();
		if (b % 3 == 0) {
			if (a == T) {
				cout << b / 3 << endl; return 0;
			}
			if (c0[a] == 1)continue;
			c0[a] = 1;
		}
		else if (b % 3 == 1) {
			if (c1[a] == 1)continue;
			c1[a] = 1;
		}
		else {
			if (c2[a] == 1)continue;
			c2[a] = 1;
		}
		for (int i = 0; i < x[a].size(); i++) {
			y.push({ x[a][i],b + 1 });
		}
	}
	cout << -1 << endl;
}





Measured memory_bytes: 5760
n = gets.to_i
ps = gets.chomp.split.join
qs = gets.chomp.split.join
array = []
[*1..n].permutation do |t|
  array << t.map(&:to_s).join
end
ans = 0
array.each_with_index do |t,i|
  if t == ps
    ans += (i + 1)
  end
  if t == qs
    ans -= (i + 1)
  end
end
puts ans.abs

Measured memory_bytes: 12284
#include <iostream>
 
using namespace std;
 
int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    if(a%2||b%2||c%2){
        cout << 0 << endl;
    }else if(a==b&&b==c){
        cout << -1 << endl;
    }else{
        long res = 0;
        while(!(a%2)&&!(b%2)&&!(c%2)){
            long aa = (b+c)/2;
            long bb = (a+c)/2;
            long cc = (a+b)/2;
            a = aa;
            b = bb;
            c = cc;
            res++;
        }
        cout << res << endl;
    }
}

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

using namespace std;

int main() {
	string s;
	cin >> s;
	for (int i = s.size(); i >= 0; i--) {
		s.pop_back();
		s.pop_back();
		if (s.substr(0, s.size() / 2) == s.substr(s.size() / 2 , s.size() / 2)) {
			cout << s.size() << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>
#include<algorithm>

using namespace std;

int main() {
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        set<string> set;
        string s;
        cin >> s;
        set.insert(s);
        for (int i = 1; i < s.size(); ++i) {
            string front = s.substr(0, i);
            string back = s.substr(i);
            string frontrev = front;
            reverse(frontrev.begin(), frontrev.end());
            string backrev = back;
            reverse(backrev.begin(), backrev.end());

            //cout << front << " " << back << " " << frontrev << " " << backrev << endl;
            set.insert(front + backrev);
            set.insert(frontrev + back);
            set.insert(frontrev + backrev);
            set.insert(backrev + front);
            set.insert(back + frontrev);
            set.insert(backrev + frontrev);
            set.insert(back + front);
        }

        cout << set.size() << endl;
    }
}

Measured memory_bytes: 3244
n = int(input())
a = list(map(int, input().split()))
box = [0] * n
ans = []

for i in range(n-1, -1, -1):
    ms = sum(box[i::i+1])
    if ms % 2 != a[i]:
        box[i] = 1
        ans.append(i+1)

print(len(ans))
print(*ans)


Measured memory_bytes: 14004
using System;
class ProgramD
    {
        static void Main(string[] args)
        {
            //まずは数字を読む

            string[] input = Console.ReadLine().Split(' ');
            int h = int.Parse(input[0]);
            int w = int.Parse(input[1]);

            char[,] chart = new char[w,h];

            //とりあえず全部読みこむ
            for (int i = 0; i < h; i++)
            {
                string input2 = Console.ReadLine();
                for (int j = 0; j < w; j++)
                    chart[j, i] = input2[j];
            }
                
                

            //上下左右をあらかじめ数えておく
            int[,] Up = new int[w, h];
            int[,] Down = new int[w, h];
            int[,] Left = new int[w, h];
            int[,] Right = new int[w, h];

            //左の計算
            for (int i = 0; i < h; i++)
                for (int j = 0; j < w; j++)
                {
                    //左の計算
                    if ('#' == chart[j, i])
                        Left[j, i] = 0;
                    else if (j == 0)
                        Left[0, i] = 1;
                    else
                        Left[j, i] = Left[j - 1, i] + 1;
                }

            for (int i = 0; i < h; i++)
                for (int j = 0; j < w; j++)
                {
                    //右の計算
                    if ('#' == chart[w- 1 - j, i])
                        Right[w - 1 - j, i] = 0;
                    else if (j == 0)
                        Right[w - 1, i] = 1;
                    else
                        Right[w - 1 - j, i] = Right[w - j, i] + 1;
                }

            for (int j = 0; j < w; j++)
                for (int i = 0; i < h; i++)
                {
                    //上の計算
                    if ('#' == chart[j, i])
                        Up[j, i] = 0;
                    else if (i == 0)
                        Up[j, 0] = 1;
                    else
                        Up[j, i] = Up[j, i - 1] + 1;
                }

            for (int j = 0; j < w; j++)
                for (int i = 0; i < h; i++)
                {
                    //上の計算
                    if ('#' == chart[j, h - i - 1])
                        Down[j, h - 1 - i] = 0;
                    else if (i == 0)
                        Down[j, h - 1] = 1;
                    else
                        Down[j, h - i - 1] = Down[j, h - i] + 1;
                }
            //照明の計算
            int lamp = 0;
            int lamp_max = 0;
            for (int j = 0; j < w; j++)
                for (int i = 0; i < h; i++)
                {
                    lamp = Up[j, i] + Down[j, i] + Left[j, i] + Right[j, i] - 3;
                    if(lamp < 0)
                      lamp = 0;
                    if (lamp_max < lamp)
                        lamp_max = lamp;
                }

            Console.WriteLine(lamp_max);


        }
    }

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



int main(){
  int N;
  cin>>N;
  vector<int64_t> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int64_t sum=vec.at(0);
  for(int i=0;i<N-2;i++){
    sum+=vec.at((i+2)/2);
  }
  cout<<sum<<endl;
  
}

Measured memory_bytes: 4772
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] DR = { -1, -1, 0, 0, 1, 1 };
	static int[] DC = { -1, 0, -1, 1, 0, 1 };
	static int N, C;
	static int[][] S;

	public static void main(String[] args) {
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			C = sc.nextInt();
			S = new int[N][N];
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j <= i; ++j) {
					S[i][j] = sc.nextInt();
				}
			}
			System.out.println(solve());
		}
	}

	static int solve() {
		int ans = -9999;
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j <= i; ++j) {
				if (S[i][j] > 0) continue;
				S[i][j] = C;
				ans = Math.max(ans, count());
				S[i][j] = 0;
			}
		}
		return ans;
	}

	static int count() {
		int ret = 0;
		boolean[][] used = new boolean[N][N];
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j <= i; ++j) {
				if (S[i][j] == 0 || used[i][j]) continue;
				int c = 1;
				boolean live = false;
				ArrayDeque<Integer> q = new ArrayDeque<Integer>();
				q.add((i << 16) + j);
				used[i][j] = true;
				while (!q.isEmpty()) {
					int cur = q.poll();
					int cr = cur >> 16;
					int cc = cur & 0xFFFF;
					for (int k = 0; k < 6; ++k) {
						int nr = cr + DR[k];
						int nc = cc + DC[k];
						if (nr < 0 || N <= nr || nc < 0 || nr < nc) continue;
						if (used[nr][nc]) continue;
						if (S[nr][nc] == 0) {
							live = true;
							continue;
						}
						if (S[nr][nc] != S[i][j]) continue;
						used[nr][nc] = true;
						++c;
						q.add((nr << 16) + nc);
					}
				}
				if (!live) {
					ret += c * (S[i][j] == C ? -1 : 1);
				}
			}
		}
		return ret;
	}
}

Measured memory_bytes: 18720
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    ll n;
    cin >> n;
    double x[n];
    string u[n];
    rep(i,n) cin >> x[i] >> u[i];

    double ans=0;
    rep(i,n){
        if(u[i] == "JPY") ans += x[i];
        else ans += x[i]*380000.0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
    Author:zzugzx
    Lang:C++
    Blog:blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod=1e9+7;
//const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};

int a[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+1+n);
    ll ans=0;
    for(int i=1;i<=k;i++)ans+=a[i];
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3652
x, n = gets.split(" ").map(&:to_i)
if n == 0
  puts x
  exit
end
pa = gets.split(" ").map(&:to_i).sort
t = (-1..101).to_a - pa
m = 0
for i in 0..t.length
  if t[i] > x
    m = i
    puts (x - t[m-1]).abs <= (t[m] - x).abs ? t[m-1] : t[m]
    exit
  end
end



Measured memory_bytes: 14368
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b;
    string str;
    vector<string> v;
    while(a--)
    {
      cin>>str;
      v.push_back(str);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)
        cout << v[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,f[300006],a,b,ans=1,max1[300006],s;
int find(int x)
{
	return x==f[x]?x:(f[x]=find(f[x]));
}
void merge(int i,int j)
{
	s=find(i);
	f[find(i)]=find(j);
	max1[f[j]]+=max1[s];
	if(ans<max1[f[j]])
	ans=max1[f[j]];
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
	{
		f[i]=i;max1[i]+=1;
	}
	for(int i=1;i<=m;++i)
	{
		scanf("%d%d",&a,&b);
		if(find(a)!=find(b))
		merge(a,b);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 5332
#include <bits/stdc++.h>
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;
typedef long long ll;
const int N=100009;
int main()
{
  string s;
  cin>>s;
  if(s[2]==s[3] && s[4]==s[5])
  	cout<<"Yes"<<endl;

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
const int maxn = 1e5 + 10;
inline int Max(int a, int b) { return a > b ? a : b; }
inline int Min(int a, int b) { return a > b ? b : a; }
namespace FastIO {
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
};
using namespace FastIO;
int N, M, num[maxn];
bool flag[maxn];
signed main()
{
    //freopen("C:\Users\hjw\Downloads\testdata (4).in", "r", stdin);
    N = read(), M = read();
    for (ri i = 1; i <= N; ++i) {
        num[i] = 1;
    }
    flag[1] = 1;
    for (ri i = 1; i <= M; ++i) {
        int u = read(), v = read();
        if (flag[u])
            flag[v] = 1;
        num[v]++, num[u]--;
        if (num[u] == 0)
            flag[u] = 0;
    }
    int ans = 0;
    for (ri i = 1; i <= N; ++i) {
        if (flag[i])
            ans++;
    }
    writeln(ans);
    return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main()
{
	int n,a,b,x=0,i,y,p;
	x=0;
	scanf("%d %d %d",&n,&a,&b);
	for(i=1;i<=n;i++)
	{	
		p=i;
		y=0;
		while(1)
		{		
			if(p>=10)
			{
				y=y+p%10;
				p=p/10;				
			}
			else 
			{
				y=y+p;
				break;
			};			
		};
		if(y>=a&&y<=b)
		{
			x=x+i;
		};
	};
	printf("%d",x);
	return 0;	
}

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

const int N=20;

pair<int,int>a[N];
int b[N],c[N],d[N],vis[N],f[N];

int main() {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i].first);
	for(int i=0;i<n;i++) scanf("%d",&a[i].second);
	int Ans=1e9;
	for(int i=0;i<(1<<n);i++) {
		for(int j=0;j<n;j++) 
			if(i&(1<<j)) b[j]=a[j].second,f[j]=1;
			else b[j]=a[j].first,f[j]=0;
		for(int j=0;j<n;j++) c[j]=b[j];
		sort(c,c+n);
		memset(vis,0,sizeof vis);
		int flag=0;
		for(int j=0;j<n;j++) {
			int k;
			for(k=0;k<n;k++) 
				if(!vis[k]&&c[k]==b[j]&&((k-j)&1)==f[j]) {
					vis[k]=1;
					d[k]=j;
					break;
				}
			if(k==n) {
				flag=1;
				break;
			}
		}
		if(flag) continue;
		int now=0;
		for(int j=0;j<n;j++)
			for(int k=0;k<j;k++)
				if(d[k]>d[j]) now++;
		Ans=min(Ans,now);
	}
	if(Ans==1e9) puts("-1");
	else cout<<Ans<<endl;
}

Measured memory_bytes: 384
from bisect import bisect_left, bisect_right
 
n,ans=int(input()),0
 
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
 
A.sort()
C.sort()
 
for b in B:
  j = bisect_left(A,b)
  k = bisect_right(C,b)
  ans += j*(n-k)
  
print(ans)

Measured memory_bytes: 22720
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var N int
var W int
var wv [][]int
var dp [][]int

func main() {
	N = nextInt()
	W = nextInt()
	wv = make([][]int, N+1)
	wv[0] = make([]int, 2)
	for i := 1; i < N+1; i++ {
		wv[i] = nextInts(2)
	}

	dp = make([][]int, N+1)
	for i := 0; i < N+1; i++ {
		dp[i] = make([]int, W+1)
	}

	for i := 1; i < N+1; i++ {
		for w := 0; w < W+1; w++ {
			if w >= wv[i][0] {
				dp[i][w] = MaxIn2Values((dp[i-1][w-wv[i][0]] + wv[i][1]), dp[i-1][w])
			} else {
				dp[i][w] = dp[i-1][w]
			}
		}
	}
	fmt.Println(dp[N][W])
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func MaxIn2Values(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 81792
from sys import setrecursionlimit
setrecursionlimit(1<<30)
mod=pow(10,9)+7
def f(x,p):
  z[x][0]=z[x][1]=1
  for y in v[x]:
    if y!=p:
      if z[y][0]==-1:
        f(y,x)
      z[x][0]=(z[x][0]*z[y][1])%mod
      z[x][1]=(z[x][1]*(z[y][0]+z[y][1]))%mod
n=int(input())
v=[[] for _ in range(n)]
for x,y in [map(int,raw_input().split()) for _ in range(n-1)]:
  v[x-1].append(y-1)
  v[y-1].append(x-1)
z=[[-1,-1] for _ in range(n)]
f(0,-1)
print sum(z[0])%mod

Measured memory_bytes: 114532
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

S = set(input())

if ('N' in S) != ('S' in S):
    print('No')
elif ('W' in S) != ('E' in S):
    print('No')
else:
    print('Yes')






Measured memory_bytes: 5300
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int h, w, a, b; cin>>h>>w>>a>>b;
    cout << h*w - ((h/a)*(w/b))*a*b << endl;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
 
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000000000
#define MAXN        300005
#define mod         998244353  
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,n,x,ans;
    cin>>a>>b>>n;
    x=min(n,b-1);
    ans=((a*1ll*x)/b) + (x/b);
    cout<<ans;
}

Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl
#define DEBUG 0

const ll inf = (ll)1e8;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int main() {
	int n, m, k;	cin >> n >> m >> k;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			int bk = i*m + j*n - 2*i*j;
			if (bk == k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
n=input()
op= ['+', '-']
for op1 in op:
    for op2 in op:
        for op3 in op:
            a = n[0]+op1+n[1]+op2+n[2]+op3+n[3]
            if eval(a) == 7:
                print(a+'=7')
                sys.exit()


Measured memory_bytes: 2940
#include<stdio.h>

int main(void)
{
 int s,i,n,num;
 
 scanf("%d",&n);
 num=n;
 s=0;
 while(num!=0){
    s+=num%10;
    num/=10;
 }
 if((n%s)==0) printf("Yes\n");
 else if((n%s)!=0) printf("No\n");

 return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define N 200009
int n, d, a, bit[N], x[N], h[N];
pair<int, int> p[N];

inline void update(int32_t x, int val) {
    for(; x < N; x += x & -x)
        bit[x] += val;
}
inline int query(int32_t x) {
    int sum = 0;
    for(; x; x -= x & -x)
        sum += bit[x];
    return sum;
}
inline void range_update(int32_t l, int32_t r, int val) {
    update(l, val), update(r + 1, -val);
}


inline int f(int n, int d, int a, int* x, int* h) {
    int ans = 0;
    int r = 1;
    for(int l = 1; l <= n; l++) {
        while(r <= n and x[l] + d - 1 >= x[r])
            r++;
        int bombs_already = query(l);
        int damage = bombs_already * a;
        if(damage >= h[l])
            continue;
        int bombs_required = (h[l] - damage + a - 1) / a;
        ans += bombs_required;
        range_update(l, r - 1, bombs_required);
    }
    return ans;
}

int32_t main() {
    cin >> n >> d >> a;
    d += d + 1;
    for(int i = 1; i <= n; i++)
        cin >> p[i].first >> p[i].second;
    sort(p + 1, p + 1 + n);
    for(int i = 1; i <= n; i++) {
        x[i] = p[i].first;
        h[i] = p[i].second;
    }
    cout << f(n, d, a, x, h) << '\n';
}


Measured memory_bytes: 8064
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
typedef pair<int, int> P;
#define int long long
int ans[100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    P a[100010];
    rep(i, n) {
        cin >> a[i].first;
        a[i].second = i;
    }
    a[n] = {0, 0};
    sort(a, a + n, greater<P>());
    int cnt = 0;
    priority_queue<int, vector<int>, greater<int>> que;
    rep(i, n) {
        int prev = cnt;
        REP(j, cnt, n - 1) {
            if(a[prev].first == a[j].first) {
                cnt++;
                que.push(a[j].second);
            }
            else break;
        }
        ans[que.top()] += cnt * (a[prev].first - a[cnt].first);
        // cout << que.top() << " " << cnt << " " << a[prev].first << " " << a[cnt].first << "->";
        // rep(i, n) cout << ans[i] << " ";
        // cout << endl;
        a[prev].first = a[cnt].first;
    }
    rep(i, n) {
        cout << ans[i] << endl;
    }


    return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> xs(n);
  for(Int i=0;i<n;i++) cin>>xs[i];
  Int l;
  cin>>l;

  const Int LOG = 18;
  array<vector<Int>, LOG+1> nxt;
  for(Int i=0;i<=LOG;i++)
    nxt[i].resize(n);

  for(Int j=0;j<n;j++)
    nxt[0][j]=--upper_bound(xs.begin(),xs.end(),xs[j]+l)-xs.begin();

  for(Int i=0;i<LOG;i++)
    for(Int j=0;j<n;j++)
      nxt[i+1][j]=nxt[i][nxt[i][j]];

  Int q;
  cin>>q;
  for(Int i=0;i<q;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    if(a>b) swap(a,b);

    Int ans=0;
    for(Int k=LOG;k>=0;k--)
      if(nxt[k][a]<b) ans+=1<<k,a=nxt[k][a];

    assert(nxt[0][a]>=b);
    if(a<b) ans++;

    cout<<ans<<"\n";
  }
  cout<<flush;
  return 0;
}


Measured memory_bytes: 16512
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;

  cout << (n + 1) % 2 << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, M, Ans = 0;
  cin >> N >> M;
  vi A(M);
  REP(i, M) {
    cin >> A.at(i);
    Ans += A.at(i);
  }
  if (Ans > N) Ans = N + 1;
  cout << N - Ans << endl;
}

Measured memory_bytes: 3704
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<Edge>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int H,W,ans=MAX;
  cin>>H>>W;
  int A[H][W],B[H][W],AB[H][W];
  bool DP[H][W][30000];
  REP(i,H){
    REP(j,W) cin>>A[i][j];
  }
  REP(i,H){
    REP(j,W) cin>>B[i][j];
  }
  REP(i,H){
    REP(j,W){
      AB[i][j]=abs(A[i][j]-B[i][j]);
      REP(k,30000) DP[i][j][k]=false;
    }
  }
  DP[0][0][15000+AB[0][0]]=true;
  DP[0][0][15000-AB[0][0]]=true;
  
  for(int i=0; i<=H-1; ++i){
    for(int j=0; j<=W-1; ++j){
      for(int k=1000; k<29000; ++k){
        if(i<=H-2){
          if(DP[i][j][k]) DP[i+1][j][k+AB[i+1][j]]=true;
          if(DP[i][j][k]) DP[i+1][j][k-AB[i+1][j]]=true;
        }
        if(j<=W-2){
          if(DP[i][j][k]) DP[i][j+1][k+AB[i][j+1]]=true;
          if(DP[i][j][k]) DP[i][j+1][k-AB[i][j+1]]=true;
        }
      }
    }
  }
  
  REP(i,30000){
    if(DP[H-1][W-1][i]) chmin(ans,abs(15000-i));
  }
  co(ans);
  return 0;
}

Measured memory_bytes: 191188
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function gcd(a,b){return b?gcd(b,a%b):a;}

console.log(main());
function main(){
  var n = o.a();
  var a = o.l();
  var x = 0;
  var z = 0;
  var ans = 0;
  var mn = 9e9;
  for(var i = 0; i < n; i++){
    if(a[i] < 0)x++;
    else if(a[i] === 0)z++;
    var t = Math.abs(a[i]);
    ans += t;
    if(t < mn)mn = t;
  }
  if(z || x % 2 === 0)return ans;
  return ans - mn*2;
}

Measured memory_bytes: 28116
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>

using namespace std;

int MAX = 1e6+2;
int main(){
	long double a, b, h, m;
	long double c, theta;
	cin >> a >> b >>h >> m;
	// h+=1;
	// m+=1;
	theta = abs(6*m-30*h-m/2)*M_PI/180;
	// cout << 6*m - 30*h-m*5/60 <<" " << theta<<endl;
	c = a*a+b*b-2*a*b*cos(theta);
	cout << setprecision(20);
	cout << sqrt(c);
}

Measured memory_bytes: 4164
#include <stdio.h>

int main()
{   
    int i,n,j,k,y;
    scanf("%d%d",&n,&y);
        for(i=0;i<=n;i++){
            for(j=0;j<=n-i;j++){
                for(k=0;k<=n-i-j;k++){
                    if(i*10000+j*5000+k*1000==y&&i+j+k==n){
                        printf("%d %d %d",i,j,k);
                        return 0;
                    }
                }
            }    
        }
    printf("-1 -1 -1");
    return 0;
}


Measured memory_bytes: 128
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.Array

main :: IO ()
main = do
  [n, x] <- map read . words <$> getLine
  a <- listArray (0, n-1) . map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
  let
    b = array (0, n-1) $ do
      k <- [0..n-1]
      return $ (,) k $ array (0, n-1) $ do
        i <- [0..n-1]
        return $ (,) i $ if k == 0
          then a ! i
          else min ((b ! (k-1)) ! i) (a ! ((i-k)`mod`n))
    ans = flip map [0..n-1] $ \k -> sum (b ! k) + k * x
  print $ minimum ans


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

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<LL, LL> PII;
typedef vector<int> VI;
typedef long double db;

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

template<typename T> void print(const T& a, ostream& out){	
	for(auto i: a) out << i << ' ';
	out << endl;
}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

inline LL get(PII a, PII b){
	return abs(a.X - b.X) + abs(a.Y - b.Y);
}

const int N = 1 << 18;
int n;
PII a[N];

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

	cin >> n;
	FOR(i, 0, n) cin >> a[i].X >> a[i].Y;

	vector<PII> A;
	for(auto i: {LINF, -LINF}) for(auto j: {LINF, -LINF})
		A.PB({i, j});
		
	vector<PII> B;

	for(auto i: A){
		int mx = 0;
		LL W = get(i, a[0]);
		FOR(j, 1, n){
			LL tut = get(i, a[j]);
			if (tut > W){
				W = tut;
				mx = j;
			}
		}

		B.PB(a[mx]);
	}

	LL ans = 0;
	FOR(i, 0, SZ(B)) FOR(j, 0, i){
		setmax(ans, get(B[i], B[j]));
	}

	cout << ans << endl; 
		
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;	
	return 0;
}


Measured memory_bytes: 6976
line = input().split(" ")
leftNum = int(line[0])
rightNum = int(line[1])

output = ""

if leftNum < rightNum:
  output = leftNum

leftNum = leftNum % rightNum  
  
while(1):
  output = abs(leftNum - rightNum)
  if output <= (rightNum / 2):
    break;
  leftNum = output

print(output)
    

Measured memory_bytes: 38256