akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	string s;
	cin >> s;
	int n = s.size();
	int j = 0;
	int cnt = 0;
	vi a(n + 1, 0);

	rep(i, 0, n - 1)
	{
		if (s[i] == '<')
		{
			a[i + 1] = a[i] + 1;
		}
	}
	rzip(i, n - 1, 0)
	{
		if (s[i] == '>')
		{
			a[i] = max(a[i], a[i + 1] + 1);
		}
	}
	int ans = 0;
	zip(i, 0, n + 1)
	{
		//cout << a[i];
		ans += a[i];
	}
	//cout << en;
	cout << ans << en;
	//vi v;
	// int i = 0;
//      int k=0;
//      int v(n+1,0);
//      int x=0;
//    zip(i,0,n)
//    {
//    	x=0;
//    	j=i;
//    	if(s[i]=='>')
//    	{
//            while(s[i]=='>')
//            {
//            	x++;
//            	i++;
//            }
//    	}
//    }
	// zip(i,0,n)
	// {
	// 	if(s[i]=='<'&&var==0)
	// 	{
	// 		a[i]=j;
//             j++;
	// 	}
	// 	else if(s[i]=='>')
	// 	{
//           while(s[i]=='>')
//           {

//           }

	// 	}
	// }


	// while (i < n)
	// {
	// 	if (s[i] == '<')
	// 	{
	// 		a[i] = j;
	// 		i++;
	// 		while (s[i] == '<')
	// 		{
	// 			j++;
	// 			a[i] = j;
	// 			i++;
	// 		}
	// 		j++;
	// 		a[i + 1] = j;
	// 	}
	// 	else
	// 	{
	// 		a[i] = j + 1;
	// 		i++;
	// 		while (s[i] == '>')
	// 		{
	// 			j--;
	// 			a[i] = j + 1;
	// 			i++;
	// 		}
	// 		j--;
	// 		a[i + 1] = j;
	// 	}
	// }
	// zip(i, 0, n + 1)
	// {
	// 	cnt += abs(a[i]);
	// }

	// cout << cnt << en;
	return 0;
}



Measured memory_bytes: 4764
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;



//頂点fromから頂点toへのコストcostの辺
template<typename T>
struct edge{
    int f,t;
    T c;
    int id;
    edge(){};
    edge(int f,int t,T c,int id = 0):f(f),t(t),c(c),id(id){};
    bool operator< (const edge &s){
        return c < s.c;
    }
};

template<typename T>
struct graph{
    std::vector<std::vector<edge<T> > > data;
    graph(int v):data(v){};
    void add_edge(edge<T> &e){
        data[e.f].push_back(e);
    }
    void add_edge(int f,int t,T c){
        data[f].emplace_back(f,t,c);
    }
    size_t size(){
        return data.size();
    }
    std::vector<edge<T>> make_edges(){
        std::vector<edge<T>> r;
        for(auto &i:data)std::copy(i.begin(),i.end(),std::back_inserter(r));
        return r;
    }
};

vector<ll> dis(n_max,INT_MAX);
template<typename T>
void dfs(graph<T> &graph, int x, ll dist = 0){
    dis[x] = dist;
    for(auto i : graph.data[x]){
        if(dis[i.t] == INT_MAX)dfs(graph, i.t, dist+i.c);
    }
}

int main(){
    ll n; cin >> n;
    graph<ll> gr(n);
    rep(i,n-1){
        ll a,b; cin >> a >> b;
        ll c; cin >> c;
        a--;b--;
        gr.add_edge(a,b,c);
        gr.add_edge(b,a,c);
    }
    ll q,k; cin >> q >> k;
    k--;
    vector<ll> x(q), y(q);
    rep(i,q){
        cin >> x[i] >> y[i];
        x[i]--;y[i]--;
    }
    dfs(gr, k);
    rep(i,q){
        cout << dis[x[i]] + dis[y[i]] << "\n";
    }
    return 0;
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	if(s[1]=='R')
		cout<<"ABC"<<endl;
	else
		cout<<"ARC";
	return 0;
}

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



int calc(int x){
    int ans = 0;
    while(x){
        ans += x%10;
        x/=10;
    }
    return ans;
}

int main() {

    int n, ans = 999999999;
    cin >> n;
    for(int i=1;i<n;i++){
        ans = min(calc(i)+calc(n-i), ans);
    }
    cout << ans << endl;


}





Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue<int>
#define PQR priority_queue<int,VE,greater<int>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e9;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	vector<P>key;
	rep(i, m) {
		int a, b; cin >> a >> b;
		int s = 0;
		rep(j, b) {
			int c; cin >> c; c--;
			s |= 1 << c;
		}
		key.emplace_back(s, a);
	}
	VE dp(1 << n); // 2^n
	rep(i, 1 << n)dp[i] = INF;
	dp[0] = 0;
	rep(s, 1 << n) {
		rep(i, m) {
			int t = s | key[i].first;
			int cost = dp[s] + key[i].second;
			dp[t] = min(dp[t], cost);
		}
	}
	int ans = dp.back();
	if (ans == INF)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
b1,b2,b3 = map(int,input().split())
if b1 == 1 and b2 == 0 and b3 == 0:
    print('Close')
else:
    pass
if b1 == 0 and b2 == 1 and b3 == 0:
    print('Close')
else:
    pass
if b1 == 1 and b2 == 1 and b3 == 0:
    print('Open')
else:
    pass
if b1 == 0 and b2 == 0 and b3 == 1:
    print('Open')
else:
    pass
if b1 == 0 and b2 == 0 and b3 == 0:
    print('Close')
else:
    pass


Measured memory_bytes: 5592
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int N = sc.nextInt();
        List<Integer> house = new ArrayList<Integer>();
        for (int i=0; i<N; i++) {
            house.add(sc.nextInt());
        }
        int maxDistance = house.get(0) + K - house.get(N-1);
        for (int i=0; i<N-1; i++) {
            maxDistance = Math.max(maxDistance, house.get(i+1) - house.get(i));
        }
        System.out.println(K-maxDistance);
    }
}

Measured memory_bytes: 92512
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  long double w,h,x,y;
  cin >> w >> h >> x >> y;
  //cout << w*h/2 << " " << (x*2==w&&y*2==h) << endl;
  printf("%llf %d\n",w*h/2,(x*2==w&&y*2==h));
  return 0;
}

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

b = set(arr)

print(len(b))

#if a!=b and a!=c:
    #print(3)
#elif a==b and a!=c:
    #print(2)
#elif a==c and a!=b:
    #print(2)
#elif b==c and b!=a:
    #print(2)
#else:
    #print(1)

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

#include <climits>

#define DEBUG if(false)

using namespace std;

int main(){

  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;

  int Mstart = H1 * 60 + M1;
  int Mend = H2 * 60 + M2;


  cout << Mend-Mstart - K << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int h, w;
    cin >> h >> w;

    rep(i, h+2){

        rep(j, w+2){
            if (j == 0 || j == w+1 || i == 0 || i == h+1) {cout << "#"; continue;}
            char t; cin >> t; cout << t;
        }
        cout << endl;
    }


}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
  int key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0){
      return 1;
    }
    else if(strlen(H[h])==0){
      return 0;
    }
  }
  return 0;
}

int insert(char str[]){
  int key, i, h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0){
      return 1;
    }
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

  int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
      scanf("%s %s", com, str);

      if ( com[0] == 'i' ){
        insert(str);
      } else {
        if (find(str)){
          printf("yes\n");
        } else {
          printf("no\n");
        }
      }
    }

    return 0;
  }



Measured memory_bytes: 15428
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    string L = "qwertasdfgzxcvb";
    while(S != "#"){
        int cnt = 0;
        int pre = -1;
        for(int i=0; i<S.size(); i++){
            bool left = false;
            for(int j=0; j<L.size(); j++){
                if(S[i] == L[j]) left = true;
            }
            if(pre==1 and !left){
                cnt++;
            }else if(pre==0 and left){
                cnt++;
            }
            if(left){
                pre = 1;
            }else{
                pre = 0;
            }
        }
        cout << cnt << endl;
        cin >> S;
    }


    return 0;
}


Measured memory_bytes: 3236
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

#define ASIZE 100010

void dfs(const int& i, vector<int> (&ad)[ASIZE], vector<bool>& visited) {
    if ( visited[i] ) return;
    visited[i] = true;
    for (auto v : ad[i] ) {
        dfs(v, ad, visited);
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vector < int > ad [ASIZE];
    vector <bool> visited (ASIZE, false);
    int ans = 0;

    for (int i=0; i<m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        ad[x].push_back(y);
        ad[y].push_back(x);
    }
    

    for (int i=1; i<=n; i++) {
        if ( visited[i] ) continue;
        ans++;
        dfs(i, ad, visited);
    }

    cout << ans << endl;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define vi vector<int>
#define pi pair<int, int>
#define pb push_back
#define ppb pop_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()


using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int N = 2e5 + 667;
int a[N];

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

	int n, ans = 0, mn = 200000;
	cin >> n;
	for(int i = 0;i<n;i++){
        cin >> a[i];
        mn = min(mn, a[i]);
        if(a[i] <= mn && i > 0) ans++;
        if(i == 0) ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e5 + 5, M = 2 * N + 5;

int head[N], to[M], nxt[M], ne, n;

void init(){
    ne = 0;
    memset(head, -1, n * sizeof head[0]);
}

void addEdge(int f, int t){
    to[ne] = t;
    nxt[ne] = head[f];
    head[f] = ne++;
}

void addBiEdge(int a, int b){
    addEdge(a, b);
    addEdge(b, a);
}

ll cnt[N];
ll ans[N];

void dfs(int u, int par, ll sum){
    ans[u] = sum;
    for(int e = head[u] ; ~e ; e = nxt[e]){
        int v = to[e];
        if(v == par)continue;
        dfs(v, u, sum + cnt[v]);
    }
}

int main(){
    int q;
    scanf("%d%d", &n, &q);
    init();
    for(int i = 1 ; i < n ; ++i){
        int u, v;
        scanf("%d%d", &u, &v);
        addBiEdge(--u, --v);
    }
    while(q--){
        int u, x;
        scanf("%d%d", &u, &x);
        cnt[--u] += x;
    }
    dfs(0, -1, cnt[0]);
    for(int i = 0 ; i < n ; ++i)
        printf("%lld%c", ans[i], " \n"[i == n - 1]);
}

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



int main() {
  long long a;

  cin >> a;

  string ans;

  while(a){
      a--;
      ans += 'a'+a%26;
      a /= 26;
  }

  reverse(ans.begin(),ans.end());
  cout << ans << endl;

}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;

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

    int lh = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;

        if (h > lh) {
            ans += h - lh;
        }

        lh = h;
    }

    cout << ans << endl;

    return 0;
}

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

#define ___ ios::sync_with_stdio(0),  cin.tie(0);
#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

const int N = 1e6+6;
vector<int> dvs[N];
unordered_map<int, int> maf;

bool go(int n){
  for(auto& dv: dvs[n]){
    if(maf.find(dv)!=maf.end()) return false;
  }
  return true;
}

void calc_div(){
  for (int i = 1; i < N; ++i){
    for (int j = i; j < N; j+=i){
      dvs[j].emplace_back(i);
    }
  }
}

int main(){___
  int n;  cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i){
    cin >> a[i];
  }
  sort(a, a+n);
  int ans = 0;
  calc_div();
  int done[N], seen[N];
  memset(done, 0, sizeof(done));
  memset(seen, 0, sizeof(seen));
  for (int i = 0; i < n; ++i){
    if(go(a[i])){
      ans++;
      if(!seen[a[i]] and i<n-1 and a[i]==a[i+1]) ans--;
    }
    maf[a[i]]++;
    seen[a[i]] = 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 129260
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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

	int D, N;
	cin >> D >> N;
	int base = 1;
	if (D == 1)base = 100;
	else if (D == 2)base = 10000;
	int ans = base*N;
	if (N == 100)ans += base;
	cout << ans << endl;



	return 0;
}



Measured memory_bytes: 256
import java.util.*;

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

        int h = sc.nextInt();
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int[][] arr = new int[h][w];

        for (int i=0; i<h-b; i++){
            String s = "";
            for (int j=0; j<a; j++){
                s += "1";
            }
            for (int k=0; k<w-a; k++){
                s += "0";
            }
            System.out.println(s);
        }
        for (int i=0; i<b; i++){
            String s = "";
            for (int j=0; j<a; j++){
                s += "0";
            }
            for (int k=0; k<w-a; k++){
                s += "1";
            }
            System.out.println(s);
        }
    }
}

Measured memory_bytes: 341972
# -*- coding: utf-8 -*-
# C - Multiple Gift
# 標準入力の取得
X,Y = list(map(int, input().split()))

# 求解処理
# Xをどんどん2倍していき、それがYを超えるまでやる
max_length = 0
while X <= Y:
    max_length += 1
    X *= 2

# 結果出力
print(max_length)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
// ------------------------
void solve() {
    int a; cin >> a;
    string s; cin >> s;
    if( a >= 3200 ) cout << s << endl; else cout << "red" << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
N, K = map(int,input().split())
ans =[1]*N
d = [1]*K
A =[1]*K
count = 0
for i in range(K):
  d[i] = int(input())
  A[i] = input().split()
for i in range(K):
  for j in range(d[i]):
      ans[int(A[i][j])-1] = 0
for i in range(N):
  if ans[i] == 1:
    count += 1
print (count)

Measured memory_bytes: 9596
#include <stdio.h>
int main(){
  char s[5];  scanf("%s", s);
  for(int i=0; i<3; i++)
    if(s[i] == '9') printf("1");
    else if(s[i] == '1') printf("9");
    else  printf("%c", s[i]);
  puts("");
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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 ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    map<string, set<pair<int, int> > > X;
    REP(i,N){
        string s;
        int p;
        cin >> s >> p;
        if(X[s].size() == 0){
            set<pair<int, int> > tmp;
            tmp.insert(make_pair(-p, i));
            X[s] = tmp;
        }
        else{
            X[s].insert(make_pair(-p, i));
        }
    }

    for(auto&& p : X){
        for(auto&& t : p.second){
            cout << t.second+1 << endl;
        }
    }
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;

signed main(){
    cin>>N;
    map<int,int>cnt;

    int ans=0;
    vint lis;
    rep(i,N){
        int a;cin>>a;
        cnt[a]++;
        if(cnt[a]==2)lis.pb(a);
        if(cnt[a]==4)chmax(ans,a*a);
    }

    if(lis.size()>=2){
        sort(all(lis));
        reverse(all(lis));
        chmax(ans,lis[0]*lis[1]);
    }


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


Measured memory_bytes: 6528
h, n = (int(x) for x in input().split())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
max_a = max(a for a, _ in ab)
dp = [0] * (h + max_a)
for i in range(1, h + 1):
    dp[i] = min(dp[i - a] + b for a, b in ab)
print(dp[h])

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

int main()
{
	int N;
	cin >> N;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	long long ans = 1;
	enum State {
		EVEN, UP, DOWN,
	};
	State now = EVEN;
	long long even_num = A[0];
	for (int i = 1; i < N; i++) {
		switch (now) {
		case EVEN:
			if (A[i] == even_num) {
				//StateはEVENのまま
			} else if (A[i] < even_num) {
				now = DOWN;
			} else {
				now = UP;
			}
			break;
		case UP:
			if (A[i] - A[i - 1] < 0) {
				ans++;
				now = EVEN;
				even_num = A[i];
			}
			break;
		case DOWN:
			if (A[i] - A[i - 1] > 0) {
				ans++;
				now = EVEN;
				even_num = A[i];
			}
			break;
		}
	}
	cout << ans << endl;
}

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

int main() {
	int N;
	cin >> N;
	string s;
	s = "No";
	if (N >= 30){
		s = "Yes";
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3616
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let n = s.len();
    let mut ok = true;
    for i in 0..n {
        if s[i] != s[n - 1 - i] {
            ok = false;
        }
    }
    for i in 0..(n - 1) / 2 {
        debug!(s[i], s[n - 1 - i]);
        if s[i] != s[(n - 1) / 2 - 1 - i] {
            ok = false;
        }
    }

    for i in (n + 3) / 2 - 1..n {
        debug!(s[i], s[n - 1 - i]);
        if s[i] != s[n - 1 - i] {
            ok = false;
        }
    }
    if ok {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
// #define INF 1e9
constexpr ll INF = 1LL << 60;
constexpr ll mod = 1e9+7;

const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    k = min(k, n-k);
    ll ans = 1;
    REP(i, k){
      ans *= ((n-i)*inv[i+1])%mod;
      ans %= mod;
    }
    return ans;
}
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
  COMinit();
  int X, Y;
  cin >> X >> Y;
  int n = -1, m = -1;
  ll ans = 0;
  REP(i, X+1){
    int x = X-i;
    if(x % 2 != 0) continue;
    x/=2;
    if(i*2 + x ==Y){
      n= i;
      m=x;
      ans += COM(n+m, min(n,m));
    }
  }
  if(n==-1){
    cout << 0 << endl;
    return 0;
  }
  // cout << ans << endl;
  cout << COM(n+m, min(n,m)) << endl;
  return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
#define fr first
#define sc second
#define pii pair<int, int>
#define all(v) v.begin(), v.end()

using namespace std;

const ll MOD = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin >> n;
    ll rem = 0;
    for (int i = 0; i < 10000000; i++) {
        rem = (rem * 10) % n;
        rem = (rem + 7) % n;
        if (rem == 0) {
            cout << i + 1;
            return 0;
        }
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 3624
//https://atcoder.jp/contests/abc050/tasks/arc066_a
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N;
	cin >> N;
	vint A(100010, 0);

	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		A[tmp]++;
	}
	bool flg = true;
	if(N%2==1){
		//Nが奇数
		if(A[0]!=1){
			flg = false;
		}
		for (int i = 1; i < N; i++) {
			if(i%2==0){
				if(A[i]!=2){
					flg = false;
				}
			}else{
				if(A[i]!=0){
					flg = false;
				}
			}
		}
	}else{
		//Nが偶数
		for (int i = 0; i < N; i++) {
			if(i%2==1){
				if(A[i]!=2){
					flg = false;
				}
			}else{
				if(A[i]!=0){
					flg = false;
				}
			}
		}
	}

	if(flg){
		int ans = 1;
		for (int i = 0; i < N/2; i++) {
			ans *= 2;
			ans %= MOD;
		}
		cout << ans << endl;
	}else{
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 24 18:23:54 2018
ITP22A
@author: maezawa
"""

n, q = list(map(int, input().split()))
a = [[] for _ in range(n)]

for i in range(q):
    c = list(map(int, input().split()))
    if c[0] == 0:
        a[c[1]].append(c[2])
    elif c[0] == 1:
        if a[c[1]]:
            print(a[c[1]][-1])
    else:
        if a[c[1]]:
            a[c[1]].pop()




Measured memory_bytes: 13708
import io.StdIn._
object Main extends App {
    val s = readLine

    val containsN = s.contains('N')
    val containsW = s.contains('W')
    val containsS = s.contains('S')
    val containsE = s.contains('E')

    if ((containsN && !containsS) ||
        (containsW && !containsE) ||
        (containsS && !containsN) ||
        (containsE && !containsW)) println("No")
    else println("Yes")

}

Measured memory_bytes: 54684
#include <stdio.h>

int main ()
{
    int h,w,i,j;
    scanf("%d %d", &h, &w);
    char grid [h][w];
    for (i=0;i<h;i++)  
        for (j=0;j<w;j++) scanf(" %c", &grid[i][j]);
    int row[1000]={};
    int col[1000]={};
    for(i=0;i<h;i++)   
       for (j=0;j<w;j++) 
        {
             if (grid[i][j] == '#' ){
                row[i]=1;
                col[j]=1;
             }
        }     
    for(i=0;i<h;i++){
        if (row[i] == 1){
            for (j=0;j<w;j++){
                if (col[j] == 1)
                printf ("%c", grid[i][j]);
            }
            printf("\n");
        }
    } 

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
char a[N][10];
int n;
int main()
{
	scanf("%d", &n);
	int ac=0,wa=0,tle=0,re=0;
	for (int i = 0; i < n; i++) {
		scanf("%s", a[i]);
		if (strcmp(a[i], "AC") == 0) ac++;
		else if (strcmp(a[i], "WA") == 0) wa++;
		else if (strcmp(a[i], "TLE") == 0) tle++;
		else if (strcmp(a[i], "RE") == 0) re++;
	}
	printf("AC x %d\n", ac);
	printf("WA x %d\n", wa);
	printf("TLE x %d\n", tle);
	printf("RE x %d\n", re);
	return 0;
}

Measured memory_bytes: 4800
#include <bits/stdc++.h>
using namespace std;
int n;
inline int calc(int x) {
    int s=0;
    while (x) {
        s+=x%10;
        x/=10;
    }
    return s;
}

int main() {
    scanf("%d",&n);
    int ans=0x7f7f7f7f;
    for (int i=1;i<n;++i) ans=min(ans,calc(i)+calc(n-i));
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 764
fun main(args: Array<String>) {
    abc132d()
}

fun abc132d() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }

    val answer = StringBuilder()
    val bc = BiCoef(n + k)

    for (i in 1..k) {
        answer.appendln(bc.nCr(n - k + 1, i) * bc.nCr(k - 1, i - 1) % MOD)
    }

    print(answer)
}

private const val MOD = (1e9 + 7).toLong()

@Suppress("unused")
private class BiCoef(max: Int) {
    private val fact = LongArray(max + 1)
    private val fInv = LongArray(max + 1)
    private val inv = LongArray(max + 1)

    init {
        fact[0] = 1
        fact[1] = 1
        fInv[0] = 1
        fInv[1] = 1
        inv[1] = 1
        for (i in 2..max) {
            fact[i] = fact[i - 1] * i % MOD
            inv[i] = MOD - inv[(MOD % i).toInt()] * (MOD / i) % MOD
            fInv[i] = fInv[i - 1] * inv[i] % MOD
        }
    }

    fun fact(n: Int): Long = if (n < 0) 0 else fact[n]
    fun inv(n: Int): Long = if (n < 0) 0 else inv[n]
    fun fInv(n: Int): Long = if (n < 0) 0 else fInv[n]
    fun comb(n: Int, k: Int): Long = nCr(n, k)
    fun nCr(n: Int, k: Int): Long = if (n < k || n < 0 || k < 0) 0 else fact[n] * (fInv[k] * fInv[n - k] % MOD) % MOD
    fun perm(n: Int, k: Int): Long = nPr(n, k)
    fun nPr(n: Int, k: Int): Long = if (n < k || n < 0 || k < 0) 0 else fact[n] * fInv[n - k] % MOD % MOD
}


Measured memory_bytes: 38260
#include "bits/stdc++.h"
using namespace std;
#define PIGRECO 3.141592653589793

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////
#define int long long

#define ll long long

struct node {
	int s, e;
	ll mn, mx, sum;
	bool lset;
	ll add_val, set_val;
	node * l, *r;
	node (int _s, int _e, int A[] = NULL): s(_s), e(_e), mn(0), mx(0), sum(0), lset(0), add_val(0), set_val(0), l(NULL), r(NULL) {

		if (A == NULL) return;
		if (s == e) mn = mx = sum = A[s];
		else {
			l = new node(s, (s + e) >> 1, A), r = new node((s + e + 2) >> 1, e, A);
			combine();
		}
	}
	void create_children() {
		if (s == e) return;
		if (l != NULL) return;
		int m = (s + e) >> 1;
		l = new node(s, m);
		r = new node(m + 1, e);
	}

	void combine() {
		if (l == NULL) return;
		sum = l->sum + r->sum;
		mn = min(l->mn, r->mn);
		mx = max(l->mx, r->mx);
	}

	void update(int pos, int val) {

		if (e == s) {

			mx = val;
		}

		else {

			int mid = (e + s) / 2;

			if (pos <= mid) {
				l->update(pos, val);

			}
			else {
				r->update(pos, val);
			}


			combine();
		}



	}



	ll range_max(int x, int y) {
		if (s == x && e == y) return mx;
		if (l == NULL || lset) return mx;
		int m = (s + e) >> 1;
		if (y <= m) return l->range_max(x, y);
		if (x > m) return r->range_max(x, y);
		return max(l->range_max(x, m), r->range_max(m + 1, y));
	}
	~node() {
		if (l != NULL) delete l;
		if (r != NULL) delete r;
	}
};










int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	vector<int>h(n + 1);
	vector<int>a(n + 1);

	int dp[n + 1];

	memset(dp, 0, sizeof(dp));

	node segment_tree(1, n, dp);


	for (int i = 1; i <= n; i++)cin >> h[i];
	for (int i = 1; i <= n; i++)cin >> a[i];

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

		dp[h[i]] += a[i];

		if (h[i] > 1)
			dp[h[i]] += segment_tree.range_max(1, h[i] - 1);

		segment_tree.update(h[i], dp[h[i]]);



	}

	int ans = 0;

	for (int i = 1; i <= n; i++) {
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;

}

Measured memory_bytes: 45412
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    if(a!=c)cout<<1<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
#define rep(i,n) for (ll i = 0; i < (n); ++i)
typedef long long int ll;
using ipair = pair<int,int>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
const int MOD=1000000007;

int main(){  
    ll n;cin>>n;
    string s;
    while(n){
        n--;
        s += 'a' + n%26;
        n /= 26;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3592
array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())
print(array[k - 1])

Measured memory_bytes: 2940
#include<stdio.h>
int main()
{
    int a,b;
    int m,c;
    while(scanf("%d %d",&a,&b)!=EOF){
        m=a+b;
        c=0;
        for(;;){
            c++;
            if((m/=10)==0)break;
        }
        printf("%d\n",c);
    }
    return 0;
}

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

int main()
{
ll n ;
cin >> n ;
string s ;
cin >> s ;
vector<ll> v(n,0);
ll cw=0,cr=n;
rep(i,n){
  if(s[i]=='W'){v[i]=1;cw++;cr--;}
}
if(cw==0||cr==0){
cout << 0 << endl;
return 0;
}
ll f=0,b=n-1;
while(1){
  while(1){
    if(v[f]==1){f++;break;}
    else f++;
  }
  while(1){
    if(v[b]==0){b--;break;}
    else b--;
  }
  if(f-1<b+1)ans++;
  if(f>=b) break;
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 5244
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
//by NeighThorn
using namespace std;
int n,m;
signed main(void){
	scanf("%d",&n);m=sqrt(n);printf("%d:",n);
	for(int i=2;i<=m;i++)
		if(n%i==0){
			while(n%i==0)
				n/=i,printf(" %d",i);
		}
	if(n!=1)
		printf(" %d\n",n);
	else
		puts("");
	return 0;
}

Measured memory_bytes: 3204
import java.util.Scanner;

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

        int n = sc.nextInt();
        String s = sc.next();
        
        int red = 0;
        int blue = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == 'R')
                red++;
            else
                blue++;
        }
        
        System.out.println(red > blue ? "Yes" : "No");
    }
}


Measured memory_bytes: 22740
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	a := make([]int, n)
	for i := range a {
		a[i] = scanInt()
	}
	b := make([]int, n)
	for i := range b {
		b[i] = scanInt()
	}

	d := 0
	ac := 0
	for i := 0; i < n; i++ {
		d += b[i] - a[i]
		if a[i] < b[i] {
			ac += (b[i] - a[i] + 1) / 2
		}
	}
	if d >= ac {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1152
#include<stdio.h> 
int main(){ 
    char s[3];
    scanf("%s", s); 
    if(s[0] + s[1] + s[2] =='a'+'b'+'c'){ 
        printf ("Yes\n");
    }else{
        printf ("No\n");
    } 
    return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if(a>b){
    int tmp=a;
    a=b;
    b=tmp;
  }
  long long A=0;
  for(int i=0; i<b; i++){
    A += a*pow(10,i);
  }
  cout << A;
  return 0;
}

Measured memory_bytes: 384
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int n;
	in(n);
	int a[n];
	for(int i=0;i<n;i++) in(a[i]);
	
	LL sum[n];
	MSV(sum, 0);
	for(int i=n-1;i>=0;i--) {
		sum[i] = a[i];
		if(i != n-1) sum[i] = (sum[i] + sum[i+1]) % MOD;
	}
	
	LL ans = 0;
	for(int i=0;i<n;i++) {
		sum[i]= (sum[i] - a[i] + MOD) % MOD;
		ans = (ans + (a[i] * sum[i]) % MOD) % MOD;
	}
	cout<<ans<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 5992
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;
	using BigNum = std::vector<long long>;

	class InputData {
	public:
		void getInput(void);
		void skipInput(void);
		Str getStr(void);
		Num getNum(void);
		BigNum getBigNum(void);
	private:
		Str str;
		Num num;
		BigNum bNum;
	};
	Str AtCoder::InputData::getStr(void) {
		return this->str;
	}
	Num AtCoder::InputData::getNum(void) {
		return this->num;
	}
	BigNum AtCoder::InputData::getBigNum(void) {
		return this->bNum;
	}
	void AtCoder::InputData::skipInput(void) {
		std::string buf = "";
		std::getline(std::cin, buf);
	}
	void AtCoder::InputData::getInput(void) {
		this->str.clear();
		this->num.clear();
		this->bNum.clear();

		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				this->str.push_back(row);
				this->num.push_back(std::atoi(row.c_str()));
				this->bNum.push_back(std::atoll(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		this->str.push_back(row);
		this->num.push_back(std::atoi(row.c_str()));
		this->bNum.push_back(std::atoll(row.c_str()));
	}

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(long long);
		void decrement(void);
		void decrement(long long);
		long long getResult(void);
	private:
		long long result;
	};
	void Ans::showResult(void) {
		printf("%lld\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(long long value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(long long value) {
		this->result -= value;
	}
	long long AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::InputData* data = new AtCoder::InputData();
	data->getInput();

	AtCoder::Num num = data->getNum();

	const int l = num[0], r = num[1], d = num[2];

	int ans = 0;
	for (int i = l; i <= r; i++) {
		ans += 0 == i % d ? 1 : 0;
	}

	printf("%d\n", ans);

	delete(data);

	return 0;
}


Measured memory_bytes: 3156
s = input()
ss = s.replace("x", "")
ssr = ss[::-1]
if  ss != ssr:
    print(-1)
else:
    l = 0
    r = len(s) - 1
    cnt = 0
    while l < r:
        if s[l] == s[r]:
            r -= 1
            l += 1
        elif s[l] == "x":
            cnt += 1
            l += 1
        elif s[r] == "x":
            cnt += 1
            r -= 1
    print(cnt)

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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

constexpr int MAX_N =200000;

int main(){
    int N;cin>>N;
    map<ll,ll> mp;
    rep(i,N){
        int a;cin>>a;
        mp[a] = i+1;
    }

    set<int> st;
    st.insert(0);
    st.insert(N+1);

    ll ans=0;
    for(int i=1;i<=N;i++){
        auto itr = st.upper_bound(mp[i]);
        int me=mp[i];
        int r=*itr;
        itr--;
        int l=*itr;
        ans += (ll)(r-me)*(ll)(me-l)*(ll)i;
        st.insert(mp[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 22144
#include<bits/stdc++.h>
using namespace std;
#define INF 1<<28
#define MAX 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

typedef long long ll;

int n, a[100005];
int dp[MAX];

int main()
{
    FASTIO
    cin>>n;
    for(int i = 1; i <= n; i++)
        cin>>a[i];
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        dp[i] = dp[i-1] + abs (a[i] - a[i-1]);
        if(i > 2){
            dp[i] = min(dp[i], dp[i-2] + abs(a[i] - a[i-2]));
        }
    }
    cout << dp[n]<<endl;
   
    return 0;
} 


Measured memory_bytes: 1024
n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
game_hands = gets.chomp.chars

win_hand = { 'r' => 'p', 's' => 'r', 'p' => 's' }
win_score = { 'r' => r, 's' => s, 'p' => p }

takahashi_hands = []
score = 0

(0...n).each do |i|
  hand = win_hand[game_hands[i]]
  prev_hand = i >= k ? takahashi_hands[i - k] : nil

  next if prev_hand == hand

  takahashi_hands[i] = hand
  score += win_score[hand]
end

puts score


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

int main() {
  long long N,M,X;
  cin>>N>>M>>X;
  vector<long long>C(N);
  vector<vector<long long>>A(N,vector<long long>(M));
  long long ans=100000000;
  for(long long i=0;i<N;i++){
    cin>>C.at(i);
    for(long long j=0;j<M;j++){
      cin>>A.at(i).at(j);
    }
  }
  for(long long i=0;i<1<<N;i++){
    vector<long long>test(M);
    long long sum=0;
    bool test2=true;
    for(long long j=0;j<N;j++){
      if(i>>j&1){
        sum+=C.at(j);
      for(long long k=0;k<M;k++){
        test.at(k)+=A.at(j).at(k);
      }
      }
    }
    for(long long m=0;m<M;m++){
      if(test.at(m)<X){
        test2=false;
      }
    }
    if(test2){
      ans=min(sum,ans);
    }
  }
  if(ans==100000000){
    cout<<"-1"<< endl;
    return 0;
  }
  else{
    cout<<ans<< endl;
    return 0;
  }
}
  

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
  // 整数の入力
  ll N,M;
  cin >> N >> M;
  vector<ll> A(N);
  ll total = 0;
  for(int i = 0;i < N;i++){
    cin >> A[i];
    total += A[i];
  }
  sort(A.begin(),A.end(),greater<ll>());
  bool can_select = true;
  for(int i = 0;i < M;i++){
    if(4 * M *A[i] < total){
      can_select = false;
      break;
    }
  }
  if(can_select){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
 return 0;
}

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

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

Measured memory_bytes: 256