akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <climits>
#include <utility>
#include <numeric>
typedef long long ll;
using namespace std;

int main(int argc, char *argv[]) {
  int a;
  cin >> a;

  if(a==0) cout << 1 << endl;
  else cout << 0 << endl;
  
  return 0;
}


Measured memory_bytes: 3620
#include<iostream>  
#include<cmath>  
#include<cstdio>  
#include<cstring>  
#include<algorithm>  
using namespace std;

const int INF = 1e9;
int dp[110000];//记录以a[i]结束的最长子序列的长度  
int a[110000];


int main()
{
	// freopen("in.txt","r",stdin);  
	int n;
	while (scanf("%d", &n) != EOF&&n)
	{
		for (int i = 0; i<n; i++)
			dp[i] = INF;
		for (int i = 0; i<n; i++)
			scanf("%d", &a[i]);

		int len = 0;
		for (int i = 0; i<n; i++)
		{
			*lower_bound(dp, dp + n, a[i]) = a[i];
		}
		printf("%d\n", lower_bound(dp, dp + n, INF) - dp);
	}
	return 0;
}


Measured memory_bytes: 3988
#include<cstdio>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
map<ll,ll>loe,ano,ple;
ll d,n=1,o,ans;
ll iabs(ll x)
{
	return x<0?-x:x;
}
ll dfs(ll use,ll rest)
{
	ll k=ple[(rest%10+10)%10];
	if(use<=0)
	{
		if(rest)
			return 0;
		else
			return 1+(o&1)*9;
	}
	if(k)
		return ano[k]*dfs(use/100,(rest-k*use)/10)+ano[k-10]*dfs(use/100,(rest+(10-k)*use)/10);
	else
		return ano[0]*dfs(use/100,rest/10);
}
ll logi(ll use,ll rest)
{
	ll k=ple[(rest%10+10)%10];
	if(use<=0)
	{
		if(rest)
			return 0;
		else
			return 1+(o&1)*9;
	}
	if(k)
		return loe[k]*dfs(use/100,(rest-k*use)/10)+loe[k-10]*dfs(use/100,(rest+(10-k)*use)/10);
	else
		return loe[0]*dfs(use/100,rest/10);
}
int main(void)
{
	for(ll i=-8; i<9; i++)
		loe[i]=9-iabs(i);
	for(ll i=-9; i<10; i++)
		ano[i]=10-iabs(i);
	for(ll i=0; i<10; i++)
		ple[i*9%10]=i;
	scanf("%lld",&d);
	for(int i=1;i<=18;i++)
	{
		o++;
		ans+=logi(n-1,d);
		n*=10;
	}
	cout<<ans;
}

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

	

int main() {
	
	int N;
	cin >>N;
	
	double P;
	
	
	if(N%2==1){
		
		P=N;
		cout <<((N/2)+1)/P <<endl;
		
	}
	else{
		
		P=0.5;
		cout <<P <<endl;
		
	}
	
}


Measured memory_bytes: 256
def equal_list(lst1, lst2):
    lst = lst1.copy()
    for element in lst2:
        try:
            lst.remove(element)
        except ValueError:
            break
    else:
        if not lst:
            return "YES"
    return "NO"


HAIKU = [5, 7, 5]
v = list(map(int, input().split()))
print(equal_list(v, HAIKU))

Measured memory_bytes: 3444
#include <iostream>
#include <set>
using namespace std;
int main(){
  int N;
  int d[110];
  
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> d[i];
  }
  
  set<int> values;
  for (int i = 0; i < N; i++){
    values.insert(d[i]);
  }
  
  cout << values.size() << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    set<int> d;
    
    if (k > a[n - 1]) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    
    rep(i, n) {
        if (k == a[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    
    rep(i, n - 1) {
        if (a[i + 1] == a[i]) {
            continue;
        }
        
        d.insert(a[i + 1] - a[i]);
    }
    
    for (auto x : d) {
        rrep(i, n) {
            if (k > a[i]) {
                break;
            }
            
            if ((a[i] - k) % x == 0) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,i,j,k,l,p;
    //tring s;
    cin>>n;
    int a[n];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    k=0;j=0;
    for(i=0; i<n-1; i++)
    {
        if(a[i]>a[i+1])
        {
            k=a[i]-a[i+1];
            a[i+1]+=k;
            j+=k;
        }
    }
    cout<<j;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i=0; i<n; i++) cin >> a[i];

    ll sum=0;
    ll ans=0;
    rep(i,n-1){
        sum=(sum+a[i])%mod;
        ans=(ans+sum*a[i+1])%mod;
    } 
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4760
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  vector<Int> A(N);
  cin>>A;

  Int ans = 0;
  for(Int i=0;i<N;i++)
    for(Int j=i+1;j<N;j++){
      ans += A[i] * A[j];
    }

  cout<<ans<<endl;

  return 0;
}


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

using namespace std;

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

#define X first
#define Y second

const long long linf=(1LL<<63)-1;
const int N=1e2+10;

int n;
int e[N][2];


vector <int> v[N];
vector <int> q[2];
int add[N];

ll mul(ll x,ll y){
        if (y==0) return 0;
        if (x>linf/y) return linf;
        return x*y;
}
int pa[N];
pll try_center(int st){
        q[0].push_back(st);
        pll ans=pll(0,1);
        pa[st]=-1;
        for(int pha=0;q[pha].size();pha^=1){
                int max_deg=0;
                q[pha^1].clear();
                ans.X++;
                for(auto x:q[pha]){
                        max_deg=max(max_deg,int(v[x].size())-(pa[x]!=-1));
                        for(auto y:v[x]) if (y!=pa[x]){
                                pa[y]=x;
                                q[pha^1].push_back(y);
                        }
                }
                if (max_deg==0) break;
                ans.Y=mul(ans.Y,max_deg);
        }
        return ans;
}

int main(){
        cin>>n;
        for(int i=1;i<n;i++){
                int x,y;
                cin>>x>>y;
                e[i][0]=x,e[i][1]=y;
                v[x].push_back(y);
                v[y].push_back(x);
        }
        pll ans=pll(linf,linf);
        for(int i=1;i<=n;i++) 
                ans=min(ans,try_center(i));
       
        for(int i=1;i<n;i++){
                for(int j=1;j<=n+1;j++){
                        v[j].clear();
                }
                for(int j=1;j<n;j++) if (j!=i){
                        v[e[j][0]].push_back(e[j][1]);
                        v[e[j][1]].push_back(e[j][0]);
                }
                v[n+1].push_back(e[i][0]);
                v[n+1].push_back(e[i][1]);
                v[e[i][0]].push_back(n+1);
                v[e[i][1]].push_back(n+1);
                pll res=try_center(n+1);
                res.X--;
                ans=min(ans,res);
        }
        cout<<ans.X<<" "<<ans.Y;
}


Measured memory_bytes: 384
import math
from decimal import *
N,K = [int(x) for x in input().split()]
ans = 0
lk = math.log(K)
l2 = math.log(2)
for i in range(1,N+1):
    if(i>=K):
        ans+=1
    else:
        l=1
        while(i*2**l<K):
            l+=1
        ans += Decimal(0.5**l)
print(ans/N)


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

int main(void)
{
    int N;
    cin >> N;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

LL dijkstra();

vector< LP > graph[SIZE];
LL dist[SIZE];
int n, m;

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

    cin >> n >> m;
    for( int i = 0; i < m; ++i ) {
        int l, r, c;
        cin >> l >> r >> c;
        graph[l].pb( MP( r, c ) );

    }

    for( int i = 2; i <= n; ++i ) {
        graph[i].pb( MP( i - 1, 0 ) );

    }

    LL res = dijkstra();
    if( res == LINF ) res = -1;
    cout << res << endl;

    return 0;
}

LL dijkstra() {
    priority_queue< LP, vector< LP >, greater< LP > > pq;
    pq.push( MP( 1, 0 ) );
    for( int i = 0; i < SIZE; ++i ) {
        dist[i] = LINF;

    }

    while( !pq.empty() ) {
        LP node = pq.top(); pq.pop();

        if( node.F == n ) continue;

        for( int i = 0; i < graph[node.F].size(); ++i ) {
            LP p = graph[node.F][i];
            if( dist[p.F] > node.S + p.S ) {
                dist[p.F] = node.S + p.S;
                pq.push( MP( p.F, dist[p.F] ) );

            }
        }
    }

    return dist[n];
}



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

int main(){
  int n;
  cin >> n;
  n %= 10;
  if(n==2||n==4||n==5||n==7||n==9) cout << "hon" << endl;
  else if(n==0||n==1||n==6||n==8) cout << "pon" << endl;
  else cout << "bon" <<endl;
}

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

struct Node{
	int v, id;
};

const int N = 2e5 + 10;

Node a[N];
set <int> s;

bool cmp(const Node& x, const Node& y){
	return x.v < y.v;
}

int main(){
	int n, l, r;
	long long ans;
	set <int>::iterator it;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++){
		scanf("%d",&a[i].v);
		a[i].id = i;
	}
	sort(a + 1, a + n + 1, cmp);
	s.insert(0);
	s.insert(n + 1);
	ans = 0;
	for (int i = 1; i <= n; i++){
		it = s.lower_bound(a[i].id);
		r = *it;
		it--;
		l = *it;
		ans += 1LL * (r - a[i].id) * (a[i].id - l) * a[i].v;
		s.insert(a[i].id);
	} 
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include<stdio.h>
#define MAXSIZE 3000
#define PI 3.141592653589
using namespace std;
int main(){
  while(1){
    int a,b;
    char ope;
    std::cin >> a>>ope>>b;
    if('?'==ope){
      return 0;
    }else if('+'==ope){
      std::cout << a+b << '\n';
    }else if('-'==ope){
      std::cout << a-b << '\n';
    }else if('*'==ope){
      std::cout << a*b << '\n';
    }else if('/'==ope){
      std::cout << a/b << '\n';
    }
  }

}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front

// #define fisier 1

using namespace std;

typedef long long ll;

const int mod = 1000000007;
const double dancila = 3.14159265359; // PI 
const double eps = 1e-9;

int n, m, a[13][13], x, lvl[13];
int main()
{

    #ifdef fisier
        ifstream cin("input.in");
        ofstream cout("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	cin >> n >> m >> x;
	for(int i = 0; i < n; ++i)
	{
		cin >> a[i][0];
		for(int j = 1; j <= m; ++j)
			cin >> a[i][j];
	}
	int ans = (1<<30);
	for(int msk = 1; msk < (1<<n); ++msk)
	{
		int cost = 0;
		memset(lvl, 0, sizeof(lvl));
		for(int j = 0; j < n; ++j)
			if(msk & (1<<j))
			{
				cost += a[j][0];
				for(int xx = 1; xx <= m; ++xx)
					lvl[xx] += a[j][xx];
			}
		for(int i = 1; i <= m; ++i)
			if(lvl[i] < x)
				cost = (1<<30);
		ans = min(ans, cost);
	}
	cout << (ans == (1<<30) ? -1 : ans);
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
long long a[1001000];
int main()
{
    int n;
    long long ans=0;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        ans+=a[i];
    }
    int t;
    cin>>t;
    while(t--)
    {
        int c,b;
        cin>>c>>b;
        cout<<ans-a[c]+b<<endl;
    }
    return 0;
}

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

Measured memory_bytes: 584
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <math.h>
using namespace std;
char s1[100005],s2[100005];
int main()
{
    long long a,b;
    cin>>a>>b;
    cin>>s1>>s2;
    long long m = a, n = b;
	while (a!=b)
	{
		if (a>b)
			a = a-b;
		else
			b = b-a;
	}
	long long bei=m*n/a;
	long long d=bei;
	int f=0;
	if(s1[0]!=s2[0])
        f=1;
    else
    {
        long long q,p;
        q=bei/n;
        p=bei/m;
        long long r1=q,r2=p;
        while(r1<m&&r2<n)
        {
            if(s1[r1]!=s2[r2])
            {
                f=1;
                break;
            }
            r1+=q;
            r2+=p;
        }
    }
    if(f)
        cout<<"-1"<<endl;
    else
        cout<<bei<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define DEBUG true
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}


int main() {
	LL sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    LL dx = tx - sx, dy = ty - sy;
    cout << string(dy, 'U') + string(dx, 'R') + string(dy, 'D') + string(dx + 1, 'L') + string(dy + 1, 'U') + string(dx + 1, 'R') + string("DR") + string(dy + 1, 'D') + string(dx + 1, 'L') + string("U") << endl;
    
    return 0;
}


Measured memory_bytes: 256
Module Program
  Sub Main
    Dim s=Gets()
    Dim a=s(0)
    Dim ans="ABC"+a
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

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

int main() {
  string S;
  cin >> S;
  int A = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == '+') {
      A++;
    }
  }
  int B = 0;
  for (int j = 0; j < S.size(); j++) {
    if (S.at(j) == '-') {
      B++;
    }
  }
  cout << A-B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

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

int n;
int a[100000];
int l[100000];
int r[100000];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	
	l[0] = a[0];
	for (i = 1; i < n; i++) {
		l[i] = gcd(l[i - 1], a[i]);
	}
	
	r[n - 1] = a[n - 1];
	for (i = n - 2; i >= 0; i--) {
		r[i] = gcd(r[i + 1], a[i]);
	}
	
	int ans = 0;
	for (i = 0; i < n; i++) {
		int g;
		if (i == 0) {
			g = r[i + 1];
		}
		else if (i == n - 1) {
			g = l[i - 1];
		}
		else {
			g = gcd(l[i - 1], r[i + 1]);
		}
		ans = max(ans, g);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// 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 (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  string S;
  ll Q;
  cin >> S >> Q;

  deque< char > q;

  for (auto a : S) {
    q.push_back(a);
  }

  ll t, f;
  char c;

  bool rev = false;

  for (ll i = 0; i < Q; i++) {
    cin >> t;

    if (t == 1) {
      rev = !rev;
    } else {
      cin >> f >> c;

      if (f == 1) {
        if (rev) {
          q.push_back(c);
        } else {
          q.push_front(c);
        }
      } else {
        if (rev) {
          q.push_front(c);
        } else {
          q.push_back(c);
        }
      }
    }
  }

  if (!rev) {
    for (auto tmp : q) {
      cout << tmp;
    }
    cout << endl;
  } else {
    for_each(rbegin(q), rend(q), [](char elem) { cout << elem; });
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 976
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }

int main() {
  int N, T;
  cin >> N >> T;
  vector<int> A(N);
  for (int i = 0; i < (int)N; ++i) cin >> A[i];

  int m = A[N - 1];
  vector<int> B(N);
  for (int i = N - 1; i >= 0; --i) {
    B[i] = m - A[i];
    chmax(m, A[i]);
  }

  cout << count((B).begin(), (B).end(), *max_element((B).begin(), (B).end())) << endl;

  return 0;
}


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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

const int INF = 1e9;
const ll LINF = 1e18;


int main() {
    int A, B, M;
    cin >> A >> B >> M;

    vector<int> a(A);
    vector<int> b(B);

    int min_a = INF;
    int min_b = INF;

    rep(i, A) {
        cin >> a[i];
        if (a[i] < min_a)
            min_a = a[i];
    }

    rep(i, B) {
        cin >> b[i];
        if (b[i] < min_b)
            min_b = b[i];
    }

    int min = min_a + min_b;

    rep(i, M) {
        int x, y, c;
        cin >> x >> y >> c;
        if (a[x - 1] + b[y - 1] - c < min)
            min = a[x - 1] + b[y - 1] - c;
    }

    cout << min << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

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

void solve()
{
  int x,y; cin>>x>>y;
 if(y-2*x>=0 and 4*x-y>=0 and (y-2*x)%2==0 and (4*x-y)%2==0)
  cout<<"Yes\n";
  else
  cout<<"No\n"; 
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  //cin>>t;
  while(t--)
  {
   solve();
  }
  return 0;
}

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
int c(int s,int t){
	int a=1;
	for(int i=s;i>=s-t+1;i--){
		a*=i;
		a%=MOD;
	}
	int b=1;
	for(int i=1;i<=t;i++){
		b*=i;
		b%=MOD;
	}
	return a*modinv(b,MOD)%MOD;
}
signed main(){
	int n,a,b;
	cin>>n>>a>>b;
	
	cout<<(modpow(2,n,MOD)-1-c(n,a)-c(n,b)+MOD*2)%MOD<<endl;
}

Measured memory_bytes: 256
a,b = map(int, input().split())
sums = 0

if a >= b:
  sums += a
  a -= 1
else:
  sums += b
  b -= 1
  
if a >= b:
  sums += a
  a -= 1
else:
  sums += b
  b -= 1

print(sums)


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
    
    int a;
    int b;
    int ans;
    
    scanf("%d", &a);
    scanf("%d", &b);
    
    ans = a - b * 2;
    
    if(ans<0){
        
        printf("0");
        
        return 0;
        
    }
    
    printf("%d", ans);
    
    return 0;
    
}

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

int main(){
	ll x,now,i;
	cin >> x;
	now = 100;i=0;
	while(now<x){
		now = now*1.01;
		i++;
	}
	cout << i << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <iomanip>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long double ld;
typedef long long ll;
typedef double db;
#define endl '\n'
#define pb push_back
#define pii pair<ll, ll>
#define ff first
#define ss second
#define sz(x) (ll)(x).size()
#define optimize1() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#pragma warning(disable:4996)

using namespace std;

const ll MX = 1e5 + 10, N = 1e3 + 10;

int n, k;
vector<pii> b, w;
int lol[N][N];

signed main() {
    optimize1();
    cin >> n >> k;
    int mod = 2 * k;
    int x, y, kol = 0;
    char c;
    for (int i = 0; i < n; ++i) {
        cin >> x >> y >> c;
        x %= mod;
        y %= mod;
        int l = 1 ? c == 'W' : 0;
        if (x >= k)
            x -= k, l++;
        if (y >= k)
            y -= k, l++;
        l %= 2;
        if (l == 1)
            kol++, lol[x][y]--;
        else
            lol[x][y]++;
    }

    for (int i = 0; i < k; ++i)
        for (int j = 0; j < k - 1; ++j)
            lol[i][j + 1] += lol[i][j];
    for (int j = 0; j < k; ++j)
        for (int i = 0; i < k - 1; ++i)
            lol[i + 1][j] += lol[i][j];
    int ans = 0;
    for(int i = 0; i < k; ++i)
        for (int j = 0; j < k; ++j) {
            int kek = lol[k - 1][k - 1] - lol[k - 1][j] - lol[i][k - 1] + 2 * lol[i][j] + kol;
            //cout << kek << endl;
            ans = max(ans, max(kek, n - kek));
        }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7584
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    string S,T; cin >> S >> T; int ans=0;
    rep(i,3){
        if(S[i]==T[i])ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
n=list(map(int,list(input())))

#右からi桁目、繰り上げあり1、繰り上げ無し0
dp=[[0]*2 for _ in range(len(n)+1)]

nrev=n[::-1]
nrev.append(0)
dp[0][0]=nrev[0]
dp[0][1]=10-nrev[0]
#print(0,dp)
for i in range(1,len(n)+1):
    dp[i][0]=min(dp[i-1][0]+nrev[i],dp[i-1][1]+(nrev[i]+1))
    dp[i][1]=min(dp[i-1][0]+(10-nrev[i]),dp[i-1][1]+(10-(nrev[i]+1)))
    #print(i,nrev[i],dp)

print(min(dp[-1]))


        



Measured memory_bytes: 173952
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        //static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var LR = new List<Tuple<long, long>>();//L-X,X+L
            for (var i = 0; i < N; ++i)
            {
                var XL = Sarray();
                var x = XL[0];
                var l = XL[1];
                LR.Add(Tuple.Create(x - l, x + l));
            }
            var sortedlr = LR.OrderBy(lr => lr.Item1).ThenBy(lr => lr.Item2).ToList();
            var dnum = 0L;
            //重なる場合どちらかを削除。おしりが長い方を削除すればよい
            for (var b = 0L; b < N; ++b)
            {
                var f = sortedlr[(int)b];
                var skip = 0L;//削除した分スキップする
                for (var h = b + 1; h < N; ++h)
                {
                    var n = sortedlr[(int)h];
                    if (f.Item2 <= n.Item1)//重ならない
                        break;
                    if (n.Item2 <= f.Item2)//fはnを含む場合fを削除
                    {
                        ++dnum;
                        break;
                    }
                    //nを削除して次の判定
                    ++dnum;
                    ++skip;
                }
                b += skip;
            }
            WriteLine(N - dnum);
            //Out.Flush();
        }
    }
}


Measured memory_bytes: 27060
#include <stdio.h>
int main(void)
{
  int n,k;
  int c=1, d=1;
  scanf("%d %d",&n,&k);
  while(n-->0){
    c+=d;
    d=c;
    if(d>k) d=k;
  }
  printf("%d\n",c);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vt<int>>;

int main(){

  ll n,d,ans = 0;
  cin >> n >> d;

  vt<ll> x(n),y(n);
  rep(i,n) cin >> x[i] >> y[i];

  rep(i,n){
    if(d >= sqrtl(x[i]*x[i]+y[i]*y[i]))
    ans++;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6452
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
struct Point {
    double x, y;
    bool operator < (const Point& p) const {
        if(x != p.x) return x < p.x;
        return y < p.y;
    }
};


double dist(double x, double y){
    return sqrt(x * x + y * y);
}
double dist(Point p, Point q){
    return dist(p.x - q.x, p.y - q.y);
}

int main(){
    int N;
    cin >> N;
    vector<Point> ps(N);
    REP(i, N){
        double x, y;
        scanf("%lf %lf", &ps[i].x, &ps[i].y);
    }
    sort(ps.begin(), ps.end());
    double ans = dist(ps[0], ps[1]);
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N && ps[j].x - ps[i].x < ans; j++){
            ans = min(ans, dist(ps[i], ps[j]));
        }
    }
    printf("%.12f\n", ans);
    return 0;
}

Measured memory_bytes: 2580
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<vector>
#include<cstring>
#include<queue>
using namespace std;

int main(){
    char a;
    while (cin>>a)
    {
        if(a>='a' && a<'z')
            cout<<(char)(a+1)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}

int32_t main()
{
	fast;
	int t=1;
	while(t--)
	{
		int n;
		cin >> n;
		string s;
		cin >> s;
		
		vector<int> v[3];
		for(int i=0;i<n;i++)
		{
			if(s[i]=='R')
			v[0].push_back(i);
			else if(s[i]=='G')
			v[1].push_back(i);
			else
			v[2].push_back(i);
		}
		int cnt=0;
		for(int i=0;i<n-2;i++)
		{
			if(s[i]=='R')
			{
				auto it=lower_bound(v[1].begin(),v[1].end(),i+1);
				
				for(it;it!=v[1].end();it++)
				{
					auto itr=lower_bound(v[2].begin(),v[2].end(),(*it)+1);
					for(itr;itr!=v[2].end();itr++)
					if(it!=v[1].end() && itr!=v[2].end() && ((*it)-i)!=((*itr)-(*it)))
					cnt++;
				}
					it=lower_bound(v[2].begin(),v[2].end(),i+1);
				for(it;it!=v[2].end();it++)
				{
					auto itr=lower_bound(v[1].begin(),v[1].end(),(*it)+1);	
					for(itr;itr!=v[1].end();itr++)
					if(it!=v[2].end() && itr!=v[1].end() && ((*it)-i)!=((*itr)-(*it)))
					cnt++;
				}
			}
			else if(s[i]=='G')
			{
				auto it=lower_bound(v[0].begin(),v[0].end(),i+1);
				for(it;it!=v[0].end();it++)
				{
					auto itr=lower_bound(v[2].begin(),v[2].end(),(*it)+1);
					for(itr;itr!=v[2].end();itr++)
					if(it!=v[0].end() && itr!=v[2].end() && ((*it)-i)!=((*itr)-(*it)))
					cnt++;
				}
				it=lower_bound(v[2].begin(),v[2].end(),i+1);
				for(it;it!=v[2].end();it++)
				{
					auto itr=lower_bound(v[0].begin(),v[0].end(),(*it)+1);
					for(itr;itr!=v[0].end();itr++)
					if(it!=v[2].end() && itr!=v[0].end() && ((*it)-i)!=((*itr)-(*it)))
					cnt++;
				}
			}
			else
			{
				auto it=lower_bound(v[0].begin(),v[0].end(),i+1);
				for(it;it!=v[0].end();it++)
				{
					auto itr=lower_bound(v[1].begin(),v[1].end(),(*it)+1);
					for(itr;itr!=v[1].end();itr++)
					if(it!=v[0].end() && itr!=v[1].end() && ((*it)-i)!=((*itr)-(*it)))
					cnt++;
				}
				it=lower_bound(v[1].begin(),v[1].end(),i+1);
				for(it;it!=v[1].end();it++)
				{
					auto itr=lower_bound(v[0].begin(),v[0].end(),(*it)+1);
					for(itr;itr!=v[0].end();itr++)
					if(it!=v[1].end() && itr!=v[0].end() && ((*it)-i)!=((*itr)-(*it)))
					cnt++;
				}
			}
		}
		cout << cnt;
	}
}




Measured memory_bytes: 3668
import std.stdio, std.conv, std.string, std.algorithm.iteration, std.math, std.range, std.algorithm.sorting, std.algorithm.searching, std.algorithm.mutation, std.array, std.typecons;

void main()
{
    readln;
    auto t = readln;
    int[] list = t.split.to!(int[]);
    int[] eList;
    int[] oList;
    eList.length = 100001;
    oList.length = 100001;
    foreach(i, n; list.enumerate())
    {
        if(i % 2 == 0)
        {
            eList[n]++;
        }else{
            oList[n]++;
        }
    }

    auto eTop = searchTop2Index(eList);
    auto oTop = searchTop2Index(oList);
    int eSameNum = eTop[0];
    int oSameNum = oTop[0];
    if(eSameNum == oSameNum)
    {
        if(eList[eTop[1]] < oList[oTop[1]])
        {
            oSameNum = oTop[1];
        }else{
            eSameNum = eTop[1];
        }
    }

    writeln(list.length - eList[eSameNum] - oList[oSameNum]);
}

auto searchTop2Index(int[] list)
{
    int top1;
    int top1Count;
    int top2;
    int top2Count;
    foreach(i, n; list.enumerate())
    {
        if(top1Count < n)
        {
            top2 = top1;
            top2Count = top1Count;
            top1 = i.to!int;
            top1Count = n;
        }else if(top2Count < n)
        {
            top2 = i.to!int;
            top2Count = n;
        }
    }
    return Tuple!(int,int)(top1, top2);
}

Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int > pp;
typedef long long ll;
 
#define sz(x) (int)x.size() 
int const N=3e5+10,oo=1e9;
ll const OO=2e18;
double const eps=1e-8,PI=acos(-1);
int mod=oo+7;

int n,aa[N],bb[N],cnt[N];
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>n;
  for(int i=0;i<n;i++)cin>>aa[i];
  int h=0;
  for(int i=0;i<n;i++){
      int j=i;
      while(j<n&&aa[j]==aa[i])j++;
      bb[h]=aa[i];
      h++;
      i=j-1;
  }
  cnt[bb[0]]=1;
  for(int i=1;i<h;i++){
      cnt[bb[i]]+=cnt[bb[i-1]];
      cnt[bb[i]]%=mod;
  }
  cout<<cnt[bb[h-1]];
  return 0;
}


Measured memory_bytes: 2560
#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);
  rep(i,n){
    cin >> a[i];
  }
  vector<int>ans(n);
  rep(i,n) {
    ans[a[i]-1]=i+1;
  }
  rep(i,n) {
    cout << ans[i] << endl;;
  }
  return 0;
}


Measured memory_bytes: 1664
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

map<char, long long> cnts;

int main(){
	FIO
	
	long long n;cin >> n;
	//vector<int> a = {1, 2, 3, 4, 5, 6, 7};
	//vector<int> ans;
	//int max_ = -1;
	//do{
		//int res = 0;
		//forn(i, a.size()){
			//res += (a[i] % (i + 1));
		//}
		//max_ = max(res, max_);
		////deb(res);
	//}while(next_permutation(all(a)));
	//deb(max_);
	if(n % 2){
		cout << n * (n / 2);
	}
	else cout << n * (n/2 - 1) + n / 2;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void solve() {
	int n;
	while (cin >> n,n) {
		vector<int> v[30];
		rep(i, n) {
			int c; cin >> c;
			rep(j, c) {
				int d; cin >> d; d--;
				v[d].push_back(i);
			}
		}
		bool f = false;
		rep(i, 30) {
			rep(j, n) {
				//dayiでj人目
				vector<bool> used(n, false);
				used[j] = true;
				for (int k = i; k >= 0;k--) {
					bool g = false;
					rep(l, v[k].size()) {
						if (used[v[k][l]])g = true;
					}
					if (g) {
						rep(l, v[k].size()) {
							used[v[k][l]] = true;
						}
					}
				}
				bool g = true;
				rep(k, n) {
					if (!used[k])g = false;
				}
				if (g) {
					f = true; cout << i+1 << endl; break;
				}
			}
			if (f)break;
		}
		if (!f) {
			cout << -1 << endl;
		}
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(7);
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <ctime>

using namespace std;

#define LOCAL 0
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1& arg1){
    cerr << name << ": " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1& arg1, Args&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " /";
    __f(comma + 1, args...);
}

template <class T> bool mini(T& a, T b) { return a > b ? (a = b, 1) : 0; }
template <class T> bool maxi(T& a, T b) { return a < b ? (a = b, 1) : 0; }

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<LL> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1e9 + 7;

int main() {
#if LOCAL
    freopen("CP.inp", "r", stdin);
//    freopen("CP.out", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vi a(n); fore(i, 0, n) cin >> a[i];
    vi l(n), r(n);
    fore(i, 0, n) l[i] = (i == 0 ? a[i] : __gcd(l[i - 1], a[i]));
    ford(i, n - 1, 0) r[i] = (i == n - 1 ? a[i] : __gcd(r[i + 1], a[i]));
    LL ans = max(l[n - 2], r[1]);
    fore(i, 1, n - 1) maxi(ans, __gcd(l[i - 1], r[i + 1]));
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
#include<cmath>
#include<iostream>
#include<climits>
using namespace std;
int n,h[100001],f[100001];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&h[i]);
		f[i]=INT_MAX;
	}
	f[1]=0;
	f[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++){
		f[i]=min(f[i],min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2])));
	}
	printf("%d",f[n]);
}

Measured memory_bytes: 1024
local n=io.read("n")
local mod=1000000007
local a={}
local b={[0]=0}
for i=1,n do
    a[i]=io.read("n")%mod
    b[i]=(b[i-1]+a[i])%mod
end

local total=0
for i=1,n-1 do
    total=total+a[i]*(b[n]-b[i])%mod
end
print(total%mod)

Measured memory_bytes: 10548
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long 
#define int ll
//#define slld(t) scanf("%lld",&t)
// #define sd(t) scanf("%d",&t)
// #define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define pdd pair<double , double>
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N    105
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
#define s3   1.73205080757          // square root 3
const  int inf = (int)1e18+10 ;
const int MAX= 100;

 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ordered_set S;

int powmod(int x , int y){
	int res = 1;
	while(y > 0){
		if(y%2==1)
			res = (res*x)%mod;
		x = (x*x)%mod;
		y/=2;
	}
	return res;
}
int mul(int x , int y){
	return (x*y)%mod;
}


int a[N][N] = {{0}} , b[N][N] = {{0}} , c[N][N] = {{0}};
bool dp[N][N][26000] = {{{0}}};
signed main(){
  fast;
  
 
  int h , w;
  cin >> h >> w;
  // cout << (1300 * 80 * 80) << endl;
  for(int i = 1 ; i <= h ; i++){
  	   for(int j = 1 ; j <= w ; j++){
  	   	     cin >> a[i][j];
  	   }
  }
  for(int i = 1 ; i <= h ; i++){
  	   for(int j = 1 ; j <= w ; j++){
  	   	     cin >> b[i][j];
  	   	     c[i][j] = a[i][j] - b[i][j];
  	   }
  }

  int mx = 12810;
  dp[1][1][mx + c[1][1]] = 1;
  dp[1][1][mx - c[1][1]] = 1;

  for(int i = 1 ; i <= h ; i++){
  	   for(int j = 1 ; j <= w ; j++){
  	   	    for(int sum = 0 ; sum <= mx + mx ; sum++){
  	   	    	   int val1 = sum - c[i][j];
  	   	    	   int val2 = sum + c[i][j];
  	   	    	   if(val1 >= 0 && val1 <= mx + mx)
  	   	    	   dp[i][j][sum] |= (dp[i-1][j][val1] | dp[i][j-1][val1]);
  	   	    	   if(val2 >= 0 && val2 <= mx + mx)
  	   	    	   dp[i][j][sum] |= (dp[i-1][j][val2] | dp[i][j-1][val2]);
  	   	    }  
  	   }
  }
  int ans1 , ans2;
  for(int i = mx ; i <= mx + mx ; i++)
  	if(dp[h][w][i]){
  		  ans1 = i - mx;
  		  break;
  	}
  for(int i = mx - 1 ; i >= 0 ; i--)
  	if(dp[h][w][i]){
  		  ans2= mx - i;
  		  break;
  }
  cout << min(ans2 , ans1) << endl;

 }

Measured memory_bytes: 215552
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 605;
const int MM = 1000000007;

int main()
{
	ll X, Y;
	scanf("%lld%lld", &X, &Y);
	for(int t = 1;; t++){
		if( X*2 > Y ) return !printf("%d\n", t);
		X *= 2;
	}
}


Measured memory_bytes: 256