akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

const int MOD = 1e9 + 7;
const ll INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;



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

	string S; cin >> S;
	int N = S.size();
	int i = 0;
	int ans = 1;
	i = 1;
	int num = 1;
	while (i < N) {
		if (num == 1) {
			if (S[i - 1] == S[i]) {
				if (i == N - 1)break;
				ans++;
				i += 2;
				num = 2;
			}
			else {
				ans++;
				i += 1;
			}
		}
		else {
			ans++;
			num = 1;
			i++;
		}
	}
	print(ans);
}



Measured memory_bytes: 720
//https://atcoder.jp/contests/abc148/tasks/abc148_b
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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() {
    ll N; cin>>N;
    string S,T; cin>>S>>T;
    FOR(i,0,N){
        cout<<S.at(i)<<T.at(i);
    }    
    cout<<endl;
    return 0;
}

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


void solve(long long N){
    long long res = 0;
    for (long long i = 1; i <= N; i++) {
        if (i % 3 == 0 || i % 5 == 0 || i % 15 == 0) continue;
        res+=i;
    }
    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

int ceil(int a, int b){
  if(a % b == 0) return a / b;
  return a / b + 1;
}

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

  int n, k;
  cin >> n >> k;

  int ans = ceil(n - 1, k - 1);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
src = list(map(int,input().split()))

seq = 0
mem = []
for i,a in enumerate(src):
    a -= 1
    if i == a:
        seq += 1
    else:
        if seq > 0:
            mem.append(seq)
            seq = 0
if seq:
    mem.append(seq)

ans = 0
for m in mem:
    ans += (m+1)//2
print(ans)


Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
int main(){
    char s[3]={};
    int count=0;
    for(int i=0;i<3;i++){
        cin>>s[i];
        if(s[i]=='o'){
            count++;
        }
    }
    cout<<700+count*100<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
      
		long n = long.Parse(Console.ReadLine());
      if(n==109)Console.WriteLine(19);////////////////
    long digit = whatDigit(n);
    long answer = 0;
    if(n<10) Console.WriteLine(n);
    else
    {
      answer += 9*(digit-1);
      long memo = 10;
      for(long i = 0; i < digit-2; i++)
      {
        memo *= 10;
      }
      answer += n / memo - 1;
      if(n % 10 == 9) answer++;
      Console.WriteLine(answer);
    }
	}
  
  static long whatDigit (long n)//nは何桁か
  {
    for(long i = 1; i < 20; i++)
    {
      n /= 10;
      if(n == 0)
      {
        return i;
        break;
      }
    }
    return 0;
  }
}


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

int main() {
  int h, w;
  scanf("%d %d", &h, &w);

  long long ans;
  if (h == 1 || w == 1)
    ans = 1;
  else if (h % 2 == 0 || w % 2 == 0)
    ans = 1LL * h * w / 2;
  else {
    ans = 1LL * (h / 2) * w;
    ans += (w + 1) / 2;
  }
  printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 256
#include"stdio.h"
#include<iostream>

using namespace std;

int getLeftChild(int node_num){
  return 2*node_num;
}

int getRightChild(int node_num){
  return 2*node_num+1;
}

void swapHeap(int data[], int node1, int node2){
  int dummy;

  dummy       = data[node1];
  data[node1] = data[node2];
  data[node2] = dummy;
  
}


void maxHeapify(int data[], int N, int node_num){
  int node_left_child  = getLeftChild(node_num);
  int node_right_child = getRightChild(node_num);

  int largest;

  if(node_left_child <= N && data[node_left_child] > data[node_num]){
    largest = node_left_child;
  }else{
    largest = node_num;
  }

  if(node_right_child <= N && data[node_right_child] > data[largest]){
    largest = node_right_child;    
  }

  if(largest != node_num){
    swapHeap(data, node_num, largest);
    maxHeapify(data, N,  largest);
  }
}


void buildMaxHeap(int data[], int N){
  for(int i = int(N/2);i >= 1;i--){
    maxHeapify(data, N , i);
  }
}

void printHeap(int data[], int N){
  for(int i=1;i<=N;i++){
    printf(" %d", data[i]);
  }
  printf("\n");
}

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

  int* data = new int [N+1];

  for(int i=1;i<=N;i++){
    cin >> data[i];
  }

  buildMaxHeap(data, N);
  printHeap(data,N);

  delete [] data;

  return 0;
}



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

int main(){
	int a,b;
	cin >> a >> b;
	int c = a - 2*b;
	if(a>=2*b)	cout << c << endl;
	else cout << "0" << endl;
	return 0;
}

Measured memory_bytes: 256
//It’s never too late to become what you might have been....
 #include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1000000000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define boost1 ios::sync_with_stdio(false);
#define boost2 cin.tie(0);
#define mem(a,val) memset(a,val,sizeof a)
#define endl "\n"
#define maxn 100001

ll dp[maxn][25],l,r,a[maxn];
int ok(ll x)
{
	ll cur=l;
	for(ll j=20;j>=0;j--)
	{
		if(x&(1<<j))
		cur=dp[cur][j];
	}
	return cur>=r;
}
int main()
{
	boost1;boost2;	
	ll i,j,n,x,y,lo,mid,hi,ind,q,L;
	cin>>n;
	for(i=1;i<=n;i++)
	cin>>a[i];
	cin>>L;
	for(i=1;i<=n;i++)
	{
		x=a[i]+L;
		if(a[n]<=x)
		dp[i][0]=n;
		else
		{
			ind=lower_bound(a+1,a+n+1,x)-a;
			if(a[ind]>x)
			ind--;
			assert(a[ind]<=x);
			dp[i][0]=ind;
		}
	}
	for(j=1;j<20;j++)
	{
		for(i=1;i<=n;i++)
		dp[i][j]=dp[dp[i][j-1]][j-1];
	}
	cin>>q;
	while(q--)
	{
		cin>>l>>r;
		if(l>r)
		swap(l,r);
		lo=0;
		hi=n;
		while(hi-lo>1)
		{
			mid=(lo+hi)/2;
			if(ok(mid))
			hi=mid;
			else
			lo=mid;
		}
		cout<<hi<<endl;
	}
	return 0;
}


Measured memory_bytes: 21120
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

int main() {
	
	int n;
	cin >> n;
	vector<double> a(n);
	rep(i, n) cin >> a.at(i);
	sort(a.begin(), a.end());

	 double ans = (a.at(0) + a.at(1)) / 2;
	 
	 for (int i = 2; i < n; i++) {
		 ans = (ans + a.at(i)) / 2;
	 }

	 cout << ans << endl;

	return 0;
}

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s;
	int k;
	cin >> s >> k;
	if(SZ(s) == 1)
	{
		cout << (k >> 1) << "\n";
		return 0;
	}
	bool eq = s[0] == s.back();
	int n = SZ(s);
	s += s;
	int k1 = 0, k2 = 0;
	FOR(i, 1, SZ(s))
		if(s[i] == s[i - 1])
		{
			s[i] = '#';
			if(i < n)
				k1++;
			else
				k2++;
		}
	LL ans;
	if(!eq || s[n - 1] == '#')
		ans = (LL)k * k1;
	else if(s.back() == '#')
		ans = (LL)(k >> 1) * (k1 + k2) + (k & 1) * k1;
	else
		ans = k1 + (k - 1LL) * k2;
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;
using P = pair<int,int>;
using Q = pair<P,P>;

int n,m,q;
vector<int>a;
vector<Q>d;
int ans;

void dfs(int i,int x){
  if(i==n){
    int sum=0;
    rep(i,q){
      int k=d[i].fi.fi;
      int l=d[i].fi.se;
      int c=d[i].se.fi;
      int s=d[i].se.se;
      if(a[l]-a[k]==c)sum+=s;
    }
    chmax(ans,sum);
    return;
  }
  for(int j=x;j<=m;j++){
    a.push_back(j);
    dfs(i+1,j);
    a.pop_back();
  }
}

int main(){
  cin>>n>>m>>q;
  rep(i,q){
    int p,b,c,e;
    cin>>p>>b>>c>>e;
    p--;b--;
    d.emplace_back(Q(P(p,b),P(c,e)));
  }
  dfs(0,1);
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int n;
int a[1000009];
int dp[100009];
int ssss(int i)
{
    if(i==n)return 0;
 
    if(dp[i]!=-1)
        return dp[i];
    int d=0;
    for(int j=i+1;j<n;j++)
    {
        if(a[j]>a[i])d=max(d,1+ssss(j));
    }
    return dp[i]=d;
}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    /*int ans=0;
    for(int i=0;i<n;i++)
        ans=max(ans,1+ssss(i));
    cout<<ans;*/
    sort(a,a+n);
    int last=-1,ans=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]>last)
        {
            ans++;
            last=a[i];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 640
from heapq import*
L,R=[],[]
B=0
Q,*E=open(0)
for e in E:
    if e[0]>'1':
        w=-L[0]
        print(w,B+w*(len(L)>len(R)))
    else:
        _,a,b=map(int,e.split())
        B+=b
        if len(L)>len(R):
            B-=a
            a=-heappushpop(L,-a)
            B+=a+a
            heappush(R,a)
        else:
            B+=a
            a=heappushpop(R,a)
            B-=a+a
            heappush(L,-a)

Measured memory_bytes: 28656
'use strict'
function Main(input){
  input=readAsNumArray(input);
  var N=input.shift();
  input=binarySearchSort(input);
  var A=input;
  if(N===1){
    console.log(A[0]);
    return;
  }
  var g=A[0];
  for(let i=0;i<N-1;i++){
    g=GCM(A[i+1],g);
  }
  console.log(g);
} 

function GCM(a,b){
  while(!(a===0||b===0)){
    if(a>b){
      a=a%b;
    }else{
      b=b%a;
    }
  }
  var m=Math.max(a,b)
  return m;
}

function readAsNumArray(input){

var I=[],i=0;

var checkNum=/^-*\d+/;

var checkSpace=/ +|\n+/;

while(input.length>0){

if(input.match(checkNum)!==null){

I[i]=parseInt(input.match(checkNum)[0]);

input=input.replace(checkNum,""); 

i++;

continue;

}

input=input.replace(checkSpace,"");

continue;

} 
return input=I;
}

function binarySearchSort(arr){
  var n=arr.length;
  var newArr=[];
  for(let i=0;i<n;i++){
    var d=0,m=0,u=n-1;
    m=Math.floor((d+u)/2);
    while(!(d>u)){
      if(newArr[m]<arr[i]){
        d=m+1;
      }else{
        u=m-1;
      }
      m=Math.floor((d+u)/2);
    }
    newArr.splice(m+1,0,arr[i]);
  }
  return newArr;
}


Main(require('fs').readFileSync('/dev/stdin','utf8'));


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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<ll, ll>a,pair<ll,ll>b)
{
    return a.fi>b.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
/*
const int mxn = 5*(1e6) +10;
vi spf(mxn);
void sieve()
{
    for(ll i =0;i<mxn;i++)spf[i]  = i;
    for(ll i=2;i<mxn;i+=2)spf[i] = 2;
    for(ll i = 3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(ll j = i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)spf[j] = i;
            }
        }
    }
}
*/

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll n; cin>>n;
vi arr(n);
rep(i,0,n)cin>>arr[i];
ll ans = 1000;
ll curr = INT_MAX;
for(ll i=0;i<n;i++)
{
    if(curr>=arr[i])curr = arr[i];
    else
    {
        ll x = ans/curr;
        ans+=x*(arr[i]-curr);
        if(x>0)curr = arr[i];
    }
}
cout<<ans<<endl;
return 0;
}
/*
23 5
10 3 3
2 1 4 11 8 10 5 6 7 9 12 3 14 13 16 18 21 15 17 19 20 23 22
4 6 3 18 23
*/


Measured memory_bytes: 3656
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
int dp[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	while (m--)
	{
		int x;
		cin >> x;
		dp[x] = -1;
	}
	dp[0] = 1;
	for (int i = 1; i <= n; i++)
	{
		if (dp[i] == -1) dp[i] = 0;
		else if (i == 1) dp[i] = dp[i - 1];
		else dp[i] = (dp[i - 1] + dp[i - 2]) % INF;
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(){

    ll n;
    cin>>n;

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

    ll val = 0;
    for(ll i=0;i<n;i++){
        val ^= v[i];
    }

    for(ll i=0;i<n;i++){
        ll ans = val ^ v[i];
        cout<<ans<<" ";
    }
    return 0;
}


Measured memory_bytes: 4772
A, B, C = map(int, input().split())
K = int(input())
m_sum = A + B + C
a = max(A, B, C)
b = min(A, B, C)
c = m_sum - a - b
for i in range(K):
	m_sum += max(a, b, c)
	a *= 2
print(m_sum)

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll k, a, b;
    cin >> k >> a >> b;
    bool ok = false;
    for (ll c = a; c <= b; c++)
    {
        if (c % k == 0)
            ok = true;
    }
    if (ok)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
}


Measured memory_bytes: 3648
// https://atcoder.jp/contests/arc069/tasks/arc069_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  string S;
  cin >> N >> S;

  auto get_next = [](char prev, char cur, char ch) -> char {
    if (cur == 'S' && ch == 'o') return prev == 'S' ? 'S' : 'W';
    if (cur == 'S' && ch == 'x') return prev == 'S' ? 'W' : 'S';
    if (cur == 'W' && ch == 'o') return prev == 'S' ? 'W' : 'S';
    if (cur == 'W' && ch == 'x') return prev == 'S' ? 'S' : 'W';
  };

  auto to_s = [](ll v) -> char { return v == 0 ? 'S' : 'W'; };

  rep(f, 2) rep(s, 2) {
    string res;

    res.push_back(to_s(f));
    res.push_back(to_s(s));

    repf(cur_i, 1, N - 1) {
      char n = get_next(res[cur_i - 1], res[cur_i], S[cur_i]);
      res.push_back(n);
    }

    if (get_next(res[N - 2], res[N - 1], S[N - 1]) == res[0] &&
        get_next(res[N - 1], res[0], S[0]) == res[1])
      drop(res);
  }

  drop(-1);
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  set<int> s;
  rep(i, n) {
    int x; cin >> x;
    s.insert(x);
  }
  cout << (n == s.size() ? "YES" : "NO") << endl;
}


Measured memory_bytes: 9600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)        cout<<a<<endl;
#else
#define tr(a)    
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)    for(int i=a;i<b;i++)
using namespace std;
vi stones;
vi adj[100005];
bool isGood=1;
int dfs(int u,int p){
    vi recv;
    if(sz(adj[u])==1)return stones[u];
    for(auto i:adj[u])if(i!=p)recv.pb(dfs(i,u));
    ll sum=accumulate(all(recv),0LL);
    sort(all(recv));
    ll maxpairs=min(sum/2,sum-recv.back());
    if(sum<stones[u]){isGood=0;return 0;}
    int pair=sum-stones[u];
    //pair is number of pairs
    if(pair>maxpairs){
        isGood=0;
        return 0;
    }
    return sum-2*pair;
}
void solve(){
    int N;
    cin>>N;
    stones.resize(N);
    rep(i,0,N)cin>>stones[i];
    int root=-1;
    if(N==2){
        if(stones[0]==stones[1]){
            cout<<"YES\n";
            return;
        }
        else{
            cout<<"NO\n";
            return;
        }
    }
    rep(i,0,N-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        adj[a].pb(b);
        adj[b].pb(a);
        if(sz(adj[a])>1)root=a;
        if(sz(adj[b])>1)root=b;
    }
    if(!dfs(root,-1) and isGood){
        cout<<"YES\n";
    }
    else{
        cout<<"NO\n";
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

int main(){
  int n; cin >> n;
  int a[n];
  int two = 0;
  int four = 0;
  rep(i, n) {
    cin >> a[i];
    if(a[i] % 4 == 0) four++;
    else if(a[i] % 2 == 0) two++;
  }
  if(four * 2 + 1 >= n ||  four * 2 + two >= n) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0; 
}

Measured memory_bytes: 3980
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            if(N % 2 != 0)
            {
                Console.WriteLine("No");
                return;
            }

            string T1 = S.Substring(0, N / 2);
            string T2 = S.Substring(N / 2, N / 2);
            for (int i = 0; i < N/2; i++)
            {
                if(T1[i] != T2[i])
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
            return;
        }
    }
}


Measured memory_bytes: 13140
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n; cin >> n ; vl num(n);
  
  rep(i,n) cin >> num[i];
  
  ll sum = 0;
  
  rep(i,n){
    sum = (sum^num[i]);
  }
  
  rep(i,n){
    cout << (sum^num[i]) << ' ';
  }
  
}

Measured memory_bytes: 4756
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  unsigned N, A, B;
  std::cin >> N >> A >> B;
  std::vector<unsigned> h(N);
  for (unsigned i = 0; i < N; ++i) {
    std::cin >> h[i];
  }
  auto C = A - B;
  unsigned long long min = 0;
  unsigned long long max = std::numeric_limits<unsigned>::max() / (B * 2);
  unsigned long long ans = std::numeric_limits<unsigned>::max();
  for (unsigned i = 0; i < 100; ++i) {
    auto center = (min + max) / 2;
    if (i == 99) { ++center; }
    unsigned long long hoge = center * B;
    unsigned long long accum = 0;
    for (unsigned j = 0; j < N; ++j) {
      if (h[j] > hoge) {
        accum += (h[j] - hoge) / C;
        if ((h[j] - hoge) % C) { ++accum; }
      }
    }
    if (accum > center) {
      min = center;
    } else {
      max = center;
    }
    ans = std::min(ans, std::max(accum, center));
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 640
N = int(input())

Firstlist = []
for i in range (0, N):
	Firstlist.append(input())

M = int(input())

Secondlist = []
for i in range (0, M):
	Secondlist.append(input())

Firstlist_set = list(set(Firstlist))

Point = []
for i in range (0, len(Firstlist_set)):
	Point.append(Firstlist.count(Firstlist_set[i]))

for i in range (0, len(Firstlist_set)):
	Point[i] = Point[i] - Secondlist.count(Firstlist_set[i])

print(max(max(Point),0))

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

int main() {
  int a , b , c;
  cin >> a >> b;
  c = a * b % 2;
  
  if (c == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }

  
}


Measured memory_bytes: 256
#include<stdio.h>
int f(int);
int fib[45];
int main(){
  int i,n;
  scanf("%d",&n );
  for (i = 0; i < n+1; i++) {
    fib[i]=f(i);

  }
  printf("%d\n",fib[n]);
return 0;
}
int f(int n){
  if (n==0||n==1) {
    return 1;
  }
  else return fib[n-2]+fib[n-1];
}

Measured memory_bytes: 596
<?php

while ($stdin = fgets(STDIN)) {
    $line[] = trim($stdin);
}
foreach ($line as $key => $value) {
    $data[] = explode(' ', $value);
}

foreach ($data as &$line) {
    $line = array_map(function($val) { return (int)$val; }, $line);
}


$N = $data[0][0];
$ans = 0;

for ($i = 1; $i <= $N; $i++) {
    $ans += $i;
}


printf('%s', $ans);


Measured memory_bytes: 4728
unittest
{
//	assert( [ "8 6" ].parse.expand.solve == 16 );
	assert( [ "3 3" ].parse.expand.solve == -1 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto xy = input.front.split.to!( long[] );
	return tuple( xy[ 0 ], xy[ 1 ] );
}

auto solve( long x, long y )
{
	if( x % y == 0 ) return -1;
	else             return x;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void print_vec(vector<int>& a,int n=-1){
	n = (n==-1 ? a.size():n);
	for(int i=0;i<n;i++)
		cout << a[i] << (i<n-1 ? " ":"\n");
}

void print_vec(vector<long long>& a,int n=-1){
	n=(n==-1 ? a.size():n);
	for(int i=0;i<n;i++)
		cout << a[i] << (i<n-1 ? " ":"\n");
}

void solve(){
	int n;
	cin>>n;
	int m=(1<<n)-1;
	vector<vector<int>> all_poss(m+1,vector<int>(n,0));
	for(int i=0;i<all_poss.size();i++){
		int j=i;
		for(int k=0;k<n;k++){
			all_poss[i][k]=j%2;
			j/=2;
		}
	}

	vector<vector<pair<int,int>>> que(n);
	for(int i=0;i<n;i++){
		int an;
		cin>>an;
		for(int j=0;j<an;j++){
			int x,y;
			cin>>x>>y;
			que[i].pb({x-1,y});
		}
	}

	int ans=0;
	for(int i=0;i<all_poss.size();i++){
		bool flag = true;
		for(int j=0;j<n;j++){
			for(int k=0;k<que[j].size();k++){
				if(all_poss[i][j]==1){
					if(que[j][k].S == 1){
						if(all_poss[i][que[j][k].F] == 0)
							flag=false;
					}
					else{
						if(all_poss[i][que[j][k].F] == 1)
							flag = false;
					}
				}
			}
		}

		if(flag){
			int sm = 0;
			for(int j=0;j<n;j++){
				sm+=all_poss[i][j];
				ans = max(ans,sm);
			}
		}
	}
	cout << ans << "\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	
	solve();
	return 0;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>
#include <queue>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N, M;
  std::cin >> N >> M;
  std::vector<int> u(M);
  std::vector<int> v(M);
  for (int i = 0; i < M; ++i) {
    std::cin >> u[i] >> v[i];
    u[i]--, v[i]--;
  }
  int S, T;
  std::cin >> S >> T;
  S--, T--;

  std::vector<std::vector<int>> G(N);
  for (int i = 0; i < M; ++i)
    G[u[i]].push_back(v[i]);

  // Main
  std::vector<std::vector<int>> visited(N);
  for (int i = 0; i < N; ++i)
    visited[i] = std::vector<int>(3, -1);
  visited[S][0] = 0;

  std::queue<std::pair<int, int>> que;
  que.push(std::make_pair(S, 0));

  // int j = 0;
  while (not que.empty()) {
    int v, k;
    // std::cout << "node: " << v << std::endl;
    std::tie(v, k) = que.front();
    que.pop();
    int l = k + 1;
    if (l >= 3)
      l = 0;
    for (auto c : G[v]) {
      if (visited[c][l] >= 0)
        continue;
      assert(visited[c][l] == -1);
      visited[c][l] = visited[v][k] + 1;
      que.push(std::make_pair(c, l));
    }
  }

  // Output
  if (visited[T][0] == -1) {
    std::cout << -1 << std::endl;
  } else {
    std::cout << visited[T][0] / 3 << std::endl;
  }

  return 0;
}


Measured memory_bytes: 12032
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

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

		String s = sc.next();

		SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");


		Date std = sdf.parse("2019/04/30");

		Date date = sdf.parse(s);



		if(date.after(std)) {
			System.out.println("TBD");
		} else {
			System.out.println("Heisei");
		}


		sc.close();
	}

}


Measured memory_bytes: 22480
N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(M)]

def comb(n):
    return n*(n+1)//2

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
        self.size = [1] * N
        self.connection = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        self.connection -= (comb(self.size[ra]) + comb(self.size[rb]))
        self.connection += comb(self.size[ra] + self.size[rb])
        if self.rank[ra] < self.rank[rb]:
            self.size[rb] += self.size[ra]
            self.parent[ra] = rb
        else:
            self.size[ra] += self.size[rb]
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1

uf = UnionFind(N)
ans = [N*(N-1)//2]

for a,b in list(reversed(src))[:-1]:
    a,b = a-1,b-1
    uf.unite(a,b)
    ans.append(ans[0] - uf.connection)

print(*ans[::-1], sep='\n')

Measured memory_bytes: 27744
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

struct plot {
  int_least16_t X;
  int Y;
  ll H;
};

void printAns(int x, int y, ll z) { cout << x << ' ' << y << ' ' << z << endl; }

bool plotCompareH(const plot& p1, const plot& p2) { return p1.H > p2.H; }

int main() {
  int N;
  cin >> N;
  vector<plot> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i].X >> p[i].Y >> p[i].H;
  }

  sort(p.begin(), p.end(), plotCompareH);

  if (N == 1) {
    printAns(p[0].X, p[0].Y, p[0].H);
    return 0;
  }

  for (int Cx = 0; Cx <= 100; Cx++) {
    for (int Cy = 0; Cy <= 100; Cy++) {
      ll Top = abs(Cx - p[0].X) + abs(Cy - p[0].Y) + p[0].H;
      int cnt = 1;
      for (int i = 1; i < N; i++) {
        if (p[i].H == max(Top - abs(p[i].X - Cx) - abs(p[i].Y - Cy), 0LL))
          cnt++;
      }
      if (cnt == N) {
        printAns(Cx, Cy, Top);
        return 0;
      }
    }
  }
  return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a<c && b<c){
    cout << a+b << endl;}
  else if(b<a && c<a){
    cout << b+c << endl;}
  else{
    cout << c+a << endl;}
}

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

using namespace std;

const int N = 1e5 + 5;

int n, a[N], m;
long long pref[N];
map <long long, long long> mm;

void input(){
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
}

void solve(){
    pref[0] = 0;
    for (int i = 1; i <= n; i++) pref[i] = pref[i - 1] + a[i];

    long long ans = 0;
    mm[0] = 1;
    for (int i = 1; i <= n; i++) {
        ans += mm[pref[i] % m];
        mm[pref[i] % m]++;
    }

    //for (int i = 1; i <= n; i++) if (a[i] % m == 0) ans++;

    printf("%lld", ans);
}

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


Measured memory_bytes: 5376
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,fa[100005],s[100005],e[100005],siz[100005];
typedef long long ll;
ll cur,ans[100005];
int find(int x){
    if(fa[x]==x) return x;
    return fa[x]=find(fa[x]);
}
inline ll calc(ll x){return x*(x-1)/2;}
int main()
{
    scanf("%d%d",&n,&m); 
    for(int i=1;i<=m;i++) scanf("%d%d",s+i,e+i);
    for(int i=1;i<=n;i++) fa[i]=i,siz[i]=1;
    ll tot=calc(n);
    ans[m+1]=tot;
    for(int i=m;i>1;i--){
        int a=find(s[i]),b=find(e[i]);
        if(siz[a]<siz[b]) swap(a,b);
        if(a!=b) {fa[b]=fa[a];
        cur-=calc(siz[a]);
        cur-=calc(siz[b]);
        siz[a]+=siz[b];siz[b]=0;
        cur+=calc(siz[a]);}
        ans[i]=tot-cur;
    }
    for(int i=2;i<=m+1;i++) printf("%lld\n",ans[i]);
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <cmath>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    int sum=0;
    int x;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        sum+=x;
    }
    if(sum>n)
    cout<<"-1";
    else
    cout<<n-sum;
}



Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;

int main()
{
  int x;
  cin >> x;
  ll ans = 0;
  if (x >= 500)
  {
    ans += (x / 500) * 1000;
    x %= 500;
  }
  ans += (x / 5) * 5;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<assert.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 1e6+10, M = 1e6+10;
int n;
int main() {
	int mx = 0, f1 = 0;
	cin>>n;
	for(int i = 0;i < n;i++) {
		int x, y;
		cin>>x>>y;
		if(x == y) {
			mx++;
		} else {
			if(mx >= 3) f1 = 1;
			mx = 0;
		}
	}
	if(mx >= 3) f1 = 1;
	if(f1) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
    int N, M;
    string s[110], t[110];
    map<string, int> m;

    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> s[i];

        auto it = m.find(s[i]);
        if(it == m.end()) m[s[i]] = 0;

        m[s[i]] += 1;
    }
    cin >> M;
    for(int i = 0; i < M; i++) {
        cin >> t[i];
        
        auto it = m.find(t[i]);
        if(it == m.end()) m[t[i]] = 0;

        m[t[i]] -= 1;
    }

    int val = 0;
    for(auto it = m.begin(); it != m.end(); it++) {
        if (it->second > val) val = it->second;
    }

    cout << val << endl;
    

}

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

using namespace std;
using ll = long long;
using p = pair<int, int>;
#define rep(i,n)  for(int i = 0; i < n ; i++)

int main()
{
	long A,B,M;
	cin >> A>>B>>M;
	vector<long> a(A);
	vector<long> b(B);
	long minA = pow(10, 5);
	rep(i, A)
	{
		cin >> a.at(i);
		minA = min(minA, a.at(i));
	}
	long minB = pow(10, 5);
	rep(i, B)
	{
		cin >> b.at(i);
		minB = min(minB, b.at(i));
	}
	long minp = minA + minB;
	for (int i = 0; i < M; i++)
	{
		long x, y, c;
		cin >> x >> y >> c;
		long price = a.at(x-1) + b.at(y-1) - c;
		minp = min(minp, price);
	}
	cout << minp << endl;
}

Measured memory_bytes: 1792
N = int(input())
S = input()
R = S[::-1]

count = 0

for v in range(1000):
  V = str(v).zfill(3)
  right = -1
  left = -1
  if V[2] in R:
    r = R.index(V[2]) + 1
    right = N-r
  else:
    continue
  if V[0] in S:
    left = S.index(V[0]) + 1
  else:
    continue
  if V[1] in S[left:right]:
    count += 1

print(count)

Measured memory_bytes: 9224
#include <stdio.h>

void insertionSort(int *,int);
void abc(int *,int);

int main(){

  int N,i,j;
  int A[100];

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
      }
  insertionSort(A,N);
  
  return 0;
}

void insertionSort(int A[],int N){
  int i,j,v;

  abc(A,N);
  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    abc(A,N);
  }
}

void abc(int A[],int N){
  int i;

  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i<N-1) printf(" ");
  }
  printf("\n");
}
  

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

struct Edge{
    int to;
    int distance;
    Edge(int t, int d) : to(t), distance(d) {}
};

using Graph = vector<vector<Edge>>;

int main() {
    int n;
    cin >> n;
    Graph g(n);
    vector<int> color(n,-1);
    rep(i,n-1) {
        int u, v, d;
        cin >> u >> v >> d;
        u--; v--;
        d %= 2;
        g[u].emplace_back(Edge(v,d));
        g[v].emplace_back(Edge(u,d));
    }
    queue<int> q;
    color[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        rep(i,g[v].size()) {
            int t = g[v][i].to;
            int d = g[v][i].distance;
            if (color[t] != -1) continue;
            color[t] = (color[v]+d) % 2;
            q.push(t);
        }
    }
    rep(i,n) cout << color[i] << endl;



}

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

int main(){
    long long N, M, K;
    cin >> N >> M >> K;
    vector<long long> A(N+1,0), B(M+1,0);
    long long buf, ans = 0, time = 0;
    for(int i = 1; i <= N; ++i){
        cin >> buf;
        A[i] = A[i-1] + buf;
    }
    for(int i = 1; i <= M; ++i){
        cin >> buf;
        B[i] = B[i-1] + buf;
    }
    buf = M;
    for(int i = 0; i <= N; ++i){
        if(A[i] > K)continue;
        time = A[i];
        for(int j = buf; j >= 0; --j){
            if(j==0){
                buf = 0;
                break;
            }
            else if(time + B[j] > K)--buf;
            else break;
        }
        ans = max(ans, i + buf);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6416
#include <bits/stdc++.h>
using namespace std;
int sosu(int x){
	if(x<=1){
		return 1;
	}
	if(x==2){
		return 0;
	}else{
		for(int i=2;i*i<=x;i++){
			if(x%i==0){
			return 1;
			}
		}
	}
	return 0;
}
int main() {
	int q; cin >> q;
	int l[100005], r[100005];
	for(int i=0;i<q;i++){
		cin >> l[i] >> r[i];
	}
	int c[100005];
	c[0] = 0;
	for(int i=1;i<=100000;i++){
		c[i] = c[i-1];
		if(sosu(i)==0 && sosu((i+1)/2)==0){
			c[i]++;
		}
	}
	for(int i=0;i<q;i++){
		cout << c[r[i]]-c[l[i]-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(){
	int n,flag=0,t;
	scanf("%d",&n);
	while(n){
		t=n%10;
		if(t==7)flag=1;
		n/=10;
	}
	if(flag)printf("Yes");
	else printf("No");
	return 0;
} 

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

int main(){
    int S, h, m, s;
    
    cin >> S;
    
    if(S >= 0 && S <= 86400){
        s = S % 60;
        m = (S / 60) % 60;
        h = S / 3600;
        
        cout << h << ":" << m << ":" << s << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int ans[200001];

int main(void){
	scanf("%d",&n);
	if(n==3){
		printf("2 5 63\n");
	}else if(n==4){
		printf("2 5 20 63\n");
	}else{
		int ca=0;
		for(int i=0;i<n/8;i++){
			ans[i*8]=ca+2;
			ans[i*8+1]=ca+3;
			ans[i*8+2]=ca+4;
			ans[i*8+3]=ca+6;
			ans[i*8+4]=ca+8;
			ans[i*8+5]=ca+9;
			ans[i*8+6]=ca+10;
			ans[i*8+7]=ca+12;
			ca+=12;
		}
		if(n%8==1){
			ans[n-1]=ca+6;
		}
		if(n%8==2){
			ans[n-2]=ca+2;
			ans[n-1]=ca+4;
		}
		if(n%8==3){
			ans[n-3]=ca+3;
			ans[n-2]=ca+6;
			ans[n-1]=ca+9;
		}
		if(n%8==4){
			ans[n-4]=ca+3;
			ans[n-3]=ca+6;
			ans[n-2]=ca+9;
			ans[n-1]=ca+12;
		}
		if(n%8==5){
			ans[n-4]=ca+2;
			ans[n-3]=ca+4;
			ans[n-5]=ca+3;
			ans[n-2]=ca+9;
			ans[n-1]=ca+12;
		}
		if(n%8==6){
			ans[n-6]=ca+2;
			ans[n-5]=ca+4;
			ans[n-4]=ca+3;
			ans[n-3]=ca+9;
			ans[n-2]=ca+8;
			ans[n-1]=ca+10;
		}
		if(n%8==7){
			ans[n-6]=ca+2;
			ans[n-5]=ca+4;
			ans[n-4]=ca+3;
			ans[n-3]=ca+9;
			ans[n-2]=ca+8;
			ans[n-1]=ca+10;
			ans[n-7]=ca+6;
		}

		for(int i=0;i<n;i++){
			printf("%d%c",ans[i],i+1==n?'\n':' ');
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	ll v=1;
	ll vv=1;
	for (int i=0;i<n;i++){
		int a;
		cin>>a;
		vv*=3ll;
		if (a%2==0){
			v*=2ll;
		}
	}
	cout<<vv-v<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
int main()
{	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int t;
	t=1;
	while(t--)
	{
		LL n,d;
		cin>>n>>d;
		LL x,y;
		LL count=0;
		for(LL i=0; i<n; i++)
		{
			cin>>x>>y;
			double a=sqrt(x*x+y*y);
			if(a<=d*1.0)
			count++;
		}
		cout<<count<<"\n";
		
	
	}
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l,i##end=r;i<=i##end;++i)
#define per(i,r,l) for (int i=r,i##end=l;i>=i##end;--i)
using namespace std;
vector<int> v[5003];
int main(){
	int n; cin>>n;
	rep(k,1,5000)
		if (k*(k-1)/2==n){
			cout<<"Yes"<<endl<<k<<endl;
			int c=0;
			rep(i,1,k)
				rep(j,i+1,k){
					v[i].push_back(++c);
					v[j].push_back(c);
				}
			rep(i,1,k){
				printf("%d ",v[i].size());
				rep(j,0,(int)v[i].size()-1)
					printf("%d ",v[i][j]);
				putchar('\n');
			}
			return 0;
		}
	cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 2432
import math

N = int(input())

def F(A, B):
  return max(len(str(A)), len(str(B)))

ans = 10**10
for i in range(1, math.ceil(math.sqrt(N+1))+1):
  if N % i == 0:
    ans = min(ans, F(i, N//i))

print(ans)

Measured memory_bytes: 3060
/*
NOTE :
*min_element(.begin(),.end())
*max_element(.begin(),.end())
stack push pop top
queue push pop front
priority_queue<> pq
 push()  pop() size()  top()
map<>
 find() begin() end() insert(map<>::value_type())
pair<>
sort(.begin(), .end())
sort(arr, arr+N)
sort(a, a+N, greater<int>())
binary_search(vc.begin(), vc.end(), x)  //binary_search???true, false?????????
vector<int>::iterator lit = lower_bound(vc.begin(), vc.end(), x);
  lower_bound?????????????????????"??\???"????????????????????????????????????????????¬???????????????
vector<int>::iterator uit = upper_bound(vc.begin(), vc.end(), x);
  upper_bound????????????????????????"?¶???????"?????????????????????????????????????????¬???????????????
*/
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cassert>
#include <sstream>
#include <algorithm>
#include <valarray>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

#define MAX 100
#define INF INT_MAX / 3
#define LLINF 10e12 // 1<<31 // 2^31
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,a,n) for(int i=(a);i<=(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique(ALL((o))), (o).end());
#define SQ(x) ((x)*(x))

using namespace std;
typedef long long ll;
typedef valarray<int> array_t;
/////
int n, m;
int dp[50010];
vector<int> c;

int solve()
{
  dp[0] = 0;
  REP2(i,1,n) dp[i] = INF;
  REP(i,m) REP2(j,c[i],n) dp[j] = min(dp[j],dp[j-c[i]]+1);
  return dp[n];
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // FROM HERE
  cin >> n >> m;
  REP(i,m)
  {
    int tmp; cin >> tmp;
    c.push_back(tmp);
  }
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main ()
{
    long long int a,b,sum;
    scanf("%lld%lld",&a,&b);
    if(a>1 && b>1)
    {
      sum=a*b;
      if(sum%2!=0)
      {
        sum=sum+1;
      }
      sum=sum/2;
    }
    else{
      sum=1;
    }
    printf("%lld\n",sum);
    return 0;
 
}

Measured memory_bytes: 128
#include<stdio.h>
int digit_sum(int n)
{
	int result = 0;
	while(n > 0)
	{
		result += n % 10;
		n /= 10;
	}
	return result;
}
int main()
{
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	int sum = 0;
	for(int i = 1; i <= n; i++)
	{
		int dsum = digit_sum(i);
		if(a <= dsum && dsum <= b)
		{
			sum += i;
		}
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;
int f(int x) {
  int cnt = 0;
  while(x) {
    if(x%2 != 0) return cnt;
    else {
      x = x/2;
      cnt++;
    }
  } 
  return cnt;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = 1000000000;
  rep(i ,n) ans = min(f(a[i]), ans);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256