akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int MOD = 998244353;
const int MAXN = 10000005;

long long modpow(long long a, long long p){
	if(p == 0)return 1;
	if(p % 2 == 1)return a * modpow(a, p - 1) % MOD;
	
	long long r = modpow(a, p / 2);
	return r * r % MOD;
}
long long modinv(long long a){
	return modpow(a, MOD - 2);
}

int N;
long long fact[MAXN], invfact[MAXN];

long long C(int n, int r){
	return fact[n] * invfact[r] % MOD * invfact[n - r] % MOD;
}

int main(){	
	scanf("%d", &N);
	
	for(int i = 0; i <= N; i++){
		if(i == 0)fact[i] = 1;
		else fact[i] = i * fact[i - 1] % MOD;
	}
	
	for(int i = N; i >= 0; i--){
		if(i == N)invfact[i] = modinv(fact[i]);
		else invfact[i] = (i + 1) * invfact[i + 1] % MOD;
	}
	
	long long res = 0, cur = 1;
	for(int c = 0; c <= N; c++){
		res = (res + cur * C(N, c)) % MOD;
		
		if(c < N){
			cur = cur * 2 % MOD;
			if(c >= N / 2)cur = (cur - 2 * C(c, N / 2) + 2LL * MOD) % MOD;
		}
	}
	
	printf("%lld\n", res);
	
	return 0;
}


Measured memory_bytes: 156544
N = int(input())
lis1 = list(map(int,input().split()))
lis2 = list(map(int,input().split()))

sum1 = 0
sum2 = sum(lis2)
sum = 0

for j in range(N):
    sum1 += lis1[j]
    if not j == 0:
        sum2 -= lis2[j-1]
    if sum <= sum1 + sum2:
        sum = sum1 + sum2


print(sum)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define MAX   400400
#define FOR(i,a,b) for (int i=(a),_b=(b);i<=_b;i=i+1)
#define FORD(i,b,a) for (int i=(b),_a=(a);i>=_a;i=i-1)
#define REP(i,n) for (int i=0,_n=(n);i<_n;i=i+1)
#define FORE(i,v) for (__typeof((v).begin()) i=(v).begin();i!=(v).end();i++)
#define ALL(v) (v).begin(),(v).end()
#define fi   first
#define se   second
#define MASK(i) (1LL<<(i))
#define BIT(x,i) (((x)>>(i))&1)
#define div   ___div
#define next   ___next
#define prev   ___prev
#define left   ___left
#define right   ___right
#define __builtin_popcount __builtin_popcountll
using namespace std;
template<class X,class Y>
    void minimize(X &x,const Y &y) {
        if (x>y) x=y;
    }
template<class X,class Y>
    void maximize(X &x,const Y &y) {
        if (x<y) x=y;
    }
template<class T>
    T Abs(const T &x) {
        return (x<0?-x:x);
    }

/* Author: Van Hanh Pham - skyvn97 */

/** END OF TEMPLATE - ACTUAL SOLUTION COMES HERE **/

char input[MAX];
string readString(void) {
    scanf("%s", input);
    return string(input);
}

struct Node {
     int cnt;
     bool haveString;
     Node* child[26];

     Node() {
        cnt = 0;
        haveString = false;
        REP(i, 26) child[i] = NULL;
     }
};

struct Query {
    int pos, answer, id;
    string perm;
    Query() {
        pos = answer = id = 0;
    }
    void input(int id) {
        this->id = id;
        scanf("%d", &pos);
        perm = readString();
    }
};
/*** LOOK AT MY CODE. MY CODE IS AMAZING :D ***/

Node* root;
Query queries[MAX];
vector<int> queriesAt[MAX];
int numStrings, numQueries;
int numPrefix[MAX];
string str[MAX];

void init(void) {
    scanf("%d", &numStrings);
    FOR(i, 1, numStrings) str[i] = readString();
    scanf("%d", &numQueries);
    FOR(i, 1, numQueries) queries[i].input(i);
}

int addString(const string &s) {
    int res = 0;
    Node *p = root;
    FORE(it, s) {
        if (p->child[*it - 'a'] == NULL) p->child[*it - 'a'] = new Node();
        p = p->child[*it - 'a'];
        p->cnt++;
        if (p->haveString) res++;
    }
    p->haveString = true;
    return res;
}

int cnt[30][30];
void answerQueries(int strID) {
    memset(cnt, 0, sizeof cnt);

    Node *p = root;
    FORE(it, str[strID]) {
        int j = *it - 'a';
        REP(i, 26) if (i != j && p->child[i] != NULL) cnt[j][i] += p->child[i]->cnt;
        p = p->child[j];
    }

    FORE(it, queriesAt[strID]) {
        int id = *it;
        queries[id].answer = numPrefix[strID] + 1;
        string &perm = queries[id].perm;
        REP(i, 26) FOR(j, i + 1, 25) queries[id].answer += cnt[perm[j] - 'a'][perm[i] - 'a'];
    }
}

bool CompLength(const int &a, const int &b) {
    return str[a].size() < str[b].size();
}
void process(void) {
    root = new Node();
    vector<int> strIDs;
    FOR(i, 1, numStrings) strIDs.push_back(i);
    sort(ALL(strIDs), CompLength);
    FORE(it, strIDs) numPrefix[*it] = addString(str[*it]);


    FOR(i, 1, numQueries) queriesAt[queries[i].pos].push_back(i);
    FOR(i, 1, numStrings) answerQueries(i);
    FOR(i, 1, numQueries) printf("%d\n", queries[i].answer);
}

int main(void) {
    init();
    process();
    return 0;
}


Measured memory_bytes: 117376
#include<iostream>
using namespace std;
int main()
{
    int n,c;
    cin>> n;
    int ara[n];
    for(int i=0;i<n;i++)
    {
        ara[i]=0;
    }
    for(int i=0;i<n-1;i++)
    {
        cin>> c;
        ara[c-1]++;
    }
    for(int i=0;i<n;i++)
    {
        cout << ara[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vpl vector<pair<long long,long long>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
long long MOD = 1000000007;
const long double pi = 3.1415926535897932;
#define pb push_back
#define mp make_pair
#define mt make_tuple
//(mod m)でのaの逆元を計算する
//a/b(mod m)=a(mod m)*modinv(b,m)
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N;
    cin>>N;
    vl X(N);
    rep(i,N)cin>>X[i];
    ll min=INF;
    rep2(i,1,101){
        ll res=0;
        rep(j,N){
            res+=(X[j]-i)*(X[j]-i);
        }
        chmin(min,res);
    }
    cout<<min<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> A(N);
    rep(i, N) cin >> A.at(i);

    int cnt = X;
    rep(i, N) {
        int j = 0;
        while(true) {
            int day;
            day = 1 + A.at(i) * j;
            if(day <= D) {
                cnt++;
                j++;
            } else {
                break;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{

	public static void main(String[] args) {
		Scanner hoge = new Scanner(System.in);

		int a = hoge.nextInt();
		int b = hoge.nextInt();
		int c = hoge.nextInt();
		
		if(a < b && b < c) System.out.println("Yes");
		else System.out.println("No");

		

	}


}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> h(n,0);
	vector<int> dp(n,0);

	for(int i=0; i<n; i++){
		cin >> h[i];
	}

	// 初期化
	dp[0] = 0;

	for(int i=1; i<n; i++){
		if (i == 1){
			dp[i] = abs(h[i]-h[i-1]);
		}else{
			dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
		}
	}

	cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
s = input()
k = int(input())

n = len(s)
if n == 1:
    print(k // 2)
    exit()

i = 0
while s[i] == s[i+1]:
    i += 1
    if i == n-1:
        print(n * k // 2)
        exit()

mode = 0
count = 0
ans = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        if mode == 0:
            count = 2
            mode = 1
        else:
            count += 1
    elif mode == 1:
        mode = 0
        ans += count // 2
        count = 0

if mode == 1:
    ans += count // 2

ans *= k

if s[0] == s[-1]:
    a = 1
    while s[a-1] == s[a]:
        a += 1
    b = n-1
    while s[b-1] == s[b]:
        b -= 1
    b = n - b
    ans -= ((a//2) + (b//2) - ((a+b) // 2))*(k-1)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  scanf("%d",&n);
  char a[10];
  int c0=0,c1=0,c2=0,c3=0;
  while(n--){
    scanf("%s",&a);
    if (a[0]=='A'){
      c0++;
    }
    else if (a[0]=='W'){
      c1++;
    }
    else if (a[0]=='T'){
      c2++;
    }
    else if (a[0]=='R'){
      c3++;
    }
  }
  printf("AC x %d\n",c0);
  printf("WA x %d\n",c1);
  printf("TLE x %d\n",c2);
  printf("RE x %d\n",c3);
}


Measured memory_bytes: 3784
#include <iostream>
#include <queue>
#include <string>
#include <map>
using namespace std;

struct worm{
	int c;
	string s;
};
queue<worm> que;
bool str_check(string str){
	for(int i = 1;i < str.size();++i){
		if(str[0] != str[i]) return false;
	}
	return true;
}
int f(){
	map<string,int> check;
	while(que.size()){
		worm w = que.front(),tmp;
		que.pop();
		int n = w.c;
		string str = w.s;
		if(str_check(str)){
			return n;
		}
		for(int i = 0;i < str.size() - 1;++i){
			if(str[i] != str[i+1]){
				if((str[i] == 'r' && str[i+1] == 'b') || (str[i] == 'b' && str[i+1] == 'r')){
					str[i] = str[i+1] = 'g';
				}
				else if((str[i] == 'g' && str[i+1] == 'b') || (str[i] == 'b' && str[i+1] == 'g')){
					str[i] = str[i+1] = 'r';
				}
				else {
					str[i] = str[i+1] = 'b';
				}

				if(!check.count(str)){
					tmp.s = str;
					tmp.c = n + 1;
					que.push(tmp);
					check[str] = n + 1;
				}
				str = w.s;
			}
		}
	}
	return -1;
}
int main(){
	string str;
	worm w;
	while(cin >> str){
		if(str == "0") break;
		w.s = str;
		w.c = 0;
		que.push(w);
		int n = f();
		if(n == -1) cout << "NA\n";
		else cout << n << endl;
		while(que.size()){
			que.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#include<stdlib.h>


int ASCttenannoryaku(const void *a,const void *b) {
	return *(int *)a - *(int *)b;
}
int main(void)
{
	int n, a;
	scanf("%d""%d",&n,&a);
	if (n < 10)
		a = a + 100 * (10 - n);

	printf("%d",a);
	return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> eastList = new ArrayList<>();
		char[] actionArr = {'N', 'E', 'S', 'W'};
		Random random = new Random();
		try {
			String[] diceNumber = br.readLine().split("\\s");
			Dice01 dice01 = new Dice01(diceNumber);
			int q = Integer.parseInt(br.readLine());
			for (int i = 0; i < q; i++) {
				String[] topAndSouth = br.readLine().split("\\s");
				while(true) {
					
					dice01.rollDice(actionArr[random.nextInt(4)], diceNumber.length);
					if (dice01.takeTopNumber() == Integer.parseInt(topAndSouth[0])
							&& dice01.takeSouthNumber() == Integer.parseInt(topAndSouth[1])) {
						eastList.add(dice01.takeEastNumber());
						break;
					}
				}
			}
			for (int east: eastList) {
				System.out.println(east);
			}
			
		} catch (NumberFormatException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
}


class Dice01 {
	private int number[];
	private int work[];

	public Dice01() {

	}

	public Dice01(String[] args) {
		number = new int[args.length];
		work = new int[args.length];
		// サイコロの初期化
		for (int i = 0; i < args.length; i++) {
			number[i] = Integer.parseInt(args[i]);
		}
	}

	public void rollDice(char action, int num) {
		for (int i = 0; i < num; i++) {
			this.work[i] = this.number[i];
		}

		switch (action) {
		case 'E':
			// West→Top, South→South, Top→East, Bottm→West, North→North, East→Bottom
			setNumber(work[3], work[1], work[0], work[5], work[4], work[2]);
			break;
		case 'N':
			// South→Top, Bottom→South, East→East, West→West, Top→Nouth, Nouth→Bottom
			setNumber(work[1], work[5], work[2], work[3], work[0], work[4]);
			break;
		case 'S':
			// North→Top, Top→South, East→East, West→West, Bottom→North, South→Bottom
			setNumber(work[4], work[0], work[2], work[3], work[5], work[1]);
			break;
		case 'W':
			// East→Top, South→South, Bottom→East, Top→West, North→North, West→Bottom
			setNumber(work[2], work[1], work[5], work[0], work[4], work[3]);
			break;
		default :
			break;
		}
	}

	public void setNumber(int n1, int n2, int n3, int n4, int n5, int n6) {
		this.number[0] = n1;
		this.number[1] = n2;
		this.number[2] = n3;
		this.number[3] = n4;
		this.number[4] = n5;
		this.number[5] = n6;
	}

	public int takeTopNumber() {
		return this.number[0];
	}
	
	public int takeSouthNumber() {
		return this.number[1];
	}
	
	public int takeEastNumber() {
		return this.number[2];
	}
}




Measured memory_bytes: 24756
### main

loop do
  exp = gets.strip
  break if exp == '#'

  cls = exp.split('|').map{|cl| cl.delete('()').split('&')}
  #p cls

  result = false

  for cl in cls
    clok = true

    for i in (0..1)
      ci = cl[i]
      for j in ((i + 1)..2)
        cj = cl[j]
        if ci == '~' + cj || cj == '~' + ci
          clok = false
          break
        end
      end
      break if ! clok
    end

    if clok
      result = true
      break
    end
  end

  puts (result ? 'yes' : 'no')
end

Measured memory_bytes: 6120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = (int)s.length();
	if (n < 26) {
		for (char c = 'a'; c <= 'z'; ++c) {
			if (s.find(c) == string::npos) {
				cout << s << c << endl;
				return 0;
			}
		}
	}
	else {
		for (int i = n - 2; i >= 0; --i) {
			if (s[i] < s[i + 1]) {
				char best = s[i + 1];
				for (int j = i + 1; j < n; ++j) {
					if (s[j] > s[i]) {
						best = min(best, s[j]);
					}
				}
				s[i] = best;
				s = s.substr(0, i + 1);
				cout << s << endl;
				return 0;
			}
		}
		dunk(-1);
	}
	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 n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		
		
		String ans = "APPROVED";
		for(int i = 0 ; i < n ; i++) {
			a[i] = Integer.parseInt(sc.next());
			
			if(a[i] % 2 == 0 ) {
				
				if(a[i] % 3 != 0 && a[i] % 5 != 0) {
					ans = "DENIED";	
				} 
				
				
			}
			
			
		}
		
		System.out.println(ans);
	}



}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
 
 
#define rep(i,n,m) for(int i=n;i<m;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define desc_sort(v) sort(v.rbegin(),v.rend())
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define M 1000000007 
#define pushll(head,d) push_into_linkedlist(&head,d)
#define popll(head) dp_delete_first(&head)
#define eol cout<<"\n"
#define N 1000000
#define int long long
 
typedef long long ll;
 
 
ll zero=0,one=0,two=0;
string s;
vector<int> v;
int n,q;
void input()
{
	cin>>n;
}


void  solve()
{
    v.pb(1);
    v.pb(1);
    v.pb(1);
    v.pb(2);
    v.pb(1);
    v.pb(2);
    v.pb(1);
    v.pb(5);
    v.pb(2);
    v.pb(2);
    v.pb(1);
    v.pb(5);
    v.pb(1);
    v.pb(2);
    v.pb(1);
    v.pb(14);
    v.pb(1);
    v.pb(5);
    v.pb(1);
    v.pb(5);
    v.pb(2);
    v.pb(2);
    v.pb(1);
    v.pb(15);
    v.pb(2);
    v.pb(2);
    v.pb(5);
    v.pb(4);
    v.pb(1);
    v.pb(4);
    v.pb(1);
    v.pb(51);
    cout<<v[n-1];
    
}
 
 
signed main()
{   
    ios
    int T=1;
    // cin>>T;
    while(T--)
    {
		input();
// 		for(int i=0;i<q;i++)
		solve();
// 		cout<<endl;
 
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
using pll = pair<ll,ll>;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1000000007;

int main(){
    int R,G,B,n;
    cin >> R >> G >> B >> n;
    int ans = 0;
    for(int i=0;i*R<=n;i++){
        for(int j=0;j*G<=n;j++){
            if( n - R*i - j*G < 0) continue;
            if((n-R*i-j*G)%B == 0) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin>>n;

  vll a(n),b(n),c(n),d(n);
  REP(i,n)cin>>a[i]>>b[i];
  REP(i,n)cin>>c[i]>>d[i];

  vpl ba(n),dc(n);
  REP(i,n){
    ba[i].FI=b[i];
    ba[i].SE=a[i];
  }
  sort(ALL(ba),greater<pll>());

  set<pll> s;
  REP(i,n)s.insert(pll(d[i],c[i]));

  ll ans=0;
  REP(i,n){
    auto it=s.begin();
    pll p=pll(LLINF,LLINF);
    while(it!=s.end()){
      pll now=*it;
      if(now.SE>ba[i].SE && now.FI>ba[i].FI){
        if(now.SE<p.SE)
          p=now;
      }
      it++;
    }
    if(p!=pll(LLINF,LLINF)){
      s.erase(p);
      ans++;
    }
  }

  cout<<ans<<endl;



}



Measured memory_bytes: 3664
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 998244353;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj,n,m,a,b,c,d,e,f,g,h,r,w,l,num,ans,ok,ng,mid;
ll x[500005],y[500005],z[500005];
ll dp[5050][5005];
ll sum[305];

char s[500005],t[500005],u[500005];
bool dame,flag;
//string s;

int main(){
	cin >> s;
	n = strlen(s);
	ll r=0,b=0;
	ll rsum[5000],bsum[45000];
	for(i=0;i<n;i++){
		if(s[i] == '2'){
			b += 2;
		}else if(s[i] == '1'){
			r += 1;
			b += 1;
		}else{
			r += 2;
		}
		rsum[i+1] = r;
		bsum[i+1] = b;
	}
	for(i=n;i<n*2;i++){
		rsum[i+1] = r;
		bsum[i+1] = b;
	}
	dp[0][0] = 1;
	for(i=0;i<=r;i++){
		for(j=0;j<=b;j++){
			if(i+j == 0)continue;
			if(rsum[i+j] >= i && i >= 1){
				dp[i][j] += dp[i-1][j];
			}
			if(bsum[i+j] >= j && j >= 1){
				dp[i][j] += dp[i][j-1];
			}
			dp[i][j] %= mod;
			//pe(dp[i][j]);
		}
		//el;
	}
	p(dp[r][b]);
	return 0;
}

Measured memory_bytes: 183296
if __name__ == "__main__":
    N = int(input())
    A = [int(x) for x in input().split(" ")]
    A.sort(reverse=True)
    al = 0
    bob = 0
    for i, a in enumerate(A):
        if i % 2 == 0:
            al += a
        else:
            bob += a
    print(al - bob)


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, ans[9] = {111, 222, 333, 444, 555, 666, 777, 888, 999};
    cin >> N;
    cout << *lower_bound(ans, ans + 9, N) << endl;
    return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> l = {a, b, c};
    sort(l.begin(), l.end());
    l.erase(unique(l.begin(), l.end()), l.end());
    cout << l.size() << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main{

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      int[][][] rooms = new int[4][3][10];
      for( int i = 0; i < 4; i++ ) {
        for( int j = 0; j < 3; j++ ) {
          Arrays.fill(rooms[i][j], 0);
        }
      }
      String[] lines = br.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int b,f,r,v;

      for(int i = 0; i < n; i++) {
        lines = br.readLine().split(" ");
        b = Integer.parseInt(lines[0]) - 1;
        f = Integer.parseInt(lines[1]) - 1;
        r = Integer.parseInt(lines[2]) - 1;
        v = Integer.parseInt(lines[3]);
        rooms[b][f][r] += v;
      }

      StringBuilder result = new StringBuilder(400);
      String sep = "####################\n";
      for(int i = 0; i < 4; i++ ) {
        for( int j = 0; j < 3; j++ ) {
          for( int k = 0; k < 10; k++ ){
            result.append(" " +rooms[i][j][k]);
          }
          result.append("\n");
        }
        if( i != 3) result.append(sep);
      }
      System.out.print(result);
    }
  }
}


Measured memory_bytes: 24332
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S,T;
    cin >> S >> T;
    int len = S.length();
    bool f = false;
    char s[len];
    for(int i = 0; i < len; i++){
        if(S.compare(T) == 0){f = true; break;}
        S = S.back()+S.substr(0,len-1);
    }
    cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
n = int(input())
A= list(map(int, input().split()))

mod = int(1e9+7)
def invmod(a, mod):
    if a==1:
        return 1
    return -invmod(mod%a, mod) * (mod//a) %mod


memo={}
for i, a in enumerate(A):
  if a in memo:
    L = memo[a]
    C = i - memo[a] -1
    R = len(A) - i-1
    break
  else:
    memo[a] = i
    
#print(L,C,R)
_LR = [0]*(n+3)
_LCR = [0] * (n+3) # _LCR[k] = (L+C+R)C(k)
_k = [0] * (n+3)
_LR[0] = _LCR[0] = _k[0] = 1

LR = [0]*(n+2) #LR[k] = (L+R)C(k)
LR[0] = 1
#LDR = [0]*(n+2)
#LDDR = [0]*(n+2)

LCR = [0] * (n+2) # LCR[k] = _LCR[k] - LR[k]
#LDCR = [0] * (n+2) #最後に*2を忘れないこと
#LDCDR = [0] * (n+2)

for k in range(1,n+2):
  _LR[k] = (_LR[k-1] * (L+R+1-k)) %mod
  _LCR[k] = (_LCR[k-1] * (L+C+R+1-k))% mod
  _k[k] = (_k[k-1] * invmod(k,mod)) %mod
  
  LR[k] = (_LR[k] * _k[k])%mod
#  LDR[k] = LR[k-1]
#  LDDR[k] = LDR[k-1]
  
  LCR[k] = (_LCR[k] * _k[k])%mod - LR[k]
#  LDCR[k] = LCR[k-1]
#  LDCDR[k] = LDCR[k-1]
  #print(LR, LCR)
  print((LR[k] + LR[k-1] + LR[k-2] + LCR[k] + 2*LCR[k-1] + LCR[k-2])%mod)
  
#print(LR)
#print(LDR)
#print(LDDR)
#print(_LCR)
#print(LCR)
#print(LDCR)
#print(LDCDR)

Measured memory_bytes: 31328
N, M = map(int, input().split())
ans = 0

#Sが全部使える場合
if 2*N <= M:
    ans += N
    M -= 2*N
    #余ったCの取り扱い。Mが4個でSccを一個作れる。
    ans += M//4

#Cが足りないのでSを全部使えない場合
else:
    ans += M//2

print(ans)


Measured memory_bytes: 2940
n, = map(int, input().strip().split())

# a5 - b5 = (a-b)(a4 + a3b + a2b2 + ab3 + b4)

def check(x):
  for a in range(200):
    b = a - x
    c = a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4
    d = x * c
    if d == n:
      return [a, b]
  return None

for i in range(1, n+1):
  res = check(i)
  if res:
    break

r1, r2 = res
print(r1, r2)

Measured memory_bytes: 9084
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	k := iScan()
	fmt.Println(n - k + 1)
}


Measured memory_bytes: 1772
N = int(input())
H = list(map(int, input().split()))

def ok(H, i):
    for j in range(0,i):
        #print(i, j, H[i], H[j])
        if H[i] < H[j]:
            #print("out")
            return 0
    return 1

    
cnt = 1
for i in range(1, N):
    cnt += ok(H, i)

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
typedef long long               ll;
typedef long double             ld;
 
 
#define racecar          ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define si(a)            scanf("%d", &a)
#define si2(a,b)         scanf("%d %d", &a,&b)
#define sll(a)           scanf("%I64d",&a)
#define sll2(a,b)        scanf("%I64d %I64d",&a,&b)
#define pb               push_back
#define pi(a)            printf("%d",int(a))
#define pll(a)           printf("%I64d",ll(a))
#define all(x)           (x).begin(),(x).end()
#define rall(x)          (x).rbegin(),(x).rend()
#define ps               printf(" ")
#define nln              printf("\n")
#define ff               first
#define ss               second
#define vi               vector<int>
#define vll              vector<ll>
#define vstr             vector<string>
#define vc               vector<char>
#define pii              pair<int,int>
#define PLL              pair<ll,ll>
#define PI               acos(-1)
#define sq(x)            x*x
#define forr(i,a,b)      for(ll i=ll(a);i<ll(b);i++)
#define forn(i,a,b)      for(ll i=ll(a);i>ll(b);i--)
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(max3(a,b,c),d)
#define min3(a,b,c)      min(a,min(b,c))
#define mod              1000000007
#define inf              9223372036854775807

///knight moves:
///int dx[] = {-2, -1, 1, 2, -2, -1, 1, 2}; 
///int dy[] = {-1, -2, -2, -1, 1, 2, 2, 1};

 
ll power(ll b,ll n)
{
    if(n==0) return 1;
    else if(n%2) return b*power(b,n/2)*power(b,n/2);
    else return power(b,n/2)*power(b,n/2);
}
 
ld root(ll n,ll r)
{
    ld dif=0.0001;
    ld guess=n/2.0;
    while(abs(pow(guess,r)-n)>=dif)
    {
        ld temp=pow(guess,r)-n;
        ld tmp=r*pow(guess,r-1);
        guess-=temp/tmp;
    }
    return guess;
}
 
void fileio()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

map<char,int>m;

		
int solve()
{
    ll r;
    sll(r);
    pll(3*r*r);
		
	return 0;
}
	
 
int main()
{   
 
//    racecar;
//    cout<<fixed<<setprecision(6);
//    fileio();
    solve();
}

 
 
///    Before submission=>
///    ***check for integer overflow,array bounds
///    ***check for n


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
# define INF 0x3f3f3f3f
#define MOD 1000000007
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d%d",&x,&y)
#define siii(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d%d",x,y)
#define piii(x,y,z) printf("%d%d%d",x,y,z) 
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld%lld",&x,&y)
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld%lld",x,y)
#define plll(x,y,z) printf("%lld%lld%lld",x,y,z) 
 
#define ll long long
#define mp make_pair
#define pb push_back
#define pp pop_back
#define nl printf("\n");
#define sf scanf
#define pf printf
#define rep(i,n) for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define tci int t;scanf("%d",&t);while(t--)
const int maxn=10e6+4;

int main()
{
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

    int a,b;
    sii(a,b);

    int p= (b-a)*2;
    cout<<a+p;


    return 0;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    sort(a.begin(), a.end());
    int ans = 1;
    rep(i, n-1) if(a.at(i) != a.at(i+1)) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict
    # from collections import deque
    # from collections import Counter
    import numpy as np
    # import math
    # import random
    input = stdin.readline


    n, m, x = map(int, input().split())
    cc = [0]*n
    aa = [0]*n
    for i in range(n):
        c, *a = map(int, input().split())
        cc[i] = c
        aa[i] = np.array(a)
    ans = sum(cc)+1
    for i in range(2**n):
        understand = np.array([0]*m)
        total = 0
        for j in range(n):
            if ((i >> j) & 1):
                understand += aa[j]
                total += cc[j]
        if (understand>=x).all() and ans > total:
            ans = total
    if ans == sum(cc)+1:
        print('-1')
    else:
        print(ans)


Measured memory_bytes: 27344
n,m = map(int,input().split())
s = input()
dp = [0]*(n+1)
r = n

for i in range(n-1,-1,-1):
    if int(s[i]) == 1:
        dp[i] = -1
        continue
    while r > i+m:r-=1
    while dp[r] == -1:r -= 1
    if r == i:
        print(-1)
        exit(0)
    dp[i] = dp[r]+1
now = 0
ans = []
for i in range(n+1):
    if dp[i] == -1:continue
    if dp[i] != dp[now]:
        ans.append(i-now)
        now = i
print(*ans)
        
    
    

Measured memory_bytes: 10232
import scala.io.StdIn._

object Main {
  def main(args: Array[String]) {
    def combinationCount(input: String): Unit = {
      if(input != "0 0") {
        val Array(toNum, sumNum) = input.split(" ").map(_.toInt)
        var combinationNum = 0
        for (i <- 1 until toNum - 1;
             j <- i + 1 until toNum;
             k <- j + 1 to toNum; if i + j + k == sumNum) combinationNum += 1
        println(combinationNum)
        combinationCount(readLine())
      }
    }

    combinationCount(readLine())
  }
}

Measured memory_bytes: 56312
A, B,C,D = map(int, input().split())
m = C//B+1 if C%B!=0 else C//B
n = A//D+1 if A%D!=0 else A//D
while A>0:
  C -= B
  if C<=0:
    print('Yes')
    break
  A -= D
else:
  print('No')

Measured memory_bytes: 61628
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#define INF 100000000000000
using namespace std;

int main() {
    double r;
    cin >> r;
    printf("%.8lf %.8lf\n", r*r*M_PI, 2*r*M_PI);
    return 0;
}




Measured memory_bytes: 3296
#include<stdio.h>

//関数プロトタイプ宣言
void diceRoll(int *d,char *r);

int main(){
	int dice[6];	//サイコロ
	char roll[101];	//命令を表す文字列
	
	for(int i = 0;i < 6;i++){
		scanf("%d",&dice[i]);
	}
	
	scanf("%s",roll);
	
	diceRoll(dice,roll);
	
	printf("%d\n",dice[0]);
	
	return 0;
}

void diceRoll(int *d,char *r){
	int x;	//入れ替え用変数
	for(int i = 0;r[i] != '\0';i++){
		switch(r[i]){
			case 'E':
				x = d[0];
				d[0] = d[3];
				d[3] = d[5];
				d[5] = d[2];
				d[2] = x;
				break;
			case 'N':
				x = d[0];
				d[0] = d[1];
				d[1] = d[5];
				d[5] = d[4];
				d[4] = x;
				break;
			case 'S':
				x = d[0];
				d[0] = d[4];
				d[4] = d[5];
				d[5] = d[1];
				d[1] = x;
				break;
			case 'W':
				x = d[0];
				d[0] = d[2];
				d[2] = d[5];
				d[5] = d[3];
				d[3] = x;
				break;
		}
	}
}



Measured memory_bytes: 2088
import sys

input = sys.stdin.readline


def main():
    a = [int(x) for x in input().split()]
    a.sort()

    ans = -(-(a[1] - a[0]) // 2)
    ans += a[2] - a[1]
    if (a[1] - a[0]) & 1:
        ans += 1

    print(ans)


    
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <queue>
#include <utility>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}
bool intersectSS(const L& a, const L& b){
    return ( ccw(a[0],a[1],b[0]) *ccw(a[0],a[1],b[1]) <= 0 ) &&
        ( ccw(b[0],b[1],a[0]) *ccw(b[0],b[1],a[1]) <= 0 );
}

int main(){
    int na, nb;
    cin >> na >> nb;
    VP a(na), b(nb);
    for(int i=0; i<na; i++){
        int x,y;
        cin >> x >> y;
        a[i] = P(x,y);
    }
    for(int i=0; i<nb; i++){
        int x,y;
        cin >> x >> y;
        b[i] = P(x,y);
    }

    double ans = INF;
    for(int r=0; r<2; r++){
        priority_queue<pair<double, int> > wait;
        wait.push(make_pair(0, 0));
        vector<double> mindist(na, INF);
        mindist[0] = 0;
        while(!wait.empty()){
            int pos = wait.top().second;
            double dist = -wait.top().first;
            wait.pop();
            if(dist > mindist[pos] +EPS) continue;
            if(pos==1){
                ans = min(ans, dist +abs(b[1]-b[0]));
                break;
            }
            for(int i=0; i<na; i++){
                if(i==pos || intersectSS(L(a[pos], a[i]), L(b[0], b[1]))) continue;
                double ndist = dist + abs(a[i] -a[pos]);
                if(ndist +EPS < mindist[i]){
                    mindist[i] = ndist;
                    wait.push(make_pair(-ndist, i));
                }
            }
        }
        swap(na, nb);
        swap(a, b);
    }
    if(ans==INF){
        cout << -1 << endl;
    }else{
        cout << fixed;
        cout << setprecision(10);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3408
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

ll n;
ll a[10005];
ll b[10005];

ll sum(ll arr[]);

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

    ll sa = sum(a);
    ll sb = sum(b);

    ll f, s;
    f = s = 0;
    for (ll i = 0; i < n; i++) {
        if (a[i] > b[i]) {
            f += a[i] - b[i];
        }
        else if (a[i] < b[i]) {
            s += (b[i] - a[i] + 1) / 2;
        }
    }

    if (max(f, s) <= sb - sa) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

ll sum(ll arr[]) {
    ll a = 0;
    for (int i = 0; i < n; i++) a += arr[i];
    return a;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int n;
int k ; 
long long arr [ 100001 ] ;
long long dp [ 100001 ] ;
long long bus ( int x ) {
  	if ( x >= n - 1  ) return  0 ;
 	if ( dp [ x ] != -1 ) return dp [ x ] ;
  	dp [ x ] =  abs ( arr [ x ] - arr [ x + 1 ] ) + bus ( x + 1 ) ;
  	for ( int i = 2 ; i <= k ; i++ ) { 
      if ( ( x + i ) > n - 1 ) break ; 
      dp [ x ] = min ( dp [ x ] ,   abs ( arr [ x ] - arr [ x + i  ] ) + bus ( x + i ) );
    }
  	return dp [ x ] ;
}
int main ( ) {
  memset ( dp , -1 , sizeof dp ) ;
  cin>>n;
  cin>>k;
  for ( int i = 0 ; i < n ; i++ ) cin >> arr [ i ] ;  
  cout<<bus ( 0 ) <<endl;
}

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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

int main(){

    ll N;

    cin >> N;

    cout << N / 3 << endl;

    return 0;
}

Measured memory_bytes: 256
def examA():
    N = I()
    ans = 0
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    # https://tjkendev.github.io/procon-library/python/string/z-algorithm.html
    def z_algo(S):
        N = len(S)
        A = [0] * N
        i = 1; j = 0
        A[0] = l = len(S)
        while i < l:
            while i + j < l and S[j] == S[i + j]:
                j += 1
            if not j:
                i += 1
                continue
            A[i] = j
            k = 1
            while l - i > k < j - A[k]:
                A[i + k] = A[k]
                k += 1
            i += k; j -= k
        return A
    N = I()
    S = SI()
    ans = 0
    for i in range(N):
        Z = z_algo(S[i:])
        for k,n in enumerate(Z[1:]):
            cur = min(k+1,n)
            ans = max(ans,cur)
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examE()

"""

"""

Measured memory_bytes: 51232
N = int(input())
if N <= 111:
    print(111)
elif N <= 222:
    print(222)
elif N <= 333:
    print(333)
elif N <= 444:
    print(444)
elif N <= 555:
    print(555)
elif N <= 666:
    print(666)
elif N <= 777:
    print(777)
elif N <= 888:
    print(888)
elif N <= 999:
    print(999)


Measured memory_bytes: 3060
class SegmentTree:
    def __init__(self, n, init_value):
        self.n = n
        n2 = 1  # nより大きい2の冪数
        while n2 < n:
            n2 <<= 1
        self.n2 = n2
        self.tree = [[init_value, init_value] for _ in range(n2 << 1)]
        self.ini = init_value

    def update(self, i, x):
        # 注: 同じiへのクエリは複数来ないことを利用して単純化
        i += self.n2
        self.tree[i][0] = x
        while i > 1:
            i >>= 1
            sti = self.tree[i]
            if sti[0] > x:
                sti[1] = sti[0]
                sti[0] = x
            elif sti[1] > x:
                sti[1] = x

    def get(self, a, b):
        result = [self.ini, self.ini]
        q = [(1, 0, self.n2)]

        while q:
            k, l, r = q.pop()

            if a <= l and r <= b:
                stk = self.tree[k]
                if result[0] > stk[0]:
                    result[1] = min(result[0], stk[1])
                    result[0] = stk[0]
                elif result[1] > stk[0]:
                    result[1] = stk[0]
                continue

            m = (l + r) // 2
            k <<= 1
            if a < m and l < b:
                q.append((k, l, m))
            if a < r and l < m:
                q.append((k + 1, m, r))

        return result


def solve(n, ppp):
    str = SegmentTree(n, n)
    right = []
    for i in range(n - 1, -1, -1):
        p = ppp[i]
        right.append(str.get(p, n))
        str.update(p - 1, i)
    right.reverse()

    ans = 0
    stl = SegmentTree(n, 1)
    for i in range(n):
        p = ppp[i]
        l1, l2 = stl.get(p, n)
        l1, l2 = -l1, -l2
        r1, r2 = right[i]
        ans += p * ((l1 - l2) * (r1 - i) + (r2 - r1) * (i - l1))
        stl.update(p - 1, -i)

    return ans


n = int(input())
ppp = list(map(int, input().split()))
print(solve(n, ppp))


Measured memory_bytes: 125212
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define per(i,a,n) for(int i=(n-1);i>=(a);i--)
typedef long long ll;
const int maxn = 1e5 + 5;
int n, a, b;
struct node{
    int to;
    int next;
}G[maxn<<1];
int val1[maxn];
int val2[maxn];
int head[maxn]; //每个节点的头结点
bool vis[maxn];
bool chosen[maxn];
int cnt = 1; //边的总数量
void add(int from,int to){
    G[cnt].to = to;
    G[cnt].next = head[from];
    head[from] = cnt++;
}
void Print(bool sign){
    if(sign){
        printf("Fennec\n");
    }else{
        printf("Snuke\n");
    }
}
void bfs(){
    queue<int>q;
    q.push(1);
    vis[1] = 1;
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(int i=head[u];i;i=G[i].next){
            if(vis[G[i].to]) continue;
            vis[G[i].to] = 1;
            val1[G[i].to] = val1[u] + 1;
            q.push(G[i].to);
        }
    }
    memset(vis,0,sizeof(vis));
    q.push(n);
    vis[n] = 1;
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(int i=head[u];i;i=G[i].next){
            if(vis[G[i].to]) continue;
            vis[G[i].to] = 1;
            val2[G[i].to] = val2[u] + 1;
            q.push(G[i].to);
        }
    }
}
int main(){
#ifdef LOCAL
    //freopen("a.in","r",stdin);
#endif
    scanf("%d",&n);
    rep(i,0,n-1){
        scanf("%d%d",&a,&b);
        add(a,b);add(b,a);
    }
    bfs();
    int cnt = 0;
    rep(i,1,n+1){
        if(val1[i]<=val2[i])
            cnt++;
    }
    bool flag = 0;
    if(cnt>n/2)
        flag = 1;
    Print(flag);

    return 0;
}


Measured memory_bytes: 3072
s = list(str(input()))
t = list(str(input()))

pos = False
rep = list(range(len(s)-len(t)+1))
rep.reverse()
for i in rep:
    flag = True
    for j in range(len(t)):
        if s[i+j] == '?':
            pass
        elif s[i+j] == t[j]:
            pass
        else:
            flag = False

    if flag == False:
        continue
    for j in range(len(t)):
        s[i+j] = t[j]
    pos = True
    break

if pos == False:
    print('UNRESTORABLE')
else:
    for i in range(len(s)):
        if s[i] == '?':
            s[i] = 'a'
    print(''.join(s))

Measured memory_bytes: 8972
from itertools import accumulate
N = 100000
prime = [True for _ in range(N+1)]
prime[0] = False
prime[1] = False
i = 2
for i in range(N+1):
    if prime[i]:
        for j in range(2*i, N+1, i):
            prime[j] = False
prime2 = [0 for _ in range(N+1)]
for i in range(N+1):
    if prime[i] and prime[(i+1)//2]:
        prime2[i] = 1
acc = list(accumulate(prime2))

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(acc[r] - acc[l-1])


Measured memory_bytes: 8112
n = int(input())
A = list(map(int, input().split()))
s = 0
num = 0
sign = "+"
for a in A:
    s += a
    if sign == "+":
        if s > 0:
            pass
        else:
            num += abs(s) + 1
            s = 1
        sign = "-"
        continue
    if sign == "-":
        if s < 0:
            pass
        else:
            num += s + 1
            s = -1
        sign = "+"
        continue
s = 0
num2 = 0
sign = "-"
for a in A:
    s += a
    if sign == "+":
        if s > 0:
            pass
        else:
            num2 += abs(s) + 1
            s = 1
        sign = "-"
        continue
    if sign == "-":
        if s < 0:
            pass
        else:
            num2 += s + 1
            s = -1
        sign = "+"
        continue
print(min(num, num2))


Measured memory_bytes: 14468
def main():
    n = int(input())
    a = list(map(int, input().split()))
    MAX = 10**18
    if 0 in set(a):
        print(0)
    else:
        ans = a[0]
        for ai in a[1:]:
            ans *= ai
            if ans > MAX:
                print(-1)
                return
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 21628
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int N,ans;
	cin >> N;
	if (N % 2 == 0){
		ans = N / 2 * N / 2;
	}
	else{
		ans = (N + 1 )/ 2 * (N / 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
#include<stdlib.h>
 
#include<string.h>
 
 
 
int main(void){
 
char num_str[1002];
 
int num;
 
long sum=0;
 
int i;
 
char tmp;
 
 
 
while(1){
 
fgets(num_str, sizeof(num_str), stdin);
 
 
 
if (num_str[0]=='0') break;
 
 
 
for (i=0; i<strlen(num_str)-1;i++){
 
tmp=num_str[i];
 
num =atoi(&tmp);
 
sum=sum+num;
 
};
 
printf("%ld\n",sum);
 
 
 
sum=0;
 
memset(num_str,1002,0);
 
};
 
return 0;
 
};

Measured memory_bytes: 532