akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
vector<pair<int ,int> > vv;
map<int ,int > mm,uu;
int a[101];
bool cmp(int a,int b,int c)
{
    if(a+b>c&&b+c>a&&a+c>b)
        return true;
    return false;
}
int main()
{
    long long res=0;
    vv.clear();
    mm.clear();
    uu.clear();
    int T;
    cin>>T;
    for(int i=1;i<=T;i++)
    {
        cin>>a[i];
        mm[a[i]]++;
    }
    for(int i=1;i<=T;i++)
    {
        if(uu[a[i]]==0)
        {
            vv.push_back({a[i],mm[a[i]]});
            uu[a[i]]=1;
        }
    }
    /*for(int i=0;i<vv.size();i++)
        cout<<vv[i].first<<" "<<vv[i].second<<endl;*/
    if(vv.size()<3)
    {
        cout<<"0";
        return 0;
    }
    for(int i=0;i<vv.size()-2;i++)
    {
        for(int j=i+1;j<vv.size()-1;j++)
        {
            for(int k=j+1;k<vv.size();k++)
            {
                if(cmp(vv[i].first,vv[j].first,vv[k].first))
                {
                    res+=1ll*vv[i].second*vv[j].second*vv[k].second;
                }
            }
        }
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

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

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 2006, M = N << 1;

int n, m, k;
int tot, head[N], ver[M], nxt[M];
int dist[N];
bool st[N];
int ton[N];
int x, y;

inline void add(int u, int v) 
{
    ver[++tot] = v, nxt[tot] = head[u], head[u] = tot;
}

inline void Dij(int s)
{
    priority_queue <PII> q;
    q.push(make_pair(0, s));
    memset(dist, 0x3f, sizeof dist);
    dist[s] = 0;
    memset(st, false, sizeof st);
    while (!q.empty())
    {
        int u = q.top().second; q.pop();
        if (st[u]) continue;
        st[u] = true;
        for (int i = head[u]; i; i = nxt[i])
        {
            int v = ver[i];
            if (dist[v] > dist[u] + 1)
            {
                dist[v] = dist[u] + 1;
                q.push(make_pair(-dist[v], v));
            }
        }
    }
    for (int i = s + 1; i <= n; i+=1) ++ton[dist[i]];
}

int main()
{
	//File("");
	cin >> n >> x >> y;
	for (int i = 1; i < n; i+=1) add(i, i + 1), add(i + 1, i);
	add(x, y), add(y, x);
	for (int i = 1; i <= n; i+=1)
	    Dij(i);
	for (int i = 1; i < n; i+=1)
	    cout << ton[i] << 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 n = sc.nextInt();
    double x[] = new double[n];
    double y[] = new double[n];
    for(int i=0;i<n;i++){
      x[i]=sc.nextDouble();
      y[i]=sc.nextDouble();
    }
    
    double dist[][]=new double[n][n];
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        dist[i][j]=calcDistance(x[i],y[i],x[j],y[j]);
      }
    }
    double answer =0;
    
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        answer = answer + dist[i][j];
      }
    }
    System.out.println(answer/n);
    
    
  }
  
  public static double calcDistance(double x1 , double y1,double x2 , double y2){
    double dist =0;
    dist = Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    return dist;
  }
    
  

  
}

Measured memory_bytes: 23120
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int a[] = new int[n];
    int b[] = new int[n];
    int c[] = new int[n-1];
    int ans = 0;
    
    for (int i=0; i<n; i++) {
      a[i] = Integer.parseInt(sc.next())-1;
    }
    for (int i=0; i<n; i++) {
      b[i] = Integer.parseInt(sc.next());
    }
    for (int i=0; i<n-1; i++) {
      c[i] = Integer.parseInt(sc.next());
    }
    
    for (int i=0; i<n; i++) {
      ans += b[a[i]];
      if(i>0 && a[i-1] == a[i]-1) {
        ans += c[a[i-1]];
      }
    }
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 23892
#include<stdio.h>
#include <iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include<math.h>
#include<queue>
#include<stack>
#include<list>
#include<vector>
#include<map>
#include<set>
#define FOR(i,a) for(int i=0;i<a;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define ll long long
using namespace std;


int a, b;
int main() {
	cin >> a >> b;
	if ((a + b) % 2){
	cout << (a + b) / 2 +1<<endl;
    }
	else {
		cout << (a + b) / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N=int(input())
num=list(map(int,input().split()))
goukei=0
for i in range(N):
    goukei += num[i]
    goukei = (goukei%(10**9+7)) 
temp=goukei
sn=0
for i in range(N):
    temp=temp-num[i]
    sn+=num[i]*temp
print(sn%(10**9+7))



Measured memory_bytes: 31560
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
#define N 105
#define ll long long
ll n,a[N],g,ans;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
int main()
{
	scanf("%lld%lld",&n,&a[1]),g=ans=a[1];
	for(int i=2;i<=n;i++) scanf("%lld",&a[i]),g=gcd(a[i],ans),ans=(ll)ans/g*a[i];
	printf("%lld\n",ans);
	return 0;
}

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

#define int long long
#define fi first
#define se second
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int a,b;

signed main() {
    cin >> a >> b;
    if (a <= b) rep(i,b) cout << a;
    else rep(i,a) cout << b;
    cout << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
#define per(i, x, y) for (int i = x; i >= y; i--)
using namespace std;

const int N = 1e5 + 10;
typedef long long ll;
ll n, m, K, pos[N], a[N], b[N], vis[N], p[N], ans[N];

int main() {
    cin >> n;
    rep(i, 1, n) scanf("%lld", &pos[i]), b[i] = i;
    per(i, n, 1) pos[i] -= pos[i - 1];
    cin >> m >> K;
    rep(i, 1, m) scanf("%lld", &a[i]), swap(b[a[i]], b[a[i] + 1]);
    rep(i, 1, n) if (!vis[i]) {
        int cnt = 0;
        int j = i;
        for (; !vis[j]; j = b[j]) {
            vis[j] = 1;
            p[++cnt] = j;
        }
        rep(j, 1, cnt) ans[p[j]] = pos[p[(j + K % cnt - 1) % cnt + 1]];
    }
    rep(i, 1, n) ans[i] += ans[i - 1], printf("%lld.0\n", ans[i]);
    return 0;
}


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

#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define yes printf("Yes\n")
#define no printf("No\n")
#define print(ans) printf("%lld\n", ans)
#define nl cout << endl;
#define gap << " " <<
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()

typedef long long int ll;

int main()
{
    fastio;

    ll t, n, m, i, j, k, x, y, z, c, d, l, r, temp, temp1, temp2;

        cin >> x;

        if(x >= 30)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

typedef struct edge{
	int to;
	int cost;
};
vector<edge>tree[100010];
int N;

//priority_queue<pair<int,int>>MST;
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>MST;
//cost,to

void showMST(){
	cout << "[size] ";
	cout << MST.size() << endl;
	cout << "[top] ";
	cout << "to : " << MST.top().second << " cost : " << MST.top().first << endl;
	
}

void showTree(){
	
	for(int i=0;i<N;i++){
		cout << "showTree" << endl;
		for(int j=0;j<tree[i].size();j++){
			cout << "node = " << i << " : to = " << tree[i][j].to << " : cost = " << tree[i][j].cost << endl;
		}
	}
}
int main(){
	
	int answer=0;
	int check[100010]={};
	vector<pair<int,int>> cities_x;//x座標,その都市
	vector<pair<int,int>> cities_y;
	
	


	
	cin >> N;
	for(int i=0;i<N;i++){//街は0〜N-1まで
		int x,y;
		cin >> x >> y;
		cities_x.push_back(make_pair(x,i));
		cities_y.push_back(make_pair(y,i));
	}
	
	sort(cities_x.begin(),cities_x.end());//x座標で都市をソート
	sort(cities_y.begin(),cities_y.end());//y座標で都市をソート
	
	int node,to,cost;
	for(int i=0;i<N;i++){
		if(i!=0){//cities_x[i].second
			node = cities_x[i].second;
			to = cities_x[i-1].second;
			cost = abs(cities_x[i].first-cities_x[i-1].first);
			
			tree[node].push_back(edge{to,cost});
			
		}
		if(i!=N-1){
			node = cities_x[i].second;
			to = cities_x[i+1].second;
			cost = abs(cities_x[i].first-cities_x[i+1].first);
			
			tree[node].push_back(edge{to,cost});
		}
		if(i!=0){
			node = cities_y[i].second;
			to = cities_y[i-1].second;
			cost = abs(cities_y[i].first-cities_y[i-1].first);
			
			tree[node].push_back(edge{to,cost});
			
		}
		if(i!=N-1){
			node = cities_y[i].second;
			to = cities_y[i+1].second;
			cost = abs(cities_y[i].first-cities_y[i+1].first);
			
			tree[node].push_back(edge{to,cost});
		}
//		tree[cities_x[i].second].push_back(edge{cities_x[i+1].second,min(abs(cities_x[i].first-cities_x[i+1].first),abs(cities_y[i].first-cities_y[i+1].first))});
//		tree[cities_x[i+1].second].push_back(edge{cities_x[i].second,min(abs(cities_x[i].first-cities_x[i+1].first),abs(cities_y[i].first-cities_y[i+1].first))});
	}
	
//	showTree();

	
	for(int i=0;i<tree[0].size();i++){
		MST.push(make_pair(tree[0][i].cost,tree[0][i].to));
	}
//	showMST();
	check[0]=1;
	
	pair<int,int> memo;// <cost,to>
	
	while(!MST.empty()){
		memo=MST.top();
		MST.pop();
		if(check[memo.second]==0){
//			cout << "to : " << memo.second << endl;
			answer+=memo.first;
			check[memo.second]=1;
		
			for(int i=0;i<tree[memo.second].size();i++){
				MST.push(make_pair(tree[memo.second][i].cost,tree[memo.second][i].to));
			}
//			showMST();
		}
	}
	
	cout << answer << endl;
//	sort(tree[0].begin(),tree[0].end(),[](const edge& x,const edge& y){return x.to < y.to;});
	return 0;
}

Measured memory_bytes: 12012
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

/*
   cin.tie(0);
   ios::sync_with_stdio(false);
   */

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

bool contain(int mask, int pos){
    return ((mask & (1 << pos)) != 0);
}

void solve(int n){
    int t[n][n], defo[n];
    rep(i, n){
        cin >> defo[i];
        rep(j, n){
            cin >> t[i][j];
        }
    }
    
    int dp[1 << n];
    rep(i, 1 << n) dp[i] = INF / 2;
    dp[0] = 0;

    for(int mask = 1; mask < (1 << n); mask++){
        for(int i = 0; i < n; i++){
            if(contain(mask, i)){
                int mini = defo[i];
                for(int j = 0; j < n + 1; j++){
                    // cout << "debug: " << t[i][j] << endl;
                    if(contain(mask, j) && i != j){
                        mini = min(mini, t[i][j]);
                    }
                }
                // cout << mask << ": " << dp[mask] << " " << dp[mask ^ (1 << i)] <<" " <<  mini << endl;
                dp[mask] = min(dp[mask], dp[mask ^ (1 << i)] + mini); 
            }
        }
    }
    // rep(i, (1 << n)) cout << i << ": " << dp[i] << endl;
    cout << dp[(1 << n) - 1] << endl;
}

int main(){
    int n;
    while(cin >> n){
        if(n == 0)break;
	solve(n);
    }
    
    return 0;
}



Measured memory_bytes: 3348
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 +7  ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////



///////////////////////////////////////////////////////////////
void solve(){
    int n ;
    cin >> n ;
    string s ;
    cin >> s ;
    ll dp[n][3] ;
    memset(dp,0,sizeof dp);
    for( int i = n-1 ; i >= 0 ; i--){
        if(i!=n-1){
            dp[i][0] = dp[i+1][0];
            dp[i][1] = dp[i+1][1];
            dp[i][2] = dp[i+1][2] ;
        }
        if(s[i]=='R'){
            dp[i][0]++;
        }
        if(s[i]=='B'){
            dp[i][1]++;
        }
        if(s[i]=='G'){
            dp[i][2]++;
        }
    }
    ll ans = 0 ;
    for( int i = 0 ; i < n ; i++){
        for( int j = i+1 ; j < n-1 ; j++){
            ll cnt = 0 ;
            if(s[i]!=s[j]){
                if(s[i]=='R' && s[j]=='G'){
                    cnt += dp[j+1][1] + ( (2*j-i<n && s[2*j-i]=='B')?-1:0);
                }
                if(s[i]=='R' && s[j]=='B'){
                    cnt += dp[j+1][2] + ( (2*j-i<n && s[2*j-i]=='G')?-1:0);
                }
                if(s[i]=='B' && s[j]=='G'){
                    cnt += dp[j+1][0] + ( (2*j-i<n && s[2*j-i]=='R')?-1:0);
                }
                if(s[i]=='G' && s[j]=='R'){
                    cnt += dp[j+1][1] + ( (2*j-i<n && s[2*j-i]=='B')?-1:0);
                }
                if(s[i]=='B' && s[j]=='R'){
                    cnt += dp[j+1][2] + ( (2*j-i<n && s[2*j-i]=='G')?-1:0);
                }
                if(s[i]=='G' && s[j]=='B'){
                    cnt += dp[j+1][0] + ( (2*j-i<n && s[2*j-i]=='R')?-1:0);
                }
            }
           // cout << i << " " << j << " " << cnt << "\n";
            ans += cnt ;
        }
    }
//    ll ans1 = 0 ;
//    for( int i = 0 ; i < n ; i++){
//        for( int j = i+1 ; j < n-1 ; j++){
//            int cnt = 0 ;
//            for( int k = j + 1 ; k < n ; k++){
//               if( j-i!=k-j && s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i])
//                    cnt++;
//            }
//            ans1+=cnt;
//           // cout << i << " " << j << " " << cnt << "\n" ;
//        }
//    }
    cout << ans ;

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




Measured memory_bytes: 3708
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define mp make_pair
#define rep(a,b,c) for(int a=1;a<=b;a+=c)
#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)

const double PI=acos(-1);
const double EPS=1e-12;
const ll MOD=1e9+7;
const ll INF=1e15;


using namespace std;

ll dat[405];
ll minn[405][405];
ll summ[405];
int in;
ll chain(int x,int y){
	if(minn[x][y]!=INF)return minn[x][y];
	if(x==y)return minn[x][y]=0;
	ll temp=0;
	repp(i,x,y-1,1){
		temp=chain(x,i)+chain(i+1,y)-summ[x-1]+summ[y];
		minn[x][y]=min(minn[x][y],temp);
	}
	return minn[x][y];
}


int main(){
	//ios::sync_with_stdio(false);cin.tie(NULL);	cout.tie(NULL);
	rep(i,400,1){
		rep(j,400,1){
			minn[i][j]=INF;
		}
	}
	cin>>in;
	summ[0]=0;
	rep(i,in,1){
		cin>>dat[i];
		summ[i]=summ[i-1]+dat[i];
	}
	cout<<chain(1,in)<<endl;
	return 0;
}


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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

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

  if( N == 7 || N == 5 || N == 3 )
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}



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

void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("op.txt", "w", stdout);
#endif
}
 
int main()
{
    c_p_c();

    ll t,n,time;

   
    
    cin>>t>>n>>time;

  
   cout<<((t+n-1)/n)*time<<endl;

    return 0;
} 




Measured memory_bytes: 3532
#include <string.h>
#include <stdio.h>
#include <math.h>

typedef long long ll;

int memo[3005][3005], vis[3005][3005], k;
char s[3005], t[3005], str[3005];

int max(int a, int b)
{
    return a>b ? a : b;
}
int solve(int i, int j)
{
    if(i==0 && j==0)
    {
        if(t[j]==s[i])
            return memo[i][j] = 1;
        else
            return memo[i][j] = 0;
    }
    if(i==0)
    {
        if(t[j]==s[i])
            return memo[i][j] = 1;
        else
            return memo[i][j] = solve(i, j-1);
    }
    if(j==0)
    {
        if(t[j]==s[i])
            return memo[i][j] = 1;
        else
            return memo[i][j] = solve(i-1, j);
    }
    if(vis[i][j])
        return memo[i][j];
    vis[i][j]++;
    if(s[i]==t[j])
        return memo[i][j] = 1+solve(i-1, j-1);
    else
        return memo[i][j] = max(solve(i, j-1), solve(i-1, j));
}

void solvestr(int i, int j)
{
    //printf("i=%d j=%d\n", i, j);
    if(i==0 && j==0 && s[i]==t[j])
    {
        str[k++] = s[i];
        return;
    }
    if(i==0 && j==0)
    {
        return ;
    }
    if(i==0 && s[i]==t[j])
    {
        str[k++] = s[i];
        return;
    }
    if(j==0 && s[i]==t[j])
    {
        str[k++] = s[i];
        return;
    }
    if(i==0)
    {
        solvestr(i, j-1);
        return ;
    }
    if(j==0)
    {
        solvestr(i-1, j);
        return;
    }
    if(s[i]==t[j])
    {
        str[k++] = s[i];
        solvestr(i-1, j-1);
        return ;
    }
    if(memo[i][j] == memo[i-1][j])
    {
        solvestr(i-1, j);
        return ;
    }
    if(memo[i][j] == memo[i][j-1])
    {
        solvestr(i, j-1);
        return ;
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    memset(memo, 0, sizeof(memo));
    memset(vis, 0, sizeof(vis));
    scanf("%s %s", s, t);
    int len = solve(strlen(s)-1, strlen(t)-1);
    //printf("%d\n", len);
    k=0;
    solvestr(strlen(s)-1, strlen(t)-1);
    for(int i=k-1; i>=0; i--)
        printf("%c", str[i]);
    printf("\n");
    // for(int i=0; i<4; i++)
    // {
    //     for(int j=0; j<4; j++)
    //         printf("%d ", memo[i][j]);
    //     printf("\n");
    // }
    return 0;
}

Measured memory_bytes: 71040
//#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(false);cin.tie();cout.tie();
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1000000007;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
pll T[2000005];
queue<pll > K;
int main()
{
    speed
    ll n,d,a;
    cin>>n>>d>>a;
    d*=2;
    for(int i=1;i<=n;i++)
        cin>>T[i].st>>T[i].nd;
    sort(T+1,T+n+1);
    ll suma=0,wynik=0;
    for(int i=1;i<=n;i++)
    {
        while(!K.empty()&&T[i].st-d>K.front().st)
        {
            suma-=K.front().nd;
            K.pop();
        }
        if(suma>=INF/a||suma*a>=T[i].nd)
            continue;
        ll ile=(T[i].nd-suma*a)/a;
        if((T[i].nd-suma*a)%a!=0)
            ile++;
        wynik+=ile;
        K.push(mp(T[i].st,ile));
        suma+=ile;
    }
    cout<<wynik;
    return 0;
}


Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    int N, D, A;
    cin >> N >> D >> A;

    int X[N], H[N];
    P p[N];
    for(int i=0; i<N; i++){
        int a, b;
        cin >> a >> b;
        p[i] = P(a, b);
    }

    sort(p, p+N);
    for(int i=0; i<N; i++){
        X[i] = p[i].first;
        H[i] = p[i].second;
    }

    ll ans = 0;
    int sum[N+1];
    fill(sum ,sum+N+1, 0);
    for(int i=1; i<=N; i++){
        sum[i] += sum[i-1];

        if(H[i-1] <= sum[i]) continue;

        int rest = H[i-1] - sum[i];
        int cnt;
        if(rest%A == 0) cnt = rest / A;
        else cnt = rest/A + 1;

        ans = ans + cnt;
        sum[i] += A*cnt;

        int right = lower_bound(X, X+N, X[i-1]+2*D+1) - X;
        sum[right+1] -= A*cnt;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4096
import math
a,b,h,m = map(int,input().split())

aaa = abs((60*h+m)*0.5 - m*6)
if aaa > 180:
    aaa = 360 - aaa
print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(aaa))))

Measured memory_bytes: 9508
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 1e9
using namespace std;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}

typedef long long ll;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

#pragma endregion

int main() {
  int n = in();
  string s = in<string>();
  vector<vector<int> > v(3, vector<int>(n));

  int countR = 0, countG = 0, countB = 0;
  rrep(i, n) {
    if (s[i] == 'R') {
      ++countR;
    } else if (s[i] == 'G') {
      ++countG;
    } else {
      ++countB;
    }
    v[0][i] = countR;
    v[1][i] = countG;
    v[2][i] = countB;
  }

  ll ans = 0;
  char c;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n - 1; ++j) {
      if (s[i] == s[j]) {
        continue;
      }
      if (s[i] == 'R') {
        if (s[j] == 'G') {
          c = 'B';
        } else {
          c = 'G';
        }
      } else if (s[i] == 'G') {
        if (s[j] == 'R') {
          c = 'B';
        } else {
          c = 'R';
        }
      } else {
        if (s[j] == 'R') {
          c = 'G';
        } else {
          c = 'R';
        }
      }
      // not #2
      int k = j - i + j;
      if (c == 'R') {
        ans += v[0][j + 1];
      } else if (c == 'G') {
        ans += v[1][j + 1];
      } else {
        ans += v[2][j + 1];
      }
      if (s[k] == c) {
        --ans;
      }
    }
  }
  std::cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll n,m;
ll a[1005];
ll b[1005];

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

	cin >> n >> m;

	for (ll i = 0;i < n;i++){
		cin >> a[i];
	}
	for (ll i = 0;i < m;i++){
		cin >> b[i];
	}

	sort(a,a+n); sort(b,b+m);

	ll now = n*m;

	ll nai = n-1, nbi = m-1;
	ll ans = 1;
	ll cnt = 0;
	ll mod = 1000000007;

	for (;now >= 1;now--){
		ll cnt = 1;

		//cout << a[nai] << " " << b[nbi] << " " << now << " " << ans << endl;

		if(now == a[nai] && now == b[nbi]){
			//cnt++;
			nai--; nbi--;
			continue;
		}
		if(now == a[nai]){
			//cnt++;
			ans *= (m-1-nbi);
			ans %= mod;
			nai--;
			continue;
		}
		if(now == b[nbi]){
			//cnt++;
			ans *= (n-1-nai);
			ans %= mod;
			nbi--;
			continue;
		}

		ans *= ((n-1-nai) * (m-1-nbi) - (n*m-now));
		if(ans == 0){
			cout << 0 << endl;
			return 0;
		}
		ans %= mod;

	}

	cout << ans%mod << endl;

	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a,b,c,d,e;
int t[6];
int ten(int x){
	if(x%10!=0)
		return x-x%10+10;
	else return x;
}
int main(){
	cin>>a>>b>>c>>d>>e;
	t[1]=ten(a)+ten(b)+ten(c)+ten(d)+e;
	t[2]=ten(a)+ten(b)+ten(c)+ten(e)+d;
	t[3]=ten(a)+ten(b)+ten(e)+ten(d)+c;
	t[4]=ten(a)+ten(e)+ten(c)+ten(d)+b;
	t[5]=ten(e)+ten(b)+ten(c)+ten(d)+a;
	sort(t+1,t+6);
	cout<<t[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 11.11.2017 15:06:47       
**/
#include <bits/stdc++.h>

using namespace std;

const int N = 12345;

int a[N];
int smash[N];
int n;

long long solve(int v) {
  if (3 * v > n) {
    long long res = 0;
    for (int i = v; i <= n; i++) {
      if (i % 2 == 0 && i / 2 >= v) {
        continue;
      }
      if (i + i > n) {
        if (a[i] > 0 && smash[i] == 0) {
          res += a[i];
        }
      } else {
        if (smash[i] == 0) {
          if (smash[i + i] > 0) {
            res += max(0, a[i]);
          } else {
            res += max(0, max(a[i], a[i] + a[i + i]));
          }
        }
      }
    }
    return res;
  }
  if (smash[v] > 0) {
    return solve(v + 1);
  }
  long long cur = a[v] + solve(v + 1);
  for (int i = v + v; i <= n; i += v) {
    smash[i]++;
  }
  cur = max(cur, solve(v + 1));
  for (int i = v + v; i <= n; i += v) {
    smash[i]--;
  }
  return cur;
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  cout << solve(1) << endl;
  cerr << "time = " << clock() << " ms" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int H, W;
    while(1){
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0) break;
        for(int h = 0; h < H; h++){
            for(int w = 0; w < W; w++){
                if((h + w) % 2 != 0){
                    printf(".");
                }else{
                    printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 2044
#include <stdio.h>

struct player {
  int n, point;
};

int cmp(const struct player *a, const struct player *b) {
  if (a->point == b->point) {
    return b->n - a->n;
  } else {
    return a->point - b->point;
  }
}

int calc() {
  int point = 0;
  int i;
  int pin[21], top, frame;
  
  // ÇÝÝ
  for (i = 0; getchar() != '\n'; i++) {
    scanf("%d", pin + i);
    //printf("%d ", pin[i]);
  }
  //puts("");
  top = i;
  
  for (i = frame = 0; frame < 9; frame++) {
    if (pin[i] == 10) {
      point += pin[i] + pin[i + 1] + pin[i + 2];
      i++;
    } else {
      if (pin[i] + pin[i + 1] == 10) {
	point += pin[i] + pin[i + 1] + pin[i + 2];
      } else {
	point += pin[i] + pin[i + 1];
      }
      i += 2;
    }
  }
  
  while (i < top) { point += pin[i++]; }
  
  return point;
}

void input(struct player *p) {
  scanf("%d", &(p->n));
  p->point = calc();
}

int main() {
  int m;
  struct player p[40];
  
  while (scanf("%d\n", &m), m) {
    int i;
    
    for (i = 0; i < m; i++) {
      input(p + i);
    }
    
    qsort(p, m, sizeof(p[0]), (int (*)(const void*, const void*))cmp);
    
    for (i = m; i--;) {
      printf("%d %d\n", p[i].n, p[i].point);
    }
  }
  
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, n, m) for(int i = n; i < (int)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()

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

ll MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<P> v(N);
    vector<P> C(N);
    REP(i, N) {
        ll A, B;
        cin >> A >> B;
        v[i] = P(A, B);
        C[i] = P(A+B, i);
    }
    sort(ALL(C));
    ll a = 0;
    ll b = 0;
    REP(i, N) {
        if (i % 2 == 0) {
            a += v[C[N-1-i].second].first;
        } else {
            b += v[C[N-1-i].second].second;
        }
    }
    PRINT(a - b);
    return 0;
}


Measured memory_bytes: 3328
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$M,$X,$Y) = explode(" ",trim(fgets(STDIN)));
$x = explode(" ",trim(fgets(STDIN)));
$y = explode(" ",trim(fgets(STDIN)));
$mx = max($x);
$my = min($y);
$z = $mx + 1;

if ($X < $z && $z <= $Y && $z <= $my) {
  printf("No War\n");
}
else {
  printf("War\n");
}


Measured memory_bytes: 3828
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		List<int[][]> result = new ArrayList<int[][]>();
		
		int n;
		while( (n = stdIn.nextInt()) != 0 ){
			int[][] spread = new int[n+1][n+1];
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					spread[i][j] = stdIn.nextInt();
					spread[i][n] += spread[i][j];
					spread[n][j] += spread[i][j];
					spread[n][n] += spread[i][j];
				}				
			}
			result.add(spread);
						
		}
		
		for(int[][] ans : result){
			for(int[] x : ans){
				for(int y : x){
					System.out.printf("%5d",y);
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=100005;
//i_am_noob
int a,b;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b;
	print1((3*a+b)/2);
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, q = map(int, input().split())

ct = [0] * (n+1)
o = [0] * (n+1)
g = [[] for _ in range(n+1)]

for i in range(n-1):
  a,b= map(int, input().split())
  g[a].append(b)
  g[b].append(a)

for i in range(q):
  p,x= map(int, input().split())
  o[p] += x

todo = [1]
seen = [False] * (n+1)
while todo:
  p = todo.pop(-1)
  ct[p] += o[p]
  seen[p] = True
  for i in g[p]:
    if seen[i]:
      ct[p] += ct[i]
    else:
      todo.append(i)

print(*ct[1:])



Measured memory_bytes: 62592
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vl a(n);
    map<ll, ll> mp;
    rep(i, n) {
        cin >> a[i];
        mp[a[i]]++;
    }

    ll x = 0;
    for(auto p : mp) {
        x += p.second*(p.second - 1)/2;
    }

    rep(i, n) {
        out(x + 1 - mp[a[i]]);
    }
    
    re0;
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;


int main(){
    cin>>N>>S;
    ll ans = 0;
    rep(i,10){
        rep(j,10){
            rep(k,10){
                ll step = 0;
                rep(m,N){
                    if(step == 0 && S[m] - '0' == i){
                        ++step;
                    }else if(step == 1 && S[m] - '0' == j){
                        ++step;
                    }else if(step == 2 && S[m] - '0' == k){
                        ++ans;
                        break;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
a = list(map(int, input().split()))

class FenwickTree:
  def __init__(self, n):
    self.n = n
    self.data = [0] * (n + 2)
  def sum(self, i):
    i += 1
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  def add(self, i, x):
    i += 1
    while i <= self.n:
      self.data[i] += x
      i += i & -i
  def lowerbound(self, s):
    x = 0
    y = 0
    for i in range(self.n.bit_length(), -1, -1):
      k = x + (1 << i)
      if k <= self.n and (y + self.data[k] < s):
        y += self.data[k]
        x += 1 << i
    return x + 1
fwk = FenwickTree(N)
for x in range(N): fwk.add(x, a[x])
for _ in range(Q):
  q, x, y = map(int, input().split())
  if q: print(fwk.sum(y - 1) - fwk.sum(x - 1))
  else: fwk.add(x, y)

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

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


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

using namespace std;


int main(){
  int n,l,r;
  while(cin >> n >> l >> r && n!=0 && l!=0 && r!=0){
    vector<int> a(n);
    for(int i=0;i<n;++i) cin >> a[i];

    int num=0;
    for(int i=l;i<=r;++i){
      int flag=0;
      for(int j=0;j<n;++j){
	if(i%a[j]==0) {
	  flag++;
	  if((j+1)%2==1) num++;
	  break;
	}
      }
      if(flag==0 && n%2==0) num++;
    }
    cout << num << endl;
  }

  
  return 0;
}



Measured memory_bytes: 3016
n = 100010;

a = [0] * n

isprime = [1] * n
isprime[0] = isprime[1] = 0

for i in range(2, n):
    if isprime[i]:
        for j in range(i * i, n, i):
            isprime[j] = 0
for i in range(3, n, 2):
    if isprime[i] and isprime[(i + 1) // 2]:
        a[i] = 1
for i in range(1, n - 1):
    a[i + 1] += a[i]
q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(a[r] - a[l - 1])





Measured memory_bytes: 7156
require 'set'
n, k = gets.strip.split.map(&:to_i)
td = readlines.map {|line| line.strip.split.map(&:to_i) }

td = td.sort_by {|td| td.last*-1 }

selected = td[0, k]
unselected = td[k, n]

current_kinds = Set.new(selected.map(&:first))
current_score = selected.map(&:last).inject(:+)
max = current_score + current_kinds.size**2

if n==k
  p max
  exit
end

dup_set = Set.new
dups_in_selected = []
selected.each do |t, d|
  if dup_set.include?(t)
    dups_in_selected << [t,d]
  else
    dup_set << t
  end
end

unselected.each do |t, d|
  next if current_kinds.include?(t)
  removed = dups_in_selected.pop
  break if removed.nil?
  current_score -= removed.last
  current_score += d
  current_kinds << t
  tmp_max = current_score + current_kinds.size**2
  max = tmp_max if tmp_max > max
end

p max






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

int main()
{
  string S;
  string ans="CODEFESTIVAL2016";
  cin>>S;
  int cnt=0;
  for(int i=0;i<S.size();i++){
    if(S[i]==ans[i]) continue;
    cnt++;
  }
  cout<<cnt;
}
  

Measured memory_bytes: 256
n,k = map(int,input().split())
a = [i for i in range(n+1)]
d = []
A = []

for j in range(k):
  d.append(int(input()))
  A.append(list(map(int,input().split())))
  
  
for i in A:
  for j in i:
    if j in a:
      a.remove(j)
      
      
print(len(a)-1)

Measured memory_bytes: 9140
N = gets.to_i
A, B, C = $<.map{|s|s.split.map(&:to_i).sort}

def f(a, b)
  dp = []
  j = 0
  a.size.times{|i|
    j +=1 while a[j] && a[j] < b[i]
    dp[i] = j
  }
  dp
end

dp1 = f(A, B)
dp2 = f(B, C)
sum = 0
cusum1 = [sum] + dp1.map{|n|sum+=n}
p dp2.map{|n|
  cusum1[n]
}.inject:+


Measured memory_bytes: 26708
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <sstream>

using namespace std;

typedef long long ll;

ll ToInt(string s) {
  istringstream in(s);
  ll x;
  in >> x;
  return x;
}

int Sum(ll x) {
  int result = 0;
  while (x > 0) {
    result += x % 10;
    x /= 10;
  }
  return result;
}

int main()
{
  string s;
  cin >> s;

  int result = Sum(ToInt(s));

  if (s.size() > 1) {
    result = max<int>(result, 9 * (s.size() - 1));
  }

  for (int len = 1; len < s.size(); ++len) {
    string prefix = s.substr(0, len);
    ll p = ToInt(prefix) - 1;
    if (p > 0) {
      result = max<int>(result, Sum(p) + 9 * (s.size() - prefix.size()));
    }
  }

  cout << result << endl;

  return 0;
}


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

int main(){
    ll N; cin>>N;
    string s;
    ll AC = 0, WA = 0, TLE = 0, RE = 0;
    for(int i=0; i<N; ++i){
        cin>>s;
        if(s=="AC") AC++;
        else if(s=="WA") WA++;
        else if(s=="TLE") TLE++;
        else RE++;
    }
    cout<<"AC x "<<AC<<endl;
    cout<<"WA x "<<WA<<endl;
    cout<<"TLE x "<<TLE<<endl;
    cout<<"RE x "<<RE<<endl;
}

Measured memory_bytes: 3596
N, H = map(int, input().split())
swords = sorted([tuple(map(int, input().split())) for _ in range(N)],
                key=lambda x: -x[1])
max_a = max(swords, key=lambda x: x[0])[0]
cnt = 0
for a, b in swords:
    if b > max_a:
        cnt += 1
        H -= b
    if H <= 0:
        print(cnt)
        break
else:
    print(cnt + -(-H // max_a))

Measured memory_bytes: 22056
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#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 {
#ifdef LOCAL
~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 << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ld, ld> pdd;

void solve();

const int N = 2e5 + 10;

int main() {
    fast_cin();

    int t=1;
    // cin >> t;
    while(t--) {
        solve();
    }
}

void solve() {
    int n;
    cin >> n;
    int a[N];
    for (int i=1; i <= n; i++) { 
        cin >> a[i];
    }

    vector<int> dp(N, 1e9+10);
    dp[1] = 0;
    for (int i=1; i <= n; i++) {
        for (auto j: {1, 2}) {
            if (i + j <= n) {
                dp[i+j] = min(dp[i+j], dp[i] + abs(a[i+j] - a[i]));
            }
        }
    }
    
    cout << dp[n] << '\n';
}


Measured memory_bytes: 1408
import numpy as np
N=int(input())
#F i,j,k 店i　曜日j 時間帯k
#P 店iと両方回転している時間帯の数がci P：　利益
F=[]
for i in range(N):
    f=list(map(int, input().split()))
    F.append(f)
F=np.array(F)

P=[]
for i in range(N):
    p=list(map(int, input().split()))
    P.append(p)

#N*10
ans=-np.inf
for b in range(1,2**10):
    C=np.zeros(N)
    for i in range(10):
        if b>>i&1==1:
            now=F[:,i]
            C+=now
    subnow=0
    #print(C)
    for j,c in enumerate(C):
        subnow+=P[j][int(c)]
    ans=max(ans, subnow)

print(ans)


Measured memory_bytes: 12484
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	// map<a, b>: a は b 番目にある(番兵のために 1-indiziert にする)
	map<int, int> m;
	for( int i = 1; i <= n; ++i ){
		int tmp; cin >> tmp;
		m[tmp] = i;
	}
	// 左端と右端の番兵
	// 0 は 0 番目，n+1 は n+1 番目にある
	m[0] = 0; m[n+1] = n+1;
	ll ans = 0;
	set<ll> bntzt;
	bntzt.insert(0); bntzt.insert(n+1);
	for( int k = 1; k <= n; ++k ){
		auto itr = bntzt.lower_bound(m[k]);
		ll r = *(itr);
		ll l = *(--itr);
		ans += k*(m[k]-l)*(r-m[k]);
		bntzt.insert(m[k]);
	}
	cout << ans << endl;	
	return 0;
}

Measured memory_bytes: 18944
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    from collections import defaultdict

    NIL = -1

    n = int(input())

    T = defaultdict(lambda: {'left':NIL, 'right':NIL, 'parent':NIL})
    D = {}
    H = {}

    for _ in range(n):
        u, left, right = map(int, input().split())
        T[u]['left'] = left
        T[u]['right'] = right
        if left != NIL:
            T[left]['parent'] = u
        if right != NIL:
            T[right]['parent'] = u

    def set_depth(u, d):
        if u == NIL:
            return
        D[u] = d
        set_depth(T[u]['left'], d+1)
        set_depth(T[u]['right'], d+1)

    def set_height(u):
        h1 = 0
        h2 = 0
        if T[u]['left'] != NIL:
            h1 = set_height(T[u]['left'])+1
        if T[u]['right'] != NIL:
            h2 = set_height(T[u]['right'])+1
        height = max(h1, h2)
        H[u] = height
        return height

    for u, value in T.items():
        if value['parent'] == NIL:
            root = u
            break

    set_depth(root, 0)
    set_height(root)

    # 節点uの兄弟を返す
    def get_sibling(u):
        if T[u]['parent'] == NIL:
            return NIL
        if T[T[u]['parent']]['left'] != u:  # and 以降なくても問題ない
            return T[T[u]['parent']]['left']
        if T[T[u]['parent']]['right'] != u:  # and 以降なくても問題ない
            return T[T[u]['parent']]['right']
        return NIL

    for u in range(n):
        value = T[u]
        parent = value['parent']
        sibling = get_sibling(u)
        deg = 0
        if T[u]['left'] != NIL:
            deg += 1
        if T[u]['right'] != NIL:
            deg += 1
        if value['parent'] == NIL:
            type = 'root'
        elif value['left'] == NIL and value['right'] == NIL:
            type = 'leaf'
        else:
            type = 'internal node'
        depth = D[u]
        height = H[u]
        print('node ' + str(u) + ': ', end='')
        print('parent = ' + str(parent) +', ', end='')
        print('sibling = ' + str(sibling) + ', ', end='')
        print('degree = ' + str(deg) + ', ', end='')
        print('depth = ' + str(depth) + ', ', end='')
        print('height = ' + str(height) + ', ', end='')
        print(type)


Measured memory_bytes: 6036
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  ll n;
  cin >> n;
  ll a, b;
  cin >> a >> b;
  if ((b - a) % 2 == 0) {
    cout << (b - a) / 2 << endl;
  } else {
    cout << min(a - 1, n - b) + 1 + (b - a - 1) / 2 << endl;
  }
}

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

Measured memory_bytes: 3596
def Postal_Code(a , b , s):

    ans = "No"

    if s[:a].isdecimal() and s[a+1:].isdecimal() and s[a] == '-':
        ans = "Yes"

    return ans

def main():
    a , b = map(int , input().split())
    s = str(input())
    print(Postal_Code(a , b , s))

if __name__ == '__main__':
    main()


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

using namespace std;

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

	int n, m;
	long long k;
	cin >> n >> m >> k;

	vector<long long> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	vector<long long> b(m);
	for(int i = 0; i < m; ++i) {
		cin >> b[i];
	}

	int j = -1;
	long long sum = 0;
	while(j + 1 < n) {
		if(sum + a[j + 1] <= k) {
			sum += a[j + 1];
			j += 1;
		} else {
			break;
		}
	}
	int ans = j + 1;
	for(int i = 0; i < m; ++i) {
		sum += b[i];
		while(j >= 0 && sum > k) {
			sum -= a[j];
			j -= 1;
		}
		if(sum <= k) {
			ans = max(ans, i + 1 + j + 1);
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 6364