akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll,ll> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b)) << "\n";
    return 0;
}

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

int main() {
  int w,a,b; cin>>w>>a>>b;
  if (b+w < a) cout << a-b-w << endl;
  else if (a+w < b) cout<< b-a-w << endl;
  else cout << 0 << endl;
}



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

using namespace std;

#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forlr(i, l, r) for (int i = int(l); i < int(r); i++)
#define repeat(n) for (int hjfjke = 0; hjfjke < int(n); hjfjke++)
#define all(c) c.begin(), c.end()
#define ll long long

int dp[100500][3];
int a[100500][3];

int32_t main() {
    std::iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    forn (i, n)
        cin >> a[i][0] >> a[i][1] >> a[i][2];

    dp[0][0] = dp[0][1] = dp[0][2] = 0;

    for (int i = 1; i <= n; i++) {

        for (int now = 0; now < 3; now++) {
            dp[i][now] = -1e9 - 500;
            for (int was = 0; was < 3; was++)
                if (was != now)
                    dp[i][now] = max(dp[i][now], dp[i - 1][was] + a[i - 1][now]);
        }
    }

    cout << max(max(dp[n][0], dp[n][1]), dp[n][2]);

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S;
    N = S.size() + 1;
    vi a(N);
    a[0] = 0;
    for (int i = 1; i < N; i++) {
        if (S[i - 1] == '<') {
            a[i] = a[i - 1] + 1;
        } else {
            a[i] = 0;
        }
    }
    for (int i = N - 2; i >= 0; i--) {
        if (S[i] == '>') {
            a[i] = max(a[i], a[i + 1] + 1);
        }
    }
    for (int i = 0; i < N; i++)
        ans += a[i];

    cout << ans << endl;
}

Measured memory_bytes: 2820
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vvll = vector<vector<ll>>;
using vll = vector<ll>;
using vstr = vector<string>;

ll N,K;
vll d;

vector<char> num{'3','5','7'};

bool ok(string s)
{
    bool seven=false;
    bool five=false;
    bool three=false;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='7')seven=true;
        if(s[i]=='5')five=true;
        if(s[i]=='3')three=true;
    }
    return seven && five && three;
}

void dfs(vstr& enm,string cur)
{
    if(cur!="")if(N<stol(cur))return;
    if(ok(cur))enm.emplace_back(cur);
    for(int i=0;i<3;i++)
    {
        string next=cur+num[i];
        dfs(enm,next);
    }
}

int main()
{
    cin>>N;

    vstr enm;
    dfs(enm,"");

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

Measured memory_bytes: 4324
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    int intN = Integer.parseInt(N);
    int sum =0;
    for (int i=0; i<N.length(); i++) {
      sum +=  Character.getNumericValue(N.charAt(i));
    }
    if (intN % sum == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22868
from numpy.fft import rfft, irfft
import numpy as np

N, M = map(int, input().split())
A = list(map(int, input().split()))

a = np.bincount(A, minlength=2 ** 18)

fa = rfft(a)
a2 = irfft(fa ** 2)
a2 = np.round(a2).astype(np.int)

cum_a2 = np.cumsum(a2)

index = np.searchsorted(cum_a2, N ** 2 - M)

a2[index] -= cum_a2[index] - (N ** 2 - M)

ans = sum(A) * 2 * N - (a2[: index + 1] * np.arange(index + 1)).sum()
print(ans)


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    cout << n * n * n << endl;
    return 0;
}


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

using namespace std;

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string a,b,d,e;
	cin>>d>>e;
	a="0";
	b="0";
	a+=d;
	b+=e;
	
	int n=a.size()-1;
	int m=b.size()-1;

	vector<vector<int>> dp;
	for (int j=0; j<=n; j++)
	{
		vector<int> v;
		for (int i=0; i<=m; i++)
		{
			v.push_back(0);
		}
		dp.push_back(v);
	}
	
	for (int i=1; i<=n; i++)
	{
		for (int j=1; j<=m; j++)
		{
			if (a[i]==b[j])
			{
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	string ans="";
	int j=m;
	int i=n;
	while (i>0 and j>0)
	{
		if (a[i]==b[j])
		{
			ans+=a[i];
			i--;
			j--;
		}
		else
		{
			if (dp[i-1][j]>=dp[i][j-1])
			{
				i--;
			}
			else
			{
				j--;
			}
		}
	}
	reverse(ans.begin(), ans.end());
	cout<<ans;
	return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;

int n, a[N], b[N];

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i)
		a[i] = i * 30000;
	for (int i = 1; i <= n; ++i)
		b[i] = a[n - i + 1];
	for (int i = 1; i <= n; ++i) {
		int x;
		scanf("%d", &x);
		b[x] += i;
	}
	for (int i = 1; i < n; ++i)
		printf("%d ", a[i]);
	printf("%d\n", a[n]);
	for (int i = 1; i < n; ++i)
		printf("%d ", b[i]);
	printf("%d\n", b[n]);
	return 0;
}


Measured memory_bytes: 768
s=[int(x) for x in input().split()]
print(min(abs(s[0]-s[1])+abs(s[1]-s[2]),
         abs(s[0]-s[2])+abs(s[2]-s[1]),
         abs(s[1]-s[0])+abs(s[0]-s[2]),
         abs(s[1]-s[2])+abs(s[2]-s[0]),
         abs(s[2]-s[0])+abs(s[0]-s[1]),
         abs(s[2]-s[1])+abs(s[1]-s[0]),
         )
     )

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	string t;
	cin >> s;
	cin >> t;
	int n = s.length();
	int m = t.length();
	string ans;
	vector<vector<pair<int, int>>> dir(n + 1, vector<pair<int,int>> (m + 1, {0, -1}));
	for(int i = 1;i <= n; ++i){
		for(int j = 1; j <= m; ++j){
			if(s[i - 1] == t[j - 1]){
				dir[i][j].first = 1 + dir[i - 1][j - 1].first;
				dir[i][j].second = 2;
			}
			else if(dir[i - 1][j].first > dir[i][j - 1].first){
				dir[i][j].first = dir[i - 1][j].first;
				dir[i][j].second = 1;
			}
			else{
				dir[i][j].first = dir[i][j - 1].first;
				dir[i][j].second = 0;
			}
		}
	}
	int i = n, j = m;
	while(dir[i][j].second != -1){
		if(dir[i][j].second == 2){
			ans.push_back(s[i - 1]);
			--i,--j;
		}
		else if(dir[i][j].second == 1)
			--i;
		else
			--j;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
 
signed main()
{
  string n; cin >> n;
  if(n[0]=='9'||n[1]=='9'){
      cout << "Yes" << "\n";
  }else{
      cout << "No" << "\n";
  }
}

Measured memory_bytes: 3532
#include<iostream>
using namespace std;
int main()
{
	int N,*sort,i,j,k,v;
	cin >> N;
	sort = (int*)malloc(sizeof(int) * N);
	for (i = 0; i < N; i++)
		cin >> sort[i];
	for (i = 0; i < N; i++)
	{
		v = sort[i];
		k = i-1;
		while (k>=0&&sort[k]>v)
		{
			sort[k + 1] = sort[k];
			k--;
		}
		sort[k + 1] = v;
		for (j = 0; j < N-1; j++)
			cout << sort[j]<<' ';
		cout << sort[N-1] << endl;
	}
	return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>

int count5(int n) {
  int t = 0, i;
  for (i = 5; i <= n; i *= 5)
    t += n / i;

  return t;
}

int main(void) {
  int n, num0;

  while (1) {
    scanf("%d", &n);
    if (n == 0) break;

    num0 = count5(n);
    printf("%d\n", num0);
  }
  return 0;
}

Measured memory_bytes: 600
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    CSF=LLIN(N-1)
    def solve(CSF):
        now = 0
        for c,s,f in CSF:
            if now<=s:
                now = s
            else:
                over = now-s
                if over%f:
                    now += (f-(over%f))
            now += c
        print(now)
                
    for i in range(N):
        solve(CSF[i:])


if __name__ == '__main__':
    main()

Measured memory_bytes: 3700
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

/*const int MM = 4e8;
int mpos = 0;
char mem[MM];
inline void * operator new ( size_t n )
{
	char *res = mem + mpos;
	mpos += n;
	return (void *)res;
}
inline void operator delete ( void * ) { } */

#define TIME (clock() * 1.0 / CLOCKS_PER_SEC)

const ld pi = acos(-1.0);
const ll INF = 1e18 + 239;
const int BIG = 1e9 + 239;
const ll MOD = 1e9 + 7;
const ll MOD2 = MOD * MOD;
const int M = 2 * 1e5 + 239;
const int N = 2 * 1e3 + 239;
const int X = 1e4 + 239;
const int L = 18;
const int T = (1 << 18);
const int two = 2;
const int th = 3;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int n, a[M];

int main()
{   /*
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout); /**/
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 1; i < n; i++)
        if (a[i] > a[i - 1] + 1)
        {
            cout << "-1";
            return 0;
        }
    if (a[0] != 0)
    {
        cout << "-1";
        return 0;
    }
    ll ans = 0;
    for (int i = 1; i < n; i++)
    {
        if (a[i] == a[i - 1] + 1)
            ans++;
        else
            ans += a[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

ll n;
vl a;
vvl dp,DP;

int main(){
	cin>>n;
	a=vl(n+2);
	dp=DP=vvl(n+2,vl(n+2));
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int k=0;k<n;k++) for(int i=1;i<=n;i++) if(i+k<=n&&a[i-1]<a[i]||a[i+k]>a[i+k+1]){
		ll L=i,R=i+k,m=inf,M=max(a[i-1],a[i+k+1]);
		for(int j=L;j<=R;j++) m=min(m,a[j]);
		if(m<=M) continue;
		vi b,c;
		ll I=L,t=0;
		for(int j=L;j<=R;j++) if(a[j]==m){
			t++;
			if(I!=j){
				b.push_back(I);
				c.push_back(j-1);
			}
			I=j+1;
		}
		if(I!=R+1){
			b.push_back(I);
			c.push_back(R);
		}
		if(t==R-L+1){
			dp[L][R]=Pow(2,m-M-1);
			DP[L][R]=(Pow(2,t)+mod-2)%mod;
			continue;
		}
		ll S=b.size(),res=1,sum=Pow(2,t);
		for(int j=0;j<S;j++){
			int l=b[j],r=c[j];
			(res*=2*dp[l][r])%=mod;
			(sum*=4*dp[l][r]+DP[l][r])%=mod;
		}
		(sum+=2*mod-2*res)%=mod;
		(res*=Pow(2,m-M-1))%=mod;
		dp[L][R]=res,DP[L][R]=sum;
	}
	cout<<(2*dp[1][n]+DP[1][n])%mod<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll X;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> X;
}

int solve(){ 
    ll ans=0;
    ans += 1000*(X/500);
    X %= 500;
    ans += 5*(X/5);
    cout << ans << endl; 
    return 0;
}   

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>      // std::setprecision
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/numeric/ublas/vector.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;
using namespace boost::numeric;
namespace bst = boost;
template<class T> void fill(T& v) { for (auto& i : v) cin >> i; }

int main() {
  int N, K;

  cin >> N >> K;
  
  vector<int> h(N);
  
  fill(h);
  
  int r = 0;
  for (auto i : h) {
    if (i >= K)
      r++;
  }

  cout << r << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N,K;cin >> N >> K;
    vector<int> h(N);
    rep(i,N)cin >> h[i];
    int res = 0;
    rep(i,N){
        if(h[i]>=K)res++;
    }
    cout << res << endl;
    return 0;
}

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

class LCA {

    using Graph = vector<vector<int>>;

    vector<int> dist;
    vector<vector<int>> parent;

    void dfs(const Graph& g, int v, int p, int d) {
        parent[0][v] = p;
        dist[v] = d;
        for (int nv: g[v]) {
            if (nv != p) {
                dfs(g, nv, v, d + 1);
            }
        }
    }


public:
    LCA(Graph g, int root) {
        init(g, root);
    }

    void init(Graph g, int root) {
        int V = g.size();
        int K = 1;
        while ((1<<K) < V) {
            K++;
        }
        parent.assign(K, vector<int>(V, -1));
        dist.assign(V, -1);
        dfs(g, root, -1, 0);
        for (int k = 0; k < K - 1; k++) {
            for (int v = 0; v < V; v++) {
                if (parent[k][v] < 0) {
                    parent[k + 1][v] = -1;
                }
                else {
                    parent[k + 1][v] = parent[k][parent[k][v]];
                }
            }
        }
    }

    

    int query(int u, int v) {
        if (dist[u] < dist[v]) {
            swap(u, v);
        }
        int K = parent.size();
        for (int k = 0; k < K; k++) {
            if ((dist[u] - dist[v]) >> k & 1) {
                u = parent[k][u];
            }
        }

        if (u == v) {
            return u;
        }
        for (int k = K - 1; k >= 0; k--) {
            if (parent[k][u] != parent[k][v]) {
                u = parent[k][u];
                v = parent[k][v];
            }
        }
        return parent[0][u];
    }

};

int main() {
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int c;
            cin >> c;
            g[i].push_back(c);
            g[c].push_back(i);
        }
    }

    LCA lca = LCA(g, 0);

    vector<int> ANS;
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int u, v;
        cin >> u >> v;
        ANS.push_back(lca.query(u, v));
    }

    for (int i = 0; i < ANS.size(); i++) {
        cout << ANS[i] << '\n';
    }



    return 0;
}


Measured memory_bytes: 29040
#include<stdio.h>

int isPrime(int x){
  int i;
  if(x<2) return 0;
  else if(x==2) return 1;
  if (x%2==0) return 0;
  for(i=3; i*i<=x; i+=2){
    if(x%i==0) return 0;
  }
  return 1;
}

int main(){
  int n,x,i;
  int ct=0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&x);
    if(isPrime(x)) ct++;
  }
  printf("%d\n",ct);

  return 0;
}


Measured memory_bytes: 2064
// AtCoder Regular Contest 095 - Problem C: Many Medians (https://arc095.contest.atcoder.jp/tasks/arc095_a)
#include <iostream>

#include <map>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

const ll MAX { 200010 };
ii xs[MAX];
int medians[MAX];

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

    int N;
    cin >> N;

    for (int i = 0; i < N; ++i)
    {
        cin >> xs[i].first;
        xs[i].second = i;
    }

    sort(xs, xs + N);

    int limit = (N - 1)/2;

    for (int i = 0; i < N; ++i)
        medians[xs[i].second] = (i <= limit) ? xs[N/2].first : xs[limit].first;

    for (int i = 0; i < N; ++i)
        printf("%d\n", medians[i]);

    return 0;
}


Measured memory_bytes: 6144
#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 lli long long int
#define all(x) x.begin(),x.end()
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
int main()
{

	double r;
	cin>>r;
	cout<<2.0*M_PI*r;
}



Measured memory_bytes: 3784
#include <stdio.h>
#include <math.h>

int main() {
  int number_of_balls, kind_of_colors;
  long long int answer;
  scanf("%d %d", &number_of_balls, &kind_of_colors);
  answer = kind_of_colors * pow(kind_of_colors - 1, number_of_balls - 1);
  printf("%lld\n", answer);
  return 0;
}


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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;

string res;

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

    reverse(all(t));

    if (s == t)
    {
        println("YES");
    }
    else
    {
        println("NO");
    }
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/	
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)

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

ll power( ll a, ll n, ll m= 1000000007){
  ll ans = 1;
  while(n){
  if(n&1)
  {
  ans *= a;
  ans%=m;
  }
  a*=a;
  a%=m;
  n/=2;
  }
  return ans ;
} 


vector< int > prm ;
vector < bool > vsp ;

void prime ( int nn = 100000 ) {
	vsp = vector < bool > ( nn+1, 0 );
	int size_prime = nn;
	for( ll i =2; i*i < size_prime ; i++){
		
		if( vsp[i] == 1)
		continue;
		for(ll j = i*i; j < size_prime ;j+=i){
			
			vsp[j] =1;
			
		}
		
		
	}
	
	for( int i= 2; i < size_prime ; i++)
	if (vsp[i] == 0)
	prm.pb(i);
	
	
}


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


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...
// never forget  to recheck your predefined function in template .. 
// already defined ::  prime , power , gcd : ( ll ).. 








int Main(){
  
  
  
  
  ll k;
  cin>>k;
  string ans = "";
  for( int i =0 ; i  < k;i++){
	  ans+= "ACL";
  }
  
  cout<<ans<<endl;
  
  
return 0;

}






int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;
}


  




Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a[105];
    int i,m,n,sum=0;
    scanf("%d",&m);
    for(n=0;n<m;n++)
        scanf("%d",&a[n]);
    for(n=0;n<m;n++)
    {
        if((n+1)%2==0)
            continue;
        if(a[n]%2==1)
            sum++;
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 1732
/* In the name of Allah */

    #include<bits/stdc++.h>
    using namespace std;
    const int MAXN = 100 * 1000 + 10;
	int x[MAXN];
    int h[MAXN];
    int main(){
    	int n, m;
    	cin >> n >> m;
    	for(int i = 1; i <= n; i++){
    		cin >> h[i];
    	}
    	for(int i = 1; i <= m; i++){
    		int a, b;
    		cin >> a >> b;
    		x[a] = max(x[a], h[b]);
    		x[b] = max(x[b], h[a]);
    	}
    	int sum = 0;
    	for(int i = 1; i <= n; i++){
 			if(h[i] > x[i]){
 				sum++;
			 }
    	}
    	cout << sum;
    	return 0;
    }

Measured memory_bytes: 4380
S = input()
K = int(input())

prev_c = S[0]
num_changes = 0
for c in S[1:]:
    if c == prev_c:
        num_changes += 1
        prev_c = 'replaced'
    else:
        prev_c = c

total_changes = 0
if len(S) == 1:
    if len(S) % 2 == 0:
        total_changes = int(K/2)
    else:
        total_changes = int((K-1)/2)
elif S[0] == prev_c and S[1] == S[0] and len(S) % 2 == 1:
    num_changes2 = 0
    for c in S:
        if c == prev_c:
            num_changes2 += 1
            prev_c = 'replaced'
        else:
            prev_c = c
    total_changes = num_changes * int(K/2 + 1) + num_changes2 * int(K/2)
elif S[0] == prev_c:
    num_changes2 = 0
    for c in S:
        if c == prev_c:
            num_changes2 += 1
            prev_c = 'replaced'
        else:
            prev_c = c
    total_changes = num_changes + num_changes2 * (K-1)
else:
    total_changes = num_changes * K

print(total_changes)


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;
vector<bool> prime(100005,true);
void pre(){
    prime[0]=false;
    prime[1]=false;
    for(int i=2;i<=100005;i++){
        if(prime[i]){
            for(int j=i*i;j<=100005;j=j+i){
                prime[j]=false;
            }
        }
    }
}

int32_t main(){
	ios::sync_with_stdio(false);
    pre();
    int n;
    cin>>n;
    vi P;
    for(int i=0;i<=55555;i++){
        if(prime[i] && i%5==1){
            P.PB(i);
        }
        if(P.size()==n){
            break;
        }
    }
    REP(i,0,n){
        cout<<P[i]<<" "; 
    }
    cout<<"\n";
    // deb(P.size());
    // deb(P);


	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 998244353;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
ll n, t[1010], a[1010],nowa,nowb;
int main() {
	cin >> n;
	rep(i, n) {
		cin >> t[i] >> a[i];
		if (i == 0)nowa = t[i], nowb = a[i];
		else {
			ll ct = max(nowa / t[i] + 1+(nowa%t[i]==0?-1:0), nowb / a[i] + 1+(nowb%a[i]==0?-1:0));
			nowa = ct * t[i], nowb = ct * a[i];
		}
	}
	cout << nowa + nowb << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <cstring>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    int left;
    int right;

    for (int i = 0; i < n; ++i){
        scanf("%d", &v[i]);
    }
    left = 0;
    right = k-1;
    int ans = v[right] - v[left]+min(abs(v[left]),abs(v[right]));
    while(right < n){
        ans = min(ans, v[right]-v[left] + min(abs(v[left]),abs(v[right])));
        right++;
        left ++;
    }
    cout << ans << endl;







    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
vector<int> ss(string&s ){
  vector<int> v;
  for(int i=0;i<(int)s.size();i++){
    v.push_back( s[i] - 'a' );
  }
  return v;
}

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

void dfs(int x,int y,int c,int k,const vector<int>& v,set<P> &s){
  s.insert(P(x,y));
  if( c == (int)v.size() ) return;
  int d = (v[c]+k)%6;
  dfs( x + dx[0][d], y + dy[0][d], c+1, k, v, s );
}

bool eq(const set<P>& a, const set<P>& b){
  if(a.size() != b.size() ) return false;
  for( auto x = a.begin(), y = b.begin(); x != a.end() || y != b.end(); x++, y++ )
    if( *x != *y ) return false;
  return true;
}

void view(const set<P> &s ){
  for( auto x : s ){
    cout << x.first << " " <<x.second << endl;
  }
}

int main(){

  int T;
  cin >> T;
  getchar();
  while(T--){
    string S1,S2; 
    getline(cin,S1);
    getline(cin,S2);
    vector<int> v1 = ss( S1 ), v2 = ss( S2 );
    getline(cin,S1);   
    bool f = false;
    for(int i=0;i<6;i++){
      set<P> s1;
      dfs( 0,0,0,i,v1,s1 );
      //cout << "s1------------- "<< endl;
      // view(s1);
      for(int j=0;j<6;j++){
        for( auto ps : s1 ){
          set<P> s2;
          dfs(ps.first,ps.second,0,j,v2,s2);
          //cout << "s2 "<< endl;
          //view(s2);
          if( eq(s1, s2) ) {
            //cout << "ok---------" << endl;
            f = true;
          }
        }
      }      
    }
    if( f ) cout << "true" << endl;
    else cout << "false" << endl;
  }
}

Measured memory_bytes: 3140
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        int n;
        try (Scanner sc = new Scanner(System.in)) {
            n = sc.nextInt();
        }
        int a=n/2;
        int b=n%2;
        
        if(b==0)
            System.out.println(a);
        else
            System.out.println(a+1);
    }
}

Measured memory_bytes: 22740
n = int(input())
a = []
re = "Yes"
for i in range(n):
        a.append(input())
        if a.count(a[i]) >= 2:
                re = "No"
        if i != 0:
                if a[i][0] != a[i-1][-1]:
                        re ="No"

print(re)

        


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <utility>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,k;
vector<int> ashiba(100010);
vector<int> ashiba_sum(100010,INT_MAX);

int main(){
	cin >> n>> k;
	for (int i = 0;i < n; i++) cin >> ashiba.at(i);
	ashiba_sum.at(0) = 0;
	for (int i = 1;i < n;i++){
		for (int j = 1;j<k+1;j++){
			if (i - j < 0) break;
			chmin(ashiba_sum.at(i), ashiba_sum.at(i-j) + abs(ashiba.at(i) - ashiba.at(i-j)));
		}
	}
	cout << ashiba_sum.at(n-1) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  map<char, set<char>> mp1;
  map<char, set<char>> mp2;
  for (int i = 0; i < s.size(); i++) {
    mp1[t[i]].insert(s[i]);
    mp2[s[i]].insert(t[i]);
    if (mp1[t[i]].size() >= 2 || mp2[s[i]].size() >= 2) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
int main() {
  string N;
  cin >> N;
  bool b = false;
  for (int i = 0; i < N.size(); i++) {
    if (N.at(i) == '7') {
      b = true;
      break;
    }
  }
  if (b) {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
}

Measured memory_bytes: 3584
function main(input) {
  var N = input[0].split(" ")[0]-0;
  var M = input[0].split(" ")[1]-0;
  var X = input[0].split(" ")[2]-0;
  var Y = input[0].split(" ")[3]-0;
  var alist = input[1].split(" ").map(v=>v-0).sort((a,b)=>a-b);
  var blist = input[2].split(" ").map(v=>v-0).sort((a,b)=>a-b);
  var amax = alist[alist.length-1];
  var bmin = blist[0];
  var ans = "War";
  for(var i=X+1;i<=Y;i++){
    if(amax<i && bmin>=i){
      ans = "No War";
      break;
    }
  }
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 7500
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = Math.min(a*b,c);
        System.out.println(d);
    }
}


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

struct Dice
{
	int Top, Front, Right, Left, Back, Bottom;
};

void copy (Dice &a, Dice &b)
{
	a.Top = b.Top;
	a.Front = b.Front;
	a.Right = b.Right;
	a.Left = b.Left;
	a.Back = b.Back;
	a.Bottom = b.Bottom;
}

int main()
{
	Dice d1, d2;	
	char c;
	for (int i = 0; i < 6; i++)
	{
		if (i == 0) cin >> d1.Top;
		if (i == 1) cin >> d1.Front;
		if (i == 2) cin >> d1.Right;
		if (i == 3) cin >> d1.Left;
		if (i == 4) cin >> d1.Back;
		if (i == 5) cin >> d1.Bottom;
	}
	copy(d2, d1);
	while ((c = getchar()) != EOF)
	{
		switch (c)
		{
			case 'S': d2.Top = d1.Back; 
					  d2.Front = d1.Top;
					  d2.Back = d1.Bottom;
					  d2.Bottom = d1.Front;
					  break;
			case 'N': d2.Top = d1.Front;
					  d2.Front = d1.Bottom;
					  d2.Back = d1.Top;
					  d2.Bottom = d1.Back;
					  break;
			case 'E': d2.Top = d1.Left;
					  d2.Right = d1.Top;
					  d2.Left = d1.Bottom;
					  d2.Bottom = d1.Right;
					  break;
			case 'W': d2.Top = d1.Right;
					  d2.Right = d1.Bottom;
					  d2.Left = d1.Top;
					  d2.Bottom = d1.Left;
					  break;
		}
		copy(d1,d2);
	}
	cout << d1.Top << endl;
	return 0;
}



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

int main(int argc, char* argv[]){
  int num,input,move;
  vector<int> target;
  cin >> num;
  for(int i=0;i<num;i++){
    cin >> input;
    target.push_back(input);
  }
 for(int k=0;k<num;k++){
    if(k==num-1) cout << target[k] << endl;
    else cout << target[k] << " ";
  }
  for(int i=1;i<num;i++){
    int j=i-1;
    move=target[i];
    while(j>=0 and target[j]>move){
      swap(target[j],target[j+1]);
      j--;
      move=target[j+1];
    }
    for(int k=0;k<num;k++){
      if(k==num-1) cout << target[k] << endl;
      else cout << target[k] << " ";
    }
  }
}

Measured memory_bytes: 3120
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n=int(input())
ans=0
for i in range(1,n+1):
    tmp=0
    if i%2==1:
        for j in range(1,i+1):
            if i%j==0:
                tmp+=1
    if tmp==8:
        ans+=1
print(ans)

Measured memory_bytes: 64364
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	string s;

	int a, b;
	cin >> a >> s >> b;
	if (s == "-") {
		b = -b;
	}
	cout << a + b << endl;
	
}


Measured memory_bytes: 256
program StringPalindrome
  implicit none

  character(99) :: cha
  integer :: n, i
  logical :: log

  read(*,*) cha
  n = len_trim(cha)
  log = .true.

  do i = 1, (n-1)/2
     if(cha(i:i) /= cha(n-i+1:n-i+1)) then
        log = .false.
        exit
     end if
     if(i <= (n-1)/4) then
        if(cha(i:i) /= cha((n-1)/2-i+1:(n-1)/2-i+1)) then
           log = .false.
           exit
        end if
        if(cha(i+(n+1)/2:i+(n+1)/2) /= cha(n-i+1:n-i+1)) then
           log = .false.
           exit
        end if
     end if
  end do

  if(log .eqv. .true.) then
     print *, 'Yes'
  else
     print *, 'No'
  end if

  stop
end program StringPalindrome


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  
  ll tot = 0;
  
  rep(i,n){
    //int upper = c.end() - upper_bound(c.begin(),c.end(),b[i]);
    //int lower = lower_bound(a.begin(),a.end(),b[i])-a.begin();
    //tot += upper*lower;
    
    auto a_itr = lower_bound(a.begin(), a.end(), b[i]);
    auto c_itr = upper_bound(c.begin(), c.end(), b[i]);
 
    tot += (a_itr - a.begin()) * (c.end() - c_itr);
  }
  cout << tot << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;

using namespace std;

int main() 
{
    int ans = -INF;
    int n;cin >> n;
    v2_int f(n ,v_int(11, 0));
    v2_int p(n, v_int(11, 0));

    irep(i, n) {
        irep(j, 10) {
            cin >> f[i][j];
        } 
    }

    irep(i, n) {
        irep(j, 11) {
            cin >> p[i][j];
        }
    }

    for(int i = 1; i < (1 << 10); i++) {
        int benefit = 0; 
        for(int j = 0; j < n; j++) {
            //cout << "i," << i << "bit"<< bit << endl;
            int store = 0; 
            for(int k = 0; k < 10; k++) {
                if(f[j][k] == 1 && (i & (1 << k))) {
                    ////cout << i << endl;
                    store++;
                }
            }
            benefit += p[j][store];
        }
        ans = max(ans, benefit);
    }
    cout << ans << endl;
    return 0;
}
    



Measured memory_bytes: 256
program sample
    implicit none
  
    integer(8) :: i,j,m,n,k,c,d,x
    real(8)::a,b
    
  
    read(*,*) x
    m=1
    do i=33,1,-1
        if (i**2<=x)then
            m=i**2
            exit
        end if
    end do
    n=1
    do i=10,1,-1
        n=i**3
        if (n<=x)then
            
            exit
        end if
    end do
    if (n>m)then
        m=n
    end if

    do i=3,1,-1
        if (i**5<=x)then
            n=i**5
            if (n>m)then
                m=n
            end if
            exit
        end if
    end do
    
    if (2**7<=x)then
        n=2**7
        if (n>m)then
            m=n
        end if
    end if
    
    write(*,*) m
  
    stop
end program sample
  



Measured memory_bytes: 2804
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  std::string S, T;
  std::cin >> S >> T;
  std::cout << (S == T.substr(0, S.size()) ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 3572
#include<cmath>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[200005],head=2,tail=4;
long long sum[200005],sa,sb,sc,sd,ans=(1ll<<60),mx,mn;
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum[i]=sum[i-1]+a[i];
	}
	sa=a[1];sb=a[2];sc=a[3];sd=sum[n]-sum[3];
	for(register int i=3;i<=n;i++){
		while(head<i&&abs(sa-sb)>abs(sa-sb+2*a[head])){
			sa+=a[head];
			sb-=a[head];
			head++;
		}
		while(tail<=n&&abs(sd-sc)>abs(sc-sd+2*a[tail])){
			sc+=a[tail];
			sd-=a[tail];
			tail++;
		}
		mx=max(sa,max(sb,max(sc,sd)));
		mn=min(sa,min(sb,min(sc,sd)));
		ans=min(ans,mx-mn);
		sb+=a[i];
		sc-=a[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6080
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	int N, M;
	int X, Y;
	cin >> N >> M >> X >> Y;

	int x_max = -100;
	int y_min = 100;

	int v;
	for (int i = 0; i < N; i++) {
		cin >> v;
		if (v > x_max) {
			x_max = v;
		}
	}
	for (int i = 0; i < M; i++) {
		cin >> v;
		if (v < y_min) {
			y_min = v;
		}
	}

	if (max(x_max,X) < min(y_min,Y)) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
<?php

function input($func = null) {
    if ($func === null) {
        return trim(fgets(STDIN));
    } else {
        return $func(trim(fgets(STDIN)));
    }
}
function input_array($func = null) {
    if ($func === null) {
        return explode(input());
    } else {
        return array_map(function($v) use ($func) {
            return $func($v);
        }, explode(' ', input()));
    }
}

$prime_counts = array_fill(0, 100, 0);

$n = input('intval');
if ($n === 1) {
    echo 0 . "\n";
    exit;
}

for ($m = 2; $m <= $n; $m++) {
    $int = $m;
    while ( $int !== 1 ) {
        $j = 2;
        while ($j <= 100) {
            if ($int % $j === 0) {
                $prime_counts[$j]++;
                $int /= $j;
                break;
            }
            $j++;
        }
    }
}

$prime_counts = array_values(array_filter($prime_counts, function($count) {
    return $count !== 0;
}));

$result = 0;

$result += count(array_values(array_filter($prime_counts, function($count) {
    return $count >= 74;
})));

$count_2 = count(array_values(array_filter($prime_counts, function($count) {
    return $count >= 2;
})));
$count_4 = count(array_values(array_filter($prime_counts, function($count) {
    return $count >= 4;
})));
$count_14 = count(array_values(array_filter($prime_counts, function($count) {
    return $count >= 14;
})));
$count_24 = count(array_values(array_filter($prime_counts, function($count) {
    return $count >= 24;
})));

if ($count_4 >= 1) {
    $result += $count_14 * ($count_4 - 1);
}
if ($count_2 >= 1) {
    $result += $count_24 * ($count_2 - 1);
}
if ($count_4 >= 1 && $count_2 >= 2) {
    $result += intdiv($count_4 * ($count_4 - 1), 2) * ($count_2 - 2);
}

echo $result . "\n";

Measured memory_bytes: 4728
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

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

    cout << a + a*a + a*a*a << endl;

    return 0;
}

Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int a, b, c;
		int temp;
		Scanner scan = new Scanner(System.in);

		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();

		temp = a;
		a = b;
		b = temp;

		temp = a;
		a = c;
		c = temp;

		System.out.println(a + " " + b + " " + c);
	}
}


Measured memory_bytes: 21204
#include <stdio.h>
#include <string.h>
int min(int a,int b){
	int min = a;
	if(min>b)min=b;
	return min;
}
int main(void){
	int num0=0;
	int num1=0;
	char s[2];
	int i;
	while( (s[0]=getchar())!=-1){
		if(s[0]=='0'){
			num0++;
		}else if (s[0]=='1'){
			num1++;
		}
	}
	int ans = min(num0,num1)*2;
	//printf("num0 = %d\n",num0);
	//printf("num1 = %d\n",num1);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128