akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define vci vector<ll>
#define vcs vector<string>
#define vcp vector<pair<ll, ll>>
#define vct vector<tuple<ll, ll, ll>>
using namespace std;
//vector<vector<ll>> vv(n, vector<ll>(n));

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	ll n;
	cin >> n;
	cout << "ABC" << n << endl;
}


Measured memory_bytes: 256
use scanner::Scanner;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let k: usize = sc.read();
    let x: usize = sc.read();
    let y: usize = sc.read();

    println!("{}", if n <= k { n * x } else { (k * x + (n - k) * y) });
}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}

Measured memory_bytes: 4352
def main
  x = gets.to_i

  result = logic(x)

  puts("#{result}")
end

def logic(x)
  a = x.div(11) * 2
  b = x.modulo(11)
  c = b.zero? ? 0 : b < 7 ? 1 : 2
  a + c
end

main


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

int mod; 

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

const int MaxN = 1e4 + 5; 

int n, res; 
int f[MaxN]; 

int main()
{
	std::cin >> n >> mod; 
	if (n == 1)
		return puts("1"), 0; 
	else if (n == 2)
		return puts("3"), 0; 

	f[0] = 1; 
	for (int i = 2; i <= n; ++i)
	{
		int c = i <= (n >> 1) + 1 ? i - 1 : n - i + 2; 
		for (int j = c; j <= n; ++j)
			add(f[j], f[j - c]); 
	}
	for (int i = 0; i < n; ++i)
		add(res, 1LL * (n - i) * f[i] % mod); 

	std::cout << res << '\n'; 

	return 0; 
}


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

int main(){
  long int N, A, B, ans = 0;
  cin >> N >> A >> B ;
  ans += (N / (A + B)) * A ;
  if(N % (A + B) < A){
      ans += N % (A + B) ;
  }
  else ans += A ;
  cout << ans << endl ;
  return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000

int main(){

	int N,M;
	cin>>N>>M;
	
	vector<vector<pair<int,int>>> Q(N+1,vector<pair<int,int>>());
	
	for(int i=0;i<M;i++){
		int l,r,x;
		cin>>l>>r>>x;
		Q[r].emplace_back(l,x);
	}
	
	vector<vector<vector<int>>> dp(N+1,vector<vector<int>>(N+1,vector<int>(N+1,0)));
	dp[0][0][0] = 1;
	
	for(int i=0;i<=N;i++){
		for(int j=0;j<Q[i].size();j++){
			for(int x=0;x<=N;x++){
				for(int y=0;y<=N;y++){
					int t = 1;
					if(x>=Q[i][j].first)t++;
					if(y>=Q[i][j].first)t++;
					if(t!=Q[i][j].second){
						dp[i][x][y]=0;
					}
				}
			}
		}
		if(i==N)break;
		for(int j=0;j<=N;j++){
			for(int k=0;k<=N;k++){
				if(dp[i][j][k]==0)continue;
				int t = dp[i][j][k];
				dp[i+1][j][k] = mod(dp[i+1][j][k]+t);
				dp[i+1][k][i] = mod(dp[i+1][k][i]+t);
				dp[i+1][i][j] = mod(dp[i+1][i][j]+t);
			}
		}
	}
	
	int ans =  0;
	for(int j=0;j<=N;j++){
		for(int k=0;k<=N;k++){
			ans = mod(ans + dp.back()[j][k]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(void){
    int i,sx,sy,tx,ty,x,y;
    cin >> sx;
    cin >> sy;
    cin >> tx;
    cin >> ty;
    x=tx-sx;
    y=ty-sy;
    for(i=0;i<y;i++){
        cout << "U";
    }
    for(i=0;i<x;i++){
        cout << "R";
    }
    for(i=0;i<y;i++){
        cout << "D";
    }
    for(i=0;i<x+1;i++){
        cout << "L";
    }
    for(i=0;i<y+1;i++){
        cout << "U";
    }
    for(i=0;i<x+1;i++){
        cout << "R";
    }
    cout << "DR";
    for(i=0;i<y+1;i++){
        cout << "D";
    }
    for(i=0;i<x+1;i++){
        cout << "L";
    }
    cout << "U";
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str1, str2, str3;
  int total, ia, ib, imax;  
  cin >> total >> ia >> ib;

  int i = (ia + ib) - total;
  if(i < 0)
  {
      i = 0;
  }
    
  imax = ia - ib;

  if(imax < 0){imax = ia;}
  else{imax = ib;}

  cout << imax << " " << i << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  cin>>a>>b>>c;
  int res=a*b*c;
  chmin(res,a*b);
  chmin(res,b*c);
  chmin(res,a*c);
  cout<<res/2<<endl;

  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long tmp = 0;	
		for(int i = 0; i<N ; i++) {
			tmp=tmp+i;
		}
      	System.out.println(tmp);
	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 101010
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define out(s) cout<<s
#define outs(s,a) cout<<s<<a
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
void solve(){
	ll a,b,c,k;
	in2(a,b);
	in2(c,k);
	if(k<=a){
		cout<<k<<"\n";
		return;
	}else if(k<=a+b){
		cout<<a<<"\n";
	}else{
		ll diff=k-(a+b);
		cout<<a-diff<<'\n';
	}
}	
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	clock_t t1=clock();
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
	clock_t t2=clock();
	cerr<<"Time elapsed:- "<<(double)(t2-t1)/CLOCKS_PER_SEC<<'\n';
}	

Measured memory_bytes: 3792
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int N;
vector<int> G[222];
int match[222];
bool used[222];
bool dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    int u=G[v][i], w=match[u];
    if(w<0||(!used[w]&&dfs(w))){/////////
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}
int solve(){
  int res = 0;
  memset(match,-1,sizeof(match));
  for(int v=0;v<2*N;v++){
    if(match[v]<0){
      memset(used,0,sizeof(used));
      if(dfs(v))res++;
    }
  }
  return res;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>N;
  int a[N],b[N],c[N],d[N];
  FOR(i,0,N)cin>>a[i]>>b[i];
  FOR(i,0,N)cin>>c[i]>>d[i];
  FOR(i,0,N){
    FOR(j,0,N){
      if(a[i]<c[j]&&b[i]<d[j]){
        G[i].push_back(j+100);
        G[j+100].push_back(i);
      }
    }
  }
  cout<<solve()<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n;
  cin>>n;
  int a[n],b[n];
  rep(i,n){
    cin>>a[i];
    b[i]=a[i];
  }
  sort(b,b+n);
  int maxi=b[n-1],semi=b[n-2];
  if(maxi==semi){
    rep(i,n){
      cout<<maxi<<"\n";
    }
  }else{
    rep(i,n){
      if(a[i]==maxi){
        cout<<semi<<"\n";
      }else{
        cout<<maxi<<"\n";
      }
    }
  }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for(int i = 1; i <= n; ++ i)

using namespace std;
const int N = 1005;
char s[N];

int main()
{
	int k;
	scanf("%s", s + 1);
	scanf("%d", &k);
	if(k == 1) { printf("%s", s + 1); return 0; }
	int len = strlen(s + 1);
	REP(i, len) if(i % k == 1) printf("%c", s[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc123/tasks/abc123_d
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll X,Y,Z,K; cin>>X>>Y>>Z>>K;
    vector<ll> ax(X);
    vector<ll> by(Y);
    vector<ll> cz(Z);
    for(auto&& a:ax){ cin>>a; }
    for(auto&& b:by){ cin>>b; }
    for(auto&& c:cz){ cin>>c; }
#if 1
    using SumABC=tuple<ll,ll,ll,ll>; //sum,a_id,b_id,c_id
    priority_queue<SumABC> que;
    sort(ax.begin(),ax.end(),greater<ll>());
    sort(by.begin(),by.end(),greater<ll>());
    sort(cz.begin(),cz.end(),greater<ll>());

    set<tuple<ll,ll,ll>> se;
    auto que_pb = [&](ll ix,ll iy, ll iz){
        if(ix<ax.size()&&iy<by.size()&&iz<cz.size()){
            tuple<ll,ll,ll> s = make_tuple(ix,iy,iz);
            if (se.count(s)) return;
            auto tmp=ax[ix]+by[iy]+cz[iz];
            que.emplace(make_tuple(tmp,ix,iy,iz));
            se.emplace(s);
        }
    };

    //que.emplace(make_tuple(ax[0]+by[0]+cz[0],0,0,0));
    que_pb(0,0,0);
    REP(k,K){
        ll sum,x,y,z;
        tie(sum,x,y,z)=que.top();
        que.pop();
        cout<<sum<<endl;
        que_pb(x+1,y,z);
        que_pb(x,y+1,z);
        que_pb(x,y,z+1);
    }
#else
    //半分列挙
    vector<ll> abw(X*Y);
    REP(x,X){
        REP(y,Y){
            abw.at(y*X+x) = ax.at(x) + by.at(y);
        }
    }
    sort(abw.begin(),abw.end(),greater<ll>());
    sort(cz.begin(),cz.end(),greater<ll>());

    vector<ll> tt;
    tt.reserve(K*K);
    REP(i,min<ll>(K,abw.size())){
        REP(j,min<ll>(K,cz.size())){
            tt.emplace_back(abw.at(i)+cz.at(j));
        }
    }

    sort(tt.begin(),tt.end(),greater<ll>());
    REP(i,K){
        cout<<tt.at(i)<<endl;
    }
#endif
    return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

ll L, R;
ll dp[61][2][2][2];

int main(){
    cin >> L >> R;

    dp[60][0][0][0] = 1;

    for(int i = 59; i >= 0; --i){
        int r = R >> i & 1;
        int l = L >> i & 1;

        rep(j, 2)rep(k, 2)rep(s, 2){

            rep(x, 2)rep(y, 2){

                if(!y && x) continue;

                int nj, nk, ns;
                nj = j, nk = k, ns = s;

                // s:既に最上位ビットを通過したか
                if(!s && y && !x) continue;
                if(x && y) ns = 1;

                // j:L <= x を既に満たしているか
                if(!j && l && !x) continue;
                if(!l && x) nj = 1;

                // k:y <= R を既に満たしているか
                if(!k && !r && y) continue;
                if(r && !y) nk = 1;

                dp[i][nj][nk][ns] += dp[i + 1][j][k][s];
                dp[i][nj][nk][ns] %= MOD;
            }

        }

    }

    ll ans = 0;
    rep(j, 2)rep(k, 2)rep(s, 2){
        ans += dp[0][j][k][s];
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}

int main(){
  int N;
  cin >> N;
  vector<string> s(N);
  rep(i,N) cin >> s.at(i);
  map<string,int> ss;
  rep(i,N) {
    ss[s.at(i)]++;
  }
  int max = -1;
  for(auto p : ss){
    chmax(max,p.second);
  }

  for(auto p : ss){
    if(p.second == max){
      cout << p.first << endl;
    }
  }
  
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main() {
  /*  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(c,b/a);    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
using namespace std;

int n, k;
int a[100];
int dp[100001];

int dfs(int k) {
	if (k == 0) return 0;
	if (k < 0) return 1;
	if (dp[k] != -1) return dp[k];
	
	int i;
	for (i = 0; i < n; i++) {
		if (dfs(k - a[i]) == 0) {
			break;
		}
	}
	//cout << "dfs(" << k << ") = " << (i < n) << endl;
	return dp[k] = (i < n);
}

signed main() {
	int i, j;
	
	cin >> n >> k;
	for (i = 0; i < n; i++) cin >> a[i];
	for (i = 0; i <= k; i++) dp[i] = -1;
	
	if (dfs(k)) cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 3712
import math
a, b, h, m = map(int, input().split()) #a:短針、b:長針、h時m分

rad_a = (360 / 12) * h + (360 / 12) * (m / 60)
rad_b = (360 / 60) * m
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(abs(rad_a-rad_b)))))

Measured memory_bytes: 9504
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import deque
import pprint

inf = 10**18
mod = 10**9+7

x,n = map(int, input().split())
if n == 0:
    print(x)
    sys,exit()
p = list(map(int, input().split()))
p.sort()
ind = bisect.bisect_left(p,x)
if ind == n:
    print(x)
elif ind == 0:
    if p[ind] != x:
        print(x)
    else:
        print(x-1)
else:
    if p[ind] != x:
        print(x)
    else:
        maxans = 0
        minans = inf
        pre = x
        k = ind
        while k != n and pre == p[k]:
            k+=1
            pre+=1
        maxans = p[k-1]+1
        pre = x
        k = ind
        while k != -1 and pre == p[k]:
            k-=1
            pre-=1
        minans = p[k+1]-1
        ans = 0
        if abs(x-maxans) < abs(x-minans):
            ans = maxans
        else:
            ans = minans
        print(ans)

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

#define ll long long int

using namespace std;

int main(){

    int n;

    cin >> n; int x;

    if(599>=n){
        x=8;
    }else if(799>=n)x=7;
    else if(999>=n)x=6;
    else if(1199>=n)x=5;
    else if(1399>=n)x=4;
    else if(1599>=n)x=3;
    else if(1799>=n)x=2;
    else if(1999>=n)x=1;
    printf("%d\n",x);


    
    return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());

  double center = (double)A.back() / 2;
  int bestIndex = 0;
  for (int i = 0; i < N; i++) {
    if (abs(center - A[bestIndex]) > abs(center - A[i])) {
      bestIndex = i;
    }
  }

  printf("%d %d\n", A.back(), A[bestIndex]);

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  int n;
  while(cin >> n){
	int flag = 1;
	for(int i = 0;i < 10;i++){	  
	  if((n & (1<<i)) && flag){
		flag = 0;
		cout << (1<<i);
	  }else if((n & (1<<i)) && !flag){
		cout << " " << (1<<i);
	  }


	}
	cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))

N = int(input())
A = inpl()
B = inpl()

C = 0
D = 0

for a, b in zip(A, B):
    if b - a > 0:
        C += (b-a) - ((b-a)%2)
    else:
        D += (a-b)

if C >= 2*D:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4600
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	ios::sync_with_stdio(false);
	
	const int R = int(1e9);
	
	int N = 0;
	cin >> N;
	int minv, maxv = -R;
	cin >> minv;
	for (int j = 1; j < N; ++j) {
		int v;
		cin >> v;
		maxv = max(maxv, v - minv);
		minv = min(minv, v);
	}
	cout << maxv << endl;
	return 0;	
}

Measured memory_bytes: 3152
def inpl(): return [int(i) for i in input().split()]

N,M = inpl()
H = {0: 1}
k = 0
ans = 0
for i in inpl():
    k += i
    t = k % M
    if t not in H:
        H[t] = 0
    H[t] += 1
    
for i in H.values():
   ans += i * (i - 1) // 2

print(ans)

Measured memory_bytes: 14424
#include<iostream>
#include<string>
#include <bits/stdc++.h>
#include<vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <math.h>
#include <iomanip>
using namespace std;
using ll = long long;

int main(){
  string s;
  cin >> s;
  if(s == "SSS"){
    cout << 0 << endl;
  }else if(s == "RRR"){
    cout << 3 << endl;
  }else if(s=="RRS" || s=="SRR"){
    cout << 2 << endl;
  }else{
    cout << 1 << endl;
  }
  return 0;
}


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

using namespace std;

#define mod 998244353
#define ll long long

ll power(ll a, ll b){
	ll ret = 1;
	while(b){
		if(b%2 == 1) ret = (ret*a)%mod;
		a = (a*a)%mod;
		b = b/2;
	}
	return ret;
}

ll modInv(ll a){
	return power(a, mod - 2);
}

int
main(void){
	ll n, m, k;
	cin >> n >> m >> k;
	if(m == 1){
		if(k >= n - 1) cout << 1;
		else cout << 0;
		return 0;
	}
	ll ans = 0;
	ll cur = m;
	for(int i = 1; i < n; i++){
		cur = cur *(m - 1);
		cur %= mod;
	}
	//cout << cur << endl;
	ans += cur;
	for(int i = 1; i <= k; i++){
		//cur = cur/(m - 1);
		cur = cur * modInv(m - 1); cur %= mod;
		//cur = cur*m; cur %= mod;
		//cur= cur*m;
		cur = cur * (n - i); cur %= mod;
		cur = cur * modInv(i);
		cur %= mod;
		ans += cur;
		ans %= mod;
	}
	cout << ans;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; i++) {
        if (i % d == 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int x = 1;
  int y = 1;
  
  for (int i = 0; i < N; i++){
    y *= 2;
    if (x + K <= y){
      x += K;
    }else{
      x *= 2;
    }
  }
  
 cout << x << endl;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (a, b, c, d) = Read4Longs();
            return (Math.Abs(a - c) <= d || (Math.Abs(a - b) <= d && Math.Abs(b - c) <= d)) ? "Yes" : "No";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28144
use std::cmp;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let s = sc.chars();
    let n = s.len();
    let mut min = n;
    for i in 1..n {
        if s[i - 1] != s[i] {
            let t = cmp::max(i, n - i);
            min = cmp::min(min, t);
        }
    }
    println!("{}", min);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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


int main(){
    int N,T;cin>>N>>T;
    int a[1000000];
    rep(i,0,T)cin>>a[i];
    sort(a,a+T,greater<>());
    if((N+1)/2>=a[0])cout<<0<<endl;
    else{
        if(N%2==1)cout<<a[0]-(N-(N+1)/2)*2<<endl;
        else cout<<2*(a[0]-(N/2))-1<<endl;
    } 
}







Measured memory_bytes: 256
def main():
  N, K, C=map(int, input().split())
  S = input()

  R=[0]*K
  n, k=N-1, 0
  while k < K:
    if S[n]=='o':
      R[k]=n+1
      k+=1
      n -= C
    n-=1
  R=R[::-1]
  
  n, k=0, 0
  while k < K:
    if S[n]=='o':
      if n+1 == R[k]:
        print(n+1)
      k+=1
      n += C
    n+=1
  #print(L)
  

  
if __name__=='__main__':
  main()


Measured memory_bytes: 18280
import sys
from collections import deque
s = input()

queue = deque()
queue.append(0)
candidates = ['dream', 'dreamer', 'erase', 'eraser']

index = 0
while queue:
    index = queue.popleft()
    match = False
    for candidate in candidates:
        if s[index:index + len(candidate)] == candidate:
            match = True
            if index + len(candidate) == len(s):
                print('YES')
                sys.exit(0)
            queue.append(index + len(candidate))
print('NO')


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

using namespace std;

typedef long long ll;

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

	int M, K;
	cin >> M >> K;

	if(K >= (1 << M)){
		cout << -1 << endl;
		return 0;
	}

	if(M == 1){
		if(K == 0){
			cout << "0 0 1 1" << endl;
		}else{
			cout << -1 << endl;
		}
	}else{
		for(int i = 0; i < (1 << M); i++){
			if(i == K) continue;
			cout << i << " ";
		}

		cout << K << " ";

		for(int i = (1 << M) - 1; i >= 0; i--){
			if(i == K) continue;
			cout << i << " ";
		}

		cout << K << " ";
	}

	cout << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringJoiner;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    int N = S.length();
    String[] split = S.split("");
    //文字置き換え
    for (int i = 0; i < N ; i++) {
      split[i] = "x";
    }
    //文字列に直す
    StringJoiner T = new StringJoiner("");
    for (String s : split) {
      T.add(s);
    }
    System.out.println(T.toString());      
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int n,tl,yl,xl,ti,xi,yi;
bool check(int t,int x,int y){
	if (x<0) x=-x;if (y<0) y=-y;
	if (x+y>t) return 0;
	if ((t-(x+y))%2!=0) return 0;
	return 1;
}
int main() {
	cin>>n;bool p,tag=1;
	for (int i=1;i<=n;i++){
		cin>>ti>>xi>>yi;
		int tt=ti-tl,xx=xi-xl,yy=yi-yl;
		p=check(tt,xx,yy);if (!p) tag=0;;
	}
	if (tag) cout<<"Yes";else cout<<"No";
	return 0;
}

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

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

    if (A > 9 || B > 9)
    {
        cout << "-1" << endl;
    }
    else
    {
        cout << A * B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b = rm()
print((a*3 + b)//2)
















Measured memory_bytes: 27064
#include <stdio.h>

int main() {
    long long int n, max, sum;
    scanf("%lld",&n);
    long long int A[200001];
    for (int i=0;i<n;i++) {
        scanf("%lld",A+i);
    }
    max = 1;
    sum = 0;
    for (int i=0;i<n;i++) {
        if (A[i] > max) max = A[i];
        sum += (max - A[i]);
    }
    printf("%lld\n",sum);
    return 0;
}

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

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

    string S;
    int K;
    cin >> S >> K;

    long long cnt = 0;
    if (count(S.begin(), S.end(), S[0]) == S.length())
        cnt = (1ll * S.length() * K) / 2;
    else {
        int i = 0, j = S.length() - 1;
        if (S[0] == S[S.length() - 1]) {
            for (; i < S.length() && S[i] == S[0]; i++);
            for (; j > i && S[j] == S[0]; j--);
            cnt += i / 2 + (S.length() - 1 - j) / 2 + 1ll * (i + (S.length() - 1 - j)) / 2 * (K - 1);
        }

        for (i++, j++; i < j; i++) {
            if (S[i] == S[i - 1]) {
                S[i] = '-';
                cnt += K;
            }
        }
    }
    cout << cnt << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

char str[500005];

int main(int argc, char* argv[])
{
    scanf("%s", str);

    int n=strlen(str)+1;
    int i;
    vector<int> a(n), b(n);
    for(i=0; i<n-1; i++) {
        if(str[i]=='<') {
            a[i+1]=a[i]+1;
        }
        else {
            a[i+1]=0;
        }
    }
    for(i=n-2; i>=0; i--) {
        if(str[i]=='>') {
            b[i]=b[i+1]+1;
        }
        else {
            b[i]=0;
        }
    }

    ll sum=0;
    for(i=0; i<n; i++) {
        sum += MAX(a[i],b[i]);
    }
    printf("%lld\n", sum);



    return 0;
}



Measured memory_bytes: 4608
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[100010], A_[100010];
    rep(i, N) {
        cin >> A[i];
        A_[A[i]] = i + 1;
    }
    rep(i, N) {
        if (i != 0) cout << " ";
        cout << A_[i + 1];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <cmath>
#include <map>
#include <string>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define pb push_back
#define mp make_pair
#define F first
#define S second

int main()
{
    ll ans = 0;

    ll n;
    cin >> n;

    rep (i, n + 1) {
        if (i == 0) continue;

        int i2 = i;
        int digit = 0;
        while (i2 != 0) {
            i2 /= 10;
            digit++;
        }

        if (digit % 2 == 1) ans++;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
from collections import deque


def solve():
    H, W = map(int, input().split())
    CH, CW = map(int, input().split())
    DH, DW = map(int, input().split())
    S = ["##"+input()+"##" for _ in range(H)]
    for i in range(2):
        S.insert(0, "#"*(W+4))
        S.append("#"*(W+4))

    inf = int(1e9)
    cost = [[inf for _ in range(W+4)] for _ in range(H+4)]
    cost0 = deque()
    ans = -1

    cost0.append((CH+1, CW+1, 0))
    cost[CH+1][CW+1] = 0

    move = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)]+move]

    cost1 = deque()

    while cost0:
        h, w, c = cost0.popleft()
        cost1.append((h, w, c))

        for i, j in move:
            dh = h+i
            dw = w+j
            if S[dh][dw] == "." and c < cost[dh][dw]:
                cost[dh][dw] = c
                cost0.appendleft((dh, dw, cost[dh][dw]))

        if len(cost0) == 0:
            while cost1:
                h, w, c = cost1.popleft()
                for i, j in warp:
                    dh = h+i
                    dw = w+j
                    if S[dh][dw] == "." and c+1 < cost[dh][dw]:
                        cost[dh][dw] = c+1
                        cost0.append((dh, dw, cost[dh][dw]))

        if cost[DH+1][DW+1] != inf:
            ans = cost[DH+1][DW+1]

    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 24588
def solve(c, a):
    dp = [0]*(c+1)
    for w, p in a:
        for i in range(c, -1, -1):
            if dp[i] > 0 and i+w < c+1:
                dp[i+w] = max(dp[i+w], dp[i] + p)
        if w < c+1:
            dp[w] = max(dp[w], p)
    return max(dp)
  
n, k = map(int, input().split())
a = []
for _ in range(n):
    a.append(list(map(int, input().split())))
print(solve(k, a))

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

using namespace std;

int n,d,x;
int sum=0;
int a[110];
int main()
{
    cin>>n>>d>>x;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];

    }
    for(int i=0;i<n;i++)
    {
        sum++;
        int m=1;
        int b=a[i];
        while((m*b+1)<=d)
        {
            m++;
            sum++;
        }
    }
    cout<<(sum+x);

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, 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_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn ok(aa: &Vec<u64>) -> bool {
    let n = aa.len() as u64;
    let mut ok = true;
    for &a in aa.iter() {
        if a >= n {
            ok = false;
        }
    }
    ok
}

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: u64,
      mut aa: [u64; n],
    }

    let mut ans = 0;
    while !ok(&aa) {
        let s: u64 = aa.iter().map(|v| v/n).sum();
        for i in 0..n as usize {
            let temp = aa[i]/n;
            ans += temp;
            aa[i] -= temp * n;
            aa[i] += s - temp;
        }
    }
    puts!("{}\n", ans);
}


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

int main() {
	int q;
	string s;
	cin >> q;
	for(int i = 0; i < q; ++i){
		cin >> s;
		sort(s.begin(), s.end());
		int minum = stoi(s);
		sort(s.begin(), s.end(), greater<char>());
		int maxum = stoi(s);
		cout << maxum - minum << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__



void solve(void){
  
  int N;
  cin >> N;
  
  vector<int> P(N);
  vector<int> Q(N);
  
  REP(i,N){
    cin >> P[i];
    Q[i]=i+1;
  }
  
  int count=0;
  
  REP(i,N){
    if(P[i]!=Q[i]){
      count++;
    }
  }
  if(count==0){count=2;}
  
  puts(count==2?"YES":"NO");
  
  return;
   
}

#define TESTCASES 1

int main(int argc, const char * argv[]) {


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

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}


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

int main(){
  int c[9];
  int sum = 0;
  rep(i,9) {
    cin >>c[i];
    sum += c[i];
  }
  int jud = 3*(c[0]+c[4]+c[8]);
  if(sum==jud) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0; 
}

Measured memory_bytes: 3632
import java.io.*;
import java.util.*;
class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	static List<Long> list=new ArrayList<Long>();
	
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt();long a1=sc.nextLong(),b1=sc.nextLong();long[] a=new long[n];
		for(int i=0;i<n;i++)
		{
			a[i]=sc.nextLong();
		}
		for(int i=1;i<n;i++)
		{
			list.add((a[i]-a[i-1])*a1);
		}
		long ans=0;
		for(int i=0;i<list.size();i++)
		{
			ans+=Math.min(list.get(i),b1);
		}
		out.println(ans);out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 30668
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    Int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}



Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;

namespace C
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            var l = Cint();
            
            Cout(Math.Pow((double) l / 3, 3));
        }

        #region Input and Output

        private static readonly List<string> Buffer = new List<string>();

        private static string Cin()
        {
            ReadBuffer();

            var str = Buffer.First();
            Buffer.RemoveAt(0);

            return str;
        }

        private static IEnumerable<string> CinA() => Console.ReadLine()?.Split();
        private static int Cint() => int.Parse(Cin());
        private static int[] CintA() => CinA().Select(int.Parse).ToArray();
        private static void Cout(object obj) => Console.WriteLine(obj);

        private static void ReadBuffer()
        {
            if (Buffer.Any()) return;

            var line = Console.ReadLine();
            if (line != null && line.Contains(' '))
            {
                Buffer.AddRange(line.Split());
            }
            else
            {
                Buffer.Add(line);
            }
        }

        #endregion

        #region Loops

        private static void Loop(int count, Action<int> action) => Loop(0, count, action);

        private static void Loop(int init, int count, Action<int> action, int step = 1)
        {
            for (var i = init; i < count + init; i += step)
            {
                action(i);
            }
        }

        #endregion
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi s(n);
    rep(i, n) cin >> s[i]; 
    sort(s.begin(), s.end());
    int ans = accumulate(s.begin(), s.end(), 0);
    if (ans%10 != 0) {
        cout << ans << endl;
    } else {
        rep(i, n) {
            if ((ans - s[i])%10 != 0) {
                cout << ans-s[i] << endl;
                return 0;
            }
        }
        cout << 0 << endl;
    }
}

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

using namespace std;
#define N 100100
#define SIGMA 26

long double L, l;
int main()
{
    ios::sync_with_stdio();
    cin.tie(0);
    cin >> L;
    l = L / 3.0;
    cout << fixed << setprecision(6) << l * l * l;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int n;
	cin >> n;
	int a[n];
	long long int ans = 0;

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

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

		if (a[i] < a[i - 1]) {

			ans += a[i - 1] - a[i];
			a[i] += a[i - 1] - a[i];
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <string.h>
#include<cstdlib>
using namespace std;
struct Node
{
	int key;//??°?????¬????????´??°key
	Node *next, *prev;//???????????????????´??????????next?????????????????????????´???????prev
};
Node *nil;//??´??????
Node* listSearch(int key)
{
	Node *cur = nil->next;//?????´???????????¢???????´?????§???????
	while (cur != nil&&cur->key != key)
	{
		cur=cur->next;
	}
	return cur;//?????????????????????????????????
}
void init()
{
	//malloc???C????¨?????????????????????°?????¨?????¨?????????????????§?°???????????????´???sizeof???Node????????????Node?±???????????????´?????§?°?
	nil = (Node*)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}
void printList()
{
	Node *cur = nil->next;
	int isf = 0;
	while (1)
	{
		if (cur == nil) break;
		if (isf++ > 0)
			cout << " ";
		cout << cur->key;//?????°????????????
		cur = cur->next;//?????????????????????
	}
	cout << endl;
}
void deleteNode(Node *t)
{
	if (t == nil) return;//???t?????´????????¶????????????
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}
void deleteFirst()
{
	deleteNode(nil->next);
}
void deleteLast()
{
	deleteNode(nil->prev);
}
void deleteKey(int key)
{
	deleteNode(listSearch(key));//??????????´¢??°?????????
}
void insert(int key)
{
	Node *x = (Node*)malloc(sizeof(Node));
	x->key = key;
	//??¨??´???????????????????´?
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}
int main()
{
	int key, n;//n???????????°
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	cin >> n;
	init();
	for (int i = 0; i < n; i++)//????????????????°±???????¬???????
	{
		cin >> com;
		if (com[0] == 'i')
		{
			cin >> key;
			insert(key);
			np++;
			size++;
		}
		else if (com[0] == 'd')
		{
			if (strlen(com) > 6)
			{
				if (com[6] == 'F')
					deleteFirst();
				else if (com[6] == 'L')
					deleteLast();
			}
			else
			{
				cin >> key;
				deleteKey(key); 
				nd++;
			}
			size--;
		}
	}
	printList();
	return 0;
}

Measured memory_bytes: 34248
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
int x,sum,maxx,n;
int read()
{
	int x=0,f=1;
	char k=getchar();
	while(k<'0'||k>'9')
	{
		if(k=='-') f=-1;
		k=getchar();
	}
	while(k>='0'&&k<='9')
	{
		x=x*10+k-'0';
		k=getchar();
	}
	return x*f;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		x=read();
		sum+=x;
		maxx=std::max(x,maxx);
	}
	if(sum-maxx>maxx) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
from collections import deque
#import numpy as np

H, W = map(int, input().split())
d = [[-1]*W for i in range(H)]
#temp = [[float("inf")]*W for i in range(H)]
maze = [list(input()) for i in range(H)]

black_cells = deque()
for i in range(H):
    for j in range(W):
        if maze[i][j]=="#":
            black_cells.append((i,j))
            d[i][j] = 0

def bfs():
    #max = 0
    #dx = [1, 0, -1, 0]
    #dy = [0, 1, 0, -1]

    #que = deque([])
    s = 0
    while black_cells:
        p, q = black_cells.popleft()
        s = d[p][q]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            nx = q + dx
            ny = p + dy
            #a = temp[ny][nx]
            if 0<=nx<W and 0<=ny<H and d[ny][nx]==-1:
                #que.append((nx))
                #temp[ny][nx] = d[p[0]][p[1]] + 1
                #a = temp[ny][nx]
                #d[ny][nx] = d[p[0]][p[1]] + 1
                #if a < d[ny][nx]:
                black_cells.append((ny, nx))
                d[ny][nx] = s + 1
                    #if max < d[ny][nx]:
                        #max = d[ny][nx]

    return s






#for i in slist:
#    s = bfs(i[0], i[1])

print(bfs())
#print(s)


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

ll gcd(ll n, ll m);

int main(void){
    ll A,B;
    cin >> A >> B;
    ll g  = gcd(A,B);
    //cout << g << endl;
    ll ans = 1;
    ll x = g;
    for(ll i =2;i*i<=g;i++){
        if(x%i==0){
            ans++;
            while(1){
                x = x/i;
                if(x%i>0)break;
            }
        }
    }
    if(x>1) cout << ans +1 <<endl;
    else cout << ans << endl;
}

ll gcd(ll n,ll m){
    ll a,b,r;
    a = n;
    b = m;
    r = n % m;
    while(r > 0){
        a = b;
        b = r;
        r = a%b;
    }
    return b;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,a[N];
multiset<int> s;
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) a[i]=gi();
    sort(a+1,a+n+1);
    if(a[n-1]!=a[n]) return puts("Impossible"),0;
    for(int i=1;i<=n-2;i++) s.insert(a[i]);
    for(int i=a[n]-1;i>=a[n]/2+1;i--) {
        if(s.find(i)==s.end()) return puts("Impossible"),0;
        s.erase(s.find(i));
        if(s.find(i)==s.end()) return puts("Impossible"),0;
        s.erase(s.find(i));        
    }
    if(a[n]%2==0) {
        if(s.find(a[n]/2)==s.end()) return puts("Impossible"),0;
        s.erase(s.find(a[n]/2));
    }
    for(int x:s) if(x<(a[n]+1)/2+1) return puts("Impossible"),0;
    puts("Possible");
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


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

int main(){
	int n, a[26];
	while (scanf("%d", &n), n != 0) {
		for (int i = 0; i < n; i++) {
			scanf(" %d", &a[i]);
		}
		printf("31\n");
		int o = 31, it = 0;
		while (o > 5) {
		printf("%d\n%d\n", o - a[it], o - 5);
		o -= 5;
		if (++it >= n)
			it = 0;
		}
		printf("0\n");
	}

	return 0;
}

Measured memory_bytes: 2676