akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <queue>
#include <iomanip>
#include <iterator>

#define MOD 1000000007
#define INF 1000000001

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


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

    ll k, l = 2, h = N + 1;
    while (h - l > 1) {
        k = (l + h) / 2;
        // print(l, h, k, k+(k-1)/2);
        if (k * (k - 1) / 2 > N) {
            h = k;
        } else {
            l = k;
        }
        // print(l, h);
    }
    k = l;
    // print(k, k*(k-1)/2);
    if (k * (k - 1) / 2 != N) {
        cout << "No" << endl;
        return 0;
    }
    
    cout << "Yes" << endl;
    cout << k << endl;
    vector<vector<int>> S(k);
    int n = 0;
    for (int i = 0; i < k; ++i) {
        for (int j = i + 1; j < k; ++j) {
            n += 1;
            S[i].push_back(n);
            S[j].push_back(n);
        }
    }

    for (int i = 0; i < k; ++i) {
        cout << S[i].size() << " ";
        for (int j = 0; j < S[i].size(); ++j) {
            cout << S[i][j] << (j < N-1 ? " " : "");
        }
        cout << endl;
    }

    // print(S);
    
    return 0;
}


Measured memory_bytes: 2304
//"BISMILLAHIR RAHMANIR RAHIM"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const long long M = 1e9+7 ;
int main()
{
    ll n,i,j,ans=0,s=0;
    cin>>n;
    ll ara[n];
    for(i=0;i<n;i++){
        cin>>ara[i];
    }
    ll pre[n]={0};
    pre[0]=ara[0];
    for(i=1;i<n;i++){
        pre[i]=(pre[i-1]+ara[i])%M;
    }
    for(i=0;i<n;i++){
        s= (ara[i]*(pre[n-1]-pre[i]))%M;
        ans= ( ans+s)%M;
    }
    ans= (ans+M)%M;
    cout<<ans<<endl;
    return 0;
}



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

int main(){
	int n,m,i,j,sums,sumt,anss,anst,judge;
	int s[100];
	int t[100];

	while(cin>>n>>m,n||m){
		sums=sumt=0;
		anss=anst=100;
		judge=0;
		for(i=0;i<n;i++){
			cin>>s[i];
			sums+=s[i];
		}
		for(i=0;i<m;i++){
			cin>>t[i];
			sumt+=t[i];
		}

		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				int swaps=sums+t[j]-s[i];
				int swapt=sumt+s[i]-t[j];
				if(swaps==swapt&&anss+anst>s[i]+t[j]){
					anss=s[i];
					anst=t[j];
					judge=1;
				}
			}
		}
		if(judge==1){
			cout<<anss<<' '<<anst<<endl;
		}
		else{
			cout<<-1<<endl;
		}
	}

	return(0);
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  int n;
  cin>>n;
  vector<vector<pair<int,int>>>ue(n+1);
  for(int i=1;i<=n-1;i++){
    int u,v,w;
    cin>>u>>v>>w;
    ue[v].push_back(make_pair(u,w));
    ue[u].push_back(make_pair(v,w));
  }
  queue<ll>q;
  q.push(1);
  vector<ll>l(n+1);
  vector<bool>c(n+1);
  c[1]=true;
  while(!q.empty()){
    ll x=q.front();
    q.pop();
    int z=ue[x].size();
    for(int i=0;i<z;i++){
      int y=ue[x][i].first;
      if(!c[y]){
        q.push(y);
        l[y]=(l[x]+ue[x][i].second)%2;
        c[y]=true;
      }
    }
  }
  for(int i=1;i<=n;i++) cout<<l[i]%2<<endl;
}

Measured memory_bytes: 9996
import sys


def main():

    N, K = [int(x) for x in sys.stdin.readline().rstrip().split()]
    S = list(sys.stdin.readline().rstrip())

    S_new = []
    for i, s in enumerate(S):
        if i + 1 == K:
            s = s.lower()
        S_new.append(s)

    print("".join(S_new))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <cstdio>
#define ll long long
int main() {
    ll n, m, cnt = 0;
    scanf("%lld%lld", &n, &m);
    int t = m / 2;
    if(t > n) {
        cnt += n;
        m -= 2 * n;
        cnt += m / 4;
    }else if(t == n)
        cnt += n;
    else 
        cnt += m / 2;
    printf("%lld", cnt);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     ff 				first
#define 	ss 				second
#define 	pb 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vvll            vector<vll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
vll pwx(10);
void cal(ll x){ pwx[0] = 1; rep(i, 1, 10)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */

#define space 200005

void solve() {
    ll n;
    cin >> n;
    rep(i, 0, n) cout << "ACL";
    cout << nl;

}

int main(){
    boost;
    // cal(3);

    // // For getting input from input.txt file 
    // freopen("alchemy_input.txt", "r", stdin); 
  
    // // Printing the Output to output.txt file 
    // freopen("output.txt", "w", stdout);

    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
#define debug(a) cerr<<#a<<" --> "<<(a)<<endl;
#define fastInput ios_base::sync_with_stdio(false);cin.tie(0)
#define INPUT freopen("input.txt","r",stdin)
#define OUTPUT freopen("output.txt","w",stdout)
#define ERROR  1e-9
#define pi (2*acos(0))
const ll mod = 998244353;
const int N = 1e6+5 ;


void Print(vector<string>&v)
{
    for(int i=0; i<v.size(); i++)
    {
        cout<<v[i]<<"\n";
    }
    printf("\n");
}
void SOLVE(int cas)
{
    int h,w;
    scanf("%d %d",&h,&w);
    vector<string>s(h),red(h),blue(h);
    for(int i=0;i<h;i++)
    {
        cin>>s[i];
    }
    for(int i=0;i<h;i++)
    {
        red[i].resize(w);
        blue[i].resize(w);
        for(int j=0;j<w;j++)
        {
            red[i][j]='.';
            blue[i][j]='.';
            if(j==0)
            {
                red[i][j]='#';
            }
            if(j==w-1)
            {
                blue[i][j]= '#';
            }
            if(i%2==0 && j<w-1)
            {
                red[i][j]='#';
            }
            if(i%2==1 && j>0)
            {
                blue[i][j]='#';
            }
            if(s[i][j]=='#')
            {
                red[i][j]='#';
                blue[i][j]='#';
            }
        }
    }
    Print(red);
    Print(blue);



}


/*


*/



int main()
{
    //INPUT;
    //OUTPUT;
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        SOLVE(++cas);
    }

    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


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

using namespace std;

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

inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}

typedef long long ll;

int main() {
  int x, y;
  int g[] = {0, 1, 2, 1, 3, 1, 3, 1, 1, 3, 1, 3, 1};
  cin >> x >> y;
  if (g[x] == g[y])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

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

    long long ans = 0;
    for (int i = N - 1; i >= 0; i--) {
        A[i] += ans;
        ans += (B[i] - A[i] % B[i]) % B[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 1001000
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
ll binary(ll a[],ll n,ll key)
{
    ll l=0,r=n-1,mid;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(a[mid]==key)
            return mid;
        else if(a[mid]>key)
            r=mid-1;
        else
            l=mid+1;
    }
    return -1;
}
ll lowerbound(ll a[],ll n,ll key)
{
    ll l=0,r=n-1,mid,ans=-1;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(a[mid]==key)
        {
            r=mid-1;
            ans=mid;
        }
        else if(a[mid]<key)
            l=mid+1;
        else
            r=mid-1;
    }
    return ans;
}
ll upperbound(ll a[],ll n,ll key)
{
    ll l=0,r=n-1,mid,ans=-1;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(a[mid]==key)
        {
            ans=mid;
            l=mid+1;
        }
        else if(a[mid]>key)
            r=mid-1;
        else
            l=mid+1;
    }
    return (ans+1==n?-1:ans+1);
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin.sync_with_stdio(false);
    ll t;
    t=1;
//    cin>>t;
    while(t--)
    {
        string s;cin>>s;
        if(s[2]==s[3] && s[4]==s[5])
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,tmp,i;
  vector<ll> ans;
  cin >> n;
  tmp=n;
  for(i=2;i*i<=n;i++){
    while(n%i==0){
      ans.push_back(i);
      n/=i;
    }
  }
  if(n!=1) ans.push_back(n);
  cout << tmp<<": ";
  for(int i=0;i<ans.size();i++){
    cout << ans[i];
    if(i!=ans.size()-1) cout <<" ";
    else cout << endl;
  }
}



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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++)
    {
        if (a[i] % 2 == 0)
        {
            if (a[i] % 3 != 0 && a[i] % 5 != 0)
            {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    ll n;
    ll min = 1000000001000;
    cin >> n;
    for(ll i=1; i*i<=n; i++){
        if(n%i == 0){
            if(i+n/i < min) min = i+n/i;
        }
    }
    cout << min-2 << endl;
    return 0;
}

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

int main()
{
    ll n;
    cin>>n;
    ll a[n+1]={0};
    ll ans=0;
    for(ll i=1;i<n+1;i++)
    {
        for(ll j=i;j<n+1;j=j+i)
        {
            a[j]++;
        }
    }
    for(ll i=1;i<n+1;i++)
        ans =ans+ i*a[i];

    cout<<ans;
}

Measured memory_bytes: 81764
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int a,b,c,d;cin>>a>>b>>c>>d;

  if(a+b<c+d)out("Right")
  else if(a+b>c+d)out("Left")
  else out("Balanced")

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

const int N = 300010;
const int mod = 1e9 + 7;

int n, m, fact[N << 1], invf[N << 1];

int qpow(int x, int y)
{
	int out = 1;
	while (y)
	{
		if (y & 1) out = (ll) out * x % mod;
		x = (ll) x * x % mod;
		y >>= 1;
	}
	return out;
}

int c(int x, int y)
{
	return (ll) fact[x] * invf[y] % mod * invf[x - y] % mod;
}

int f(int x, int y)
{
	int out = 0;
	for (int i = 0; i * x <= y && i <= n - m; ++i)
	{
		out = (out + (i & 1 ? -1ll : 1ll) * c(n - m, i) * c(n + y - i * x, n) % mod + mod) % mod;
	}
	return out;
}

int solve(int r)
{
	int out = c(n + r, r);
	for (int x = 1; x <= r / m; ++x)
	{
		out = (out + (ll) c(n, m) * (f(x, r - m * (x + 1)) - f(x, r - m * x) + mod)) % mod;
	}
	return out;
}

int main()
{
	int l, r;
	
	cin >> n >> m >> l >> r;
	
	fact[0] = 1;
	for (int i = 1; i <= n + r; ++i) fact[i] = (ll) fact[i - 1] * i % mod;
	invf[n + r] = qpow(fact[n + r], mod - 2); 
	for (int i = n + r; i >= 1; --i) invf[i - 1] = (ll) invf[i] * i % mod;
	
	cout << (solve(r) - solve(l - 1) + mod) % mod;
	
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a, b, c;
  a = n / 100;
  n = n - a * 100;
  b = n / 10;
  n = n - b * 10;
  c = n;
  cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;



int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  int r,g,b,n;
  scanf("%d%d%d%d",&r,&g,&b,&n);
  int ret = 0;
  for(int i=0;i*r<=n;i++)
    for(int j=0;i*r+j*g<=n;j++){
      int lt = n - i*r-j*g;
      if(lt%b==0)ret++;
    }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

   int N;
   
   scanf("%d",&N);
   
   int H[N];
   
   int i,j;
   
   for(i = 0;i < N;i++){
      scanf("%d",&H[i]);
   }
  
   int ans = 0;
   int count;
   for(i = 1;i < N;i++){
      for(j = 0;j < i;j++){
         if(H[i] >= H[j]){
            count = 0;
         }
         else {
            count = 1;
            break;
         }
      }
      if(count == 0){
         ans = ans + 1;
      }
   }
   
  
   printf("%d\n",ans+1);
   
  return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))


c = []
count = 0

for i in range(n):

    if a[i] - b[i] >= 0:
        count += b[i]
    elif a[i] - b[i] < 0:
        count += a[i]
        if a[i+1] + (a[i] - b[i]) >0:
            a[i+1] = a[i+1] + (a[i] - b[i])
            count -= (a[i]-b[i])
        elif a[i+1] + (a[i]-b[i]) <=0:
            count += a[i+1]
            a[i+1] = 0
            
print(count)

Measured memory_bytes: 18752
#include <stdio.h>
int main ()
{
	int a[2001],i,r,D;
	    scanf ("%d %d %d",&r,&D,&a[0]);
	    for(i=0;i<10;i++)
	    {
		    a[i+1]=r*a[i]-D;
	    }
	    for (i=1;i<=10;i++)
	    {
		    printf ("%d\n",a[i]);
	    }
	    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i);
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
    int sx,sy;
    int tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int x,y;
    x=tx-sx;
    y=ty-sy;
    rep(i,y){
        op('U');
    }
    rep(i,x){
        op('R');
    }
    op('U');
    rep(i,x+1){
        op('L');
    }
    rep(i,y+1)op('D');
    op('R');

    rep(i,x){
        op('R');
    }
    rep(i,y){
        op('U');
    }
    op('R');
    rep(i,y+1)op('D');
    rep(i,x+1){
        op('L');
    }
    op('U');
    cout<<endl;
    return 0;
}

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

using namespace std;

int n;
vector<vector<int>> G;
vector<int> node;
vector<int> vis;

void dfs(int cur, vector<int>& dp, vector<int>& res) {
	res[cur] = dp.size();
	for (auto next : G[cur]) {
		if (vis[next] == 0) {
			vis[next] = 1;
			int index = lower_bound(dp.begin(), dp.end(), node[next]) - dp.begin();
			if (index == dp.size()) {
				dp.push_back(node[next]);
				dfs(next, dp, res);
				dp.pop_back();
			}
			else
			{
				int temp = dp[index];
				dp[index] = node[next];
				dfs(next, dp, res);
				dp[index] = temp;
			}
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin >> n;
	node = vector<int>(n);
	G = vector<vector<int>>(n);
	for (int i = 0; i < n; i++) {
		cin >> node[i];
	}
	for (int i = 0; i < n - 1; i++) {
		int v, u;
		cin >> v >> u;
		G[v - 1].push_back(u - 1);
		G[u - 1].push_back(v - 1);
	}

	vis = vector<int>(n, 0);
	vector<int> res(n, 0);
	vector<int> dp;
	dp.push_back(node[0]);
	vis[0] = 1;
	dfs(0, dp, res);
	for (auto i : res) {
		cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 30816
n=int(input())
a=[]
m=n if n&1 else n+1
i=1
while(i<=n):
    j=i+1
    while(j<=n):
        if j!=m-i:
            a+=[(i,j)]
        j+=1
    i+=1
print(len(a))
for x in a:
    print(*x)

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (true)
    {
        int d, w;
        cin >> d >> w;
        if (d == 0 && w == 0)
        {
            return 0;
        }
        vector<vector<int>> e(d, vector<int>(w));
        for (int i = 0; i < d; i++)
        {
            for (int j = 0; j < w; j++)
            {
                cin >> e[i][j];
            }
        }
        int ans = 0;
        for (int sy = 0; sy < d; sy++)
        {
            for (int sx = 0; sx < w; sx++)
            {
                for (int cntx = 2; sx + cntx < w; cntx++)
                {
                    for (int cnty = 2; sy + cnty < d; cnty++)
                    {
                        int gx = sx + cntx;
                        int gy = sy + cnty;
                        // sxからgx、syからgyまでの区間を確認する
                        int kabe = INF; //壁の中で最小を更新
                        int rec = 0;
                        for (int i = sy; i <= gy; i++)
                        {
                            for (int j = sx; j <= gx; j++)
                            {
                                if (i == sy || i == gy || j == sx || j == gx)
                                {
                                    chmin(kabe, e[i][j]);
                                }
                            }
                        }
                        bool flg = false;
                        for (int i = sy + 1; i < gy && !flg; i++)
                        {
                            for (int j = sx + 1; j < gx && !flg; j++)
                            {
                                if (e[i][j] >= kabe)
                                {
                                    rec = 0;
                                    flg = true;
                                }
                                else
                                {
                                    rec += kabe - e[i][j];
                                }
                            }
                        }
                        chmax(ans, rec);
                    }
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3144
package main

import (
	"fmt"
	"math"
)

func main() {
	var A, B, C int
	var K float64
	fmt.Scanf("%d %d %d", &A, &B, &C)
	fmt.Scan(&K)

	if A > B && A > C {
		A *= int(math.Pow(2, K))
	} else if B > C {
		B *= int(math.Pow(2, K))
	} else {
		C *= int(math.Pow(2, K))
	}
	fmt.Println(A+B+C)
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

#define NMAX 100
int main(){
    int N,T;
    int t[NMAX],c[NMAX];
    int min;

    cin>>N>>T;
    for(int i=0;i<N;i++){
        cin>>c[i]>>t[i];
    }
    
    if(t[0]<=T){ min = c[0];
    }else{ min = 100000; }

    for(int i=0;i<N;i++){
        if((c[i]<=min)&&(t[i]<=T)){
            min=c[i];
        }
    }
    if(min>1000){
        cout<<"TLE";
    }else{
        cout<<min;
    }
    return 0;
}

Measured memory_bytes: 256
using System;

public static class baseball
{
    public static void Main()
    {
        int kai = int.Parse(Console.ReadLine());
        for (int i = 1; i <= kai; i++)
        {
            int runner = 0;
            int score = 0;
            int outcount = 0;
            while (outcount != 3)
            {
                string input = Console.ReadLine();
                switch (input)
                {
                    case "HIT":
                        runner = runner + 1;
                        if (runner == 4)
                        {
                            score = score + 1;
                            runner = 3;
                        }
                        break;
                    case "HOMERUN":
                        score = score + runner + 1;
                        runner = 0;
                        break;
                    case "OUT":
                        outcount = outcount + 1;
                        if (outcount == 3)
                        {
                            Console.WriteLine(score);
                        }
                        break;
                    default:
                        Console.WriteLine("HITかHOMERUNかOUTのみ入力できます。");
                        break;
                }
            }
        }
    }
}

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

constexpr int mod = 1e9 + 7;

struct ModCombination {
  ModCombination(unsigned int n) : n(n), F(n + 1, 1), I(n + 1, 1) {
    for (int i = 1; i <= n; ++i) F[i] = 1ll * i * F[i - 1] % mod;
    for (int64_t i = mod - 2, j = F[n]; i; i >>= 1) {
      if (i & 1) I[n] = I[n] * j % mod;
      j = j * j % mod;
    }
    for (int i = n - 1; i; --i) I[i] = I[i + 1] * (i + 1ll) % mod;
  }

  unsigned int n;
  vector<int> F, I;

  int operator()(int p, int k) {
    if (p > n) cerr << "errored by ModCombination's operator()";
    if (k < 0 || k > p) return 0;
    return 1ll * F[p] * I[k] % mod * I[p - k] % mod;
  }
};

int mod_pow(int64_t a, int x) {
  int64_t res = 1;
  a %= mod;
  for (int i = 1; i <= x; i <<= 1) {
    if (i & x) (res *= a) %= mod;
    (a *= a) %= mod;
  }

  return res;
}

int main() {
  int N, M, K;
  cin >> N >> M >> K;

  ModCombination mC(N + M + K + 1);

  int64_t ans = 0, sum = 1;
  for (int i = N - 1; i <= N + M + K - 1; ++i) {
    (ans += 1ll * mC(i, N - 1) * mod_pow(3, N + M + K - 1 - i) % mod * sum % mod) %= mod;
    sum = (2 * sum % mod - (mC(i - (N - 1), i - (N - 1) - M) + mC(i - (N - 1), K)) % mod + mod) % mod;
  }

  cout << ans << endl;
}


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

const int mxN=1e5+1;

void solve(){
    int n;
    cin>>n;
    vector<pair<int,int>>v;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        v.push_back({a,b});
    }
    for(int i=0;i<n-2;i++){
        if((v[i].first == v[i].second) && (v[i+1].first == v[i+1].second) && (v[i+2].first == v[i+2].second)){
            cout<<"Yes"<<endl;
            return;
        }
    }
    cout<<"No"<<endl;
    return;
}

signed main(){
    int t;
//    cin>>t;
//    while(t--){
        solve();
//    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int A,B;cin>>A>>B;
    cout<<6-A-B<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void) {
	
	double s,l,r;

	scanf("%lf",&r);
	s=M_PI*r*r;
	l=M_PI*2*r;
	printf("%lf %lf \n",s,l);
  
    return 0;
}


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

using LL = long long;
using Point = pair<LL, LL>;

LL N, K;
vector<Point> P;
vector<LL> X, Y;

LL solve() {
  LL r = 1e31;
  for(auto j = 1; j < N; ++j) for(auto i = 0; i < j; ++i) for(auto l = 1; l < N; ++l) for(auto k = 0; k < l; ++k) {
    auto lx=X[i], hx=X[j];
    auto ly=Y[k], hy=Y[l];
    auto sum=0;
    for(auto p: P) if(lx<=p.first && p.first<=hx && ly<=p.second && p.second<=hy) ++sum;
    if(K<=sum) r=min(r, (hx-lx)*(hy-ly));
  }
  return r;
}

int main() {
  cin >> N >> K;
  for(auto i = 0; i < N; ++i) {
    LL x, y;
    cin >> x >> y;
    P.emplace_back(x, y);
    X.emplace_back(x);
    Y.emplace_back(y);
  }
  sort(begin(X), end(X));
  sort(begin(Y), end(Y));
  cout << solve() << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>

using namespace std;

string Mr_J(string s){
  string a;
  a.clear();
  a+=s[s.length()-1];
  a+=s.substr(0,s.length()-1);
  
  return a;
}

string Mr_C(string s){
  string a;
  a.clear();

  a+=s.substr(1,s.length());
  a+=s[0];
  return a;
}

string Mr_E(string s){
  string a;
  a.clear();
  if(s.length()%2 == 0){
    a+=s.substr(s.length()/2,s.length()/2);
    a+=s.substr(0,s.length()/2);
  }
  else{
    a+=s.substr(s.length()/2+1,s.length()/2);
    a+=s.substr(s.length()/2,1);
    a+=s.substr(0,s.length()/2);
  }
  return a;
}

string Mr_A(string s){
  
  reverse(s.begin(),s.end());
  
  return s;
}

string Mr_M(string s){
  string a;
  a.clear();
  for(int i=0;i<s.length();i++){
    if('0'<= s[i] && s[i] <='9'){
      if(s[i] == '9')a+='0';
      else a+=(char)(s[i]+1);
    }
    else a+=s[i];
  }

  return a;
}

string Mr_P(string s){
  string a;
  a.clear();
  for(int i=0;i<s.length();i++){
    if('0'<= s[i] && s[i] <= '9'){
      if(s[i] == '0')a+='9';
      else a+=(char)(s[i]-1);
    }
    else a+=s[i];
  }
  return a;
}


int main(){
  int n;
  string operation,message;
  
  cin >> n;
  while(n-- > 0){
    cin >> operation >> message;
    for(int i=operation.length()-1;i>=0;i--){
      if(operation[i] == 'A'){
	message = Mr_A(message);
	//cout << "A = " << message << endl;
      }
      else if(operation[i] == 'J'){
	message = Mr_J(message);
	//cout << "J = " << message << endl; 
      }
      else if(operation[i] == 'C'){
	message = Mr_C(message);
	//cout << "C = " << message << endl;
      }
      else if(operation[i] == 'E'){
	message = Mr_E(message);
	//cout << "E = " << message << endl;
      }
      else if(operation[i] == 'P'){
	message = Mr_P(message);
	//cout << "P = " << message << endl;
      }
      else if(operation[i] == 'M'){
	message = Mr_M(message);
	//cout << "M = " << message << endl;
      }

    }
    cout << message << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <string.h>
int main(void)
{

        char k[100000];
        scanf("%s",&k);

        int n = strlen(k);
        int a=0,b=0;
        int i,m;

        for(i=0;i<n;i++){
        if (k[i]=='0') a++;
        else if(k[i]=='1') b++;
        }

        m=a;
        if (a>b) m=b;

        printf("%d\n",2*m);

        return 0;
}

Measured memory_bytes: 256
/*
  AtCoder Beginner Contest 105
  C - Base -2 Number
*/

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

long long N;
vector<long long> base;

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

  long long buf = -2;
  base.push_back(1);
  while (abs(buf) < 10000000000LL) {
    base.push_back(buf);
    buf *= -2;
  }


  if (N == 0) printf("0\n");

  int idx = 0;
  long long n = 2;
  vector<bool> ans;
  while (N != 0) {
    long long remain = N % n;

    if (remain != 0) {
      ans.push_back(true);
      N -= base[idx];
    }
    else {
      ans.push_back(false);
    }

    idx += 1;
    n *= 2;
  }

  reverse(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); ++i) {
    if (ans[i]) printf("1");
    else printf("0");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 256
from itertools import product
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int,input().split()))

sw = list(product([True, False], repeat=N))
cnt, ans = 0, 0
for pat in sw:
  flag = True
  for i in range(M):
    cnt = 0
    for j in range(ks[i][0]):
      if pat[ks[i][j+1]-1]:
        cnt += 1
    if cnt % 2 != p[i]:
      flag = False
      break
  if flag:
    ans += 1
print(ans)

Measured memory_bytes: 3188
# https://atcoder.jp/contests/abc083/tasks/abc083_b
# B - Some Sums

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

target_list = []

# まずは全探索
for i in range(1, n+1):
    tmp_sum = sum([int(x) for x in list(str(i))])
    if a <= tmp_sum <= b:
        target_list.append(i)

print(sum(target_list))


Measured memory_bytes: 3296
#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;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 long long    
#define vi                 vector<ll >
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define int                long long                        
#define pb                 push_back                                                     
#define mii                map<ll ,ll >
#define rep(i, a, b)       for(ll  i=a;i<b;i++)
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define hell               1000000007
// #define hell               (ll)998244353
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define mp                 make_pair
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define inf                3223372036854775807
#define endl               '\n' 
#define PI                  3.14159265
#define N                  200005
ll n, m, k, a[N];


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ll tests = 1;
    // cin >> tests;
    rep(test, 1, tests+1)
    {
        cin >> n;
        cout << (360) / (__gcd(360LL, n)) << endl;
    }
    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}

Measured memory_bytes: 3632
n, m = [int(i) for i in input().split()]
s = []
c = []
for _ in range(m):
    i, k = [int(i) for i in input().split()]
    s.append(i)
    c.append(k)

res = [-1] * n
ok = True
for i, k in zip(s, c):
    if res[i-1] == -1:
        res[i-1] = k
    elif res[i-1] != k:
        ok = False
        break

ans = [0] if m == 0 and n == 1 else [abs(res.pop(0))]
ans += [0 if i == -1 else i for i in res]
ans = int(''.join([str(i) for i in ans]))
print(ans) if ok and len(str(ans)) == n else print(-1)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int n, T,c, t, m = 1000;
    bool flag = 0;
    cin >> n>>T;
    for (int i = 0; i < n; i++) {
        cin >> c >> t;
        if (t <= T ){
            flag = 1;
            m = min(m, c);
        }
    }
    if (flag) cout << m << endl;
    else cout << "TLE" << endl;
}

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

vector<char> v={'R','G','B'};
vector<int> w={0,1,2};

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int64_t sum=0;

  vector<int64_t> r(N+1,0),g(N+1,0),b(N+1,0);
  for(int i=0;i<N;++i){
    if(S[i]=='R'){
      r[i+1]=r[i]+1;
      g[i+1]=g[i];
      b[i+1]=b[i];
    }
    else if(S[i]=='G'){
      r[i+1]=r[i];
      g[i+1]=g[i]+1;
      b[i+1]=b[i];
    }
    else if(S[i]=='B'){
      r[i+1]=r[i];
      g[i+1]=g[i];
      b[i+1]=b[i]+1;
    }
  }


  do{
    for(int i=0;i<N;++i){
      for(int j=i+2;j<N;++j){
        if(S[i]==v[w[0]] && S[j]==v[w[2]]){
          if(v[w[1]]=='R') sum += r[j]-r[i];
          else if(v[w[1]]=='G') sum += g[j]-g[i];
          else if(v[w[1]]=='B') sum += b[j]-b[i];
          if((j-i)%2==0 && S[(j+i)/2]==v[w[1]]) --sum;
        }
      }
    }
  }while(next_permutation(w.begin(),w.end()));

  cout<<sum<<endl;
}

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

using namespace std;


int mod_pow(int a, int n,int mod) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= a % mod;
			ans %= mod;
		}
		a *= a%mod;
		a %= mod;
		n >>= 1;

	}
	return ans;
}
int main()
{
	int n;
	cin >> n;
	int pow = 1;
	int ans = 0;
	for (int i = 0; i < 1000000; i++) {
		 
		ans += (pow * 7)%n;
		ans %= n;
		
		pow = (pow * 10) % n;
		
		if (ans == 0) {
			cout << i+1;
			return 0;
		}
	}
	cout << -1;
}



Measured memory_bytes: 3192
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

void solve() {
    lli n, m;
    cin >> n >> m;

    vlli v(m), d(m - 1);
    for (int i = 0; i < m; ++i) {
        cin >> v[i];
    }
    sort(all(v));

    for (int i = 1; i < m; ++i) {
        d[i - 1] = v[i] - v[i - 1];
    }

    sort(all(d));

    lli ans = 0;
    if (n < m) {
        for (int i = 0; i < m - n; ++i) {
            ans += d[i];
        }
    }

    cout << ans << endl;
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;

    solve();

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
  int a; scanf("%d",&a);
  int b; scanf("%d",&b);
  int c; scanf("%d",&c);
  
  if(a == b && a != c){
    printf("Yes");
   }else if(a == c && b != c){
    printf("Yes");
   }else if(c == b && a != b){
    printf("Yes");
   }else{
    printf("No");
  }
}

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

int s2i(string a,string b){
  int h=0,m=0;
  for(int i=0;i<a.size();i++) h*=10,h+=a[i]-'0';
  for(int i=0;i<b.size();i++) m*=10,m+=b[i]-'0';
  return h*60+m;
}

int main() {
  int fee[7][7]={
    {0,300,500,600,700,1350,1650},
    {300,0,350,450,600,1150,1500},
    {500,350,0,250,400,1000,1350},
    {600,450,250,0,250,850,1300},
    {700,600,400,250,0,600,1150},
    {1350,1150,1000,850,600,0,500},
    {1650,1500,1350,1300,1150,500,0}};

  int D[7][7]={
    {0,6,13,18,23,43,58},
    {6,0,7,12,17,37,52},
    {13,7,0,5,10,30,45},
    {18,12,5,0,5,25,40},
    {23,17,10,5,0,20,35},
    {43,37,30,25,20,0,15},
    {58,52,45,40,35,15,0}};

  int s,g;
  string a[2],b[2];
  while(1 ){
    cin>> s;
    if(s==0)break;
    cin >> a[0] >> a[1];
    cin >> g;
    cin >> b[0]>>b[1];
    s--,g--;
    int ans = fee[s][g];
    int st = s2i(a[0],a[1]);
    int gt = s2i(b[0],b[1]);
    if(D[s][g]<=40 && ((60*17+30<= st&&st<=60*19+30)||(60*17+30<=gt&&gt<=60*19+30)))ans/=2;
    if(ans%50!=0) ans = (ans/50+1)*50;
    cout << ans <<endl;
  }




  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long

using namespace std;
const int MOD = 1e9 + 7;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n-1];
    for(int i = 0;i<n-1;i++){
    	cin>>a[i];
    }
    int ans = 0;
    for(int i = 0;i<n;i++){
    	if(i != 0 and i != n-1){
    		ans += min(a[i], a[i-1]);
    	} else {
    		if(i == 0){
    			ans += a[i];
    		} 
    		if(i == n-1){
    			ans += a[i-1];
    		}
    	}
    }
    cout<<ans<<endl;
    return 0;
}






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

int main() {
  int n,ans;
  cin >> n;
  ans = (n+1)*100/108;
  if(ans*108/100==n) cout << ans << endl;
  else cout << ":(" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,M; cin>>N>>M;
    vint x(N+M),y(N+M);
    REP(i,N+M) cin>>x[i]>>y[i];

    REP(i,N){
        int min_dist=1e18,min_idx=-1;
        REP(j,M){
            int dist=abs(x[N+j]-x[i])+abs(y[N+j]-y[i]);
            if(dist<min_dist){
                min_dist=dist;
                min_idx=j+1;
            }
        }
        cout<<min_idx<<endl;
    }
}


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

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

    vector<string> s(n);
    vector<pair<int, int>> opening, closing;
    for(int i=0; i<n; i++){
        cin >> s[i];
        int l = s[i].length();

        stack<char> bracket;
        for(int j=0; j<l; j++){
            if(s[i][j] == ')'){
                if(bracket.empty() == false && bracket.top() == '(') bracket.pop();
                else                                               bracket.push(')');
            }
            if(s[i][j] == '(') bracket.push('(');
        }

        int open = 0, close = 0;
        while(bracket.empty() == false){
            char bt = bracket.top(); bracket.pop();
            if(bt == '(') open  += 1;
            if(bt == ')') close += 1;
        }
        //cout << close << " " << open << endl;
        if(open >= close) opening.push_back({close, open});
        if(open <  close) closing.push_back({open, close});
    }
    sort(opening.begin(), opening.end());
    sort(closing.begin(), closing.end());
    reverse(closing.begin(), closing.end());

    int total = 0;
    for(auto o : opening){
        total -= o.first;
        if(total < 0){
            cout << "No" << endl;
            return 0;
        }
        total += o.second;
    }
    for(auto c : closing){
        total -= c.second;
        if(total < 0){
            cout << "No" << endl;
            return 0;
        }
        total += c.first;
    }
    
    if(total != 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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

int main(){
    long long a,b;
    cin>>a>>b;
    if(a*b<=0) cout<<"Zero"<<endl;
    else if(a>0&&b>0) cout<<"Positive"<<endl;
    else if((-a-(-b)+1)%2==0) cout<<"Positive"<<endl;
    else cout<<"Negative"<<endl;
    
}

Measured memory_bytes: 256
/* ex 4-3
    kas056 */
#include <stdio.h>

int height(int a, int b);//関数の宣言

int main(void){
    int A, B, snow;
    scanf("%d %d", &A, &B);//入力を読み取る

    snow = height(A,B);//関数（後述）を呼ぶ

    printf("%d", snow);

    return 0;
}

int height(int a,int b){//関数を作る
    int poll = 0;
    int difference = b - a;

    //雪の深さによっては二本の柱の差は変化しないことを利用する
    for (int i = 1; i < difference ; i ++){
        poll += i;//差がdifferenceとなる隣り合わせの柱のうち、低い方を求める
    }

    return (poll - a);//低い柱の本来の高さ-測定した低い方の柱=雪の深さ
}

Measured memory_bytes: 128
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)


int main() {
	VI a(3);
	rep(i, 3) {
		cin >> a[i];
	}
	ll cnt = 0;
	int ma;
	while (!(a[0]==a[1] && a[1]==a[2])) {
		sort(all(a));
		ma = a[2] - a[0];
		if (ma % 2 == 0) {
			a[0] += 2;
		} else {
			a[1]++;
			a[0]++;
		}
		cnt++;
		/*if (a[0] == a[1] && a[1] == a[2]) {
			break;
		}*/
	}
	cout << cnt << endl;

}






Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    A = [int(input_raw[i]) for i in range(N)]
    for i in range(N):
        if A[i] == 1:
            break
    one_idx = i
    min_count = sys.maxint
    for i in range(K):
        left_num = max(0, one_idx - i)
        right_num = max(0, N - (one_idx + K - i))
        x_left = 0
        if left_num > 0:
            x_left = max(1, (left_num))/ (K - 1) + (1 if max(0, (left_num)) % (K - 1) != 0 else 0)
        x_right = 0
        if right_num > 0:
            x_right = max(1, (right_num))/ (K - 1) + (1 if max(0, (right_num)) % (K - 1) != 0 else 0)
        min_count = min(x_left + x_right, min_count)

    print min_count + 1

if __name__ == '__main__':
    main()


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

int main() {
  ll n;
  cin >> n;

  ll r = n < 3 ? 1 : 2;
  for (ll k = 2; k * k <= n; k++) {
    ll t = n;
    while (t >= k) t % k ? t %= k : t /= k;
    if (t == 1) r++;

    if ((n - 1) % k == 0 && (n - 1) / k != k) r++;
  }

  cout << r << endl;
}


Measured memory_bytes: 256