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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll n;
  cin>>n;
  vector<ll> a(n),b(n);
  rep(i,n)cin>>a[i]>>b[i];

  sort(begin(a),end(a));
  sort(begin(b),end(b));
  if(n&1){
    int m = n/2;
    cout<<b[m]-a[m]+1<<endl;
  }else{
    int m = n/2;
    double mn = (a[m]+a[m-1])/2.0;
    double mx = (b[m]+b[m-1])/2.0;
    double ansd = (mx-mn)/0.5;
    ll ans = ansd+1;
    cout<<ans<<endl;
  }

}

Measured memory_bytes: 6436
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        int M = Integer.parseInt(scanner.next());
        System.out.println(Math.max(0, N - 2 * M));
    }
}


Measured memory_bytes: 23892
import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int[] NK = readln.chomp.split.to!(int[]);
  int N = NK[0],
      K = NK[1];
  int[] A = readln.chomp.split.to!(int[]);
  int[int] cs;
  int ans;

  foreach (a; A) {
    if (a in cs) {
      cs[a]++;
    } else {
      cs[a] = 1;
    }
  }

  int[] ks = cs.keys.sort!((a, b) => cs[a] < cs[b]).array;
  ulong k = cs.keys.length;
  size_t idx;

  while (k > K) {
    k--;
    ans += cs[ks[idx++]];
  }

  writeln(ans);
}


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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

int gcd(int n, int m) {
  return (m == 0? n :gcd(m, n % m));
}

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

  int n, k;
  cin >> n >> k;
  vi a(n);
  int MAX = 0;
  rep(i, 0, n) {
    cin >> a[i];
    MAX = max(MAX, a[i]);
  }

  int g = a[0];
  rep(i, 1, n) g = gcd(g, a[i]);
  if(k <= MAX && k % g == 0) cout << "POSSIBLE\n";
  else cout << "IMPOSSIBLE\n";
}


Measured memory_bytes: 640
io = STDIN
h,w=io.gets.split.map(&:to_i)
$c=Array(10)
a=[]
10.times do |i|
  $c[i]=io.gets.split.map(&:to_i)
end
h.times do
  a<<io.gets.split.map(&:to_i)
end
10.times do |k|
  10.times do |i|
    10.times do |j|
      $c[i][j]=[$c[i][j],$c[i][k]+$c[k][j]].min
    end
  end
end
def sum(e)
  $c[e][1]
end
puts a.flatten.select{|i|i!=-1}.inject(0){|s,e|s+$c[e][1]}


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

signed main(){
	int n, temp, sum = 0, val = 0;
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>temp;
		sum += temp;
		val += (temp*temp);
	}
	cout<<(sum*sum - val)/2;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
int main(){
FASTIO;
int h,a;
cin>>h>>a;
cout<<h/a+(h%a>0)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int D,N; cin>>D>>N;
    if(D==0){
        if(N==100){
            cout<<101;
            return 0;
        }
        cout<<N;
    }
    else if(D==1){
        if(N==100){
            cout<<10100;
            return 0;
        }
        cout<<N*100;

    }
    else{
        if(N==100){
            cout<<1010000;
            return 0;
        }
        cout<<N*100*100;
    }
    return 0;
}

Measured memory_bytes: 256
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

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

ll dp[100][100010];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    int n;cin >> n;
    ll W;cin >> W;
    vector<pair<ll,ll> > a(n);
    REP(i,n)cin >> a[i].first >> a[i].second;
    
    dp[0][0] = 0;
    dp[0][a[0].first] = a[0].second;
    for(int i = 1;i < n;i++){
        for(int j = 0;j < 100010;j++){
            dp[i][j] = max(dp[i][j],dp[i-1][j]);
            if(j >= a[i].first)dp[i][j] = max(dp[i][j],dp[i-1][j-a[i].first] + a[i].second);
        }
    }
    ll ans = 0;
    for(int i = 0;i <= W;i++)ans = max(ans,dp[n-1][i]);
    cout << ans << '\n';
    return 0;
}
/*
 * ちょっと待って！
 * そのコード本当に提出して大丈夫？
 * たくさんのコーナーケースがあるよ！
 * 君の注意力は大したことないよ！
 * WAを出すと君は冷静さを失うよ！
 * */


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

int main() {
    int K;
    cin >> K;
    if(K % 2 == 0)
        cout << pow(K / 2, 2) << endl;
    else
        cout << (K / 2) * (1 + K / 2) << endl;
    return 0;
}

Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long a, b, c;
    scan(a, b, c);
    foreach (i; 1 .. 10 ^^ 6)
    {
        if ((a * i) % b == c)
        {
            writeln("YES");
            return;
        }
    }
    writeln("NO");
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3648
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

typedef long double LD;
typedef long long LL;

int main(int argc, char* argv[]) {
	LL n, ans = 0;
	cin >> n;
	vector<vector<int>> sum(20, vector<int>(20));
	vector<int> two(n), five(n);
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		bool p = false;
		LL x = 0;
		for (char c : s) {
			if (c == '.') {
				p = true;
			} else {
				x = (x * 10) + c - '0';
				two[i] -= p;
				five[i] -= p;
			}
		}
		while (x % 2 == 0) {
			++two[i];
			x /= 2;
		}
		while (x % 5 == 0) {
			++five[i];
			x /= 5;
		}
	}
#if 0
	for (int i = 0; i < n; ++i) {
		sum[min(two[i], 9) + 10][min(five[i], 9) + 10] += 1;
	}
	for (int i = 0; i < n; ++i) {
		for (int j = -10; j < 10; ++j) {
			for (int k = -10; k < 10; ++k) {
				if (j + two[i] >= 0 && k + five[i] >= 0) {
					ans += sum[j + 10][k + 10];
				}
			}
		}
		ans -= two[i] >= 0 && five[i] >= 0;
	}
#else
	for (int i = 0; i < n; ++i) {
		sum[10 - min(two[i], 10)][10 - min(five[i], 10)] += 1;
	}
	for (int i = 0; i < 20; ++i) {
		for (int j = 1; j < 20; ++j) {
			sum[i][j] += sum[i][j - 1];
		}
	}
	for (int i = 1; i < 20; ++i) {
		for (int j = 0; j < 20; ++j) {
			sum[i][j] += sum[i - 1][j];
		}
	}
	for (int i = 0; i < n; ++i) {
		ans += sum[min(9, two[i]) + 10][min(9, five[i]) + 10];
		ans -= two[i] >= 0 && five[i] >= 0;
	}
#endif
	cout << ans / 2 << endl;
	return 0;
}


Measured memory_bytes: 4728
#include <cstdio>
#include <algorithm>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;
using P = std::pair<ll, ll>;

ll N, M;
ll A[100010], B[100010], C[100010];
std::vector<ll> as;
std::vector<P> ps;
ll S[100010];

int main()
{
  scanf( "%lld%lld", &N, &M );
  rep( i, N )
    scanf( "%lld", A+i ), as.push_back( A[i] );

  std::sort( all(as) );

  rep( i, N )
    S[i+1] = S[i]+as[i];

  ll r = 0;

  rep( i, M )
    scanf( "%lld%lld", B+i, C+i ), ps.push_back( P( C[i], B[i] ) );

  std::sort( all(ps) );

  ll ans = 0;

  for( int i = M-1; i >= 0; --i )
  {
    ll B = ps[i].second, C = ps[i].first;
    ll p = std::lower_bound( all(as), C )-as.begin();
    ll q = std::min( B, p );

    if( p-r > 0 )
    {
      ans += std::min(p-r,B)*C;
      //printf( "%lld*%lld\n", std::min(p-r,B), C );
      r += std::min(p-r,B);
    } 
  }

  //printf( "%lld\n", r );

  ans += S[N]-S[r];

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

  return 0;
}

Measured memory_bytes: 5872
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
int main(){
	long long n,k;
	double a[200000];
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	double l=0,r=1e9+7;
	for(int i=0;i<1000;i++){
		double m=(l+r)/2;
		long long cnt=0;
		for(int i=0;i<n;i++){
			if(a[i]<m){
				continue;
			}else{
				cnt+=floor(a[i]/m);
			}
		}
		if(cnt<=k){
			r=m;
		}else{
			l=m;
		}
	}
	long long ans=ceil(l);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5328
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;

int main() {
  string w;
  cin >> w;
  sort(all(w));

  int idx = 0;
  while (idx < (int)w.size()) {
    char base = w[idx];
    int char_count = 0;
    for (int i = idx; i < (int)w.size(); i++) {
      if (w[i] != base) break;
      char_count++;
      idx++;
    }
    if (char_count % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


void insertion_sort(int *seq, int length) {
  int key, j;
  for (int i = 1; i < length; i ++) {
    key = seq[i];
    j = i - 1;
    while (j >= 0 && seq[j] > key) {
      seq[j + 1] = seq[j];
      j --;
    }
    seq[j + 1] = key;
    for (int k = 0; k < length; k ++)
      cout << seq[k] << ((k == length-1) ? "" : " ");
    cout << endl;
  }
}


int main(){
  int N;
  int seq[100];
  cin >> N;
  for (int i = 0; i < N; i ++)
    cin >> seq[i];
  for (int k = 0; k < N; k ++)
    cout << seq[k] << ((k == N-1) ? "" : " ");
  cout << endl;
  insertion_sort(seq, N);
}



Measured memory_bytes: 3092
#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];

	bool flg=1;
	vector<int> b;
	for(int i=0; i<n-1; ++i){
		if(flg && a[i]<a[i+1]){
			b.push_back(i);
			flg=0;
		}else if(!flg && a[i]>a[i+1]){
			b.push_back(i);
			flg=1;
		}
	}
	if(!flg){
		b.push_back(n-1);
	}
	

	int m=b.size();
	long long money=1000, stock=0;
	for(int i=0; i<m; ++i){
		if(i%2==0){
			stock += money/a[b[i]];
			money %= a[b[i]];
		}else{
			money += stock*a[b[i]];
			stock=0;
		}	
	}
	cout << money << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
using namespace std;

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v.at(i);
	sort(v.rbegin(), v.rend());
	int sum = 0;
	rep(i, n) {
		if (i % 2 == 0)
			sum += v.at(i);
		else
			sum -= v.at(i);
	}
	cout << sum << "\n";
}


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

int main()
{
    int n;
    cin >> n;
    if(n >= 195) cout << 5 << endl;
    else if(n >= 189) cout << 4 << endl;
    else if(n >= 165) cout << 3 << endl;
    else if(n >= 135) cout << 2 << endl;
    else if(n >= 105) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

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

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

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

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


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	int ans=0;
	rep(i,n){
		int t;cin>>t;
		if(t>=m)ans++;
	}
	puta(ans);
	return 0;
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<int> G[100010];
vector<int> l;

void dfs(vector<bool>& used, int i) {
    used[i] = true;
    for (int j : G[i]) if (!used[j]) dfs(used,j);
    l.push_back(i);
}

int main() {
    int n,m,par;
    cin >> n >> m;
    vector<bool> used(n,false),child(n,false);
    vector<int> a(n),ans(n,n);
    for (int i = 0;i < n+m-1;++i) {
        int u,v;
        cin >> u >> v;
        u--;v--;
        G[u].push_back(v);
        child[v] = true;
    }
    for (int i = 0;i < n;++i) if (!child[i]) par = i;
    dfs(used,par);
    a.push_back(n);
    for (int i = 0;i < n;++i) a[l[i]] = i;
    for (int i = 0;i < n;++i) for (int& j : G[i]) if (a[ans[j]] > a[i]) ans[j] = i;
    for (int i = 0;i < n;++i) cout << (ans[i]+1)%(n+1) << "\n";
    return 0;
}

Measured memory_bytes: 13808
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define sz(a) (int)(a.size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(it,a,c) for(auto it=c.begin()+a;it!=c.end();it++)
#define fr(i,a,n)   for(int i=a;i<n;i++)
#define present(c,x) (c.find(x)!=c.end()) //for set/map etc.
#define cpresent(c,x) (find(all(c),x)!=c.end())
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
int N=100001;
int mod=1e9+7;


int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
bool comp(int a, int b) 
{ 
    return (a > b); 
}

bool comp1(pi a, pi b)
{
    if(a.first==b.first)return a.second<b.second;
    else return a.first>b.first;
}

template<typename T> 
istream& operator>>(istream& in, vector<T>& v)
{
    for (T& x : v) in >> x; return in;
}

template<typename T> 
ostream& operator<<(ostream& out, vector<T>& v)
{
    for (T& x : v) out << x<<" "; return out;
}

// template<typename T>
int sum1(vector<int>& v)
{
    int sum=0;
    // for(auto x: v)sum+=x;
    fr(i,0,v.size())sum+=v[i];
    return sum;
}





 void solve()
{
    string s;
    cin>>s;
    if(s[s.size()-1]=='s'){s.pb('e');s.pb('s');}
    else s.pb('s');
    cout<<s;
}

signed main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // int t;
    // cin>>t;
    // while(t--)
    // {
    //     solve();
    //     cout<<endl;
    // }
    solve();
    return 0;   
}   

Measured memory_bytes: 3644
import sys,math

N,A,B=map(int,input().split())
H = [0] * N
H = [int(input()) for i in range(N)]
 
maxH = max(H)
L=-1
R=math.ceil(maxH / B)

while R-L>1:
    MID=(L+R)//2
    if sum(math.ceil(max(h-B*MID,0)/(A-B))for h in H)>MID:
        L=MID
    else:
        R=MID

print(R)


Measured memory_bytes: 7856
dishes = []
for _ in range(5):
    x = int(input())
    dishes.append(x)
        
min_d = dishes[0]
other_dishes = []
for d in dishes[1:]:
    if min_d % 10 > d % 10 and d % 10 != 0:
        other_dishes.append(min_d)
        min_d = d
    else:
        other_dishes.append(d)

ans = 0
for d in other_dishes:
    if d % 10 == 0:
        ans += d
    else:
        ans += (d // 10) * 10
        ans += 10

ans += min_d
print(ans)
    
    

Measured memory_bytes: 3060
class Combination:

    """
    (使用例)
    comb = Combination(n_max, mod)
    comb(n, r)

    (注意)
    n_max != 0
    """

    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * \
                modinv[self.mod % i] % self.mod
        return modinv


N, M, K = map(int, input().split())
mod = 998244353
comb = Combination(N, mod)

ans = 0
for k in range(K+1):
    t1 = M % mod
    t2 = pow(M-1, N-1-k, mod)
    t3 = comb(N-1, k)
    ans = (ans + t1 * t2 * t3) % mod

print(ans)


Measured memory_bytes: 100348
package main

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

const (
	maxBufSize = 1024 * 1024
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, 1)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	out = bufio.NewWriter(os.Stdout)
)

func min(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func solve(n int64, k int64) int64 {
	if k == 1 {
		return 0
	}
	if n <= k {
		return min(n, k - n)
	}
	return solve(n % k, k)
}

func main() {
	defer out.Flush()

	n := nextInt()
	k := nextInt()
	res := solve(n, k)
	fmt.Fprintln(out, res)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextStringAsBytes() []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <cstdio>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long

using namespace std;
int num[100005];
int main()
{
    //IOS
    int n,k;
    while(cin>>n>>k)
    {
    	for(int i=1;i<=n;i++) cin>>num[i];
    	ll ans = 1e18;
    	for(int i=1;i<=n-k+1;i++)
    	{
    		ll tmp = 0;
    		if(num[i]<0 && num[i+k-1] <=0)
    		{
    			tmp = -num[i];
			}
			else if(num[i] < 0 && num[i+k-1] >= 0)
			{
				tmp = 2 * num[i+k-1] - 2 * num[i] - max(-num[i],num[i+k-1]); // 左右横跳  -  较长路径 
			}
			else
			{
				tmp = num[i+k-1];
			}
			
			ans = min( ans , tmp);
			
		}
		cout<<ans<<endl;
	}
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

typedef long long ll;
const int MAX = 1510000;
long long fac[MAX], finv[MAX], inv[MAX];
const int MOD = 1e9+7;

bool is_integer( double x ){
    return std::floor(x)==x;
}

int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

ll combination(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

uintmax_t combination2(unsigned int n, unsigned int r) {
    if ( r * 2 > n ) r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor  = 1;
    for ( unsigned int i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int X,Y;
    cin >> X >> Y;
    if ((X+Y)%3!=0){
        cout << 0 << endl;
        exit(0);
    }
    auto m=(2*X-Y)/3.0;
    auto n=(2*Y-X)/3.0;
    // cout << m << endl;
    // cout << n << endl;
    if (!is_integer(m) || !is_integer(n)) {
        cout << 0 << endl;
        exit(0);
    }
    if (n<0 || m<0) {
        cout << 0 << endl;
        exit(0);
    }
    // cout << n << endl;
    // cout << m << endl;
    COMinit();

    cout << COM(n+m,n) << endl;




    return 0;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  vector<int> cnt(n, 0);
  for(int i=0;i<n;i++) cin >> h[i];
  int mx = 0;
  for(int i=n-2;i>=0;i--){
    if(h[i] >= h[i+1]) cnt[i] = cnt[i+1]+1;
    mx = max(mx, cnt[i]);
  }
  cout << mx << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]%2==0){
            if(a[i]%3!=0 && a[i]%5!=0){
                printf("DENIED");
                return 0;
            }
        }
    }
    printf("APPROVED");
    return 0;
}

Measured memory_bytes: 1692
#include <iostream>
#include <complex>
#include <utility>
using namespace std;
#define X real()
#define Y imag()
#define EPS (1e-10)
typedef complex<double> P;
typedef pair<P,P> L;
double dot(P a, P b){
  return a.X*b.X + a.Y*b.Y;
}

double cross(P a, P b){
  return a.X*b.Y - a.Y*b.X;
}

int ccw(P a, P b, P c){
  if(cross(b-a,c-a) > EPS) return 1;
  if(cross(b-a,c-a) < -EPS) return -1;
  if(dot(b-a,c-a) < -EPS) return 2;
  if(abs(b-a) < abs(c-a) - EPS) return -2;
  return 0;
}

bool is_cross(L a, L b){
  if(ccw(a.first,a.second,b.first)*ccw(a.first,a.second,b.second) <= 0 &&
     ccw(b.first,b.second,a.first)*ccw(b.first,b.second,a.second) <= 0) return true;
  return false;
}

int main(){
  int q;
  cin >> q;
  for(int i = 0; i < q; ++i){
    P points[4];
    for(int j = 0; j < 4; ++j){
      double x, y;
      cin >> x >> y;
      points[j] = P(x, y);
    }
    L l1 = L(points[0], points[1]), l2 = L(points[2], points[3]);
    if(is_cross(l1, l2)) cout << 1 << endl;
    else cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 3272
n,m,c = map(int,input().split())
bl = list(map(int,input().split()))

ans = 0
for _ in range(n):
    al = list(map(int,input().split()))
    if sum([a*b for a,b in zip(al, bl)]) + c > 0:
        ans += 1

print(ans)
        

Measured memory_bytes: 38384
import heapq
n = int(input())
tasks = []
for _ in range(n):
  a,b = list(map(int, input().split()))
  heapq.heappush(tasks, (b, a))
res_a = 0
for i in range(n):
  b,a = heapq.heappop(tasks)
  res_a += a
  if(res_a > b):
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 28732
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

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

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N;
    cin >> N;
    priority_queue<double,vector<double>,greater<double> > que;
    for(int i = 0; i < N; i++){
        double a;
        cin >> a;
        que.push(a);
    }
    while(que.size() != 1){
        double a,b;
        a = que.top();que.pop();
        b = que.top();que.pop();
        que.push((a+b) / 2);
    }
    cout << que.top() << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

template <typename Tu>
static inline constexpr bool is_multiplication_safe(Tu a, Tu b) {
    return !a || b <= numeric_limits<Tu>::max() / a;
}

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

    ll ans = 1, a = 0;
    int n;
    bool over = false, zero = false;

    cin >> n;

    for(int i = 0; i < n; ++i) {
        cin >> a;
        if(a == 0) {
            zero = true;
            break;
        }
        if(!over) {
            if(ans * a > 1000000000000000000ll || !is_multiplication_safe(ans, a)) over = true;
            ans *= a;
        }
    }

    if(zero) printf("0\n");
    else if(over) printf("-1\n");
    else printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 3740
import java.util.*;

class Main {
	Scanner sc;
	int N, M;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		System.out.println( N*(N-1)/2+M*(M-1)/2 );
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 35660
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

int main(){
int N;
ll ans = 0;
cin>>N;
for(int i=1;i <= N;i++){
    if(i%3==0 || i%5 == 0)continue;
    else {
        ans+=i;
    }
    

}
cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
typedef long long ll;
typedef std::pair<ll, ll> P;

#define rep(i,n) for(int i = 0; i < int(n); i++)
using namespace std;

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

struct BIT {
	typedef ll input_t;

	vector<input_t> bit_;
	const long long n_;

	BIT(long long n) :n_(n) {
		bit_.resize(n + 1LL, 0);
	}

	input_t sum(int i) {
		input_t s = 0;
		while (i > 0) {
			s += bit_[i];
			i -= i & (-i);
		}
		return s;
	}

	void add(int i, input_t x) {
		while (i <= n_) {
			bit_[i] += x;
			i += (i & (-i));
		}
	}
};


struct BSearch {
	static ll solve(ll left, ll right, function<ll(ll)> pred) {
		while (right - left > 1) {
			ll middle = left + right;
			middle /= 2;
			if (pred(middle)) {
				right = middle;
			}
			else {
				left = middle;
			}
		}
		return right;
	}
};

static ll lpow(ll v, ll c) {
	ll a = 1;
	rep(i, c) {
		a *= v;
	}
	return a;
}

typedef tuple<ll, ll, ll> t3;

static t3 split(ll v) {
	ll x = 0;
	ll y = 0;
	ll c = 0;
	int i = 0;
	while (v > 0) {
		if (v % 3 == 1) {
			x |= 1LL << i;
			c++;
		}
		else if (v % 3 == 2) {
			y |= 1LL << i;
			c++;
		}
		i++;
		v /= 3;
	}
	return { x,y,c };
}

int main() {
	ll n;
	cin >> n;
	vector<ll> xs(n), ys(n), ps(n);
	rep(i, n) {
		cin >> xs[i] >> ys[i] >> ps[i];
	}
	vector<vector<ll>> xdist(1LL << n, vector<ll>(n, 0));
	vector<vector<ll>> ydist(1LL << n, vector<ll>(n, 0));
	for (ll i = 0; i < 1LL << n; i++) {
		vector<ll>& xd = xdist[i];
		vector<ll>& yd = ydist[i];
		for (ll j = 0; j < n; j++) {
			ll lx = abs(xs[j]);
			ll ly = abs(ys[j]);
			rep(k, n) {
				if (i & (1LL << k)) {
					chmin(lx, abs(xs[j] - xs[k]));
					chmin(ly, abs(ys[j] - ys[k]));
				}
			}
			xd[j] = lx * ps[j];
			yd[j] = ly * ps[j];
		}
	}
	vector<ll> ans(n + 1, 1e15);
	for (ll i = 0; i < lpow(3, n); i++) {
		auto t = split(i);
		ll x, y, c;
		tie(x, y, c) = t;
		const vector<ll>& xd = xdist[x];
		const vector<ll>& yd = ydist[y];
		ll sum = 0;
		for (ll j = 0; j < n; j++) {
			sum += min(xd[j], yd[j]);
		}
		chmin(ans[c], sum);
	}
	rep(i, n + 1) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 13044
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin


def main():
    res = 0
    n = int(input())
    for i in range(n):
        if (i+1) % 3 != 0 and (i+1) % 5 != 0:
            res += (i+1)
    print(res)


def input(): return stdin.readline().rstrip()


main()


Measured memory_bytes: 9396
#!python3

LI = lambda: list(map(int, input().split()))

# input
N, W = LI()
WV = [LI() for _ in range(N)]


def main():
    dp = [[0] * (W + 1) for _ in range(N + 1)]
    for i in range(1, N + 1):
        w, v = WV[i - 1]
        for j in range(W + 1):
            if j < w:
                dp[i][j] = dp[i - 1][j]
            else:
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v)
    ans = max(dp[-1])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 146704
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    if(abs(b - a) % 2 == 1)
    	cout << "IMPOSSIBLE" << endl;
    else
    	cout << min(a, b) + abs(b - a) / 2;
}

Measured memory_bytes: 256
ary = []
gets.to_i.times {
    ary << gets.chomp
}
count = Hash.new(0)
ary.each do |elem|
  count[elem] += 1
end
m = count.max{ |a, b| a[1] <=> b[1] }[1]
ans = []
ary.each_with_index do |x, i|
    ans << x if count[x] == m
end
puts ans.uniq.sort



Measured memory_bytes: 59124
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, K; 
  cin >> N >> K;

  int ans = 0;
  FOR(i, K, N+2){
    (ans += ((N*(N+1))/2)-((N-i+0)*(N-i+1)/2)-(i*(i-1)/2)+1) %= MOD;
  }

  cout << (ans+MOD)%MOD << "\n";

  return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(ll i=n;i<N;i++)
#define RREP(i,n,N) for(ll i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9+7;

ll N;
ll C;
ll x[100010];
ll v[100010];
ll sum[100010];
ll rsum[100010];
ll y[100010];
ll d[100010];

ll solve(){
    sum[0] = v[0];
    REP(i,1,N){
        sum[i]=sum[i-1]+v[i];
    }
    REP(i, 0, N) y[i] = C - x[i];
    rsum[N - 1] = v[N - 1];
    RREP(i, 0, N - 1) rsum[i] = rsum[i + 1] + v[i];

    d[N - 1] = rsum[N - 1] - y[N - 1];
    RREP(i, 0, N - 1) {
        d[i] = rsum[i] - y[i];
        d[i] = max(d[i], d[i + 1]);
    }


    ll ans = 0;
    REP(i, 0, N) {
        ll sm = 0;

        sm -= x[i];
        sm += sum[i];
        ans = max(ans, sm);

        sm -= x[i];

        if (i < N - 1) sm += d[i + 1];

        ans = max(ans, sm);
    }

    return ans;
}

int main() {
    cin>>N>>C;
    ll ans = 0;
    REP(i,0,N) {
        cin >> x[i] >> v[i];
    }
    ans = solve();
    REP(i,0,N) x[i] = C - x[i];
    reverse(x,x+N);
    reverse(v,v+N);
    ans = max(ans,solve());
    p(ans);
    return 0;
}

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

using namespace std;

typedef long long ll;

ll nums[1000000];
ll fat=0;

int main() {
    ll nt,a,b;
    ll temp=0;
    cin >> nt >> a >> b;
    for(int i =1; i < nt+1; i++){
        cin >> nums[i];
    }

    for(int i = 1; i < nt+1;i++){
        fat+=min(a*(nums[i]-nums[i-1]),b);
        if(i==1) temp=fat;
        //cout << fat << ' ' <<nums[i] << ' ' <<  nums[i-1] << endl;
    }

    cout << fat-temp;

    return 0;
}

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

int n;
int max1[2], max2[2];
int cnt[2][100010];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int t; scanf("%d", &t);
		++cnt[i & 1][t];
	}
	for (int i = 0; i < 2; ++i)
		for (int j = 1; j <= 100000; ++j)
			if (cnt[i][j] > cnt[i][max1[i]])
				max2[i] = max1[i], max1[i] = j;
			else if (cnt[i][j] > cnt[i][max2[i]])
				max2[i] = j;
	printf("%d\n", n -
			(max1[0] == max1[1] ?
			 max(cnt[0][max1[0]] + cnt[1][max2[1]],
				 cnt[0][max2[0]] + cnt[1][max1[1]]) :
			 cnt[0][max1[0]] + cnt[1][max1[1]]));
	return 0;
}



Measured memory_bytes: 4488
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


int main(void) {
  ll i, j, k;
  ll N;
  cin >> N;
  ll cnt[15]={};
  
  cnt[0]++; //Takahashi-kun
  for(i=0; i<N; i++) { ll t; cin >> t; cnt[t]++;}
  
  ll f=0;
  for(i=1; i<=11; i++) if(cnt[i]>=3) f=1;
  if(cnt[0]>=2 || cnt[12]>=2) f=1;
  if(f) {pt(0); return 0;}
  
  
  ll ans=0;
  for(ll S=0; S<1<<10; S++) {
    vector<ll> v; v.push_back(0);
    for(i=1; i<=11; i++) {
      if(cnt[i]==1) {
        if(S>>(i-1)&1) v.push_back(i);
        else v.push_back(24-i);
      }else if(cnt[i]==2) {
        v.push_back(i);
        v.push_back(24-i);
      }
    }
    if(cnt[12]) v.push_back(12);
    sort(v.begin(), v.end());
    
    
    ll t=INF;
    ll L=v.size();
    for(i=0; i<L-1; i++) chmin(t, v[i+1]-v[i]);
    chmin(t, 24-v[L-1]);
    
    
    chmax(ans, t);
  }
  
  
  pt(ans);
  
}



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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)

const int N = 1e6;
int a[N], b[N];

int main() {
    int n, q; cin >> n >> q;
    string s; cin >> s;

    fore(i, 1, n) {
        if(s[i-1] == 'A' && s[i] == 'C') {
            a[i] = 1 + a[i - 1];
            b[i + 1] = 1 + b[i];
        } else {
            a[i] = a[i - 1];
            b[i + 1] = b[i];
        }
    }
    // fore(i, 0, n + 1) cout << a[i] << " "; cout << endl;
    // fore(i, 0, n + 1) cout << b[i] << " "; cout << endl;

    while(q--) {
        int l, r; cin >> l >> r;
        cout << b[r] - a[l - 1] << endl;
    }

    return 0;
}

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

using namespace std;

const int INF = 1e9 + 1;

int main(){
  int N;
  cin >> N;
  
  vector<int> a(N);
  int min_a = INF;
  long long sum = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    min_a = min(a[i], min_a);
    sum += a[i];
  }
  
  bool first_win;
  if(sum & 1){
    if(N & 1){
      first_win = true;
    }else if(min_a == 1 || (min_a & 1) == 0){
      first_win = true;
    }else{
      first_win = true;
    }
  }else{
    if(N & 1){
      first_win = false;
    }else if(min_a == 1 || (min_a & 1) == 1){
      first_win = true;
    }else{
      first_win = false;
    }
  }
  
  cout << (first_win ? "First" : "Second") << endl;
  
  return 0;
}


Measured memory_bytes: 3592
from collections import deque
N = int(raw_input())
A = [int(raw_input()) for i in range(2**N)]
while N > 0:
  newA = []
  for i in range(2**(N-1)):
    stone = abs(A[i*2]-A[i*2+1])
    newA.append(stone if stone != 0 else A[i*2])
  A = newA
  N -= 1
print A[0]



Measured memory_bytes: 19448
import sys
import copy

N = int(input())
shops= [[i for i in input().split()] for i in range(N)]
for j in range(N):
    shops[j][1] = int(shops[j][1])
oshops = copy.deepcopy(shops)

for i in range(N):
    for j in range(i+1, N):
        if shops[i][0] > shops[j][0] :
            shops[i], shops[j] = shops[j], shops[i]

for i in range(N):
    for j in range(i+1, N):
        if shops[i][0] == shops[j][0] and shops[i][1] < shops[j][1] :
            shops[i], shops[j] = shops[j], shops[i]


for j in range(N):
    for k in range(N):
        if oshops[k][0] == shops[j][0] and oshops[k][1] == shops[j][1]:
            print(k+1)


Measured memory_bytes: 39792
package main

import (
  "fmt"
)

func main() {
  solve()
}

func solve() {
  var N, K, X, Y int
  fmt.Scan(&N)
  fmt.Scan(&K)
  fmt.Scan(&X)
  fmt.Scan(&Y)
  
  var sum int
  for i:=1; i <= N; i++ {
    if i <= K {
       sum += X
    } else {
       sum += Y
    } 
  }
  fmt.Println(sum)
}

Measured memory_bytes: 512
#pragma region template

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

// -type-
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;


// -const-
const ll MOD = 1000000007;

const ll MAX = (ll)0x3f0000003f000000;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// -define-
#define reps(i, k, n) for (int i = (k), i##_len = (n); i < i##_len; ++i)
#define rep(i, n) reps(i, 0, n)
#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())


// -functions-

inline bool in(string s, string c) {
    return (s.find(c) != string::npos);
}
inline bool in(string s, char c) {
    return (s.find(c) != string::npos);
}

template <class T>
inline T udiv(T a, T b) {
    return (a + b - 1) / b;
}
template <class T>
inline T rdiv(T a, T b) {
    return (a + b / 2) / b;
}

void print_args() {
}
template <class S, class... T>
void print_args(S&& a, T&&... args) {
    cout << ' ' << a;
    print_args(std::forward<T>(args)...);
}
template <class S, class... T>
void print(S&& a, T&&... args) {
    cout << a;
    print_args(std::forward<T>(args)...);
    cout << '\n';
}
template <class T>
inline void print(const T& x) {
    cout << x << '\n';
}
template <class T>
void debug(const T& x) {
    cerr << x << " (L:" << __LINE__ << ")" << '\n';
}

struct setup_main {
    setup_main() {
        // cin.tie(0);
        // ios::sync_with_stdio(0);
        cout << fixed << setprecision(15);
    }
} setup_main_;

ll ans = 0;
#pragma endregion

const int e3 = 1000;
array<int, e3 + 1> count_less = {0};

void solve(long long N, std::vector<long long> L) {
    sort(all(L));
    for (auto&& i : L) {
        count_less[i]++;
    }
    rep(i, e3) {
        count_less[i + 1] += count_less[i];
    }
    // a <= b <= c
    // c < a+b
    // c < 2*b
    int c, b, a_min;
    rep(ci, N) {
        c = L[ci];
        reps(bi, count_less[c / 2], ci) {
            b = L[bi];
            a_min = c - b + 1;
            ans += max(0, bi - count_less[a_min - 1]);
            // print(a_min, b, c, ans);
            // print(bi, ci);
        }
    }

    print(ans);
}
signed main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> L(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &L[i]);
    }

    solve(N, std::move(L));

    return 0;
}


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

int main()
{
    string str;cin>>str;
    
  vector<int> nums(str.size()); // 同じ長さのint列

  // char -> int 変換
  transform(str.begin(), str.end(), nums.begin(), [](char ch) { return ch - '0';});
  
  int ans = 1000;
  
  for(int i=0;i<str.size()-2;++i){
      int tmp= 100*nums[i] + 10*nums[i+1] + nums[i+2];
      int tmp2 = abs(753-tmp);
      ans = min(ans,tmp2);
  }
  
  cout<<ans<<endl;

  return 0;
}

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


int main() {
	ll H,W,M;cin >> H >> W >> M;
	vector<ll> row(H),col(W);
	set<P> s;
	rep(i,M){
		ll h,w;cin >> h >> w;
		--h;--w;
		row.at(h)++;
		col.at(w)++;
		s.insert({h,w});
	}
	ll rowmax = 0;
	ll colmax = 0;
	rep(i,H) rowmax = max(rowmax,row.at(i));
	rep(i,W) colmax = max(colmax,col.at(i));

	vector<ll> rowmax_array,colmax_array;
	rep(i,H) if( row.at(i) == rowmax ) rowmax_array.push_back(i);
	rep(i,W) if( col.at(i) == colmax ) colmax_array.push_back(i);

	ll ans = rowmax + colmax;
	for( auto p : rowmax_array ){
		for( auto q : colmax_array ){
			if( s.count({p,q}) ) continue;
			cout << ans << endl;
			return 0;
		}
	}

	cout << --ans << endl;

}

Measured memory_bytes: 35100
s = input()[::-1]
v = 0
mods = {}
mods[0] = 1
d = 1

for c in s:
    v += int(c) * d
    #print(v)
    v %= 2019
    d *= 10
    d %= 2019
    try:
        mods[v] += 1
    except KeyError:
        mods[v] = 1

ans = 0
for n in mods.values():
    ans += (n * (n - 1)) // 2

print(ans)

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

int main(){
  int x, y;
  while(1){
  cin >> x >> y;
  if(x==0 && y==0) break;
  if(x > y) swap(x,y);
  cout << x << " " << y << endl;
  
  }
  return 0;
    
}



Measured memory_bytes: 3068