akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <math.h>
#include <functional>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
int main(){
    vector<int> a(3);
    for (int i = 0; i < 3; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    str s = to_string(a[2]) + to_string(a[1]);
    int s2 = stoi(s);
    cout << s2 + a[0] << endl;
    return 0;
}

Measured memory_bytes: 3684
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
int n,cnt;
int main()
{
	scanf("%d",&n);
	for(int a=1;a<=9;a++)
		for(int b=0;b<=9;b++)
			for(int c=0;c<=9;c++)
				for(int d=0;d<=9;d++)
					for(int e=0;e<=9;e++)
					if(a*10000+b*1000+c*100+d*10+e<=n)
					cnt++;

	for(int c=1;c<=9;c++)
		for(int d=0;d<=9;d++)
			for(int e=0;e<=9;e++)
			if(c*100+d*10+e<=n)
					cnt++;
	for(int e=1;e<=9;e++)
	if(e<=n)
		cnt++;
	printf("%d",cnt);
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))
avg = sum(X)//N
sums_1 = 0
sums_2 = 0
for i in X:
    sums_1 += (avg - i)**2

for j in X:
    sums_2 += (avg+1 - j)**2


print(min(sums_1,sums_2))

Measured memory_bytes: 61880
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <cctype>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef long long    ll;
typedef long double  ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

template <typename T> bool chmax(T &a, T& b) {if (a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, T& b) {if (a > b) {a = b; return true;} return false;}
#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define mset(x, val) memset(x,(val),sizeof(x))
#define cons(a, b) make_pair((a), (b))
#define car first
#define cdr second

#define endl '\n'
const ll   INF  = 0x7f7f7f7f7f7f7f7f;
const int  INFi = 0x7f7f7f7f;
const string YES = "Yes";
const string NO = "No";

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

bool solve(int N, vector<ll> & t, vector<ll> & x, vector<ll> & y) {
  t.insert(t.begin(), 0);
  x.insert(x.begin(), 0);
  y.insert(y.begin(), 0);
  rep(i, N) {
    ll res = t[i+1] - t[i];
    res -= abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
    if (res < 0) return false;
    if (res % 2) return false;
  }
  return true;
}

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

  int N;
  cin >> N;
  vector<ll> t(N), x(N), y(N);
  rep (i, N) {
    cin >> t[i] >> x[i] >> y[i];
  }

  auto ans = solve(N, t, x, y);
  cout << (ans ? YES : NO) << endl;

  return 0;
}


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

int main(){
    int a[7], tmp;
    string dir;
    for (int i=1; i<7; i++) {
        cin >> a[i];
    }
    cin >> dir;
    for (int i=0; i<dir.size(); i++) {
        switch (dir[i]) {
            case 'N':
                tmp = a[1];
                a[1] = a[2];
                a[2] = a[6];
                a[6] = a[5];
                a[5] = tmp;
                break;
            case 'E':
                tmp = a[1];
                a[1] = a[4];
                a[4] = a[6];
                a[6] = a[3];
                a[3] = tmp;
                break;
            case 'S':
                tmp = a[1];
                a[1] = a[5];
                a[5] = a[6];
                a[6] = a[2];
                a[2] = tmp;
                break;
            case 'W':
                tmp = a[1];
                a[1] = a[3];
                a[3] = a[6];
                a[6] = a[4];
                a[4] = tmp;
                break;
        }
    }
    cout << a[1] << endl;
}


Measured memory_bytes: 3212
#include <iostream>
using namespace std;
int main()
{
  char b;
  cin >> b;
  if (b=='A') cout << "T" << endl;
  if (b=='C') cout << "G" << endl;
  if (b=='G') cout << "C" << endl;
  if (b=='T') cout << "A" << endl;
  return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		double r1 = sc.nextDouble(); //hour
		double r2 = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();
		
		double deg1 = ((h-3)*-30) + (m/-2);
		double deg2 = ((m-15)*-6);
		while(deg1<0)deg1+=360d;
		while(deg2<0)deg2+=360d;
		
//		System.out.println(deg1 + " " + deg2 + " degrees");
		//current unit: 360 degs
		//convert to rad
		deg1 = (deg1*Math.PI)/180;
		deg2 = (deg2*Math.PI)/180;
		
//		System.out.println(deg1 + " " + deg2 + " in rad");
		
		double x1 = Math.cos(deg1) * r1;
		double y1 = Math.sin(deg1) * r1;
		
		double x2 = Math.cos(deg2) * r2;
		double y2 = Math.sin(deg2) * r2;
		
//		System.out.printf("pos " + x1 + " " + y1 + ", " + x2 + " " + y2);
		
		double xx = (x1-x2)*(x1-x2);
		double yy = (y1-y2)*(y1-y2);
//		System.out.println("\n xxyy: " + xx + " " + yy);
		
		double dis = Math.sqrt(xx+yy);
		System.out.printf("%.16f\n", dis);
//		System.out.println("test "+ dis);
		
//		double dis2 = (r1*r1) + (r2*r2) - (2*r1*r2*Math.cos(deg1-deg2));
//		dis2 = Math.sqrt(dis2);
//		System.out.println(dis2);
	}

}


Measured memory_bytes: 28964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define COUT(x) cout << (x) << endl
#define VIEW(x) do{cout << "--" << #x << "--" << endl; view(x);}while(0)
template<typename T> void view(T e){COUT(e);}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define _GLIBCXX_DEBUG

int main(){
  
  int x, a, b;
  cin >> x >> a >> b;
  if ((abs(x-a) < abs(x-b)))
    cout << 'A' << endl;
  else
    cout << 'B' << endl;

}

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


namespace ConsoleApplication52
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            List<int> b = new List<int>();
            int d = 0;
            int f = 0;
            for (int c = 0; c < a[1]; c++)
            {
                int[] e = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (e[0] >= a[0])
                    d++;
                if (e[0] < a[0])
                    b.Add(a[0]-e[0]);
            }
            b.Sort();
            d = a[1] - d -1;
            for (int u = 0; u < d; u++)
                f += b[u];
            Console.WriteLine(f);
        }
    }
}

Measured memory_bytes: 9696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,x,y,z,l,n,m,a,r,f,c;
  long long min,max,sum;
  string s;

    getline(cin,s);

//    vector<vector<int>> A(n, vector<int>(m, 0));
for(int i=0;i<s.length();i++) {
  if(isupper(s[i])) s[i] = tolower(s[i]);
  else if (islower(s[i])) s[i] = toupper(s[i]);
}
  cout << s << endl;
}


Measured memory_bytes: 3156
#include <iostream>

using namespace std;

int a, b;
int main()
{
    cin >> a >> b;
    if (a > 12) {
        cout << b;
    } else if (13 > a && a > 5 ) {
        cout << b/2;
    } else {
        cout << "0";
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char a[10000],b[10000],c[10000];
    scanf("%s\n%s\n%s",a,b,c);
    int q=strlen(a);
    int r=strlen(b);
    int s=strlen(c);
    if((a[q-1]==b[0])&&(b[r-1]==c[0])) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    
    cout<<max(a*c,max(a*d,max(b*c,b*d)))<<endl;
}

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

using namespace std; 

int H;
vector<int> A;

void maxHeapify(int ind) {
	int lar = ind;
	int l = (2*ind)+1;
	int r = l+1;
	if (l < H && A[l] > A[ind]) {
		lar = l;
	}
	if (r < H && A[r] > A[lar]) {
		lar = r;
	}

	if (lar != ind) {
		swap(A[ind],A[lar]);
		maxHeapify(lar);
	}
	return;
}

void buildMaxHeap() {
	for (int i = H/2; i >= 0; --i) {
		maxHeapify(i);
	}
	return;
}

int main(void) {
	cin >> H;
	A = vector<int>(H);
	for (int i = 0; i < H; ++i) {
		cin >> A[i];
	}
	buildMaxHeap();
	for (int i = 0; i < H; ++i) {
		cout << " " << A[i];
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 6740
import sys

a, b = list(map(int, input().split()))

if a == 1 or b == 1:
  if a == 1 and b == 1:
    print("Draw")
    sys.exit()
  if a == 1:
    print("Alice")
    sys.exit()
  if b == 1:
    print("Bob")
    sys.exit()

if a > b:
  print("Alice")
  sys.exit()
elif a == b:
  print("Draw")
  sys.exit()
else:
  print("Bob")
  sys.exit()


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

int main() {
    int v[3];
    for(int i = 0; i < 3; i++) {
        cin >> v[i];
    }
    if(v[0] == v[1]) cout << v[2] << endl;
    else if(v[0] == v[2]) cout << v[1] << endl;
    else cout << v[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

int main()
{
    int n,l,i,flav;
    flav=0;
    scanf("%d%d",&n,&l);
    for(i=1; i<=n; i++)
        flav+=l+i-1;
    if(l<=0 && l+n-1>=0)
        printf("%d",flav);
    else
        if(l+n-1<0)
            printf("%d",flav-l-n+1);
        else
            printf("%d",flav-l);

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long
#define pii         pair<ll, ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll, ll>
#define mii         map<pii, ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define lb          lower_bound
#define ub          upper_bound

#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
 
#define track(x)                 cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
 
#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))

#define MOD         1000000007
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a + b + p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int b) {a = max(a, b); }
void self_min(int &a, int b) {a = min(a, b); }
void self_add(int &a, int b, int p = MOD) { a += b; if(a >= p) a -= p;}
void self_sub(int &a, int b, int p = MOD) { a -= b; if(a < 0) a += p;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
const int INF = 1e9 + 5;
#define N	    	400001

void solve(){
    string s;
    cin>>s;
    stack<char> t;
    rep(i, 0, sz(s)) {
        if(!t.empty() && t.top() != s[i]) {
            t.pop();
        }
        else
            t.push(s[i]);
    }
    cout<<sz(s) - t.size()<<endl;
}
int main() {
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
	}
}




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

int main(){
    int n;
    cin >> n;
    vector<double> a(n);
    double love=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        love+=1/a[i];
    }
    cout << 1/love << endl;
}


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

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> L(n + 1);
    L[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> L[i];
    }
    
    vector<int> D(n + 2);
    D[0] = 0;
    for (int i = 1; i <= n + 1; i++)
    {
        D[i] = D[i-1] + L[i-1];
        //cout << "D" << i << " " << D[i] << endl;
    }
    int cnt = 0;
    for (int i = 1; i < D.size(); i++)
    {

        if (D[i] <= x)
        {
            cnt++;
        }
        else
        {
            break;
        }
        
        
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
p=list(map(int,input().split()))

alst=[]
blst=[]
for i in range(n):
    alst.append(30000*i+1)
    blst.append(30000*(n-i-1)+1)
for i in range(n):
    blst[p[i]-1]+=i
print(*alst)
print(*blst)

Measured memory_bytes: 71568
n=int(input())
s=input()

all=[]
for i in range(10):
	for j in range(10):
		for k in range(10):
			all.append(str(i) + str(j) + str(k))

output=0
for i in range(n):
	tmps=s[i]
	tmplist=[]
	
	for j,x in enumerate(all):
		if x[0] == tmps:
			if len(x)==1:
				tmplist.append(x)
				output += 1
			else:
				all[j] = x[1:]
	
	for tmp in tmplist:
		all.remove(tmp)

print(output)



Measured memory_bytes: 73652
X = int(input())

def is_sosu(x):
    for i in range(2, (x//2) + 1, 1):
        if x % i == 0:
            return False
    return True 

chk = True
ans = 0
while(chk):
    if is_sosu(X):
       ans = X
       break
    X += 1
    if is_sosu(X):
        ans = X
        break
print(X)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a;
    cin >> a;
    for (ll i = 1; i <= 9; i++)
    {
        if (a % i == 0 && a / i <= 9)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		int sum = 0;

		for(int i=0;i<n;i++) {
			sum += sc.nextInt();
		}
		System.out.print(h<=sum?"Yes":"No");

 }
}

Measured memory_bytes: 47332
#include<stdio.h>
int main(){
	int c1,c5,c10,c50,c100,c500,goukei;
	scanf("%d%d%d%d%d%d",&c1,&c5,&c10,&c50,&c100,&c500);
	goukei=c1*1+c5*5+c10*10+c50*50+c100*100+c500*500;
	if(1000<=goukei){
		printf("1\n");
	}
	else if(1000>=goukei){
		printf("0\n");
	}
	return 0;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
vector<int> factor(int x) {
    vector<int> ret;
    int y = x;
    for (int i = 1; i * i <= y; i++) {
        if (y % i == 0) {
            ret.push_back(i);
            if (i * i != y) ret.push_back(y / i);
        }
    }
    return ret;
}
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> a(N+1);
    for (int i = 1; i <= N; i++) cin >> a[i];

    vector<int> cnt(N+1, 0);
    vector<int> ball;
    for (int i = N; i >= 1; i--) {
        if ((cnt[i] % 2) == a[i]) continue;
        ball.push_back(i);
        vector<int> factors = factor(i);
        for (int f : factors) cnt[f]++;
    }

    reverse(ball.begin(), ball.end());
    int M = ball.size();
    cout << M << '\n';
    for (int i = 0; i < ball.size(); i++) {
        if (i) cout << ' ';
        cout << ball[i];
    }
    cout << '\n';
}

Measured memory_bytes: 5276
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

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

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	lint A, B;
	cin >> A >> B;

	if (abs(A - B) % 2) cout << "IMPOSSIBLE" << "\n";
	else cout << abs(A + B) / 2 << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = sc.nextInt();
    if (x >= a && a + b >= x) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int INF = 1e9;
int n ;
int dp[100009];
vector<int>v;
int dfs(int i){
    
    if(i >= n)return INF;
    if(i == n-1) return 0;
    
    if(dp[i] != -1)return dp[i];
    
    int c1 = abs(v[i]-v[i+1]) + dfs(i+1);
    int c2 = abs(v[i]-v[i+2]) + dfs(i+2);
    int ans = min(c1 , c2);
    dp[i] = ans;
    
    return ans;
}
int main(){
    cin>>n;
    v.resize(n+2);
    for(int i=0;i<n;i++)
        cin>>v[i];
    
  
    memset(dp,-1,sizeof dp);
 
    cout<<dfs(0)<<endl;
    return 0;
}


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

int main()
{
    ll n,x,t,r,ans;
    cin>>n>>x>>t;

    r=n/x;
    if(n%x!=0)
        r++;
    ans=r*t;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3620
n = (
    1, 1, 1, 2, 1, 2, 1, 5, 2, 2,
    1, 5, 1, 2, 1, 14, 1, 5, 1, 5,
    2, 2, 1, 15, 2, 2, 5, 4, 1, 4,
    1, 51
)
print(n[int(input()) - 1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
#define NIL -1

struct node {int p,l,r;};

node T[MAX];
int n,D[MAX];

void print(int u){
  int c;
  cout<<"node"<<" "<<u<<": ";
  cout<<"parent = "<<T[u].p<<", ";
  cout<<"depth = "<<D[u]<<", ";
  if(T[u].p==NIL) cout<<"root, ";
  else if(T[u].l==NIL) cout<<"leaf, ";
  else cout<<"internal node, ";
  cout<<"[";
  for(int i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i) cout<<", ";
    cout<<c;
  }
  cout<<"]"<<endl;
}

void rec(int u,int p){
  D[u]=p;
  if(T[u].r!=NIL) rec(T[u].r,p);
  if(T[u].l!=NIL) rec(T[u].l,p+1);
}


  
  
int main(){
  int a,b,c,l,r;
  cin>>n;
  for(int i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    for(int j=0;j<b;j++){
      cin>>c;
      if(j==0) T[a].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=a;
    }
  }
  for(int i=0;i<n;i++){
    if(T[i].p==NIL) r=i;
  }
  rec(r,0);
  for(int i=0;i<n;i++) print(i);
  return 0;
}



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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) {
        cin >> P[i];
        P[i]--;
    }

    vector<int> A(N), B(N);
    rep(i, N) {
        A[i] = 30000 * (i + 1);
        B[i] = 30000 * (N - i);
    }

    rep(i, N) A[P[i]] += (i+1);

    rep(i, N) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    rep(i, N) {
        if (i > 0) cout << " ";
        cout << B[i];
    }
}



Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
int main() {
	set<int>a;
	int b, c, d;
	cin >> b >> c >> d;
	a.insert(b);
	a.insert(c);
	a.insert(d);
	cout << a.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/foreach.hpp>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
#define _GLIBCXX_DEBUG
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
vector<long> Primelist;
//template functions
/////////////////////////
void Prinit(){
long PR=10000001;
vector<long> P(PR,0);
for(long i=2;i*i<PR;i++){
    if(P.at(i)==0){
        long j=i;
      j+=i;
        while(j<PR){
            P.at(j)=1;
             j+=i;         
        }
    }
}

for(long i=2;i*i<PR;i++){//Primelist.size()=446
    if(P.at(i)==0){
        Primelist.push_back(i);
    }
}
}

void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

long strtolong(string str){
istringstream ss;
ss=istringstream(str);
long num;
ss>>num;
return num;
}

long chartolong(char ch){
long num;
num=ch-'0';
return num;
}

string longtostr(long N){
    string str;
    str=to_string(N);
    return str;
}









/////////////////////////


//Answer


int main() {
long N;
cin>>N;
if(N==1){
    cout<<0<<endl;
}else{
    cout<<1<<endl;
}

}




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

using namespace std;

constexpr int MAXN=2e5+5,P=2019;
int n;
int pre_sum[MAXN],buc[2][P];
char s[MAXN];

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;++i)
		pre_sum[i]=(pre_sum[i-1]*10+(s[i]-'0'))%P;
	buc[0][0]=1;
	long long ans=0;
	for(int i=1;i<=n;++i){
		for(int j=0;j<P;++j)
			buc[i&1][j]=0;
		for(int j=0;j<P;++j)
			buc[i&1][j*10%P]+=buc[~i&1][j];
		ans+=buc[i&1][pre_sum[i]]++;
	}
	printf("%lld",ans);
}

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

using namespace std;
typedef long long LL;
const int MX=100105,md=1000000007;
int i,j,k;
int f[MX],fac[MX],facinv[MX],M[MX];

int pw(int x,int y){
	int z=1;
	for(;y;y>>=1,x=(LL)x*x%md)if(y&1)z=(LL)z*x%md;
	return z;
}
int C(int n,int m){return (LL)fac[n]*facinv[m]%md*facinv[n-m]%md;}
void ini(int n){
	int i;
	fac[0]=facinv[0]=f[0]=M[0]=1;
	for(i=1;i<=n;i++)M[i]=(M[i-1]+M[i-1])%md;
	for(i=1;i<=n;i++)f[i]=(LL)f[i-1]*(2*i-1)%md;
	for(i=1;i<=n;i++)fac[i]=(LL)fac[i-1]*i%md;
	facinv[n]=pw(fac[n],md-2);
	for(i=n-1;i;i--)facinv[i]=(LL)facinv[i+1]*(i+1)%md;
}
int n,m,ch,ff,ans;
int a[MX],b[MX],z[MX],fg[MX],num[MX],d[MX],dp[MX];
int cal(int n,int m){
	int i,k,ans=0;
	if((m&1)&& m>1){
		for(i=0,k=1;i+i<=n;i++,k=(LL)k*m%md)ans=((LL)f[i]*k%md*C(n,i+i)%md*M[n-i-i]%md+ans)%md;
	}else{
		for(i=0,k=1;i+i<=n;i++,k=(LL)k*m%md)ans=((LL)f[i]*k%md*C(n,i+i)%md+ans)%md;
	}
	return ans;
}
int main(){
	cin>>n;
	ini(n);
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n;i++)d[a[i]]++;
	for(i=1;i<=n;i++)if(!z[i]){
		for(j=i;z[j]!=i && !z[j];j=a[j])z[j]=i;
		if(z[j]==i){
			fg[j]=1;
			for(k=a[j];k!=j;k=a[k])fg[k]=1;
		}
	}
	for(i=1;i<=n;i++)if(d[i]>fg[i]+1)return cout<<0<<endl,0;
	for(i=1;i<=n;i++)if(!fg[i])b[a[i]]=i;
	for(i=1;i<=n;i++)if(fg[i]){
		for(j=b[i];j;j=b[j])dp[i]++;
	}
	memset(z,0,sizeof z);
	ans=1;
	for(i=1;i<=n;i++)if(!z[i] && fg[i]){ 
		int nm=0,Fg=0;
		for(j=i;!z[j];j=a[j]){
			z[j]=1;
			nm++;
			if(dp[j])Fg=j;
		}
		if(!Fg)num[nm]++;
		else {
			k=0;
			for(j=a[Fg];j!=Fg;j=a[j]){
				k++;
				if(dp[j]){
					if(dp[j]>k)ans=0;
					if(dp[j]<k)ans=(ans+ans)%md;
					k=0;
				}
			}
			k++;
			if(dp[Fg]>k)ans=0;
			if(dp[Fg]<k)ans=(ans+ans)%md;
		}
	}
	for(i=1;i<=n;i++)if(num[i])ans=(LL)ans*cal(num[i],i)%md;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4096
#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 (ll 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 51
//typedef std::pair<int,int> P;

    ll N;
    ll C[510],S[510],F[510];
    ll ans=INF;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N-1)cin>>C[i]>>S[i]>>F[i];
    REP(i,N){
        ll T=S[i]+C[i];
        DEB(i)DEB(T)END
        for(int j=i+1;j<N-1;j++){
            //DEB(j)
            TF(T<=S[j])
            if(T<=S[j]){
                T=S[j]+C[j];
            }else{
                DEB(T-S[j])DEB(F[j])DEB(S[j])END
                    T=((T-S[j])/F[j]+((T-S[j])%F[j]==0?0:1))*F[j]+S[j]+C[j];
            }
            DEB(j)DEB(T)END
        }
        cout<<T<<endl;
    }
    return 0;
}






//https://youtu.be/m0uWO0ngzbs?t=14m14s


Measured memory_bytes: 256
#include <stdio.h>
int noa(){
	char s[32];
	int a=0,b=0,c=0;
	scanf("%s\n", s);
	for(int i =0;i<strlen(s);i++){
	   // printf("%c[%d][%d][%d]\n",s[i],a,b,c );
		if(s[i] == 'a'){
			a++;
			continue;
		}
		if(s[i] == 'b'){
			b++;
			continue;
		}
		if(s[i] == 'c'){
			c++;
			continue;
		}
	}
	if(a == b && b == c){
		printf("%s\n","Yes" );
		return 0;
	}else{
		printf("%s\n","No" );
		return 0;
	}
}

int main(void){
	// Your code here!
	noa();
	return 0;

}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double a = sc.nextDouble();
double pi = Math.PI;
double area = a*a*pi;
double length = 2*a*pi;
System.out.printf("%f %f\n",area,length);
}
}



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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }

  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template<class T>
inline void read(T&);
template<class T>
inline void write(const T&);

typedef long long ll;
typedef const long long & cll;
typedef const int & ci;
typedef std::pair<int, int> pii;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
using std::min;
using std::max;
using std::abs;
using std::sort;

int main () {
    int n;
    read(n);
    std::string str;
    std::cin >> str;
    int r = 0, b = 0;
    for (int i = 0; i < n; ++i) {
        if (str[i] == 'R') {
            ++r;
        } else {
            ++b;
        }
    }
    puts(r > b ? "Yes" : "No");
    return 0;
}

template<class T>
void read(T &Re) {
    T k = 0;
    char ch = getchar();
    int flag = 1;
    while (!isNum(ch)) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while (isNum(ch)) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    Re = flag * k;
}
template<class T>
void write(const T &Wr) {
    if (Wr < 0) {
        putchar('-');
        write(-Wr);
    } else {
        if (Wr < 10) {
            putchar(Wr + '0');
        } else {
            write(Wr / 10);
            putchar((Wr % 10) + '0');
        }
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,k,i,c=0;
  cin>>n>>k;
  long long int arr[n];
  for(i=0;i<n;i++)
  {
  	cin>>arr[i];
  }
  for(i=0;i<n;i++)
  {
    if(arr[i]>=k)c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll A, B;
  cin >> A >> B;
  cout << max({A - B, A + B, A * B}) << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c;
	cin>>a>>b>>c;
	vector<int> vec;
	vec.push_back(a);
	vec.push_back(b);
	vec.push_back(c);
	sort(vec.begin(), vec.end());
	if(vec[0] == 5 && vec[1] == 5 && vec[2] == 7){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}


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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        sc.close();

        int ans = a - 1;
        if (a <= b) {
            ans++;
        }
        out.printf("%d\n", ans);
        out.flush();
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define TT pair<long long, long long>
#define ordered_set tree<TT, null_type, less<TT>, rb_tree_tag, tree_order_statistics_node_update>
#define fo(i,n)   for(i=0;i<n;i++)
#define mem(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define mp make_pair
#define For(m) for(auto it = m.begin();it!=m.end();it++)
#define fi first
#define se second
typedef long long ll;
typedef long double mytype;
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //priority_queue <int, vector<int>, greater<int> > pq;
    //cout << fixed << setprecision(9) <<ans<<endl;
    //ordered_set os;//os.order_of_key();//os.find_by_order();
    ll l,r,count,n,m,sum=0,ans=0,i,j,k,tt,t,x,y,z,c,a[200005]={},b[200005]={};
    string ss;
    set<ll> s;
    vector<ll> v;
    map<ll,ll> ma;
    cin>>n;
    fo(i,n)
    cin>>a[i];
    fo(i,n)
    ma[i]=ma[i-1]+a[i];
    ll dp[500][500];
    fo(i,500)
    fo(j,500){
        if(i==j)
        dp[i][j]=0;
        else
        dp[i][j]=1e15;
    }
    for(i=1;i<n;i++){
        for(j=0;j<n-i;j++){
            for(k=j;k<j+i;k++){
            dp[j][j+i]=min(dp[j][i+j],dp[j][k]+dp[k+1][j+i]+ma[j+i]-ma[j-1]);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;
 
void testCase() {
    int m, n;
    cin >> m >> n;
    ll sum = 0;
    for (int i=0; i<n; i++) {
        ll v;
        cin >> v;
        sum += v;
    }
    if (sum <= m) {
        cout << m-sum << endl;
    }
    else {
        cout << "-1" << endl;
    }
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

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

int main() {
	string s;
	cin >> s;
	int ans = 0;
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') {
			cnt++;
			ans = max(ans, cnt);
		}
		else cnt = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int m=1000000007;
bool cmp2(int n,pii p)
 {return n<p.f;}
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int a,b,c;
cin>>a>>b>>c;
if(a>c)
{
    a-=c;
    cout<<a<<" "<<b;
    return 0;
}
else
{
    
    c-=a;
    a=0;
    if(c>=b)
    b=0;
    else
    b-=c;
    cout<<a<<" "<<b;
    return 0;
}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
void print(ll x){
	if(x<0)putchar('-'),x=-x;
	int y=x%10+'0';
	if(x>=10)print(x/10);
	putchar(y);
}
ll n,w,dp[100005];
int main(){
	n=read(),w=read();
	for(int i=1;i<=n;i++){
		ll a=read(),b=read();
		for(int j=w;j>=a;j--)
			dp[j]=max(dp[j],dp[j-a]+b);
	}
	print(dp[w]);
	return 0;
}

Measured memory_bytes: 1024
#D
from collections import deque
s=input()
q=int(input())
l=[]
turn=0
ans=deque()
ans.append(s)
for i in range(q):
    query=input().split()
    if query[0]=="1":
        turn+=1
    if query[0]=="2":
        if query[1]=="1":#先頭
            if turn%2==0:#正規
                ans.appendleft(query[2])
            else:#逆
                ans.append(query[2])
        elif query[1]=="2":#末尾
            if turn%2==0:#正規
                ans.append(query[2])
            else:#逆
                ans.appendleft(query[2])
ans="".join(ans)
if turn%2==1:
    ans=ans[::-1]
print(ans)

Measured memory_bytes: 7020
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int X[210], Y[210];

int gcd(int a, int b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll MOD = 998244353;

ll power(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
			res %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return res;
}

int main() {
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 0;i < N;i++) cin >> X[i] >> Y[i];
    set<set<int> > G;
    for (int i = 0;i < N;i++) {
    	map<PP, set<int> > T;
    	for (int j = 0;j < N;j++) {
    		if (i == j) continue;
    		int dx = X[i] - X[j];
    		int dy = Y[i] - Y[j];
    		int k = gcd(abs(dx), abs(dy));
    		dx /= k;
    		dy /= k;
    		if (dx < 0) {
    			dx = -dx;
    			dy = -dy;
    		}
    		if (dx == 0 && dy < 0) dy = -dy;
    		T[make_pair(dx, dy)].insert(j);
    	}
    	for (auto it : T) {
    		if (it.second.size() >= 2) {
    			set<int> q = it.second;
    			q.insert(i);
    			G.insert(q);
    		}
    	}
    }
    ll tol = power(2, N) + MOD - N - 1 - N * (N - 1) / 2;
    tol %= MOD;
    for (auto it : G) {
    	int k = it.size();
    	tol += MOD - (power(2, k) - 1 - k - k * (k - 1) / 2);
    	tol %= MOD; 
    }
    cout << tol << endl;
    return 0;
}

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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  int x;
  cin >> x;
  if(x < 1200) cout << "ABC" << endl;
  else cout << "ARC" << endl; 
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int n;

	scanf("%d", &n);

	long long cnt[10][10] = { 0, };

	for (int i = 1; i <= n; i++)
	{
		int first, last;
		int temp;

		temp = i;

		last = temp % 10;

		while (temp / 10)
		{
			temp /= 10;
		}

		first = temp;

		cnt[first][last]++;
	}

	long long sol = 0;

	for (int i = 1; i <= 9; i++)
	{
		for (int j = 1; j <= 9; j++)
		{
			sol += cnt[i][j] * cnt[j][i];
		}
	}

	printf("%lld\n", sol);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<map>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];
    vector<ll> cumsum(N + 1, 0);
    rep(i, 0, N) {
        cumsum[i + 1] = (cumsum[i] + A[i] - 1 + K) % K;
    }
    map<ll, ll> cnt;
    ++cnt[cumsum[0]];
    ll ans = 0;
    rep(i, 1, N + 1) {
        if (i - K >= 0) {
            --cnt[cumsum[i - K]];
        }
        ans += cnt[cumsum[i]];
        ++cnt[cumsum[i]];
    }
    cout << ans << endl;
    return 0;
}

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

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

    vector<int> vec(N);
    rep(i, N)
    {
        cin >> vec[i];
        //        cout << vec[i] << endl;
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    int Alice = 0;
    int Bob = 0;

    rep(i, N)
    {
        if (i % 2 == 0)
        {
            Alice += vec[i];
        }
        else
        {
            Bob += vec[i];
        }
    }
    cout << Alice - Bob << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;

int main() {_
ll a,b,c,k,tmp=0;
cin >> a >> b >> c >> k ;
if(k%2!=0){
    tmp=b+c;
    b=a+c;
    a=tmp;
}
cout << a-b ;

}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
 
N = INT()
if N%2:
	print(0)
	exit()

ans = 0
i = 1
while 1:
	if 2*5**i <= N:
		ans += N //(2*5**i)
		i += 1
	else:
		break
print(ans)


Measured memory_bytes: 5712
#include <stdio.h>
int main(void){
    int A[1000][999], N, days = 0, impo = 0;
    int count[1000] = {}, endsum = 0;
    
    scanf("%d\n",&N);
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N-1; j++)
        {
            scanf("%d",&A[i][j]);
        }
    }
    
    while(impo == 0 && endsum < N)
    {
        days++;
        int flag[1000] = {};
        impo = 1;
        for(int i = 0; i < N; i++)
        {
            if(flag[i] == 0 && count[i] < N-1)
            {
                int aite = A[i][count[i]];
                //printf("aite is %d\n",aite);
                //printf("aite loves %d\n",A[aite-1][count[aite-1]]);
                if(A[aite-1][count[aite-1]] == i+1 && flag[aite-1] == 0)
                {
                    //printf("authorize [%d, %d]\n",i+1,aite);
                    impo = 0;
                    flag[i] = 1;
                    if(++count[i] == N-1)
                    {
                        //printf("%d ended\n", i+1);
                        endsum++;
                    }
                    flag[aite-1] = 1; 
                    if(++count[aite-1] == N-1)
                    {
                        //printf("%d ended\n", aite);
                        endsum++;
                    }
                } 
            }
        }
    }
    
    printf("%d\n",(impo==1)? -1:days);
}


Measured memory_bytes: 4096
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define pred(x) ((x)-1)
#define succ(x) ((x)+1)
#define True    1
#define False   0
//#define max(x,y) (((x)<(y))?y:x)
//============================================================================
#define MAX_BUFFER  102
struct graph{
    unsigned char node;
    unsigned char hands;
    unsigned char first;
    unsigned char last;
    short    d;
    struct graph **gary;
};
typedef struct graph TGraph;
//============================================================================
unsigned char Ybuffer[MAX_BUFFER];
char Zbuffer[MAX_BUFFER][MAX_BUFFER];
short Stamp;
//============================================================================
void prnnode(TGraph *gptr)
{
    short j;

    printf("node=%d, hands=%d, ", gptr->node, gptr->hands);
    for (j=0; j<gptr->hands; j++)
        printf("%d ", gptr->gary[j]->node);
    printf("\n");
}
//----------------------------------------------------------------------------
void search(TGraph *gptr, short n)
{
    short i;

#ifdef DESKTOP
    prnnode(gptr);
#endif
    if (gptr->d<0 || n<gptr->d){
        gptr->d=n;
    }
    for (i=0; i<gptr->hands; i++){
        if (gptr->gary[i]->d<0 || n<gptr->gary[i]->d)
            search(gptr->gary[i], succ(n));
    }
}
//----------------------------------------------------------------------------
void input(FILE *file)
{
    short i,j,n,k,u,c,d; char buffer[20]; TGraph *graphary,*gptr;

    fgets(buffer, sizeof(buffer)-1, file);
    sscanf(buffer, "%d", &n);
    graphary=malloc(n*sizeof(TGraph));
    memset(graphary, 0, sizeof(TGraph));
    for (i=Stamp=0; i<n; i++){
        fscanf(file, "%hd", &u);
        fscanf(file, "%hd", &k);
        gptr=&graphary[pred(u)];
        gptr->node=u;
        gptr->hands=k;
        gptr->d=-1;
        gptr->gary=malloc(k*sizeof(TGraph*));
        for (j=0; j<k; j++){
            fscanf(file,"%hd", &c);
            gptr->gary[j]=&graphary[pred(c)];
        }
    }
#ifdef DESKTOP
    for (i=0; i<n; i++){
        prnnode(&graphary[i]);
    }
#endif
    search(graphary, 0);
    for (i=0; i<n; i++){
        gptr=&graphary[i];
        if (gptr->node)
            printf("%d %d\n", gptr->node, gptr->d);
    }

}
//============================================================================
#ifndef DESKTOP
int main()
{
    input(stdin);
    return 0;
}
#endif

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;


int main() {

int N;
cin>>N;
ll A[N];
rep(i,N){
    cin>>A[i];
}
ll sum=0;
ll count=0;
int right=0;
rep(left,N){
    while((right<N)&&(sum+A[right])==(sum^A[right])){
        sum+=A[right];
        
        right++;
    }
    count+=right-left;
    if(right==left)right++;
    else{
        sum-=A[left];
   
    }
}
cout<<count<<endl;
return 0;
}

Measured memory_bytes: 1792