akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,s;
    cin>>n>>k>>s;
    vl ans;
    rep(i,k)ans.push_back(s);
    rep(i,n-k){
        if(s==1000000000) ans.push_back(999999999);
        else ans.push_back(1000000000);
    }
    puta(ans);
    return 0;
}

Measured memory_bytes: 3060
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long A, long long B) {
  print(100 << " " << 100);

  A--;
  B--;
  rep(i, 100) {
    rep(j, 100) {
      if (i < 50) {
        if (A > 0 && i % 2 == 0 && j % 2 == 0) {
          cout << '.';
          A--;
        } else {
          cout << '#';
        }
      } else {
        if (B > 0 && i % 2 == 1 && j % 2 == 0) {
          cout << '#';
          B--;
        } else {
          cout << '.';
        }
      }
    }
    cout << endl;
  }
}

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;
 
struct Node{
    int key;
    Node *right,*left,*parent;
};
 
Node *root,*NIL;
 
Node *find(Node *u,int k){
    while(u!=NIL&&k!=u->key){
        if(k<u->key)u=u->left;
        else u=u->right;
    }
    return u;
}
 
void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
     
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
     
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
     
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}
 
void inorder(Node *u){
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
 
void preorder(Node *u){
        if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
 
int main(){
    int n,i,x;
    string com;
     
    scanf("%d",&n);
     
    for(i=0;i<n;i++){
        cin>>com;
        if(com[0]=='f'){
            scanf("%d",&x);
            Node *t=find(root,x);
            if(t!=NIL)printf("yes\n");
            else printf("no\n");
        }else if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
     
    return 0;
}


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


char s[10][10];
int a[10][10];
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,1,-1};


int g(int y,int x,int b){
  int res=0;

  for(int k=0;k<8;k++){
    int i=y+dy[k],j=x+dx[k];
    //   if(y==4&&x==4) cout<<b<<' '<<i<<"  "<<j<<endl;
    while(0<=j&&j<8&&0<=i&&i<8&&b*a[i][j]==2){
      i+=dy[k];
      j+=dx[k];
    }
    if(0<=j&&j<8&&0<=i&&i<8&&b==a[i][j]){

      res+=max(abs(j-x),abs(i-y))-1;

    }
  }

//  if(x==4&&y==4) cout<<"         "<<res<<endl;
//cout<<x<<"  "<<y<<' '<<res<<endl;
return res;
}



void h(int y,int x,int b){
//  cout<<y<<' '<<x<<endl;
  a[y][x]=b;
  /*
  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++){
      cout<<a[i][j];
    }
    cout<<endl;
  }
  cout<<endl;
  */
  for(int k=0;k<8;k++){
    int i=y+dy[k],j=x+dx[k];
    while(0<=j&&j<8&&0<=i&&i<8&&b*a[i][j]==2){
      i+=dy[k];
      j+=dx[k];
    }
    if(0<=j&&j<8&&0<=i&&i<8&&b==a[i][j]){
     
      i=y+dy[k];
      j=x+dx[k];
      while(b*a[i][j]==2){
        a[i][j]=b;
        i+=dy[k];
        j+=dx[k];
      }
    }
  }
 /* 
  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++){
      cout<<a[i][j];
    }
    cout<<endl;
  }
  cout<<endl;
  */
}

void f(){

  int c=0;
  int flag=2,flag1=2;
  vector<int> v,w,z;
  while(flag1){
     
    bool hoge=false;
    v.clear();
    w.clear();
    z.clear();
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++){
    
        if(a[i][j]!=0) continue;
        int res=g(i,j,flag);
        if(res>0){
          hoge=true;
          v.push_back(res);
          w.push_back(i);
          z.push_back(j);
        }
      }
    }
    if(hoge){
//      cout<<v.size()<<endl;
      int resi=-1,resj=-1,s=0;
      for(int i=0;i<v.size();i++){
//        cout<<v[i]<<' '<<w[i]<<' '<<z[i]<<endl;
        if(flag==2&&s<v[i]){
          resi=w[i];
          resj=z[i];
          s=v[i];
        }

        if(flag==1&&s<=v[i]){
          resi=w[i];
          resj=z[i];
          s=v[i];
        }

      }
//      cout<<resi<<' '<<resj<<' '<<s<<endl;
      h(resi,resj,flag);
      flag=(flag==2?1:2);

      flag1=2;
    }
    else{
      flag1--; 
      flag=(flag==2?1:2);
    }
  }
}


int main(){
  for(int i=0;i<8;i++){
    cin>>s[i];
    for(int j=0;j<8;j++){
      if(s[i][j]=='o')
        a[i][j]=2;
      else if(s[i][j]=='x')
        a[i][j]=1;
      else
        a[i][j]=0;
    }
  }

  f();

  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++){
      if(a[i][j]==2) s[i][j]='o';
      if(a[i][j]==1) s[i][j]='x';
      if(a[i][j]==0) s[i][j]='.';
    }
  }

  for(int i=0;i<8;i++){
    cout<<s[i]<<endl;
  }


}



Measured memory_bytes: 3148
import numpy as np

def f(m,n):
    ret=m/n
    ret_=int(ret)
    if ret_==ret:
        return ret_
    else:
        return ret_+1
      
N,K=list(map(int,input().split()))
a=np.array(list(map(int,input().split())))
print(f(np.sum(a!=min(a)),K-1))

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int cnt=0;
  int max_cnt = 0;
  for(int i=0;i<N;i++){
    for(int j=i;j<N;j++){
      for(int k=i;k<=j;k++){
        if(S.at(k) == 'A' || S.at(k) == 'C' || S.at(k) == 'G' || S.at(k) == 'T'){
          cnt++;
        }else{
          break;
        }
      }
      //cout <<cnt << " " << i << " " << j << endl;
      if(cnt > max_cnt){
        max_cnt = cnt;
      }
      cnt = 0;
    }
  }
  
  cout << max_cnt << endl;
  return(0);
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 3e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-6;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,k;
main() {
    file("snakes");
    ios;
    cin>>n>>k;
    fo(i,k-n+1,k+n-1,1) cout<<i<<' ';
    return 0;
}
/**

*/


Measured memory_bytes: 256
/* Akshat Sharma @akshat98 */
#include <iostream>
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp   make_pair
#define pb   push_back
#define F    first
#define S    second
#define ll   long long
#define MOD  1000000007
#define MAX  1000000001
#define vi   vector<int>
#define vl   vector<ll>
#define vpi  vector<pair<int,int> >
#define vpl  vector<pair<ll,ll> >
#define rep(i,a,b) for(i=a;i<b;i++)
#define reqp(i,a,b) for(i=a;i<=b;i++)
#define ren for(i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
ll dp[2005][2005]{};

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input_file.txt", "r", stdin);
	//freopen("output_file.txt", "w", stdout);
	#endif
	ll i,j,k,l,n,test_case,m,r;
	test_case=1;
	//cin>>test_case;
	while(test_case--){
		cin>>n;
		vpl vec(n);
		ren{
			cin>>vec[i].F;
			vec[i].S=i+1;
		}
		sort(vec.rbegin(),vec.rend());
		dp[0][1]=vec[0].F*(abs(vec[0].S-1));
		dp[0][0]=vec[0].F*(abs(vec[0].S-n));
		rep(i,1,n){
			dp[i][0]=dp[i-1][0]+vec[i].F*(abs(n-i-vec[i].S));
			reqp(j,1,i+1){
				dp[i][j]=dp[i-1][j-1]+vec[i].F*(abs(j-vec[i].S));
				dp[i][j]=max(dp[i][j],dp[i-1][j]+vec[i].F*(n-(i-j)-vec[i].S));
			}
		}
		ll ans=0;
		rep(j,0,n+1){
			ans=max(ans,dp[n-1][j]);
		}
		cout<<ans<<"\n";



	}
	
	return 0;
}

Measured memory_bytes: 26284
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,x,n) for(int i=(x);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=(n);i++)
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I'){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
<?php
  fscanf(STDIN,"%d %d %d", $a, $b, $c);
  if ($c-($a+$b) > 0){
    if (4*$a*$b - ($c-$a-$b)*($c-$a-$b) < 0){
      echo "Yes\n";
    } else {
      echo "No\n";
    }
  } else {
    echo "No\n";
  }


Measured memory_bytes: 4604
/*Stay true to yourself, yet always be open to learn. Work hard, and never give up on your dreams, 
even when nobody else believes they can come true but you. These are not cliches but real tools you 
need no matter what you do in life to stay focused on your path.
*/

 /*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pp          UU      UU     CC          CC           HH     HH     UU      UU
   pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
   */

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    long wt;
    cin >> n >> wt;
    int v[n],w[n];
    long maxv = 100000;
    for(int i=0;i<n;i++)
    cin >> w[i] >> v[i];
    long long dp[n+1][maxv+10];
    for(int i=0;i<n+1;i++)
    {
        for(int j=0;j<maxv+1;j++)
        dp[i][j] = 1000000001 ;
    }
    dp[0][0] = 0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<maxv+1;j++)
        {
            if(dp[i][j]==1000000001)
            continue;
            else{
            dp[i+1][j] = min(dp[i][j],dp[i+1][j]);
            dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]],dp[i][j]+w[i]);
            }
        }
    }

    for(int i=maxv;i>=0;i--)
     {
         if(dp[n][i]<=wt)
         {
             cout<<i;
             return 0;
         }
     }
     cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 79232
from collections import defaultdict

N, Q = map(int, input().split())
d = defaultdict(list)
for _ in range(N-1):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)
ans = [0]*(N+1)
for _ in range(Q):
    p, x = map(int, input().split())
    ans[p] += x

q = [1]
used = [False]*(N+1)
used[1] = True
while q:
    s = q.pop()
    for t in d[s]:
        if used[t]:continue
        used[t] = True
        ans[t]+=ans[s]
        q.append(t)

print(*ans[1:])

Measured memory_bytes: 66692
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int A, B, C;

int main()
{
    cin >> A >> B >> C;
    if (A == B && B != C)
    {
        cout << "Yes" << endl;
    }
    else if (B == C && C != A)
    {
        cout << "Yes" << endl;
    }
    else if (C == A && B != C)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

int main() {
	string o, e;
	cin >> o >> e;
	int a = o.size(), b = e.size();
	if (a == b) {
		for (int i = 0;i < a;i++) {
			cout << o[i] << e[i];
		}
	}
	else {
		for (int i = 0;i < b;i++) {
			cout << o[i] << e[i];
		}
		cout << o[a-1];
	}
	cout << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define ZERO(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vint vector<int>

int main() {
    string s; cin>>s;
    rep(i,SZ(s)) {
        cout<<s[i];
        if(i == 3) cout<< " ";
    }
    puts("");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

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

typedef long long ll;

int main()
{
	/*int a, b;
	cin >> a >> b;
	int ans = -1;
	if (a < 10 && b < 10)ans = a * b;
	cout << ans;*/


	/*int n;
	cin >> n;
	int i, j;

	for (i = 1; i < 10; i++) {
		for (j = 1; j < 10; j++) {
			if (i * j == n) {
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";*/


	/*ll n;
	cin >> n;
	ll ans = 1e12;
	int i;
	for (i = 1; i <= 1000000; i++) {
		if (n % i == 0) {
			ans = min(ans, i + n / i - 2);
		}
		if (i > n)break;
	}
	cout << ans;*/


	double a, b, x;
	cin >> a >> b >> x;
	double ans;
	if (x <= a * a * b / 2) {
		ans = 90 - atan(2 * x / a / b / b) * 180 / acos(-1);
	}
	else {
		ans = 90 - atan(a * a * a / (2 * a * a * b - 2 * x)) * 180 / acos(-1);
	}
	cout << setprecision(10) << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll xl=-1000000000;
const ll yl=-1000000000;
const ll xr= 1000000000;
const ll yr=-1000000000;
 
int main()
{
        ll Max1=-4000000000, Max2=-4000000000;
        ll Min1=4000000000, Min2=4000000000;
        int n;
        scanf("%d", &n);
        ll x, y;
        for(int i=1;i<=n;i++){
            cin >> x >> y;
            Max1=max(abs(x-xl)+abs(y-yl), Max1);
            Min1=min(abs(x-xl)+abs(y-yl), Min1);
            Max2=max(abs(x-xr)+abs(y-yr), Max2);
            Min2=min(abs(x-xr)+abs(y-yr), Min2);
        }
        ll ans=max(Max1-Min1, Max2-Min2);
        cout << ans;
}

Measured memory_bytes: 3172
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#define EPS 1e-10
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
#define pb push_back
#define pop pop_back
using namespace std;
typedef pair<double,int> Pos;
 
struct Point{
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}
  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (Point p){return Point(x*p.x,y*p.y);}
  Point operator / (Point p){return Point(x/p.x,y/p.y);}
  double dot(Point p){
    return x*p.x+y*p.y;
  }
  double cross(Point p){
    return x*p.y-y*p.x;
  }
  double norm(){
    x*x+y*y;
  }
  double abs(){
    return sqrt(norm());
  }
  bool operator < (const Point &p) const{
    return x != p.x ? x<p.x:y<p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};
int ccw(Point p1,Point p2,Point p3){
  Point a = p2-p1;
  Point b = p3-p1;
  if(a.cross(b) > EPS)return COUNTER_CLOCKWISE;
  if(a.cross(b) < -EPS)return CLOCKWISE;
  if(a.dot(b) < -EPS)return ONLINE_BACK;
  if(a.norm() < b.norm())return ONLINE_FRONT;
  return ON_SEGMENT;
}
 
bool cmp_x(const Point& p,const Point& q){
  if(p.x!=q.x)return p.x<q.x;
    return p.y<q.y;
}
 
vector<Point> convex_hull(Point* ps,int n){
  sort(ps,ps+n,cmp_x);
  int k=0;
  vector<Point> qs(n*2);
  for(int i=0;i<n;i++){
    while(k>1 && (qs[k-1]-qs[k-2]).cross(ps[i]-qs[k-1])<=0)k--;
    qs[k++] = ps[i];
  }
  for(int i=n-2,t=k;i>=0;i--){
    while(k>t && (qs[k-1]-qs[k-2]).cross(ps[i]-qs[k-1])<=0)k--;
    qs[k++] = ps[i];
  } 
  qs.resize(k-1);
  return qs;
}
 
bool isIntersect(Point p1,Point p2,Point p3,Point p4){
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 && ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}
 
 
int main(){
  Point p1,p2,p3,p4;
  Point poly[5];
   
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&p1.x,&p1.y,&p2.x,&p2.y,&p3.x,&p3.y,&p4.x,&p4.y) != EOF){
    double sum=0;   
    poly[0] = p1;poly[1] = p2;poly[2] = p3;poly[3]=p4;poly[4]=p1;
 
 
    vector<Point> pos = convex_hull(poly,4);
 
    if(pos.size() <= 3)cout << "NO" << endl;
    else cout << "YES" << endl;
 
 
  }
  return 0;
} 

Measured memory_bytes: 1228
def selectionsort(a)
    (0...a.size).each{|i|
        minj = i
        (i...a.size).each{|j|
            minj = j if a[j][1]<a[minj][1]
        }
        a[i], a[minj] = a[minj], a[i] if i!=minj
    }
end

gets
a = gets.split

bs = a.sort_by{|a| a[1]}

selectionsort a
puts bs.join(' '), "Stable", a.join(' '), (a==bs ? "Stable" : "Not stable")


Measured memory_bytes: 6868
import java.util.*;
class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        if(a < k){
            ans += a;
            k = k-a;
            k = k - b;
            if(k > 0) ans -= k;
        }
        else{
            ans = k;
        }
        System.out.println(ans);
    }
}

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

int main()
{
	char a[2][3]={0};
	for(int i=0;i<2;i++)
	{	
		for(int j=0;j<3;j++)
		{	
			cin>>a[i][j];
		}
	}
	int flag =0;
	for(int k=0;k<3;k++)  
    {  
			if(a[0][k] == a[1][2-k])
				flag++;
			else
				break;
	}
	if(flag==3)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b && a!=c || a==c && a!=b || b==c && b!=a)
		cout<<"Yes";
	else
		cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 


int main() {
	ll sx,sy,ex,ey;
	cin>>sx>>sy>>ex>>ey;
	ll dx=ex-sx,dy=ey-sy;
	for(int i=0;i<dy;i++){
		cout <<'U';
	}
	for(int i=0;i<dx;i++){
		cout<<'R';
	}
	for(int i=0;i<dy;i++){
		cout <<'D';
	}
	for(int i=0;i<dx;i++){
		cout<<'L';
	}
	cout << 'L';
	for(int i=0;i<dy+1;i++){
		cout <<'U';
	}
	for(int i=0;i<dx+1;i++){
		cout<<'R';
	}
	cout <<'D';
	cout<<'R';
	for(int i=0;i<dy+1;i++){
		cout <<'D';
	}
	for(int i=0;i<dx+1;i++){
		cout<<'L';
	}
	cout <<'U';
	return 0;
}

Measured memory_bytes: 256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*考えを書くスペース

*/

//main.cpp----------------------------
#define MAX 101

string a;

int main() {
  cin >> a;

  int len = a.length();

  int max = 0;
  int now = 0;
  rep(i, len) {
    if(a[i]=='A'||a[i]=='C'||a[i]=='G'||a[i]=='T') {
      ++now;
    }else {
      if(max<now) max = now;
      now = 0;
    }
  }

  if(max<now) max = now;

  cout << max << endl;

  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x) 
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define fo(i, a, b) for (int i = a; i <= b; ++i)

int main() {
    //freopen("in.txt", "r", stdin);
    int n; cin >> n;
    int a[n]; rep(i, n) cin >> a[i];

    sort(a, a+n);
    int sum = 0;
    for (int i = 0; i < n-1; ++i) sum += a[i];
    cout << (sum > a[n-1] ? "Yes" : "No") << '\n';
}



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

int main()
{
    ios_base::sync_with_stdio(false);
    uint64_t cur = 100;
    uint64_t x;
    int cnt = 0;
    cin >> x;

    while (cur < x) {
        cur += cur / 100;
        ++cnt;
    }

    cout << cnt << '\n';

}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, ans;
	cin >> n;
	vector<int> arr(n, 0);
	for(int i = 0; i < n; i++) {
		int num;
		cin >> num;
		if(i + 1 == num) {
			arr[i]++;
		}
	}
	for(int i = 0; i < n - 1; i++) {
		if((arr[i] == 1)&&(arr[i + 1] == 1)) {
			ans++;
			arr[i + 1] = 0;
		} else if((arr[i] == 1)&&(arr[i + 1] == 0)) {
			ans++;
		}
	}
	if(arr[n - 1] == 1) {
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 768
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

s=get_nsp
n=s.size-1
s.pop
ans=n
def even_s?(s)
    return false if s.size.odd?
    n=s.size/2
    n.times do|i|
        return false unless s[i]==s[i+n]
    end
    return true
end
until even_s?(s)
    ans-=1
    s.pop
end
puts ans

Measured memory_bytes: 14160
#include <bits/stdc++.h>
#define int int64_t
#define F first
#define S second
#define pb push_back
#define fo(i, n) for(int i = 0; i < n;  i ++)
using namespace std;

int32_t main(){
  int a, b;
  cin >> a >> b;
  if(a <= 9 && b <= 9)
    cout << a*b;
  else
    cout << -1;
}


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

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    for (int n = 0; n < N; ++n) {
        cin >> x[n];
    }
    if (count(x.begin(), x.end(), 0) != 0) {
        --K;
    }
    
    vector<int> R(K+1), L(K+1);
    R[0] = 0;
    auto it = upper_bound(x.begin(), x.end(), 0);
    for (int k = 1; k <= K; ++k) {
        if (it == x.end()) {
            R[k] = INF;
            continue;
        }
        R[k] = *it;
        ++it;
    }
    L[0] = 0;
    it = lower_bound(x.begin(), x.end(), 0);
    for (int k = 1; k <= K; ++k) {
        if (it == x.begin()) {
            L[k] = INF;
            continue;
        }
        --it;
        L[k] = -(*it);
    }
    int Res = INF;
    for (int k = 0; k <= K; ++k) {
        Res = min(Res, 2 * R[k] + L[K-k]);
        Res = min(Res, 2 * L[k] + R[K-k]);
    }
    cout << Res << endl;

    return 0;
}


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

int a, b;
string s;
bool f = true;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> a >> b >> s;
	for(int i=0; i<s.size(); ++i){
		if(i == a && s[i] != '-') f = false;
		else if(i != a && (s[i] < '0' || '9' < s[i])) f = false;
	}
	cout << (f ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n = int(input())
    mod = 10**9+7
    power=1

    for i in range(1,n+1):
        power*=i
        power%=mod
    print(power)

if __name__=="__main__":
    main()

Measured memory_bytes: 9092
#include<cstdio>
#define N 405
#define mod 998244353
using namespace std;
long long newf[N],f[N][N][N],g[N][N][N],C[N][N],th2[N];
int a[N],n;
void dfs(int l,int r,int h)
{
//	g[l][h][0]=1;f[l][h][0]=1;
	int start=0;
	bool bo=false;
	for (int i=l;i<=r;i++)
	{
		if (a[i-1]<=h&&a[i]>h&&start==0) start=i;
		if (a[i]<=h)
		{
			if (start!=0) 
			{
				bo=true;
				dfs(start,i-1,h+1);
				for (int i=0;i<=(r-l+1);i++) newf[i]=0;
				for (int j=(r-l+1);j>=0;j--)
				{
					int sp=f[l][h][j];
					if (j==0) sp=1;
					if (sp==0) continue;
					for (int k=0;k<=(i-start);k++)
						newf[j+k]=(newf[j+k]+sp*f[start][h+1][k]%mod)%mod;
				}
				for (int i=(r-l+1);i>=0;i--)
					f[l][h][i]=newf[i];
				for (int i=0;i<=(r-l+1);i++) newf[i]=0;
				for (int j=(r-l+1);j>=0;j--)
				{
					int sp=g[l][h][j];
					if (j==0) sp=1;
					if (sp==0) continue;
					for (int k=0;k<=(i-start);k++)
						newf[j+k]=(newf[j+k]+sp*g[start][h+1][k]%mod)%mod;
				}	
				for (int i=(r-l+1);i>=0;i--)
					g[l][h][i]=newf[i];
			}
			start=0;
		}
	}
	if (start>0)
	{
		bo=true;
		dfs(start,r,h+1);
		for (int i=0;i<=(r-l+1);i++) newf[i]=0;
		for (int j=(r-l+1);j>=0;j--)
		{
			int sp=f[l][h][j];
			if (j==0) sp=1;
			if (sp==0) continue;
			for (int k=0;k<=(r-l+1);k++)
				newf[j+k]=(newf[j+k]+sp*f[start][h+1][k]%mod)%mod;
		}
		for (int i=(r-l+1);i>=0;i--)
			f[l][h][i]=newf[i];
		for (int i=0;i<=(r-l+1);i++) newf[i]=0;
		for (int j=(r-l+1);j>=0;j--)
		{
			int sp=g[l][h][j];
			if (j==0) sp=1;
			if (sp==0) continue;
			for (int k=0;k<=(r-l+1);k++)
				newf[j+k]=(newf[j+k]+sp*g[start][h+1][k]%mod)%mod;
		}
		for (int i=(r-l+1);i>=0;i--)
			g[l][h][i]=newf[i];
	}
	int num=0;
	for (int i=l;i<=r;i++) 
		if (a[i]==h) num++;
	if (!bo)
	{
		f[l][h][num]=th2[num]-1;
		for (int i=0;i<=r-l+1;i++)
			g[l][h][i]=C[num][i];
		f[l][h][0]=g[l][h][0];
		return;
	}
	for (int i=0;i<=(r-l+1);i++) newf[i]=0;
	for (int i=(r-l+1);i>=0;i--)
	{
		if (f[l][h][i]==0) continue;
		int slen=(r-l+1)-i-num;
		for (int j=0;j<=slen;j++)
		{
			if (j==0) newf[i+j+num]=(newf[i+j+num]+f[l][h][i]*C[slen][j]%mod*(th2[i+num]-1)%mod)%mod;
			else newf[i+j+num]=(newf[i+j+num]+f[l][h][i]*C[slen][j]%mod*th2[i+num]%mod)%mod;
		}	
	}
	for (int i=(r-l+1);i>=0;i--)
		f[l][h][i]=newf[i];
	for (int i=0;i<=(r-l+1);i++)
		f[l][h][i]=(f[l][h][i]+g[l][h][i])%mod;
	for (int i=0;i<=(r-l+1);i++) newf[i]=0;
	for (int i=0;i<=(r-l+1);i++)
	{
		if (g[l][h][i]==0) continue;
		int slen=(r-l+1)-i;
		for (int j=0;j<=slen;j++)
			newf[i+j]=(newf[i+j]+g[l][h][i]*C[slen][j]%mod*th2[i]%mod)%mod;
	}
	for (int i=(r-l+1);i>=0;i--)
		g[l][h][i]=newf[i];
}
int main()
{
	scanf("%d",&n);
	C[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		C[i][0]=1;
		for (int j=1;j<=i;j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	}
	th2[0]=1;
	for (int i=1;i<=n;i++) th2[i]=th2[i-1]*2%mod;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	//num=0;
	dfs(1,n,1);
	printf("%lld\n",f[1][1][n]);
} 

Measured memory_bytes: 862592
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> b(n-1);
    cin >> b;
    int ans = b.front() + b.back();
    for(int i = 1;i<=n-2;i++){
        ans += min(b[i],b[i-1]); 
    }
    cout << ans << endl;
}

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

int main() {
	int n;
	cin >> n;
	long long p = 1;
	for (int i = 1; i <= n; i++) {
		p *= i;
		if (p > 1000000000 + 7)p = p % (1000000000 + 7);
	}
	int ans;
	ans = p % (1000000000 + 7);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

int main(void){
    int N;
    cin>>N;
    vector<int> W(N);
    for(int i=0;i<N;i++){
        cin>>W[i];
    }

    int S1=0;
    int S2=accumulate(W.begin(),W.end(),0);
    int ans=S2;

    for(int i=0;i<N;i++){
        S1+=W[i];
        S2-=W[i];
        if(ans>abs(S1-S2)){
            ans=abs(S1-S2);
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 10;
ll n, k, ans;
vector<ll> d;
ll f[maxn];
ll powMod(ll a, ll k)
{
	ll ret = 1;
	while(k)
	{
		if(k & 1) ret = ret * a % mod;
		a = a * a % mod; k >>= 1;
	}
	return ret;
}
ll inv(ll a) { return powMod(a, mod - 2);}
int main()
{
	cin >> n >> k;
	for(ll i = 1; i * i <= n; ++i)
		if(n % i == 0)
		{
			d.push_back(i);
			if(i * i != n)
				d.push_back(n / i);
		}
	sort(d.begin(), d.end());
	for(int i = 0; i < d.size(); ++i)
	{
		int len = d[i];
		f[i] = powMod(k, (len + 1) / 2);
		for(int j = 0; j < i; ++j)
			if(d[i] % d[j] == 0)
				f[i] = (f[i] + mod - f[j]) % mod;
		ll tmp = f[i] * len % mod;
		if(len % 2 == 0) tmp = tmp * inv(2) % mod;
		ans = (ans + tmp) % mod;
	}
	cout << ans << endl;
	return 0;
}

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin>>s;
    int ans=0,tot=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')tot++;
        else tot=0;
        ans=max(ans,tot);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define INF 100000
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
string  S;
int main() {
	cin >> S;
	ull cnt0 = 0;
	ull cnt1 = 0;
	ull len = S.size();
	//'0'スタート
	for (int i = 0; i < len; ++i) {
		cnt0 += (i % 2 == 0 & S[i] == '0') | (i % 2 == 1 & S[i] == '1');
		cnt1 += (i % 2 == 0 & S[i] == '1') | (i % 2 == 1 & S[i] == '0');
	}
	cout << min(cnt0, cnt1) << endl;
}

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

#define ll long long

int main(void){
    int a,b;
    cin >> a >> b;
    int tmp = b-a;
    int ans=0;
    for(int i=1;i<=tmp;i++){
        ans += i;
    }
    cout << ans - b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <string>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){
	
	int n; cin >> n;
	
	string s[n];
	for(int i=0; i<n; i++){
		cin >> s[i];
	}
	
	vector<char> vc;
	set<char> st;
	map<char, int> mp, mptemp;
	for(int i=0; i<s[0].size(); i++){
		mp[s[0][i]]++;
		st.insert(s[0][i]);
	}
	for(auto x : st){
		vc.push_back(x);
	}
	
	for(int i=1; i<n; i++){
		mptemp.clear();
		for(int j=0; j<s[i].size(); j++){
			mptemp[s[i][j]]++;
		}
		for(int j=0; j<vc.size(); j++){
			mp[vc[j]] = min(mp[vc[j]], mptemp[vc[j]]);
		}
	}
	
	string anstemp;
	for( auto x : mp ){
		for(int i=0; i<x.second; i++){
			anstemp += x.first;
		}
	}
	
	int length = anstemp.size();
	if(length == 0){
		cout << "";
	}
	else{
		char ans[length];
		for(int i=0; i<length; i++){
			ans[i] = anstemp[i];
		}
		
		sort(ans, ans+length);
		
		for(int i=0; i<length; i++){
			cout << ans[i];
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
//g++  5.4.0

#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pii pair< int,int >
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;

struct S
{
    int w,s,v;
    
    bool operator<(const S &b) const
    {
        return w+s < b.w+b.s;
    }
};
signed main()
{
    fast;
    int n;
    cin >> n;
    vector<S> ip(n);
    vector<int> dp(2e4+1,0);
    for(int i=0;i<n;i++)
    {
        cin >> ip[i].w >> ip[i].s >> ip[i].v;
    }
    sort( ip.begin() , ip.end() );
    for( auto p : ip )
    {
        for( int W = p.s ; W >= 0 ; W-- )
            dp[ W+p.w ] = max( dp[ W+p.w ] , dp[W] + p.v );
    }
    cout << *max_element( dp.begin() , dp.end() );
        
}





Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MX = 1e10 + 10;;
unsigned long long fac[200001];

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}
long long digits(long long m) {
    long long cnt = 0;
    while (m) {
        cnt++;
        m /= 10;
    }
    return cnt;
}

unsigned long long power(unsigned long long x, unsigned long long y){
    unsigned long long res = 1;
    x = x % MOD;

    while (y > 0) {
        // If y is odd, multiply x with result 
        if (y & 1)
            res = (res * x) % MOD;

        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % MOD;
    }
    return res;
}
unsigned long long modInverse(unsigned long long n) {
    return power(n, MOD - 2);
}

long long nCr(long long n, long long r) {
    if (r > n) return 0;
    return (fac[n] * modInverse(fac[r]) % MOD * modInverse(fac[n - r]) % MOD) % MOD;
}

long long bfs(vector<int> g, queue<int> q) {
    return 1ll;
}

int main() {

    int n, k;
    cin >> n >> k;
    int x = ((n - 2) * (n - 1)) / 2;
    if (x<k) {
        cout << -1;
    }
    else {
        long long total = ((n - 1) * (n - 2)) / 2;
        long long connect = total - k;
        vector<vector<int>> g(n+1);
        g[1].push_back(2);
        for (int i = 3; i <= n; i++) g[2].push_back(i);
        int cnt = 0;
        for (int i = n; i >= 3 && connect > 0; i--) {
            for (int j = i - 1; j >= 1 && connect > 0; j--) {
                if (j == 2) continue;
                g[i].push_back(j);
                connect--;
                cnt++;
            }
        }
        long long m = n - 1ll + cnt;
        cout << m << "\n";
        for (int i = 1; i <= n; i++) {
            for (int x : g[i]) {
                cout << i << " " << x << "\n";
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3576
n, x, y = map(int, input().split())
k = [0]*n
for i in range(1, n):
    for j in range(i+1, n+1):
        if j <= x or i >= y:
            l = j - i
        elif i <= x and j >= y:
            l = (j-y) + (x-i) + 1
        elif i <= x and j >= x and j <= y:
            l = min(j-i, (x-i)+(y-j)+1)
        elif i >= x and i <= y and j >= y:
            l = min(j-i, (i-x)+(j-y)+1)
        elif i <= y and j >= x:
            l = min(j-i, (i-x)+(y-j)+1)
        k[l] += 1
for i in range(1, n):
    print(k[i])

Measured memory_bytes: 47452
#include <stdio.h>

int main()
{
	char n[3] = {0};

	scanf( "%s", n );

	for( int i = 0; i < 3; i++ ){
		if( (n[i]&0xff) == '9' ){
			n[i] = '1';
		}
		else if( (n[i]&0xff) == '1' ){
			n[i] = '9';
		}
	}
	printf( "%s", n );

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int parent,left,right;};

struct Node T[MAX];
int n,D[MAX],H[MAX];

void preorder(int u) {
  if(u == NIL) return;
  cout << " " << u;
  preorder(T[u].left);
  preorder(T[u].right);
}

void inorder(int u) {
  if(u == NIL) return;
  inorder(T[u].left);
  cout << " " << u;
  inorder(T[u].right);
}

void postorder(int u) {
  if(u == NIL) return;
  postorder(T[u].left);
  postorder(T[u].right);
  cout << " " << u;
}

// void setDepth(int u , int d) {
//     if(u == NIL) return;
//     D[u] = d;
//     setDepth(T[u].right,d + 1);
//     setDepth(T[u].left,d + 1);
// }

// int setHeight(int u) {
//     int h1 = 0,h2 = 0;
//     if(T[u].left != NIL)
//     h1 = setHeight(T[u].left) + 1;
//     if(T[u].right != NIL) 
//     h2 = setHeight(T[u].right) + 1;
//     return H[u] = (h1 > h2 ? h1 : h2);
// }

// int getSibling(int u) {
//     if(T[u].parent == NIL) return NIL;
//     if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
//     return T[T[u].parent].left;
//     if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
//     return T[T[u].parent].right;
//     return NIL;
// }

// void print(int i) {
//     cout << "node " << i << ": ";
//     cout << "parent = " << T[i].parent << ", " ;
//     cout << "sibling = " << getSibling(i) << ", ";
//     int degree = 0;
//     if(T[i].right != NIL) degree++;
//     if(T[i].left != NIL) degree++;
//     cout << "degree = " << degree << ", ";
//     cout << "depth = " << D[i] << ", ";

//     cout << "height = " << H[i] << ", ";

//     if(T[i].parent == NIL) cout << "root";
//     else if(T[i].left == NIL && T[i].right == NIL) cout << "leaf";
//     else cout << "internal node";

    // cout << '[';
    // for(int j = 0,c = T[i].left;c != NIL;j++,c = T[c].right) {
    //     if(j) cout << ", ";
    //     cout << c;
    // }
    // cout << ']';
// }

int main() {
   int N,id,l,r;
   cin >> N;

    for(int i = 0; i < N; i++) {
        T[i].parent = NIL;
    }

    for(int i = 0; i < N;i++) {
        cin >> id >> l >> r;
        T[id].left = l;
        T[id].right = r;
        if(l != NIL)T[l].parent = id;
        if(r != NIL)T[r].parent = id;
    }


    for(int i = 0; i < N;i++) {
        if(T[i].parent == NIL) r = i;
    }

    // setDepth(r,0);
    // setHeight(r);

    cout << "Preorder" << endl;
    preorder(r);
    cout << endl;
    cout << "Inorder" << endl;
    inorder(r);
    cout << endl;
    cout << "Postorder" << endl;
    postorder(r);
    cout << endl;
}



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

int main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    if(A1 + A2 + A3 >= 22){
        cout << "bust" << endl;
    }
    else{
        cout << "win" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
Imports System

Module Program
    Sub Main(args As String())

        Dim N As Integer = Integer.Parse(Console.ReadLine())
        Dim A() As Integer = Console.ReadLine().Split(" ").Select(Function(x) Integer.Parse(x)).ToArray()

        Dim ans As Long = 0

        If N <> 0 Then

            Dim bef As Integer = A(0)
            For i = 1 To N - 1
                If bef > A(i) Then
                    ans += bef - A(i)
                Else
                    bef = A(i)
                End If
            Next

        End If

        Console.WriteLine(ans)

    End Sub
End Module


Measured memory_bytes: 46712
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;

void add(int &x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
}

int dp[50][2][(1 << 18)];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    
    memset(dp, 0, sizeof(dp));

    int n, x, y, z;
    cin >> n >> x >> y >> z;
    dp[0][0][0] = 1;
    int good = (1 << (z - 1)) + (1 << (z + y - 1)) + (1 << (z + y + x - 1));
    int M = (1 << (z + y + x)) - 1;
    for (int i = 0; i < n; i++) {
        for (int have = 0; have < 2; have++) {
            for (int mask = 0; mask <= M; mask++) {
                if (!dp[i][have][mask]) {
                    continue;
                }
                for (int num = 1; num <= 10; num++) {
                    int nxt = ((mask << num) | (1 << (num - 1))) & M;
                    if (have || ((nxt & good) == good)) {
                        add(dp[i + 1][1][nxt], dp[i][have][mask]);
                    } else {
                        add(dp[i + 1][0][nxt], dp[i][have][mask]);
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int mask = 0; mask <= M; mask++) {
        add(ans, dp[n][1][mask]);
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 102784
s=gets.to_i
aNumbers=[s]
aNumberHash={}
aNumberHash.store(s,0)
index=1
loop do
  tempNumber = aNumbers[index-1]
  tempANumber = tempNumber % 2 == 0 ? tempNumber/2 : tempNumber*3+1
  aNumbers << tempANumber
  aNumberHash.key?(tempANumber) ? break : aNumberHash.store(tempANumber,0)
  index += 1
end
puts (index+1)

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

int main(){
  int N,n[101];
  cin>>N;
   for(int i=0;i<N;i++){
    cin>>n[i];
   }

   unsigned long long dp[100][21]={0};
   dp[0][n[0]]=1;

   for(int i=1;i< N-1;i++){
     for(int j=0;j<=20;j++){
       if(dp[i-1][j]>0){
	 int val=j+n[i];
	 if(val<=20) dp[i][val]+=dp[i-1][j];
	 val=j-n[i];
	 if(val>=0) dp[i][val]+=dp[i-1][j];
       }
     }
   }
   cout<<dp[N-2][n[N-1]]<<endl;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    string str;
    cin >> str;
    int sum = 0;
    for(int i=0;i<str.size();i++)
        sum = (sum + str[i]-'0')%9;
    if(sum == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
}

Measured memory_bytes: 3720