akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

const int MAX_V = 100010;

vector<vector<P>> G(MAX_V);
vector<ll> dist(MAX_V, INF);
void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        int ccost, cv;
        tie(ccost, cv) = que.top();
        que.pop();

        if(dist[cv] < ccost) continue;

        for(auto x : G[cv]){
            int nv = x.first;
            int ncost = x.second;
            if(dist[cv] + ncost < dist[nv]){
                dist[nv] = dist[cv] + ncost;
                que.push(P(dist[nv], nv));
            }
        }
    }
}

int main(){
    int n; cin>>n;
    for(int i=0; i<n-1; i++){
        int u, v, w; cin>>u>>v>>w;
        u--, v--;
        G[u].push_back(P(v, w));
        G[v].push_back(P(u, w));
    }

    dijkstra(0);

    vector<int> ans(n);
    for(int i=0; i<n; i++){
        ans[i] = dist[i] % 2;
        cout << ans[i] << endl;
    }
}

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

int main() {
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != t[i]) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3856
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


sys.setrecursionlimit(1000000)


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    uf = list(range(N))
    n = [1] * N

    def getpar(a: int):
        if a == uf[a]:
            return a
        uf[a] = getpar(uf[a])
        return uf[a]

    def union(a: int, b: int):
        pa = getpar(a)
        pb = getpar(b)
        if pa == pb:
            return 0, 0
        ra = n[pa]
        rb = n[pb]
        n[pa] += n[pb]
        uf[pb] = uf[pa]
        return ra, rb

    k = N * (N - 1) // 2
    ans = []
    A.reverse()
    B.reverse()
    for Ai, Bi in zip(A, B):
        Ai -= 1
        Bi -= 1
        ra, rb = union(Ai, Bi)
        ans.append(k)
        k -= ra * rb

    assert k == 0, k
    for ansi in reversed(ans):
        print(ansi)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38320
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
bool a[500][500] = {};
char c[500][500];
bool search(int x,int w,int h,int y) {
	if (x < 0 || x >= w || y < 0 || y >= h) {
		return false;

	}
	else if (c[y][x] == '#') {
		return false;
	}
	if (a[y][x] == true) {
		return false;
	}
	if (c[y][x] == 'g') {
		return true;
	}
	a[y][x] = true;
	if (search(x + 1, w, h, y) || search(x - 1, w, h, y) || search(x, w, h, y + 1) || search(x, w, h, y - 1)) {
		return true;
	}
	else {
		return false;
	}

}

//小文字=大文字+32
int main() {
	string s;
	cin >> s;
	int tmp=0;
	int ans=0;
	rep(i, 3) {
		if (s[i] == 'R') {
			tmp++;
		}
		else {
			tmp = 0;
		}
		ans = max(ans, tmp);
	}
	cout << ans;

}
	



Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
    int a,b,i,c,e;
    scanf("%d%d",&a,&b);
    int d[a];
    for(i=0;i<a;i++)
    {
        scanf("%d",&d[i]);
    }
    c=a/(b-1);
    e=a%(b-1);
    if(b-1==1)
        c--;
    else if(e>1)
        c++;
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

int main() {
	char S[100001];
	cin >> S;

	int cnt_0 = 0;
	int cnt_1 = 0;
	size_t len = strlen(S);

	for (int i = 0; i < len; i++) {
		if (S[i] == '0')
			cnt_0++;
		else if (S[i] == '1')
			cnt_1++;
	}

	cout << 2 * min(cnt_0, cnt_1) << endl;

	return 0;
}

Measured memory_bytes: 384
//NAME-ADITYYA OJHA
/*
 *     Heart beats fast
 *         Colors and promises
 *             How to be brave
 *                 How can I love when I am afraid to fall...
                                             (courtesy-amnesiac_dusk)
 */
#include <bits/stdc++.h>
#define ll long long int
#define forin for(int i=0;i<n;i++)
#define forjn for(int j=0;j<n;j++)
#define pb push_back
#define vx vector<ll> x
#define vy  vector<ll> y
#define fas1  ios_base::sync_with_stdio(false)
#define fas2   cin.tie(NULL)
#define fas3   cout.tie(NULL)
#define  f   first
#define  s   second
#define mod 1000000007
 const ll N=1e18;

using namespace std;

//check for corner cases(for n==1)
// check for int overflow
// run on some sample cases before submitting






int main ()
{
    fas1,fas2,fas3;

      long double a,b;
      cin>>a>>b;
      long double c=a*b;

      ll z=floor(1.0*c);


      cout<<z<<endl;



}








Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
main(){
    int n;
    cin>>n;
    int k=n%10;
    if(k==0||k==1||k==6||k==8) puts("pon");
    else if(k==3) puts("bon");
    else puts("hon");
}


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



int main(){
	
	string s;
	cin>>s;
	
	int ans = 700;
	
	for(int i=0;i<s.size();i++){
		if(s[i]=='o')ans+=100;
	}
	
	cout<<ans<<endl;
		
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio

  string s;
  cin >> s;
  int n = s.size();

  int next[n], before[n];

  for(int i = 0; i < n; i++){
    if(s[i] == 'R'){
      int j;
      for(j = i + 1; j < n; j++){
        if(s[j] == 'L')
          break;
      }
      int pos = j;
      for(j = i; j < pos; j++){
        next[j] = pos;
      }
      i = j - 1;
    }
  }

  for(int i = n - 1; i >= 0; i--){
    if(s[i] == 'L'){
      int j;
      for(j = i - 1; j >= 0; j--){
        if(s[j] == 'R'){
          break;
        }
      }
      int pos = j;
      for(j = i; j > pos; j--){
        before[j] = pos;
      }
      i = j + 1;
    }
  }

  int ans[n] = {0};

  for(int i = 0; i < n; i++){
    if(s[i] == 'R'){
      int r = next[i];
      int l = i;
      if((r - l) & 1){
        ans[r - 1]++;
      }else{
        ans[r]++;
      }
    }else{
      int l = before[i];
      int r = i;
      if((r - l) & 1){
        ans[l + 1]++;
      }else{
        ans[l]++;
      }
    }
  }

  prv(ans);

  ktj();
}


Measured memory_bytes: 1872
import std.algorithm;
import std.stdio;

void main ()
{
	int a, b;
	while (readf (" %s %s", &a, &b) > 0)
	{
		if (a <= 0 && 0 <= b)
		{
			writeln ("Zero");
		}
		else if (a > 0)
		{
			writeln ("Positive");
		}
		else
		{
			b = min (b, 0);
			if ((b - a) & 1)
			{
				writeln ("Positive");
			}
			else
			{
				writeln ("Negative");
			}
		}
	}
}


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

const int MOD = 1e9 + 7;

// a^n mod を計算してみる
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod; // nの各桁(bit)と1のAND演算
		a = a * a % mod; // aの(2の累乗)乗を計算
		n >>= 1;
	}
	return res;
}

int main() {
	long long N, K;
	cin >> N >> K;
	long long ans = 0;
	map<long long, long long> ma;
	for (int i = K; i > 0; i--) {
		long long tmp = modpow(K / i, N, MOD);

		int x = 2;
		while (x * i <= K) {
			tmp -= ma[x * i];
			if (tmp < 0) {
				tmp += MOD;
			}
			x++;
		}

		ma[i] = tmp;

		ans += tmp * i;
		ans %= MOD;
	}

	cout << ans << endl;
}

Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 100000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back


int n,m;
bool a[210000][40];
int s[110000],t[110000],c[110000];

int main(){
  cin>>n>>m;
  rep(i,n){
    cin>>s[i]>>t[i]>>c[i];
  }
  
  rep(i,n){
    FOR(j,s[i]*2-1,t[i]*2+1)
      a[j][c[i]]=true;
  }

  int ans=0;
  rep(i,210000){
    int sum=0;
    FOR(j,1,40){
      sum+=a[i][j];
    }
    ans = max(ans,sum);
  }

  cout<<ans<<endl;
}


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

#define rep(i, n) for(int i = 0 ; i < n ; i ++)
#define vi vector<int>
int main(void){
  int n, d, x;
  cin>>n>>d>>x;
  vi a(n);

  rep(i,n){
    cin>>a[i];
    x += (float)d / a[i] + (d%a[i] == 0 ? 0 :  1);
  }	

  cout<<x<<endl;
}


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

//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>PII;
typedef vector<PII>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const int mod=1e9+7;
const int sze=1e5+2;
int fact(int num)
{
	if(num==0)return 1;
	int ans=1;
	for(int i=1;i<=num;i++)ans=ans*i;
	return ans;
}

signed main()
{
  int n;
  sl(n);
  int perm1[n+1],perm2[n+1];
  for(int i=1;i<=n;i++)sl(perm1[i]);
  for(int j=1;j<=n;j++)sl(perm2[j]);
  int a=0,b=0;
  for(int i=1;i<=n;i++){
	  int m=perm1[i];
	  a+=(m-1)*fact(n-i);
	  
	  for(int j=i+1;j<=n;j++){
		  if(perm1[j]>m)perm1[j]--;
	  }
  }
  for(int i=1;i<=n;i++){
	  int m=perm2[i];
	  b+=(m-1)*fact(n-i);
	  
	  for(int j=i+1;j<=n;j++){
		  if(perm2[j]>m)perm2[j]--;
	  }
  }
  cout<<abs(a-b)<<endl;
  return 0;
}


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

int main()
{
  int a, b;
  char op;
  cin >> a >> op >> b;
  if(op == '+') cout << a + b << endl;
  else cout << a - b << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int ans = 0;
		ans += Math.Min(N,9);
		if(N>=100){
			ans += Math.Min(N-99,900);
		}
		if(N>=10000){
			ans += Math.Min(N-9999,90000);
		}
		if(N>=1000000){
			ans += Math.Min(N-999999,9000000);
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC152
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }

        public static void a()
        {
            int[] nm = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            if(nm[0] == nm[1])
            { Console.WriteLine("Yes"); }
            else
            { Console.WriteLine("No"); }
        }
    }
}


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

int main() { // claudio van
  int a, b, k; scanf("%d %d %d", &a, &b, &k);
  int cnt = 0;
  for (int i = min(a, b); i >= 1; --i) {
    if (a % i == 0 and b % i == 0) {
      cnt++;
      if (cnt == k) {
        printf("%d\n", i);
        return 0;
      }
    }
  }
  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;
typedef pair<int,int> P;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(void) {
    int N; cin >> N;
    ll ans = 0;
    for(int c=1; c<=N-2; c++) {
        int x = N-c;
        const auto &pf = prime_factorize(x);
        long long res = 1;
        for (auto p : pf) res *= p.second + 1;
        ans+=res;
    }

    cout << ans+1 << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (int)n;i++)
#define repb(i,n) for(int i = (int)n;i >= 0;i--)
#define reps(i,m,n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i,m,n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v,n) sort(v,v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
#define ll long long int
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
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;}
//vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));
using namespace std;
int main(int argc, char const *argv[]) {
    int n, m;
    int ans[3];
    while (cin >> n >> m, n || m)
    {
        ans[2] = 999999999;
        vector<int> s(n + m);
        int cn=0,cm=0;
        rep(i, n + m)
        {
            cin >> s[i];
            if (i < n)
                cn += s[i];
            else{
                cm += s[i];
            }
        }
        if ((cn + cm) % 2 != 0)
        {
            cout << -1 << endl;
        }
        else{
            bool f = false;
            rep(i, n)
            {
                reps(j,n,n+m)
                {
                    if (cn-s[i]+s[j]==cm-s[j]+s[i])
                    {
                        if (ans[2] > s[j] + s[i])
                        {
                            f = true;
                            ans[0] = i;
                            ans[1] = j;
                            ans[2] = s[ans[0]] + s[ans[1]];
                        }
                    }
                }
            }
            if(f)   
                cout << s[ans[0]] << " " << s[ans[1]] << endl;
            else
                cout << -1 << endl;
        }
    }
    return 0;
}



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

int main() {
  int h,w;
  cin>>h>>w;
  string s[h];
  for(int i=0;i<h;i++) cin>>s[i];
  for(int i=0;i<w+2;i++) cout<<'#';
  cout<<endl;
  for(int i=0;i<h;i++) cout<<'#'<<s[i]<<'#'<<endl;
  for(int i=0;i<w+2;i++) cout<<'#';
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import math
N = int(sys.stdin.readline().strip())
 
def calc(xa, ya, ra, xb, yb, rb):
    dist = math.sqrt((yb - ya) **2 + (xb - xa) **2)
    if dist > (ra + rb):
        return 0
    elif abs(ra - rb) <= dist <= (ra + rb):
        return 1
    elif dist < abs(ra - rb):
        if ra > rb:
            return 2
        else:
            return -2
 
for i in xrange(N):
    line = sys.stdin.readline().strip()
    xa, ya, ra, xb, yb, rb = map(float, line.split())
    print calc(xa, ya, ra, xb, yb, rb)

Measured memory_bytes: 4404
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

int main(void)
{
  long long N, M, K, A, B = 0, i = 0, j = 0, suma = 0, max = 0, read = 0, readmax = 0;
  long long deskA[200001], deskB[200001];
  scanf("%lld %lld %lld", &N, &M, &K);
  for (i = 0; i < N; i++)
  {
    scanf("%lld", &deskA[i]);
  }
  for (i = 0; i < M; i++)
  {
    scanf("%lld", &deskB[i]);
  }

  for (i = 0; i < N; i++)
  {
    if (suma + deskA[i] <= K)
    {
      suma += deskA[i];
      A++;
    }else{
        break;
    }
  }
  max = suma;
  read = A;
  for (j = 0; j < M; j++)
  {
    if (max + deskB[j] <= K)
    {
      max += deskB[j];
      read++;
      B++;
    }
    else
      break;
  }
  readmax = read;
  for (i = 0; i < A; i++)
  {
    max -= deskA[A - i - 1];
    read--;
    for (j = B; j < M; j++)
    {
      if (max + deskB[j] <= K)
      {
        max += deskB[j];
        read++;
        B++;
      }
      else
        break;
    }
    if (readmax < read)
    {
      readmax = read;
    }
  }
  printf("%lld\n", readmax);
}

Measured memory_bytes: 4796
#include <stdio.h>

int max(int a, int b){return a > b ? a : b;}

int main(void){
	int a, b, x, y;
	scanf("%d %d %d %d", &a, &b, &x, &y);
	printf("%d\n", max(a * b, x * y));
	return 0;
}


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

using namespace std;

main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	
	if(s == "SUN")
	{
		cout << 7;
		return 0;
	}
	
	if(s == "SAT")
	{
		cout << 1;
		return 0;
	}
	
	if(s == "FRI")
	{
		cout << 2;
		return 0;
	}
	
	if(s == "THU")
	{
		cout << 3;
		return 0;
	}
	
	if(s == "WED")
	{
		cout << 4;
		return 0;
	}
	
	if(s == "TUE")
	{
		cout << 5;
		return 0;
	}
	
	if(s == "MON")
	{
		cout << 6;
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin>>L.at(i);
  }
  sort(L.begin(),L.end());
  int ans=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int k=j+1;k<N;k++){
        
        if(L.at(i)<L.at(j) && L.at(j)<L.at(k) && L.at(i)+L.at(j)>L.at(k)){
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main(){
  int n[101];
  int i;
  int num;
  cin >> num;
  for(i=0;i<num;i++) cin >> n[i];
  cout << n[num-1];
  for(i=1;i<num;i++) cout <<" "<< n[num-i-1];
  cout << endl;
  return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int N, A, B;
	string S;
	cin >> N >> A >> B;
	cin >> S;
	int a, b;
	a = b = 0;
	rep(i,S.size()) {
		const string yes = "Yes", no = "No";
		if(S[i] == 'a') {
			if(a+b < A+B) {
				a++;
				cout << yes << endl;
			}
			else {
				cout << no << endl;
			}
		}
		else if(S[i] == 'b') {
			if(a+b < A+B && b < B) {
				b++;
				cout << yes << endl;
			}
			else {
				cout << no << endl;
			}
		}
		else {
			cout << no << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = int64_t;

int N;

int main()
{
    cin >> N;
    unordered_map<string, int> m;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        m[s]++;
    }

    cout << m.size() << endl;
}


Measured memory_bytes: 17792
//Optimise
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// #define MULTI_TEST
#ifdef LOCAL
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
    out << '[' << p.first << ", " << p.second << ']';
    return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
    while (*name == ',' || *name == ' ')
        name++;
    std::cerr << name << " { ";
    for (const auto &v : arg)
        cerr << v << ' ';
    cerr << " }\n";
}
template <typename Arg1, typename... Args>
void PC(const char *names, Arg1 &&arg1, Args &&... args)
{
    while (*names == ',' || *names == ' ')
        names++;
    const char *comma = strchr(names, ',');
    std::cerr.write(names, comma - names) << " { ";
    for (const auto &v : arg1)
        cerr << v << ' ';
    cerr << " }\n";
    PC(comma, args...);
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
    std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define f first
#define s second
#define pb push_back
auto TimeStart = chrono::steady_clock::now();

const int NAX = 2e5 + 10, MOD = 1000000007;

int dp[NAX];

int solve(int n)
{
    if (dp[n] >= 0)
        return dp[n];
    if (n == 0)
        return 1;
    for (int i = 100; i <= 105; ++i)
        if (n >= i)
            if (solve(n - i))
                return dp[n] = true;
    return dp[n] = false;
}

void solveCase(int caseNo)
{
    int n;
    cin >> n;
    memset(dp, -1, sizeof dp);
    cout << solve(n) << '\n';
}

int main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
#ifdef MULTI_TEST
    cin >> t;
#endif
    for (int i = 1; i <= t; ++i)
    {
        solveCase(i);
#ifdef TIME
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
string s,s_;
ll dp[4000][4000]={0},S[4000][4000]={0};

void solve(){
    cin >> n;
    cin >> s_;
    s="<"+s_;
    dp[0][0]=1;
    rep(i,n){
        S[0][i+1]=S[0][i]+dp[0][i];
    }
    rep(i,n){
        rep(k,n-i){
            if (s[i]=='<') dp[i+1][k]+=(S[i][k+1]-S[i][0]+mod)%mod;
            if (s[i]=='>') dp[i+1][k]+=(S[i][n-i+1]-S[i][k+1]+mod)%mod;

            //cout << i+1 << " " << k << " " << dp[i+1][k] << endl;

            S[i+1][k+1]=(S[i+1][k]+dp[i+1][k])%mod;
        }
    }

    cout << dp[n][0] << endl;
}

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

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

int main(){
  int d, t, s;
  cin >> d >> t >> s;
  
  if(d % s == 0){
    if(d / s <= t){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    if(d / s + 1 <= t){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll fac[200007],finv[200007],inv[200007];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<200007;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;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cominit();
    ll n,k;
    cin>>n>>k;
    cout << com(n-1,k-1) <<endl;
    return 0;
}



Measured memory_bytes: 7904
#include<stdio.h>
#define MAX 100

int main(){
  int i,j,k,v,n,A[MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    for(k=0;k<n;k++){
      if(k) printf(" ");
      printf("%d",A[k]);
      
    }
    printf("\n");
  }
  return 0;
}



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

int main(){
  int a,b;
  cin >> a>> b;
  int ans=0;
  
  for(int i=a;i<=b;i++){
    string s= to_string(i);
    if(s[0]==s[4] && s[1]==s[3]){
      ans++;
    }
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

// ref :: https://www.hamayanhamayan.com/entry/2018/11/24/223908

int n, q, k;
string s;

ll solve(int k) {
    ll cnt = 0, ret = 0;
    int c = 0, num_m = 0, num_c = 0;
    rep(a, n) {
        if (s[a] == 'D') {
            while (c < n && c - a < k) { // aを固定して、可能な限りcを伸ばす
                if (s[c] == 'M') num_m++;
                else if (s[c] == 'C') {
                    num_c++;
                    cnt += num_m;
                }
                c++;
            }
            ret += cnt;
        }
        else if (s[a] == 'M') {
            num_m--;
            cnt -= num_c;
        }
        else if (s[a] == 'C') {
            num_c--;
        }
    }
    return ret;
}

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

    while(q--) {
        cin >> k;
        cout << solve(k) << endl;
    }    
}


Measured memory_bytes: 5288
#include<iostream>
//#include<vector>
int main(void) {
	int Row, Coloum;
	std::cin >> Row >> Coloum;
	int ElementRow = Row + 1, ElementColoum = Coloum + 1;
	//std::vector<std::vector<int>>Matrix(ElementRow, std::vector<int>(ElementColoum));
	int Matrix[101][101] = {};
	for (int R = 0; R < Row; ++R) {
		for (int C = 0; C < Coloum; ++C) {
			std::cin >> Matrix[R][C];
			Matrix[R][Coloum] += Matrix[R][C];
		}
	}
	for (int C = 0; C < ElementColoum; ++C) {
		for (int R = 0; R < Row; ++R) {
			Matrix[Row][C] += Matrix[R][C];
		}
	}
	for (int R = 0; R < ElementRow; ++R) {
		for (int C = 0; C < ElementColoum; ++C) {
			if(C== ElementColoum-1){ std::cout << Matrix[R][C] ;
			break;
			}
			std::cout << Matrix[R][C] << " ";
		}
		std::cout << std::endl;
	}
//	system("pause");
	return 0;
}

Measured memory_bytes: 3112
function Main(input) {
	var len = input.length;
	var min = 9999;
	for(var i = 0; i < len-2; i++) {
      var tmp = input.substr(i, 3);
      var v = parseInt(tmp, 10);
      var a = Math.abs(v-753);
      if (a < min) {
        min = a;
      }
	}
    console.log(min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

Measured memory_bytes: 1156
import sys
input=sys.stdin.readline
from collections import Counter

def main():
    n=int(input())
    a=[0]+list(map(int,input().split()))
    
    for i in range(n+1):
        a[i]+=a[i-1]
    
    ans=0
    C=Counter(a)
    for v in C.values():
        if  v >= 2:
            ans += v*(v-1)//2
    
    print(ans)    
  
if __name__=='__main__':
    main()

Measured memory_bytes: 36736
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
/*================Header Template==============*/
int a,b;
char mp[105][105];
int main() {
	read(a),read(b);
	for(int i=1;i<=50;i++)
		for(int j=1;j<=100;j++)
			mp[i][j]='.';
	for(int i=51;i<=100;i++)
		for(int j=1;j<=100;j++)
			mp[i][j]='#';
	b--;
	for(int i=1;i<=50&&b;i+=2)
		for(int j=1;j<=100&&b;j+=2)
			mp[i][j]='#',b--;
	a--;
	for(int i=100;i>50&&a;i-=2)
		for(int j=1;j<=100&&a;j+=2)
			mp[i][j]='.',a--;
	puts("100 100");
	for(int i=1;i<=100;i++,puts(""))
		for(int j=1;j<=100;j++)
			printf("%c",mp[i][j]);
}

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

int main(){
  int N;
  cin>>N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin>>L.at(i);
  }
  
  bool flag=true;
  
  for(int i=0;i<N;i++){
    int sum=0;
    for(int j=0;j<N;j++){
      if(i==j){
        continue;
      }
      sum+=L.at(j);
    }
    if(sum<=L.at(i)){
      flag=false;
      break;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(){
    int h,w;
    while(cin>>h>>w){
        if(h+w == 0)break;
        vector<string> v(h);
        map<char,pair<int,int>> mp;
        for(int i=0;i<h;i++)cin>>v[i];
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                mp[v[i][j]] = pair<int,int>(i,j);
            }
        }
        string s;
        cin>>s;
        pair<int,int> now = pair<int,int>(0,0);
        int ans=0;
        for(int i=0;i<s.size();i++){
            pair<int,int> next = mp[s[i]];
            ans += abs(now.first-next.first)+abs(now.second-next.second);
            now = next;
        }
        cout<<ans + s.size()<<endl;
    }
}


Measured memory_bytes: 3064
MOD = 998244353
N = int(input())
robots = []
for _ in range(N):
    x, d = map(int, input().split())
    robots.append((x, d))
robots.sort(reverse=True)
dp = [0] * (N + 1)
los = [N] * (N + 1)
dp[0] = 1
los[0] = 0
for i, (x, d) in enumerate(robots):
    lo = i
    while lo > 0 and robots[lo - 1][0] < x + d:
        lo = los[lo]
    los[i + 1] = lo
    dp[i + 1] += (dp[i] + dp[lo]) % MOD
print(dp[-1])


Measured memory_bytes: 72664
#include <bits/stdc++.h> //g++-9で実行（gcc version 9.3.0），g++だとデフォルトのclang

using namespace std;

//#define int long long                         //intでオーバフローした時の切り替え用
#define debug(x) cerr << #x << ": " << x << endl //エラー出力として変数名と変数の中身表示
#define DEBUG_VEC(v)                   \
    cerr << #v << ":";                 \
    for (int i = 0; i < v.size(); i++) \
        cerr << " " << v[i];           \
    cerr << endl;
#define DEBUG_MAT(v)                          \
    cerr << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cerr << v[i][j] << " ";           \
        }                                     \
        cerr << endl;                         \
    }
#define Sp(p) cout << setprecision(25) << fixed << p << endl; //小数点以下を25桁で表示
#define all(obj) (obj).begin(), (obj).end()
#define pb push_back

//usingエイリアス（別名という意味，型定義のこと）
using ll = long long;
//template <class T> using Vec = std::vector<T>;//エイリアステンプレート

const ll MOD = (ll)1e9 + 7;
//const ll MOD = 998244353;
const ll INF = (ll)1e18 + 1;
const double EPS = 1e-9;
const long double pi = 3.1415926535897932384626433832795028841971L;

//マクロでintをlong longと定義したときはsinged
int main()
{
    cin.tie(0);                  //cinとcoutの同期を切る（高速化)
    ios::sync_with_stdio(false); //iostreamとstdioの同期を切る（高速化)

    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll tmp=0;
    if(k-a >0){
        tmp += a;
    }
    else{
        cout << k << endl;
        return 0;
    }
    if(k-a-b <=0){
        cout << tmp << endl;
        return 0;
    }
    else{
        tmp -= k-a-b;
        cout << tmp << endl;
        return 0;
    }
          return 0;
}

Measured memory_bytes: 3636
N = int(input())
s = input()
t = input()

for i in range(N):
    tmp = 0
    while True:
        if s[i+tmp] == t[tmp]:
            pass
        else:
            break

        tmp += 1
        if not i + tmp < N:
            print(i + N)
            exit(0)
print(2*N)

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

int main()
{
	int n;
	int v[20] = { 0 }, c[20] = { 0 };
	int z[20] = { 0 };

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < n; i++) {
		z[i] = v[i] - c[i];
	}
	int maxz = 0;
	for (int i = 0; i < n; i++) {
		if (z[i] > 0) {
			maxz += z[i];
		}
	}
	cout << maxz << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll a, b;
    cin >> a >> b;
    if(a+b>=10)
        cout << "error" << endl;
    else
    {
        cout << a + b << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	if (a > b) swap(a, b);
	if (b > c) swap(b, c);
	if (a > b) swap(a, b);

	b -= a;
	c -= a;
	a = 0;

	int ans = 0;
	ans += b / 2;
	c -= 2 * (b / 2);
	b -= 2 * (b / 2);

	if (b == 0) {
		ans += c;
	} else {
		ans += c + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int H, W, X, Y, A, B;
    cin >> H >> W >> X >> Y;
    A = H * W;
    B = X + Y;
    if(A % 2 == 1 && B % 2 == 1){
        cout << "No" << endl;
    }
    else cout << "Yes" << endl;
    return 0;
    
    
}



Measured memory_bytes: 3076
MOD=10**9+7
lim=200000
inv_t = [-1 for i in range(lim+1)]
factrial = [-1 for i in range(lim+1)]
factrial_inv = [-1 for i in range(lim+1)]


def mod_inv(x, mod=MOD):
    y, u, v, _x = mod, 1, 0, x
    while y:
        t = _x//y
        _x -= t*y
        _x, y = y, _x
        u -= t*v
        u, v = v, u
    u %= mod
    if u < 0:
        u += mod
    return u

def mod_pow(a, n, mod=MOD):
    res = 1
    while n:
        if n & 1:
            res = res*a % mod
        a = a*a % mod
        n >>= 1
    return res

def COMinit(max=lim, mod=MOD):
    factrial[0] = factrial_inv[0] = 1
    factrial[1] = factrial_inv[1] = 1
    inv_t[0] = inv_t[1] = 1
    for i in range(2, max):
        factrial[i] = factrial[i-1]*i % mod
        inv_t[i] = -inv_t[mod % i]*(mod//i) % mod
        factrial_inv[i] = factrial_inv[i-1]*inv_t[i] % mod

def comb(a, b, mod=MOD):
    if a<b:
        return 0
    if factrial[0] == -1:
        COMinit()
    return (factrial[a]*factrial_inv[b]*factrial_inv[a-b]) % mod


n=int(input())
ans=mod_pow(10,n)

nine=mod_pow(9,n)
ei=mod_pow(8,n)


print((ans-ei-(nine-ei)*2)%MOD)



Measured memory_bytes: 13724
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	long long int x, a[2000], sum=0, min[2000];
	int minnum[2000];
	scanf("%d %lld", &n, &x);
	for(int i=0; i<n; i++){
		scanf("%lld", &a[i]);
		min[i]=a[i];
		minnum[i]=i;
		sum=sum+a[i];
	}
	for(int i=1; i<n; i++){
		long long int sum1=0;
		for(int j=0; j<n; j++){
			int j1=j-i;
			if(j1<0) j1=j1+n;
			if(a[j1]<min[j]){
				min[j]=a[j1];
				minnum[j]=j1;
			}
			sum1=sum1+a[minnum[j]];
		}
		sum1=sum1+(long long int)i*x;
		if(sum1<sum) sum=sum1;
	}
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
cL = []
sL = []
fL = []
for i in range(n - 1):
    c, s, f = map(int, input().split(" "))
    cL.append(c)
    sL.append(s)
    fL.append(f)

ans = 0
for i in range(n - 1):
    sm = 0
    for j in range(i, n - 1):
        c = cL[j]
        s = sL[j]
        f = fL[j]
        if sm < s:
            sm = s + c
            continue
        df = f - (sm - s) % f
        if df == f:
            df = 0
        sm += c + df
    print(sm)
print(0)

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

#define NMAX 1000
#define MAX(a, b) (a > b ? a : b)

using namespace std;

//ifstream fin("f.in");
//ofstream fout("f.out");

int nInns;
int height[21];
int currentMax;
int goodInns;

int main()
{
    cin >> nInns;
    for(int i = 0; i < nInns; i++)
        cin >> height[i];
    currentMax = height[0];
    goodInns = 1;

    for(int i = 1; i < nInns; i++)
    {
        if(height[i] >= currentMax)
        {
            goodInns++;
            currentMax = height[i];
        }
    }

    cout << goodInns << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  ll d,g;
  cin >> d >> g;
  vector<ll>P(d),C(d);
  for(int i=0;i<d;i++) cin >> P[i] >> C[i];
  ll ans = INF;
  for(int bit=0;bit<(1<<d);bit++){
    ll sum = 0;
    ll cnt = 0;
    for(int i=0;i<d;i++){
      if(bit & (1<<i)){
        sum += 100*(i+1)*P[i] + C[i];
        cnt += P[i];
      }
    }
    if(sum>=g) ans = min(ans,cnt);
    else{
      for(int i=d-1;i>=0;i--){
        if(bit & (1<<i)) continue;
        for(int j=0;j<P[i];j++){
          if(sum >=g) break;
          sum += 100 * (i+1);
          cnt++;
        }
      }
      ans = min(ans,cnt);
    }
  }
  cout<<  ans <<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

ll fastPow(ll a, ll b) {
	ll ret = 1;
	while(b) {
		if(b & 1) ret = ret * a % MOD;
		b >>= 1, a = a * a % MOD;
	}
	return ret;
}

ll ans[maxN];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	ll n, k;
	cin >> n >> k;

	ll sm = 0;
	for(int i = k; i > 0; i--) {
		ans[i] = fastPow(k / i, n);
		for(int j = i * 2; j <= k; j += i)
			ans[i] = (ans[i] + MOD - ans[j]) % MOD;
		sm = (sm + ans[i] * i) % MOD;
	}
	cout << sm << '\n';
}


Measured memory_bytes: 4404
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <ctime>
 
#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)
 
using namespace std;
 
typedef long long LL;
const int N = 400010;
 
char s0[N];
int len, nxt[N];
 
void get_nxt()
{
	int j = 0;
	for (int i = 2; i <= len; i ++) {
		while (j && s0[i] != s0[j + 1]) j = nxt[j];
		if (s0[i] == s0[j + 1]) j ++;
		nxt[i] = j; 
	}
}
 
LL f[N][30], ans[30];
 
LL calc(int x, LL k, int c)
{
	if (x == 1 || x == 0) {
		int ret = 0;
		Rep(i, k) if (s0[i] - 'a' + 1 == c) ret ++;
		return ret;
	}
	
	if (f[x][0] == k) return f[x][c];
	if (k >= f[x - 1][0])
		return f[x - 1][c] + calc(x - 2, k - f[x - 1][0], c);
	else return calc(x - 1, k, c);
}
 
int main()
{
	scanf("%s", s0 + 1);
	len = strlen(s0 + 1) / 2;
	LL l, r;
	scanf("%lld%lld", &l, &r);
	get_nxt();
	
	Rep(i, len - nxt[len]) f[0][s0[i] - 'a' + 1] ++;
	Rep(i, len) f[1][s0[i] - 'a' + 1] ++;
	f[0][0] = len - nxt[len], f[1][0] = len;
	int x = 2;
	while (true) {
		Rep0(i, 26) f[x][i] = f[x - 1][i] + f[x - 2][i];
		if (f[x][0] >= r) break;
		x ++;
	}

	if (l > 1) Rep0(i, x) if (f[i][0] >= l - 1) {
		Rep(j, 26) ans[j] -= calc(i, l - 1, j);
		break;
	}
 
	Rep0(i, x) if (f[i][0] >= r) {
		Rep(j, 26) ans[j] += calc(i, r, j);
		break;
	}
	Rep(i, 26) printf("%lld ", ans[i]);
	
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<vector<pair<int, int> > > s;
    s.resize(n);
    rep (i, n) {
        int a;
        cin >> a;
        rep (j, a) {
            int x, y;
            cin >> x >> y;
            s[i].push_back(make_pair(x - 1, y));
        }
    }
    int res = 0;
    rep (bit, 1 << n) {
        bool ok = true;
        int cnt = 0;
        vector<bool> honest(n);
        rep (i, n) {
            if (bit & (1 << i)) {
                honest[i] = true;
                cnt++;
            }
        }
        rep (i, n) {
            if (!honest[i]) continue;
            rep (j, s[i].size()) {
                int x, y;
                x = s[i][j].first, y = s[i][j].second;
                if ((honest[x] && y == 0) || (!honest[x] && y == 1)) ok = false;
            }
        }
        if (ok) res = max(res, cnt);
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n, k = MAP()
    H = LIST()
    H.sort(reverse=True)
    print(sum(H[k:]))




if __name__ == "__main__":
    main()

Measured memory_bytes: 27484