akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max)) 
#define INF (INT_MAX / 4)

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

struct Edge{
	Edge(int to_, int cost_):to(to_), cost(cost_){}
	int to;
	int cost;
};

struct Vertex{
	Vertex(int v, int h, int c):vi(v), hp(h), cost(c){}
	int vi;
	int hp;
	int cost;
	bool operator > (const Vertex& b) const{
		return cost > b.cost;
	}
};

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int V, HP, L, E, S, G;
	while(1){
		cin >> V >> HP >> L >> E >> S >> G;
		if(V == 0 && HP == 0 && L == 0 && E == 0 && S == 0 && G == 0) break;
		vector<bool> ls(V);
		vector<vector<Edge> > es(V);
		rep(i, L){
			int l;
			cin >> l;
			ls[l] = true;
		}
		rep(i, E){
			int f, t, c;
			cin >> f >> t >> c;
			es[f].pb(Edge(t, c));
			es[t].pb(Edge(f, c));
		}
		
		VII dist(V, VI(HP + 1, INF));
		priority_queue<Vertex, vector<Vertex>, greater<Vertex> > que;
		dist[S][HP] = 0;
		que.push(Vertex(S, HP, 0));
		while(!que.empty()){
			Vertex v = que.top();
			que.pop();
			int cur = v.cost;
			for(Edge e : es[v.vi]){
				int hp = v.hp - e.cost;
				if(hp < 0) continue;
				auto &next = dist[e.to][hp];
				if(cur + e.cost < next){
					next = cur + e.cost;
					que.push(Vertex(e.to, hp, next));
				}
			}
			if(ls[v.vi]){
				for(int i = v.hp + 1;i <= HP;i++){
					auto &next =  dist[v.vi][i];
					int c = cur + i - v.hp;
					if(c < next){
						next = c;
						que.push(Vertex(v.vi, i, next));
					}
				}
			}
		}

		int ans = *min_element(all(dist[G]));
		if(ans == INF){
			cout << "Help!" << endl;
		}
		else{
			cout << ans << endl;
		}
	}
	return 0;
}

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

int main() {
  
  int x,a,b;
  cin >> x >> a >> b;
  
  if ( abs( x - a ) < abs( x - b ) ){
    cout << 'A' << endl;
  }else{
    cout << 'B' << endl;
  }
  
  
}



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

int main()
{
    string s;
    cin>>s;
    if(s=="SUN") cout<<7<<endl;
    else if(s=="MON") cout<<6<<endl;
    else if(s=="TUE") cout<<5<<endl;
    else if(s=="WED") cout<<4<<endl;
    else if(s=="THU") cout<<3<<endl;
    else if(s=="FRI") cout<<2<<endl;
    else if(s=="SAT") cout<<1<<endl;
}



Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  int d, x;
  readf("%s %s\n", &d, &x);

  auto res = x;
  foreach (_; 0..n) {
    auto a = readln.chomp.to!int;
    auto i = 1;
    while (i <= d) {
      res++;
      i += a;
    }
  }
  res.writeln;
}


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


int main(){
    int n,m,ans=0,i,j;
    cin>>n>>m;
    int a[n];
    vector<int> v[n+1];
    for(i=0;i<n;i++)
    cin>>a[i];
    while(m--){
        int b,c;
        cin>>b>>c;
        v[b].push_back(c);
        v[c].push_back(b);
    }
    for(i=1;i<=n;i++){
        int f=1;
        for(j=0;j<v[i].size();j++){
        if(a[i-1]<=a[v[i][j]-1])
        f=0;}
        if(f==1)
        ans++;
    }
        cout<<ans;
    }

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

const int mod = 1e9+7;

const int maxn = 2001;

long long int dp[maxn][maxn];
long long int fac[4000001],inv[4000001];
void update(long long int& x,long long int y){
	x=(x+y)%mod;
}
long long int C(long long int N,long long int K){
	return fac[N]*inv[K]%mod*inv[N-K]%mod;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	dp[0][0]=1;
	cin>>n>>k;
	fac[0]=inv[0]=fac[1]=inv[1]=1;
	for(int i=2;i<=4000000;i++)
		fac[i]=fac[i-1]*i%mod;
	for(int i=2;i<=4000000;i++)
		inv[i]=(mod-mod/i*inv[mod%i]%mod)%mod;
	for(int i=2;i<=4000000;i++)
		inv[i]=inv[i-1]*inv[i]%mod;
	if(k==1){
		cout<<1<<endl;
		return 0;
	}
	for(int i=0;i<=n;i++)
		for(int j=i;j<=n;j++){
			if(i==0&&j==0)	continue;
			if(j>i)
				update(dp[i][j],C(i+j*(k-1)-1,k-2)*dp[i][j-1]);
			if(i>0)
				update(dp[i][j],dp[i-1][j]);
		}
	cout<<dp[n][n]*fac[n]%mod<<endl;
}


Measured memory_bytes: 92928
#include<bits/stdc++.h>
#define bye return 0
#define Yes cout << "Yes" << "\n"
#define No  cout << "No" << "\n"
#define YES cout << "YES" << "\n"
#define NO cout << "NO" << "\n"
#define endl cout << "\n"
using namespace std;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> v;
    set<int> s;
    int t, a, b, c, cnt=0;
    double d, d1, d2;
    vector < vector<string> > v1;
    string s1, s2;
    cin >> a >> b;

    for(int i=0; i<a; ++i){
    	vector<string> raw;
    	cin >> s1;
    	raw.push_back(s1);
    	v1.push_back(raw);
    	raw.clear();
    }

    for(int i=0; i<b+2; ++i){
    	cout << "#";
    }
    endl;

    for(int i=0; i<v1.size(); ++i){
    	for(int j=0; j<1; ++j){
    		cout <<"#" << v1[i][j] << "#" << "\n";
    	}
    }




    for(int i=0; i<b+2; ++i){
    	cout << "#";
    }
    endl;


    bye;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[]args){
    
    	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int x=0,y=0;
            for(int i=0;i<n;i++){
                String s1=sc.next();
                String s2=sc.next();
                if(s1.compareTo(s2)<0){
                    y+=3;
                }else if(s1.compareTo(s2)>0){
                    x+=3;
                }else{
                    x+=1;
                    y+=1;
                }
            }
        System.out.println(x+" "+y);
	}
}


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

int main() {
  int N;
  cin >> N;
  vector<int> B(N-1);
  for(int i=0;i<N-1;i++){
    cin >> B.at(i);
  }
  int sum=B.at(0)+B.at(N-2);
  for(int i=1;i<N-1;i++){
    sum+=min(B.at(i-1),B.at(i));
  }
  cout << sum << endl;
}

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

typedef long long ll;
#define int ll
#define db(x) cout<<#x<<" = "<<x<<"\n";
#define FIN ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ALL(a) a.begin(),a.end()
#define mset(a,b) memset(a,b,sizeof(a));


main() 
{
	FIN;
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	cin>>arr[i];
	stack<int> s;
	
	int ans=0;
	for(int i=0;i<n;i++)
	{
	    if(s.empty()||arr[i]>=s.top())
	    {
	        s.push(arr[i]);
	        continue;
	    }
	    ans=ans+s.top()-arr[i];   
	}
	cout<<ans;

}

Measured memory_bytes: 6252
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <assert.h>
#include <numeric>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)(1e5+5)
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){fast;
	int n,i;ll s=0;cin>>n;vector<int>v(n);
	for(i=0;i<n;i++) cin>>v[i];
	for(i=0;i<n;i++) s^=v[i];
	for(i=0;i<n;i++) cout<<(s^v[i])<<" ";cout<<endl;
}


Measured memory_bytes: 4020
N = int(input())
Ts = [int(i) for i in input().split()]

drinks = []
for i in range(int(input())):
    drinks.append([int(i) for i in input().split()])

for i, j in drinks:
    cp = list(Ts)
    cp[i - 1] = j
    print(sum(cp))

Measured memory_bytes: 3060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        mut s: chars
    }
    s[5] = ' ';
    s[13] = ' ';
    println!("{}", s.iter().cloned().collect::<String>());
}


Measured memory_bytes: 4352
#ALl green
import math
d,g=map(int,input().split())
lists=[tuple(map(int,input().split())) for i in range(d)]
A=[]
for _ in range(2**d):
    lis=[]
    G=0
    G+=g
    counter=0
    strings=format(_,"0%ib"%d)
    strings=strings[::-1]
    for i in range(d):
        if strings[i]=="1":
            G-=(lists[i][0]*100*(i+1)+lists[i][1])
            counter+=lists[i][0]
        else:
            lis.append((lists[i][0],(i+1)*100))
    if G<=0:
        A.append(counter)
    else:
        lis=sorted(lis,key=lambda x:x[1],reverse=True)
        lis.append("END")
        #Gは0よりも大きく、lisに残ったものからcomplete しないようにしつつ引いていく
        flag=True
        for some in lis:
            if not(G>0 and flag):
                break            
            if some=="END":
                flag=False
            else:
                limit=some[0]-1
                number=some[1]
                if G>limit*number:
                    G=G-number*limit
                    counter+=limit
                else:
                    P=math.ceil(G/number)
                    counter=counter+P
                    A.append(counter)
                    flag=False

        if G<=0:
            A.append(counter)

print(min(A) )  


Measured memory_bytes: 3188
#include<cstdio>
#include<algorithm>
using namespace std;
int f(int n)
{
    int ans=0;
    while(n)
    {
        ans+=n%10;
        n/=10;
    }
    return ans;
}
int main()
{
    int n;
    scanf("%d",&n);
    printf("%s",(n%f(n)==0)?"Yes":"No");
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
#define inf 0x7fffffff
/*------------------------------------------------------------*/

int main(){
	int n,a,b;
	in3(n,a,b);
	(b-a)&1?printf("Borys"):printf("Alice");
}

Measured memory_bytes: 256
// abc166_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

vector<ll> get_divisors(ll n){
    vector<ll> res;
    for (int i = 1; i * i <= n; i++){
        if (i * i == n){
            res.emplace_back(i);
        }
        if (n % i == 0){
            res.emplace_back(i);
            res.emplace_back(n / i);
        }
    }
    sort(ALL(res));
    return res;
}


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll X;
    cin >> X;

    vector<ll> divs = get_divisors(X);

    REP(t, 2){
        for (auto d: divs){
            int k = t == 0 ? d : -d;

            REPN(i, -1000, 1000){
                ll a = i;
                ll b = a + k;

                if (pow(a, 5) - pow(b, 5) == X){
                    print(a, b);
                    return 0;
                }
            }
        }
    }

    return 0;
}


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

int main(){
  string s;
  cin >> s;
  
  if(s.at(2) == s.at(3) && s.at(4) == s.at(5)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a*n,b)<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
A = [input() for _ in range(n)]
B = [input() for _ in range(m)]

ans = 'No'
for i in range(n - m + 1):
    for j in range(n - m + 1):
        if all([A[i + k][j:j + m] == B[k] for k in range(m)]):
            ans = 'Yes'
print(ans)

Measured memory_bytes: 9196
#D
from collections import deque
n,k = map(int,input().split())
a = list(map(int,input().split()))
tel = deque()
tel.append(1)
visit = [False for _ in range(n)]
visit[0] = True
for i in range(n):
    nx = a[tel[i]-1]
    if visit[nx-1] == True :
        tel.append(nx)
        #ループの始まりのindexをidxに格納
        idx = tel.index(nx)
        break
    tel.append(nx)
    visit[nx-1] = True
    
#print(tel)
#print(visit)
if k <= idx:
    goal = tel[k]
else:
    k -= idx
    loop_num = len(tel) - idx - 1
    #print('idx:',idx)
    #print('loop_num:',loop_num)
    goal = tel[idx + k%loop_num]
    
print(goal)

Measured memory_bytes: 33868
N = int(input())
A = [int(i) for i in input().split()]
cnt = 0    
flag = 1

def calc_half(n):
    return int(n/2)

def check(li):
    for i in li:
        if i%2 != 0:
            return 0
        else:
            continue
    return 1
    
flag = check(A)
while flag == 1:
    A = list(map(calc_half, A))
    cnt += 1
    flag = check(A)
print(cnt)

Measured memory_bytes: 3064
from collections import defaultdict
n, m = map(int, input().split())
G = defaultdict(list)
s = []
for i in range(m):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
    s.append((a - 1, b - 1))


def dfs(cur, pre, NG, k):
    global used
    used[cur] = 1
    for v in G[cur]:
        if v != pre and used[v] != 1 and (v, cur) != NG and (cur, v) != NG:
            dfs(v, cur, NG, k + 1)


num = 0
for i in range(m):
    ng = s[i]
    used = [0] * n
    used[0] = 1
    dfs(0, -1, ng, 0)
    if sum(used) == n:
        num += 1

print(m - num)

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

class Cube{
public:
 int f[6];
 Cube(){}
 void roll_z(){ roll(1,2,4,3);}
 void roll_y(){ roll(0,2,5,3);}
 void roll_x(){ roll(0,1,5,4);}
 void roll(int i,int j,int k,int l){
   int t=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
 }
};

int getRight( Cube c1,int f1,int f2 ){
 for(int i=0;i<6;i++){
   for(int j=0;j<4;j++){
     if( c1.f[0]==f1 && c1.f[1]==f2 ) return c1.f[2];
     c1.roll_z();
   }
   if( i%2 == 0 )c1.roll_y();
   else c1.roll_x();
 }
 return -1;
}

int main(){
 Cube c;
 int f1,f2;
 for(int i=0;i<6;i++)cin>>c.f[i];
 int q; cin>>q;
 for(int i=0;i<q;i++){
   cin>>f1>>f2;
   cout<<getRight(c,f1,f2)<<endl;
 }
 return 0;
}


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

int main()
{
    int a[3];int sum=0;
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);

    for(int i=1;i<3;i++){
        sum+=a[i]-a[i-1];
    }
    cout<<sum;
    return 0;
}


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

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

    vector<ll> t(n);
    for (int i = 0; i < n; i++) {
        cin >> t[i];
    }
    
    int m; cin >> m;
    
    vector<int> p(m);
    vector<ll> x(m);
    for (int i = 0; i < m; i++) {
        cin >> p[i] >> x[i];
    }

    for (int i = 0; i < m; i++) {
    
        ll tmpSum = 0;
        for (int j = 0; j < n; j++) {

            if (j == p[i] - 1) tmpSum += x[i];
            else tmpSum += t[j];

        }
        cout << tmpSum << endl;

    }

    return 0;

}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <iomanip>
#include <limits>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> C(N);
    for (int i = 0; i < N; i++) {
        cin >> C.at(i);
    }
    for (int i = 0; i < N - 1; i++) {
        if (i == 0) {
            if (C.at(i) - 1 > C.at(i + 1)) {
                cout << "No" << endl;
                break;
            }
            else {
                C.at(i) -= 1;
            }
        }

        else if (C.at(i - 1) <  C.at(i)) {
            C.at(i) -= 1;

        }
        if (C.at(i) > C.at(i + 1)) {

                cout << "No" << endl;
                break;
        }
        if (i == N - 2) {
            cout << "Yes" << endl;

        }
    }
    if (N == 1) {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 640
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
s = ns()

b, w = 0, 0
cub = [0] * (n + 1)
cuw = [0] * (n + 1)
for i in range(1, n + 1):
    cub[i] = cub[i - 1]
    cuw[i] = cuw[i - 1]
    cub[i] += s[i - 1] == '#'
    cuw[i] += s[i - 1] == '.'

ans = inf
for i in range(n + 1):
    ans = min(cub[i] + cuw[n] - cuw[i], ans)

print(ans)

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

long long int x[100001] = {};
long long int y[100001] = {};
long long MOD = 1000000007;

int main() {
  int n, m;
  scanf("%d %d", &n, &m);

  for (int i = 0; i < n; i++) scanf("%lld", x + i);
  for (int i = 0; i < m; i++) scanf("%lld", y + i);

  long long sx = 0, sy = 0, ret = 0;

  long long tmp = 0;
  for (int i = 0; i < n; i++) tmp = (tmp + x[i]) % MOD;
  for (int i = 1; i < n; i++) {
    tmp = (tmp - x[i - 1]) % MOD; // a_i to a_(n - 1)
    sx = (sx + tmp - (x[i - 1] * (n - i)) % MOD) % MOD;
  }

  tmp = 0;
  for (int i = 0; i < m; i++) tmp = (tmp + y[i]) % MOD;
  for (int i = 1; i < m; i++) {
    tmp = (tmp - y[i - 1]) % MOD; // a_i to a_(n - 1)
    sy = (sy + tmp - (y[i - 1] * (m - i)) % MOD) % MOD;
  }

  printf("%lld\n", (sx * sy) % MOD);
  return 0;
}


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

int main(){

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	int a,b,c;
	cin>>a>>b>>c;
	int temp = c;
	for(int i=1;i<=10;i++){
		cout<<(a*temp) - b<<endl;
		temp = (a*temp)-b;
	}
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    int main(){
            int P, Q, R, p, q, r;
                cin >> P >> Q >> R;
                    p = P + Q;
                    q = Q + R;
                    r = R + P;
                        if(p <= q && p <= r){
                            cout << p;
                        }else if(q <= p && q <= r){
                            cout << q;
                        }else if(r <= p && r <= q){
                            cout << r;
                        }else{}
    return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int t1(int x){
	return (x+9)/10*10;
}
int t2(int x){
	return t1(x)-x;
}
int main(){
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	int sum = t1(a)+t1(b)+t1(c)+t1(d)+t1(e)-max({t2(a),t2(b),t2(c),t2(d),t2(e)});
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
#define add(a,b) (a+b>=mo)?(a+=b-mo):(a+=b)
using namespace std;
int f[2][22][1<<19],a[22][22];
int lowbit(int s){return s&(-s);}
int main()
{
	int n,m,q;scanf("%d%d%d",&n,&m,&q);
	memset(a,255,sizeof(a));
	while (q--)
	{
		int u,v,w;scanf("%d%d%d",&u,&v,&w);
		a[u][v]=w;
	}
	f[1][0][0]=1;
	for (int i=1;i<=m;i++)
	{
		memset(f[(i&1)^1],0,sizeof(f[(i&1)^1]));
		for (int j=0;j<n;j++)
		for (int s=0;s<(1<<(n-1));s++) if (f[i&1][j][s])
		{
			//cout<<i<<' '<<j<<' '<<s<<' '<<f[i][j][s]<<endl;
			if (j==n-1)
			{
				add(f[(i&1)^1][0][s],f[i&1][j][s]);
			}
			else
			{
				if ((a[i][j+1]!=1)&&((s&(1<<j))==0)) add(f[i&1][j+1][s],f[i&1][j][s]);
				if (a[i][j+1]!=0)
				{
					if (s&(1<<j)) add(f[i&1][j+1][s],f[i&1][j][s]);
					else add(f[i&1][j+1][s-(lowbit(s>>j)<<j)+(1<<j)],f[i&1][j][s]);
				}
			}
		}
	}
	int ans=0;
	for (int s=0;s<(1<<(n-1));s++) add(ans,f[m&1][n-1][s]);
	printf("%d\n",ans);
}
	
	
	
	
	
	
	
	
	
	
	

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

int main(){
  bool card[4][13];
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 13; j++)card[i][j] = 1;
  }
  int cardNum,num,markID;
  char mark;
  cin >> num;
  for(int i = 0; i < num; i++){
    cin >> mark >> cardNum;
    switch(mark){
      case 'S': markID = 0; break;
      case 'H': markID = 1; break;
      case 'C': markID = 2; break;
      case 'D': markID = 3; break;
    }
    card[markID][cardNum - 1] = 0;
  }

  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 13; j++){
      if(card[i][j] == 1){
        switch(i){
          case 0: mark = 'S'; break;
          case 1: mark = 'H'; break;
          case 2: mark = 'C'; break;
          case 3: mark = 'D'; break;
        }
        cout << mark <<' '<< j + 1 << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int m = scn.nextInt();
        int[][]A = new int[n][m];
        int[]b = new int[m];
        int[]c = new int [n];
        
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                A[i][j]=scn.nextInt();
            }
        }
        
        for(int i=0;i<m;i++){
            b[i]=scn.nextInt();
        }
        
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                c[i]+=A[i][j]*b[j];
            }
            System.out.println(c[i]);
        }

        

        
    }



    
}

Measured memory_bytes: 31108
use std::io::Read;
use std::collections::HashSet;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s: Vec<char> = iterator.next().unwrap().chars().collect();
    let t: Vec<char> = iterator.next().unwrap().chars().collect();

    let p: Vec<Vec<usize>> = destruct(&s);
    let q: Vec<Vec<usize>> = destruct(&t);

    if p.len() != q.len() {
        return "No".to_string();
    }

    for i in 0..p.len() {
        let pi = &p[i];
        let qi = &q[i];
        if pi.len() != qi.len() {
            return "No".to_string();
        }
        for j in 0..pi.len() {
            if pi[j] != qi[j] {
                return "No".to_string();
            }
        }
    }

    return "Yes".to_string()
}

fn destruct(s: &Vec<char>) -> Vec<Vec<usize>> {
    let mut result: Vec<Vec<usize>> = Vec::new();

    let mut checked: HashSet<char> = HashSet::new();
    for i in 0..s.len() {
        let c = s[i];
        if checked.contains(&c) {
            continue;
        }
        let mut v: Vec<usize> = Vec::new();
        for j in 0..s.len() {
            if s[j] == c {
                v.push(j);
            }
        }
        result.push(v);
        checked.insert(c);
    }

    result.sort();
    return result;
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

typedef pair<ll,int>P;

const int MAX_N = 200005;

int a[MAX_N];
int pre[MAX_N];
vector<P> b;
int bit[MAX_N+1],n,K;
//i番目までの和を計算する(iは1スタート)
int sum(int i)
{
	int s = 0;
	while(i>0){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
//i番目の値にxを加える(iは1スタート)
void add(int i,int x)
{
	while(i <= n + 2){
		bit[i] += x;
		i += i & -i;
	}
}

int main()
{
	scanf("%d%d",&n,&K);
	rep(i,n){
		scanf("%d",&a[i]);
	}
	ll sm = 0;
	b.push_back(P(0,0));
	rep(i,n){
		sm += a[i] - K;
		b.push_back(P(sm,i+1));
	}
	sort(b.begin(),b.end());
	rep(i,n+1){
		pre[b[i].second] = i;
	}
	ll res = 0;
	for(int i=n;i>=1;i--){
		add(pre[i]+1,1);
		res += sum(n+1) - sum(pre[i-1]+1);
	}
	printf("%lld\n",res);
}


Measured memory_bytes: 7152
import java.util.Scanner;

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

        int n = scanner.nextInt();

        int[] A = new int[n];
        for (int i = 0; i < n; ++i) {
            A[i] = scanner.nextInt();
        }

        int q = scanner.nextInt();

        int[] m = new int[q];
        for (int i = 0; i < q; ++i) {
            m[i] = scanner.nextInt();
        }

        boolean[] ans = new boolean[2001];
        for (int j = 0; j < (1 << n); ++j) {
            int sum = 0;

            for (int k = 0; k < n; ++k) {
                if (((j >> k) & 1) == 1) sum += A[k];
            }

            if (sum <= 2000) ans[sum] = true;
        }

        for (int i = 0; i < q; ++i) {
            System.out.println(ans[m[i]] ? "yes" : "no");
        }
    }
}


Measured memory_bytes: 26768
s = input()
t = input()

map_s = [-1] * 26
map_t = [-1] * 26
for cs, ct in zip(s, t):
    if map_s[ord(cs)-97] < 0:
        map_s[ord(cs)-97] = ord(ct)
    else:
        if map_s[ord(cs)-97] != ord(ct):
            print('No')
            break
    if map_t[ord(ct)-97] < 0:
        map_t[ord(ct)-97] = ord(cs)
    else:
        if map_t[ord(ct)-97] != ord(cs):
            print('No')
            break
else:
    print('Yes')


Measured memory_bytes: 3632
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {

	string s;
	ll x, y;
	cin >> s >> x >> y;

	vll ax, ay;
	ll count = 0; bool xory = true;
	rep(i, s.size()) {
		if (s[i] == 'F') ++count;
		else {
			if (xory) ax.push_back(count);
			else ay.push_back(count);
			count = 0;
			xory = !xory;
		}
	}
	if (0 < count) {
		if (xory) ax.push_back(count);
		else ay.push_back(count);
	}

	if (!ax.empty()) {
		x -= ax[0];
		ax.erase(ax.begin());
	}

	vector<vll> dpx(2, vll(16001, false)), dpy(2, vll(16001, false));
	dpx[0][8000] = true, dpy[0][8000] = true;
	rep(i, (ll)ax.size()) {
		fori(j, -8000, 8001) {
			if (dpx[i % 2][j + 8000]) {
				dpx[(i + 1) % 2][j + ax[i] + 8000] = true;
				dpx[(i + 1) % 2][j - ax[i] + 8000] = true;
			}
		}
		fori(j, -8000, 8001) dpx[i % 2][j + 8000] = false;
	}
	rep(i, (ll)ay.size()) {
		fori(j, -8000, 8001) {
			if (dpy[i % 2][j + 8000]) {
				dpy[(i + 1) % 2][j + ay[i] + 8000] = true;
				dpy[(i + 1) % 2][j - ay[i] + 8000] = true;
			}
		}
		fori(j, -8000, 8001) dpy[i % 2][j + 8000] = false;
	}
	cout << (dpx[(ll)ax.size() % 2][x + 8000] && dpy[(ll)ay.size() % 2][y + 8000] ? "Yes" : "No") << endl;
}

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

#define N 1000000

int main(void){
	vector<bool> isprime(N+1);
	for(int i=0;i<isprime.size();i++) isprime[i]=true;
	int upto = (int)sqrt(isprime.size());
	isprime[0]=isprime[1]=false;
	for(int i=2;i<=upto;++i){
		if(isprime[i]){//消されてなければその倍数を消す
			for(int j=2;i*j<isprime.size();++j) isprime[i*j] = false;
		}
	}
	vector<int> s(N+1,0);
	for(int i=0;i<N;++i) s[i+1]+=s[i]+((isprime[i+1])?1:0);
	int n;
	while(cin>>n,n){
		int ans=0;
		for(int i=0,p,m,x=0;i<n;++i){
			cin>>p>>m;
			x=s[(p+m>N)?N:p+m]-s[(p-m<0)?0:p-m]+isprime[(p-m<0)?0:p-m];
			ans+=x-1;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

template<typename W>
using Edge = pair<int, W>;

template<typename W>
using WeightedGraph = vector<vector<Edge<W>>>;

// 時間計算量 O( (E+V) log V )
template <typename W>
vector<W> dijkstra(int s, WeightedGraph<W> &G){  
    // s : 始点, G : 隣接リスト G[v1][v2] : (頂点, 重み)
    const W INF = numeric_limits<W>::max();
    // P.first : 距離, P.second : 頂点番号
    using P = pair<W, int>;
    // n : |V|
    int n = G.size();
    // d[i] : 始点からiまでの最短距離
    vector<W> d(n,INF);
    vector<int> b(n,-1);
    priority_queue<P,vector<P>,greater<P> > q;
    d[s] = 0;
    q.emplace(d[s],s);
    while(!q.empty()){
        P p = q.top();q.pop();
        int v = p.second;
        if( d[v]<p.first ) continue;
        for( auto&& e : G[v] ){
            int u = e.first;
            W c = e.second;
            if(d[u] > d[v]+c){
                d[u] = d[v]+c;
                b[u] = v;
                q.emplace(d[u],u);
            }
        }
    }
    return d;
}
//END CUT HERE

int main(){
    int V,E,r;
    int s,t,d;
    cin >> V >> E >> r;
    WeightedGraph<int> G(V);
    for(int i = 0; i < E; i++) {
        cin >> s >> t >> d;
        G[s].emplace_back(t, d);
    }
    auto D = dijkstra(r, G);
    for(int i = 0; i < V; i++) {
        if (D[i] == numeric_limits<int>::max()) {
            cout << "INF" << endl;
        }
        else {
            cout << D[i] << endl;
        }
    }
}


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

using namespace std;

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

  int n;
  cin >> n;
  if (n == 1) {
    cout << "Hello World\n";
  } else {
    int a,b;
    cin >> a >> b;
    cout << a + b << "\n";
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int M = scanner.nextInt();
        long K = scanner.nextLong();
        long[] A = new long[N + 1];
        long[] B = new long[M + 1];

        long[] sumA = new long[N + 1];
        long[] sumB = new long[M + 1];

        for (int i = 1 ; i <= N ; i++) {
            A[i] = scanner.nextLong();
            sumA[i] = sumA[i - 1] + A[i];
        }

        for (int i = 1 ; i <= M ; i++) {
            B[i] = scanner.nextLong();
            sumB[i] = sumB[i - 1] + B[i];
        }

        long maxCont = 0;
        int j = M;
        for (int i = 0 ; i <= N ; i++) {
            if (sumA[i] > K) {
                break;
            }
            while (sumB[j] > K - sumA[i]) {
                j--;
            }
            maxCont = Math.max(maxCont, i + j);
        }

        System.out.println(maxCont);

    }

}


Measured memory_bytes: 67212
main = do
  (x:y:_) <- return . (map read) . words =<< getLine
  putStrLn $ yesno (f x == f y)

  where
    f n = filter (elem n)  [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
    yesno True = "Yes"
    yesno False = "No"


Measured memory_bytes: 508
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    // input from txt （提出時にこの箇所は削除すること）
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////

    vector<int> colors(3);
    int result = 0;
    for (int i=0; i<3; i++) {
        cin >> colors[i];
    }
    if (colors[0] != colors[1]) result++;
    if (colors[0] != colors[2]) result++;
    if (colors[1] != colors[2]) result++;
    if (result == 0) result++;

    cout << result;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int N;
    cin >> N;
    int hun = int(N/100);
    int ten = int((N%100)/10);
    int one = int(N%10);
    if (hun == 7 || ten ==7 || one ==7 ) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
  stack<int> stk;
  int x;
  while(cin>>x){
    if(x) stk.push(x);
    else{
      cout<<stk.top()<<endl;
      stk.pop();
    }
  }
  return 0;
}

Measured memory_bytes: 3008
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BExchange solver = new BExchange();
        solver.solve(1, in, out);
        out.close();
    }

    static class BExchange {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int k = in.nextInt();
            for (int i = 0; i < k; i++) {
                if (i % 2 == 0) {
                    //t -> a
                    b += a / 2;
                    a /= 2;
                } else {
                    a += b / 2;
                    b /= 2;
                }
            }
            out.println(a + " " + b);
        }

    }
}



Measured memory_bytes: 21204
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		Console.WriteLine(N * N * N);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


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

using namespace std;

namespace mod {

template <class T, int M>
class MInt;

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp);

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n);

template <class T, int M>
class MInt {
  T n_;

 public:
  MInt() : n_(0) {}
  MInt(T n) : n_((n % M + M) % M) {}

  MInt &operator+=(const MInt &rhs) {
    n_ += rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator-=(const MInt &rhs) {
    n_ += M - rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator*=(const MInt &rhs) {
    n_ = n_ * rhs.n_ % M;
    return *this;
  }

  MInt &operator/=(const MInt &rhs) { return (*this) *= Inv(rhs); }

  T Get() { return n_; }
};

template <class T, int M>
MInt<T, M> operator-(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res -= rhs;
}

template <class T, int M>
MInt<T, M> operator+(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res += rhs;
}

template <class T, int M>
MInt<T, M> operator*(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res *= rhs;
}

template <class T, int M>
MInt<T, M> operator/(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res /= rhs;
}

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp) {
  if (exp == 0) {
    return 1;
  }

  auto a = Pow(base, exp / 2);
  a *= a;
  if (exp % 2 == 1) {
    a *= base;
  }

  return a;
}

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n) {
  return Pow(n, static_cast<T>(M - 2));
}
}  // namespace mod

const int md = 1e9 + 7;
using MInt = mod::MInt<long long, md>;
class BinCoef {
  vector<MInt> f;

 public:
  BinCoef(int n) : f(n + 1) {
    f[0] = f[1] = 1;
    for (int i = 2; i <= n; i++) {
      f[i] = MInt(i) * f[i - 1];
    }
  }

  MInt NCM(int n, int m) {
    if (n < m) {
      return 0;
    }
    return f[n] * mod::Inv(f[m] * f[n - m]);
  }

  MInt HCM(int n, int m) { return NCM(n + m - 1, m); }
};

template <typename T, typename = typename std::enable_if<
                          std::is_integral<T>::value, T>::type>
vector<pair<T, int>> prime_factorize(T n) {
  vector<pair<T, int>> cnts{};
  if (n == 1) {
    return cnts;
  }

  T a = 2;
  while (n >= a * a) {
    int cnt = 0;
    while (n % a == 0) {
      n /= a;
      cnt++;
    }

    if (cnt > 0) {
      cnts.push_back({a, cnt});
    }

    a++;
  }

  if (n != 1) {
    cnts.push_back({n, 1});
  }

  return cnts;
}

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;
  auto factors = prime_factorize(m);

  BinCoef bc(n + 40);
  MInt ans = 1;
  for (auto &factor : factors) {
    ans *= bc.HCM(n, factor.second);
  }

  cout << ans.Get() << '\n';
}

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

#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define all(vec) (vec).begin(),(vec).end()
#define sort(vec) std::sort(all(vec))
#define rev(vec) std::reverse(all(vec))

void input(){return;}
template<typename First,typename... Rest> void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}

void inputVector(){return;}
template<typename First,typename... Rest> void inputVector(std::vector<First> &first,Rest&... rest){
    int N = first.size();
    for(int i = 0;i < N;i++){
        std::cin >> first[i];
    }
    inputVector(rest...);
}

template<typename First,typename Second> void inputTwoVector(std::vector<First> &first,std::vector<Second>& second){
    int N = first.size();
    for(int i = 0;i < N;i++){
        std::cin >> first[i] >> second[i];
    }
}


void calculate(){
    int N,A,B;
    int res = 0;
    input(N,A,B);
    for(int i = 1;i <= N;++i){
        int now = 0;
        int j = i;
        while(j != 0){
            now += j % 10;
            j /= 10;
        }
        if(A <= now and now <= B) res += i;
    }    
    std::cout << res << '\n';
}

int main(int,char**){
    calculate();    
}




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

int main(){
    ll A,B,V,W,T; cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    long double d = abs(A-B); long double v = abs(V-W);
    if(d/v <= T && V-W >= 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3640
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
// #pragma comment(linker, "/stack:200000000"]
 
#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 2e5 + 20;
#endif

//tg: @galebickosikasa
 
const ll inf = (ll) 2e9;
const ld pi = asin (1) * 2;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

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



signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin >> n;
	int s = 0;
	fl (i, 1, n + 1) {
		fl (j, 1, n + 1) {
			fl (k, 1, n + 1) {
				s += __gcd (i, __gcd (j, k));
			}
		}
	}
	cout << s;






}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin >> a >> b;
	if (a>=13) cout<<b<<"\n";
	else if (a>=6) cout<<b/2<<"\n";
	else cout << 0 << "\n"; 
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
ar = []
count = 0
for i in range(n-1):
  
  if h[i] >= h[i+1]:
    count += 1
    ar.append(count)
  else:
    
    count = 0
if ar == []:
  print(0)
else:
  print(max(ar))

Measured memory_bytes: 20488