akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		String[] aline = br.readLine().split(" ");

		ArrayList<Integer> alist = new ArrayList<Integer>(n);
		ArrayList<Integer> difflist = new ArrayList<Integer>(n);

		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(aline[i]);
			alist.add(a);
			difflist.add(a - (i + 1));
		}

		Collections.sort(difflist);

		if (n % 2 == 1) {
			int d = difflist.get(n / 2);
			long minsad = 0;
			for (int i = 0; i < n; i++) {
				minsad += Math.abs(alist.get(i) - (d + i + 1));
			}
			System.out.println(minsad);
		} else {
			int d1 = difflist.get(n / 2);
			int d2 = difflist.get(n / 2 - 1);
			long minsad1 = 0;
			long minsad2 = 0;
			for (int i = 0; i < n; i++) {
				minsad1 += Math.abs(alist.get(i) - (d1 + i + 1));
				minsad2 += Math.abs(alist.get(i) - (d2 + i + 1));
			}
			System.out.println(Math.min(minsad1, minsad2));
		}

	}

}

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

int n;
vector<int> x;
vector<pair<int,int>> y;
vector<int> b;

int main() {
    cin >> n;
    x.resize(n);
    y.resize(n);
    b.resize(n);
    rep(i, n) {
        cin >> x[i];
        y[i] = make_pair(x[i], i);
    }
    sort(y.begin(), y.end());
    rep(i, n) {
        if (i < n/2) {
            b[y[i].second] = y[n/2].first ;
        } else {
            b[y[i].second] = y[n/2-1].first;
        }
    }
    rep(i, n) {
        cout << b[i] << endl;
    }
}

Measured memory_bytes: 6364
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Xml.Schema;

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 ulong NextUlong()
        {
            return ulong.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    struct S
    {
        public int X, Y, H;
    }

    class Program
    {
        private int N, M;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            M = sc.NextInt();
        }

        public void Solve()
        {
            Scan();
            int loop = M / N;
            for (int i = loop; i >= 1; i--)
            {
                if (M % i == 0)
                {
                    if (M / i >= N)
                    {
                        Console.WriteLine(i);
                        return;
                    }
                }

            }
        }

        static void Main() => new Program().Solve();
    }
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

int main(){
    double L;
    cin >> L;
    double V = (L / 3) * (L / 3) * (L / 3) ;
    printf("%lf" , V) ;
    return 0;
}



Measured memory_bytes: 256
from collections import deque
s = input()
li = ['dream', 'dreamer', 'erase', 'eraser']

ans = 'NO'
Q = deque()
Q.append(0)
while True:
    try:
        k = Q.popleft()
    except:
        break
    if k == len(s):
        ans = 'YES'
        break
    for a in li:
        if a == s[k: k + len(a)]:
            Q.append(k + len(a))

print(ans)


Measured memory_bytes: 3444
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N+2];
        int sum = 0;
        for(int i = 1; i<N+1; i++) {
            a[i] = sc.nextInt();
            sum += (int)(Math.abs(a[i]-a[i-1]));
        }
        sum += (int)(Math.abs(a[N+1]-a[N]));

        for(int i = 1; i<N+1; i++) {
            int plus = (int)(Math.abs(a[i+1] - a[i-1]));
            int minus = (int)(Math.abs(a[i+1]-a[i])) + (int)(Math.abs(a[i]-a[i-1]));
            System.out.println(sum-minus+plus);
        }

    }
}

Measured memory_bytes: 67528
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int r;
	cin>>r;
	if(r<1200)cout<<"ABC"<<endl;
	else if(r>=1200&&r<2800)cout<<"ARC"<<endl;
	else cout<<"AGC"<<endl;
		
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7

typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template< typename T >
struct edge {
	int src, to;
	T cost;

	edge(int to, T cost) : src(-1), to(to), cost(cost) {}

	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

	edge &operator=(const int &x) {
		to = x;
		return *this;
	}

	operator int() const { return to; }
};
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

int main()
{
	/*
	int a, b;
	cin >> a >> b;
	int res = max(a + b, a - b);
	res = max(res, a*b);
	cout << res << endl;*/

	int n;
	string s;
	cin >> n >> s;

	int res = 0;
	rep(i, s.size())
	{
		int tmp = 0;
		int a[30];
		rep(k, 30)
		{
			a[k] = 0;
		}
		repi(j, i + 1, s.size())
		{
			rep(l, i + 1)
			{
				if (s[j] == s[l])
				{
					a[s[l] - 'a'] = 1;
				}
			}
		}
		rep(k, 30)
		{
			tmp += a[k];
		}
		res = max(res, tmp);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define ll long long
#define ld long double
#define ms(a,v) memset(a,v,sizeof a)
#define pii pair<int, int>
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; scanf("%d", &n);
	vector<bool> possible(n+1, 0);
	possible[0] = possible[4] = possible[7] = 1;
	for (int i=8; i<=n; ++i) possible[i] = possible[i-4] | possible[i-7] ;
	printf("%s", possible[n] ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
# 上底の長さが a 、下底の長さが b 、高さが h の台形があります。
# この台形の面積を求めてください。

# 情報を取得
a = gets.to_i
b = gets.to_i
h = gets.to_i

# 計算し、結果を出力
puts ((a + b) * h) / 2

Measured memory_bytes: 1788
N = input()
l = len(N)

dp = [[[[0] * 2 for _ in range(8)]for _ in range(2)] for _ in range(l + 1)]
dp[0][False][0][False] = 1

for i in range(l):
    cur = int(N[i])

    for j in (3, 5, 7):
        if j == 3:
            s = 0
        elif j == 5:
            s = 1
        elif j == 7:
            s = 2

        for k in range(8):
            new = k | (1 << s)
            dp[i + 1][True][new][True] += dp[i][True][k][True]
            dp[i + 1][True][new][True] += dp[i][True][k][False]

        if j < cur:
            for k in range(8):
                new = k | (1 << s)
                dp[i + 1][True][new][True] += dp[i][False][k][True]
                dp[i + 1][True][new][True] += dp[i][False][k][False]

        if j == cur:
            for k in range(8):
                new = k | (1 << s)
                dp[i + 1][False][new][True] += dp[i][False][k][True]
                dp[i + 1][False][new][True] += dp[i][False][k][False]

    dp[i + 1][True][0][False] += dp[i][False][0][False]
    dp[i + 1][True][0][False] += dp[i][True][0][False]


print(dp[l][True][7][True] + dp[l][False][7][True])


Measured memory_bytes: 9304
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
vector<int>g[210000];

long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}

vector<long long> dfs(int a){
	vector<long long>ret;
	map<int,long long>M1;
	map<int,long long>M2;
	int ma=0;
	for(int i=0;i<g[a].size();i++){
		vector<long long>tmp=dfs(g[a][i]);
		if(ret.size()<tmp.size()){
			swap(ret,tmp);
		}
		for(int j=0;j<tmp.size();j++){
			int at=tmp.size()-j-1;
			M1[at]=(M1[at]+tmp[j]*pw((1+mod-tmp[j]),mod-2))%mod;
			if(M2.count(at)==0){M2[at]=1;}
			M2[at]=(M2[at]*(1+mod-tmp[j]))%mod;
			ma=max(ma,at+1);
		}
	}
	for(int i=ret.size()-ma;i<ret.size();i++){
		int at=ret.size()-1-i;
		M1[at]=(M1[at]+ret[i]*pw((1+mod-ret[i]),mod-2))%mod;
		if(M2.count(at)==0){M2[at]=1;}
		M2[at]=(M2[at]*(1+mod-ret[i]))%mod;

		ret[i]=M1[at]*M2[at]%mod;
	}
	ret.push_back(d2);
	//printf("%d %d:",a,ma);
	//for(int i=0;i<ret.size();i++)printf(" %lld",ret[i]);
	//printf("\n");
	return ret;
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		int p;scanf("%d",&p);
		g[p].push_back(i+1);
	}
	vector<long long>ret=dfs(0);
	long long ans=0;
	for(int i=0;i<ret.size();i++){
		ans=(ans+ret[i]*pw(2,a+1)%mod)%mod;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 94840
H, W, K  = map(int, input().split())
MOD = 10**9+7



L = [0]*(W-1)
row = 0
for i in range(2**(W-1)):
  LL = format(i, '08b')
  Lf = 0
  for j in range(len(LL)-1):
    if LL[j] == "1" and LL[j+1] == "1":
      Lf = 1
  if Lf == 0:
    row += 1
    LL = LL[8-(W-1):]
    for k in range(W-1):
      if LL[k] == "1":
        L[k] += 1
  #print(LL,Lf)
    


B = [] #Bridge
for _ in range(W):
  B.append([0,0,0])

for i in range(W):
  if i != 0:
    B[i][0] = L[i-1]
  else:
    B[i][0] = 0
  
  if i != W-1:
    B[i][2] = L[i]
  else:
    B[i][2] = 0

  B[i][1] = row-B[i][0]-B[i][2] 


A = [[0]*(W+2)]
for _ in range(H):
  A.append([0]*(W+2))

A[0][1] = 1

for i in range(H):
  for j in range(1,W+1):
    A[i+1][j-1] += A[i][j] * (B[j-1][0])
    A[i+1][j] += A[i][j] * (B[j-1][1])
    A[i+1][j+1] += A[i][j] * (B[j-1][2])

print(A[H][K]%MOD)

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

string s,t,d;
int a,b;
int main()
{
	cin>>s>>t;
	cin>>a>>b;
	cin>>d;
	if(d==s){
		cout<<a-1<<" "<<b;
	}
	if(d==t){
		cout<<a<<" "<<b-1;
	}
	
	
	return 0;
}

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

using namespace std;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vector<int> v(n, 0);
  vector<int> c(n, 1e9);
  for (int i = 0; i < n; i++) {
  	scanf("%d", &v[i]);
  }
  c[0] = 0;
  for (int i = 1; i < n; i++) {
    int m = min(i, k);
    for (int j = 1; j <= m; j++) {
      c[i] = min(c[i], c[i - j] + abs(v[i] - v[i - j]));
    }
  }
  printf("%d\n", c[n - 1]);
  return 0;
}

Measured memory_bytes: 1024
import math

# inputList=[]
# for i in range(6):
#     inputNum = input()
#     inputList.append(inputNum)
inputa = input().split()
inputb = input().split()

a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

listb = []
listb = [int(n) for n in inputb]

cnt = 0
for i in range(1,a-1):
    if listb[i-1] < listb[i] and listb[i] < listb[i+1]:
        cnt += 1
    elif listb[i-1] > listb[i] and listb[i] > listb[i+1]:
        cnt+=1

print(cnt)



Measured memory_bytes: 38384
#include <stdio.h>
int main (){
int W,H,x,y,r;

scanf ("%d %d %d %d %d",&W,&H,&x,&y,&r);

if (x>=r && x<=W-r && y>=r && y<=H-r){
printf ("Yes\n");
}

else {
printf ("No\n");
}

return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x;
  cin >> n >> x;
  vector<int> a(n + 1);
  for (int i = 1; i < n + 1; i++) cin >> a[i];
  long long tot = 0;
  for (int i = 1; i < n + 1; i++) {
    tot += max(a[i-1] + a[i] - x, 0);
    a[i] = min(x - a[i-1], a[i]);
  }
  cout << tot << '\n';
  return 0;
}

Measured memory_bytes: 640
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   : combinatorics NCR
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 2e2 + 10, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int n, m, dp[N][N], r;
vi v;
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	cin >> n >> m >> r;
	lp(i,1,r)
	{
		int x;
		cin >> x;
		v.pb(x);
	}
	lp(i,1,n)
	{
		lp(j,1,n)
		{
			dp[i][j] = 1e9;
			if (i == j)
				dp[i][j] = 0;
		}
	}
	while (m--) {
		int x, y, c;
		cin >> x >> y >> c;
		dp[x][y] = dp[y][x] = c;
	}
	lp(k,1,n)
		lp(i,1,n)
			lp(j,1,n)
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
	sort(all(v));
	int mn = 1e9;
	do {
		int tot = 0;
		lp(i,1,r-1)
			tot += dp[v[i - 1]][v[i]];
		mn = min(mn, tot);
	} while (next_permutation(all(v)));
	f(mn);
	return 0;
}

Measured memory_bytes: 384
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

aa = [0]
bb = [0]
for i in range(n):
    aa.append(aa[-1]+a[i])
for i in range(m):
    bb.append(bb[-1]+b[i])
c = m
ans = 0
for i in range(n+1):
    u = k - aa[i]
    for j in range(c, -1, -1):
        if bb[j] <= u:
            ans = max(ans, i+j)
            c = j
            break
print(ans)

Measured memory_bytes: 47372
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
using namespace std;

int main() {
    long long A, B, N;
    cin >> N >> A >> B;
    if (abs(A-B) % 2 == 0) {
        cout << abs(A-B) / 2 << endl;
        return 0;
    }
    long long min = std::min(A,B);
    long long max = std::max(A,B);
    if (min == max) {
        cout << 0 << endl;
        return 0;
    }

    long long a = abs(min - 1);
    long long b = abs(max - N);
    if (a < b) {
        cout << (a + 1) + abs((min - a) - (max - a - 1)) / 2 << endl;
        return 0;
    } else {
        cout << (b + 1) + abs((min + b  + 1) - (max + b)) / 2 << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	#define endl "\n"
	#define ll long long int
	#define vi vector<ll>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<ll,ll>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y) 
	#define mem(a,val) memset(a,val,sizeof(a))
	#define pb push_back
	#define f first
	#define s second
	
	using namespace std;
	
	signed main()
	{

	

	int n; cin>>n;
	string s;
	cin>>s;
	int p = n/2;
	int c=0;
	if(n%2!=0)
		cout<<"No";
	else{
		for (int i = 0; i < n/2; ++i)
		{
			/* code */
			if(s[i]==s[i+p]){
				c++;
			}
		}
		if(c==p)
			cout<<"Yes";
		else
			cout<<"No";
	}
	return 0;
	}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    N=int(input())
    P=list(map(int,input().split()))
    swapped=False
    cnt=0
    for i in range(N):
        if swapped:
            if temp!=i+1:
                swapped=False
                continue
            else:
                swapped=True
                cnt+=1
                temp=P[i]
        else:
            if P[i]!=i+1:
                swapped=False
                continue
            else:
                swapped=True
                cnt+=1
                temp=P[i]

    print(cnt)
resolve()

Measured memory_bytes: 52332
N=int(input())
P = input()
Q = input()
P=P.replace(" ","")
Q=Q.replace(" ","")
from itertools import permutations
St = '123456789'
L = list(permutations(St[:N]))
M = [None]*len(L)
for i in range(len(L)):
  M[i]="".join(L[i])
M.sort()
print(abs(M.index(P)-M.index(Q)))

Measured memory_bytes: 10868
#include <iostream>
#include<algorithm>
#include<vector> //動的配列
#include<string> 
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>

//小さい順から取り出すヒープ
//priority_queue<int, vector<int>, greater<int> > pque1;



typedef long long ll;


using namespace std;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int n;
priority_queue<int, vector<int>, greater<int> > pque1;
priority_queue<int> pque2;


int main(){
    cin>>n;
    ll a[3*n];
    for(int i=0;i<3*n;i++){
        cin>>a[i];
    }
    ll sum1=0,sum2=0;
    for(int i=0;i<n;i++){
        pque1.push(a[i]);
        sum1+=a[i];
        pque2.push(a[3*n-1-i]);
        sum2+=a[3*n-1-i];
    }
    ll ans1[n+1];
    ll ans2[n+1];
    ans1[0]=sum1;
    ans2[n]=sum2;
    for (int i=0;i<n;i++){
        sum1+=a[n+i];
        pque1.push(a[i+n]);
        sum1-=pque1.top();
        pque1.pop();
        ans1[i+1]=sum1;
        pque2.push(a[2*n-i-1]);
        sum2+=a[2*n-i-1]-pque2.top();
        ans2[n-i-1]=sum2;
        pque2.pop();
    }
    ll ans=ans1[0]-ans2[0];
    for (int i=1;i<=n;i++){
        ans=max(ans,ans1[i]-ans2[i]);
    }
    cout<<ans;
}

Measured memory_bytes: 5108
class Rectangle
	def area(vertical,width)
		area_val = vertical * width
		print "#{area_val} "
	end

	def area_length(vertical,width)
		area_length_val = 2 * (vertical + width)
		puts "#{area_length_val}"
	end
end

input = gets.split.map(&:to_i)

if input.length == 2 
	rectangle = Rectangle.new
	rectangle.area(input[0],input[1])
	rectangle.area_length(input[0],input[1])
else
	puts "You must input only two parameter"
end

Measured memory_bytes: 6100
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


struct P
{
	double e;
	string s;
};
bool operator<(const P& a, const P& b)
{
	return a.e > b.e || a.e == b.e && a.s < b.s;
}
int main()
{
	int n;
	while (cin >> n, n)
	{
		vector<P> v;
		while (n--)
		{
			string l;
			int p, a, b, c, d, e, f, s, m;
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			int x = a + b + c;
			int y = d + e;

			int earn = m * f * s;
			int span = x + y * m;

			P t;
			t.e = (double)(earn - p) / span;
			t.s = l;
			v.push_back(t);
		}
		sort(all(v));
		for (int i = 0; i < v.size(); ++i)
			cout << v[i].s << endl;
		cout << '#' << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

const int MAX_N = 100000;
const int INF = 1000000001;

int DP[MAX_N];
int a[MAX_N];

int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	fill(DP,DP+n,INF);
	for(int i=0;i<n;i++){
		*lower_bound(DP,DP+n,a[i]) = a[i];
	}
	int i=0;
	while(DP[i] != INF){
		i++;
		if(i == n){
			break;
		}
	}
	cout << i << "\n";
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    vector<int> v(n, 0);
    int a;
    for (int i = 0; i < n - 1; ++i) {
        cin >> a;
        v[a-1]++;
    }
    for (int i = 0; i < n; ++i) {
        cout << v[i] << endl;
    }
}

Measured memory_bytes: 4016
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
	string S; long long K;
	cin >> S >> K;
	for (int i = 0; i < min((long long)S.size(), K); i++) {
		if (S[i] >= '2') { cout << S[i] << endl; return 0; }
	}
	cout << '1' << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << a * b / 2.0 << endl;
  return 0;
}

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

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

    li n, t;
    cin >> n >> t;
    vector<li> as(n), bs(n);

    vector<li> order;
    for (int i = 0; i < n; ++i) {
        cin >> as[i] >> bs[i];
        bs[i] = as[i] + bs[i] + 1;
        order.push_back(i);
    }

    sort(order.begin(), order.end(), [&](int i, int j) {
        if (as[i] != 0 || as[j] != 0) {
            return as[j] * bs[i] < as[i] * bs[j];
        } else {
            return bs[i] < bs[j];
        }
    });

    li zeros = 0;
    for (; zeros < n; zeros++) {
        if (as[order[zeros]] == 0) {
            break;
        }
    }

    vector<li> mincost(30, t + 1);
    mincost[0] = 0;
    for (int i = 0; i < zeros; ++i) {
        for (int j = 29; j > 0; --j) {
            mincost[j] = min(mincost[j], mincost[j - 1] + as[order[i]] * mincost[j - 1] + bs[order[i]]);
        }
    }

    vector<li> acc;
    acc.push_back(0);
    for (int i = zeros; i < n; ++i) {
        acc.push_back(acc.back() + bs[order[i]]);
    }
    li ans = 0;
    for (int nz = 0; nz < 30; ++nz) {
        if (mincost[nz] > t) {
            continue;
        }
        ans = max(ans, nz - 1 + (li) (upper_bound(acc.begin(), acc.end(), t - mincost[nz]) - acc.begin()));
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 8048
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<cstring>

#define vti vector<int>
#define forn(i,a,n) for(int i=(a);i<(n);i++)
#define ford(i,a,d) for(int i=(a);i>(d);i--)
#define mset(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define mkp(a,b) make_pair(a,b)
using namespace std;
const long long N=1e3+3;
const long long inf=0x3f3f3f3f;
typedef long long ll;

const int Max=2e4+3;
int a[N],b[N],h,n,dp[Max];

int main()
{
//    ios::sync_with_stdio(false);
//    freopen("a.in","r",stdin);
//    freopen("ao","w",stdout);

    cin>>h>>n;
    forn(i,0,n) cin>>a[i]>>b[i];
    fill(dp,dp+Max,inf);
    dp[0]=0;
    forn(i,0,n)
    {
        for(int j=0;j<=h;j++)
        {
            dp[j+a[i]]=min(dp[j+a[i]],dp[j]+b[i]);
        }
    }
    int ans=inf;
    forn(i,h,Max) ans=min(ans,dp[i]);
    cout<<ans;

    return 0;
}


Measured memory_bytes: 384
K, N = map(int, input().split())
As = list(map(int, input().split()))

ma = 0
for i in range(1, N):
    d = As[i] - As[i-1]
    ma = ma if ma > d else d

d = K - As[-1] + As[0]
ma = ma if ma > d else d
print(K - ma)

Measured memory_bytes: 26420
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static void Exec()
		{
			long n = long.Parse(Console.ReadLine());
			long min = n.ToString().Length;

			for (long i = 1; i * i <= n; ++i) {
				if (n % i != 0) {
					continue;
				}

				var a = n / i;
				var ans = Math.Max(i.ToString().Length, a.ToString().Length);
				if (ans < min) {
					min = ans;
				}
			}

			Console.WriteLine($"{min}");

			Console.ReadKey();
		}
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
    int N,M; cin>>N>>M;
    priority_queue<int> Q;
    for(int i=0;i<N;i++){
        int a; cin>>a;
        Q.push(a);
    }

    while(M--){
        int x=Q.top(); Q.pop();
        Q.push(x/2);
    }

    int ans=0;
    while(!Q.empty()){
        ans+=Q.top(); Q.pop();
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>

int main(void)
{
	int n, m;
	char s;
	int len;
	int i, j;
	int flag_start;
	int count;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
	
		scanf("%d", &m);
		scanf("%c", &s);
		count = len = 0;
		flag_start = 0;
		for (i = 0; i < m; i++){
			scanf("%c", &s);
			if (flag_start == 0){
				if (s == 'I'){
					flag_start = 1;
					len = 1;
				}
			}
			else {
				if (len % 2 == 1){
					if (s == 'O'){
						len++;
					}
					else {
//printf("<%d>", len);
						if (len >= n * 2 + 1){
							count += ((len - (n * 2 + 1)) / 2 + 1);
						}
						len = 1;
					}
				}
				else {
					if (s == 'I'){
						len++;
					}
					else {
//printf("<%d>", len);
						if (len >= n * 2 + 1){
							count += ((len - (n * 2 + 1)) / 2 + 1);
						}
						len = 0;
						flag_start = 0;
					}
				}
			}
			
		}
//printf("<%d>->", len);
		len = (len - 1) / 2 * 2 + 1;
//printf("<%d>", len);
		if (len >= n * 2 + 1){
			count += ((len - (n * 2 + 1)) / 2 + 1);
		}

		printf("%d\n", count);

		scanf("%c", &s);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include <iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int main() {

	int n;
	int l[2001];

	cin>>n;

	rep(i,n){
		cin>>l[i];
	}
	ll total=0;
	sort(l,l+n);
	for(int i=n-1; i>=2; i--){
		for(int j=i-1; j>=1; j--){
			for(int k=j-1; k>=0; k--){
				if(l[i]<l[j]+l[k])total++;
				else break;
			}
		}
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
using namespace std;
int main(){
  int n,m,adres;
  char t[9999];
  char moji;
  while(1){
    cin>>n;
    for(int i=0;i<10000;i++){
      t[i]=' ';
    }
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin>>moji;
      adres=(moji-'0');
      cin>>moji;
      t[adres]=moji;
    }
    //cout<<moji-'0'<<endl;
    cin>>m;
    
    for(int i=0;i<m;i++){
      cin>>moji;
      adres=moji-'0';
      if(t[adres]==' '){
	cout<<moji;
      }else{
	cout<<t[adres];
      }
    }
    
    cout<<endl;

  }
  return 0;
}

Measured memory_bytes: 1160
s = input()
for i in range(1<<3):
  tmp=int(s[0])
  S=s[0]  
  for j in range(3):
    if i>>j & 1:
      S=S+'+'+s[j+1]
      tmp+=int(s[j+1])
    else:
      S=S+'-'+s[j+1]
      tmp-=int(s[j+1])  
  if tmp==7:
    print(S+'=7')
    exit()
      

Measured memory_bytes: 9216
import sys
mod=1000000007
n=int(input())
s=str(input())
ans=1
for i in range(1,n+1):
  i=i%mod
  ans=ans*i
  ans=ans%mod
d={"B":1,"W":0}
sg=[]
now=1
sss=0
for i in range(2*n):
  if d[s[i]]==now%2:
    sss+=1
    now+=1
    a="S"
  else:
    a="G"
    now-=1
    if sss>=0:
      ans*=sss
      ans=ans%mod
      sss-=1
    else:
      ans=0
  #print("i",i,a,sss,ans)
if sss==0:
  print(ans)
else:
  print(0)

Measured memory_bytes: 3572
import sys
import numpy as np
#inputを高速化する。
input = sys.stdin.readline
n, k = map(int, input().split())
h = [int(i) for i in input().split()]
# dpの配列を作る。
dp = np.zeros(n, dtype=int)
# hの配列を作る。
h = np.array(h)
for i in range(1, n):
    # start は負になることはない。
    start = max(0, i-k)
    # 行列として足し算できるのでforを使う必要がない。
    dp[i] = min(dp[start: i] + np.abs(h[i] - h[start: i]))
print(dp[n-1])

Measured memory_bytes: 23056
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=9e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m,l,r,x=-inf,y=inf;
  cin >> n >> m;
  for(int i=0; i<m; i++) {
    cin >> l >> r;
    x=max(x,l),y=min(y,r);
  }
  cout << max(0,y-x+1) << endl;
  }

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, m = map(int, input().split())
G = [[] for _ in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append(b)
seen = [False]*n
def dfs(v):
  seen[v] = True
  for nv in G[v]:
    nxt[v] = nv
    if seen[nv]:
      return nv
    s = dfs(nv)
    if s != -1:
      return s
  seen[v] = False
  return -1
for i in range(n):
  nxt = [-1]*n
  s = dfs(i)
  if s != -1:
    break
else:
  print(-1)
  exit()
while True:
  used = set()
  L = []
  while s not in used:
    used.add(s)
    L.append(s)
    s = nxt[s]
  L.append(s)
  for i in range(len(L)-1):
    a, b = L[i], L[i+1]
    for nv in G[a]:
      if nv != b and nv in used:
        nxt[a] = nv
        s = a
        break
    else:
      continue
    break
  else:
    print(len(used))
    for v in used:
      print(v+1)
    break

Measured memory_bytes: 75656
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(in) in.begin(), in.end()
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<ll, ll> pll;

vector<ll> adj[1005], comp[1005], ans;
ll parent[1005];

void getParent(ll x){
    ans.push_back(x);
    if(parent[x] == -1){
        return;
    }
    getParent(parent[x]);
}


void bfs(ll x){
    ll cnt[1005];
    for(ll i = 0 ; i < 1005 ; i++){
        cnt[i] = INT_MAX;   parent[i] = -1;
    }
    cnt[x] = 0;
    queue<ll> q;    q.push(x);
    while(q.size()){
        ll cur = q.front();
        q.pop();
        for(ll i = 0 ; i < adj[cur].size() ; i++){
            ll nxt = adj[cur][i];
            if(cnt[nxt] == INT_MAX){
                q.push(nxt);    parent[nxt] = cur;
                cnt[nxt] = cnt[cur] + 1;
            }
        }
    }
    for(ll i = 0 ; i < comp[x].size() ; i++){
        ll nxt = comp[x][i];
        if(cnt[nxt] != INT_MAX && (ans.size() == 0 || (cnt[nxt] + 1 <= ans.size() ) ) ){
            ans.clear();    getParent(nxt);
        }
    }
}

int main(){
    FIO;
    ll n, m;    cin >> n >> m;
    for(ll i = 0 ; i < m ; i++){
        ll u, v;    cin >> u >> v;
        adj[u].push_back(v);
        comp[v].push_back(u);
    }
    for(ll i = 1 ; i <= n ; i++){
        bfs(i);
    }
    if(ans.size() == 0){
        cout << -1 << endl;     return 0;
    }
    cout << ans.size() << endl;
    sort(all(ans));
    for(ll i = 0 ; i < ans.size() ; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)

int N, M, K;
vector<int> a, b;
void input() {
  cin >> N >> M >> K;
  a.resize(N);
  for (auto &e : a) cin >> e;
  b.resize(M);
  for (auto &e : b) cin >> e;
}

void solve() {
  ll t = 0;
  for (auto &e : b) t += e;

  int ans = 0;
  int j = M;
  rep(i, 0, N + 1) {
    while (j > 0 && t > K) {
      --j;
      t -= b[j];
    }
    if (t > K) break;
    ans = max(ans, (i + j));  //(a=0冊,b=j冊)～(a=N冊,b=0冊)
    if (i == N) break;
    t += a[i];
  }
  cout << ans << endl;
}

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

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

long long int n;

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


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h: usize = read();
    let w: usize = read();
    let mut field = vec![vec!['0'; w]; h];
    for y in 0..h {
        field[y] = read::<String>().chars().collect::<Vec<char>>();
    }
    let mut ans = "Yes";
    for y in 0..h {
        'cell_loop: for x in 0..w {
            if field[y][x] == '.' {
                continue;
            }
            for dir in 0..4 {
                let dy = [1, 0, -1, 0];
                let dx = [0, 1, 0, -1];
                let ny = y as i32 + dy[dir];
                let nx = x as i32 + dx[dir];
                if ny < 0 || ny >= h as i32 || nx < 0 || nx >= w as i32
                    || field[ny as usize][nx as usize] == '.'
                {
                    continue;
                }
                continue 'cell_loop;
            }
            ans = "No";
        }
    }
    println!("{}", ans);
}


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

int main() {
    uint64_t n;
    std::string s;
    std::cin >> n >> s;

    int answer = 0;
    char current_c = '\0';

    for(const char c: s) {
        if(c != current_c) {
            ++answer;
            current_c = c;
        }
    }

    std::cout << answer;

    return 0;
}


Measured memory_bytes: 512
from collections import Counter
n=int(input())
s=[list(input()) for _ in range(n)]
a=Counter(s[0])
for i in range(1,n):
    c=Counter(s[i])
    for k, v in a.items():
        if k not in c:
            a[k]=0
        elif c[k]<v:
            a[k]=c[k]
a=sorted(a.items())
for k, v in a:
    print(k*v,end="")
print()

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


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
int AC=0, WA=0, TLE=0,RE=0;
int main(){
	int tt;
	string verd;

	cin >> tt;
	while(tt--){
		cin >> verd;
		if(verd=="AC") AC++;
		if(verd=="WA") WA++;
		if(verd=="TLE") TLE++;
		if(verd=="RE") RE++;
	}

	cout << "AC x " << AC << endl;
	cout << "WA x " << WA << endl;
	cout << "TLE x " << TLE << endl;
	cout << "RE x " << RE << endl;
}

Measured memory_bytes: 3600
S = input()
N = len(S)
S1 = S[:(N - 1)//2]
S2 = S[(N + 1)//2:]
flag = True
for i in range(len(S1)):
    if S1[i] != S1[-1-i]:
        flag = False
for i in range(len(S2)):
    if S2[i] != S2[-1-i]:
        flag = False
for i in range(N):
    if S[i] != S[-1-i]:
        flag = False

print('Yes' if flag else 'No')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
  int N, M; cin >> N >> M;
  vector<vector<int>> s(M);
  vector<int> p(N);
  for(int i = 0; i < M; i++) {
    int k; cin >> k;
    for(int j = 0; j < k; j++) {
      int a; cin >> a; a--;
      s[i].push_back(a);
    }
  }
  for(int i = 0; i < M; i++) cin >> p[i];

  int ans = 0;
  for(int bit = 0; bit < (1<<N); bit++) {
    bool ok = true;
    for(int i = 0; i < M; i++) {
      int con = 0;
      for(auto v: s[i]) {
        if(bit & (1<<v)) con++;
      }
      if(con % 2 != p[i]) ok=false;
    }
    if(ok) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
max_range, sum_ = map(int, input().split())

count = 0
for x in range(0, min(max_range + 1, sum_ + 1)):
    for y in range(0, min(max_range + 1, sum_ - x + 1)):
        if sum_ - x - y <= max_range:
            count += 1

print(count)


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


int main(){
    int q; cin >> q;
    vector<int> prime(1000000, 1);
    prime[0] = 0;prime[1] = 0;
    for(int i = 2; i < 1100; i++){
        if(prime[i] == 1){
            for(int l = 2 * i; l < 1000000; l += i){
                prime[l] = 0;
            }
        }
    }
    vector<int> lis(1000000, 0);
    for(int i = 2; i < 1000000; i++){
        if(prime[i] == 1 && prime[(i+1)/2] == 1){
            lis[i] = 1;
        }
    }
    for(int i = 3; i < 1000000; i++){
        lis[i] = lis[i] + lis[i-1];
    }
    for(int i = 0; i < q; i++){
        int a, b; cin >> a >> b;
        cout << lis[b] - lis[a-1] << endl;
    }
}

Measured memory_bytes: 8448
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		if(x==0) {
			System.out.println(1);
		}
		if(x==1) {
			System.out.println(0);
		}
	}
}

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

int main() {
  int n;
  std::cin >> n;
  for (int i = 1; true; ++i) {
    if (i * (i + 1) / 2 >= n) {
      for (int j = i; j > 0; --j) {
        if (j <= n) {
          std::cout << j << std::endl;
          n -= j;
        }
      }
      return 0;
    }
  }
}

Measured memory_bytes: 888
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, K, Q;
    cin >> N >> K >> Q;

    map<ll, ll> data;
    rep(i, Q) {
        ll tmp;
        cin >> tmp;
        data[tmp-1]++;
    }

    rep(i, N) {
        if(data[i]>Q-K){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6912
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

//scanf("%d",&x);
//printf("%d",x);
//for(i=0;i<N;i++){  }
//if( == ){  }else{  }
//while( ){  }

/*
int N, i;
int H[100];
scanf("%d", &N);
for (i = 0; i < N; i++) scanf("%s", &H[i]);
*/

int main()
{
	int i, N;
	scanf("%d", &N);
	scanf("%d", &i);

	printf("%d", N - i + 1);
	

}

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

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

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

    int A; cin >> A;
    string S; cin >> S;
    if (A >= 3200) {
        cout << S << endl;
    } else cout << "red" << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343
// license: https://github.com/bqi343/USACO/blob/master/LICENSE

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);
	if (x - r >= 0 && x + r <= W&&y - r >= 0 && y + r <= H)
		printf("Yes\n");
	else
		printf("No\n");

	

	return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

//素数判定表
vector<ll> eratosthenes_sieve(ll n) {
    vector<ll> ps(n + 1);
    iota(ps.begin() + 2, ps.end(), 2);
    for (ll i = 2; i * i <= n; ++i)
        if (ps[i])
            for (ll j = i * i; j <= n; j += i) ps[j] = 0;
    return ps;
}

//素数表
vector<ll> make_primes(ll n) {
    vector<ll> ps = eratosthenes_sieve(n);
    ps.erase(std::remove(ps.begin(), ps.end(), 0), ps.end());
    return ps;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    vec mp = make_primes(200000);
    vec ls(200000);

    for(auto m : mp){
        if(m <= 1e5) ls[m]++;
        if(m * 2 - 1 <= 1e5) ls[m * 2 - 1] += 2;
    }
    rep1(i, 1e5){
        if(ls[i] == 3) ls[i] = 1;
        else ls[i] = 0;
    }

    rep1(i, 1e5) ls[i] += ls[i - 1];

    ll Q;
    cin >> Q;
    rep(_, Q){
        ll l, r;
        cin >> l >> r;
        print(ls[r] - ls[l - 1]);
    }

    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
string s;
void init(){
    cin >> s;
}
void solve(){
    if (s[2] == s[3] && s[4] == s[5])
        printf("Yes\n");
    else printf("No\n");
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 256