akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <map>
#include <stack>
 
#include <fstream>
 
#define ll long long


#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,st,en) for (int i = st; i <= en; i++)
#define yes cout << "YES\n";
#define no cout << "NO\n";

using namespace std;
 
void file_io()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}
 

void PLAY()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
}

int n,a,b;
string s;


int main() {
    PLAY();

    int n, a, b;
    cin >> n >> a >> b;

    cout << min(n * a, b);

    
    
}
 

 // Traversing a map 
 /*
 for (auto E : mp) {
     // access
     KEY = E.first
     VALUE = E.second

    // edit
    mp[E.first] = ??;

 }
  */

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        char[] s = new char[100000];
        int N = in.read(s, 0, s.length);
        int k = in.i();

        for (int i = 0; i < N; i++) {
            int d = k - 'z' + s[i] - 1;
            if (s[i] != 'a' && d >= 0) {
                s[i] = 'a';
                k = d;
            }
        }
        s[N - 1] += k % 26;

        out.println(new String(s, 0, N));
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

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

	int ans = 0;

	int A = min(a, k);
	k -= A;
	chmax(A, 0ll);
	int B = min(b, k);
	k -= B;
	chmax(B, 0ll);
	int C = min(c, k);
	chmax(C, 0ll);

	cout << A + C * (-1) << endl;

	return 0;
}

Measured memory_bytes: 3584
s = input()
cnt = 0
if(s[:1] == '0'):
  for i in range(len(s) // 2):
    if(s[2*i+1:2*i+2] == '0'):
      cnt += 1
    if(s[2*i+2:2*i+3] == '1'):
      cnt += 1
else:
  for i in range(len(s) // 2):
    if(s[2*i+1:2*i+2] == '1'):
      cnt += 1
    if(s[2*i+2:2*i+3] == '0'):
      cnt += 1  
print(cnt)

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

auto clk=clock();
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define Mod 1000000007
#define REP(i,a,b) for (int i = a; i <= b; i++)

bool comp(string s1,string s2){
    return (s1+s2<=s2+s1);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,l; cin>>n>>l;
    vector<string>v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++) cout<<v[i];
    cerr<<"\n"<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>

class Process {
public:
  std::string name;
  int time;
  Process(std::string n, int t): name(n), time(t) {};
};

int main() {
  int n, q;
  std::cin >> n >> q;
  std::queue<Process*> ps;
  for (int i = 0; i < n; ++i) {
    std::string name;
    int time;
    std::cin >> name >> time; 
    ps.push(new Process(name, time));
  }
  int time = 0;
  while (ps.size() > 0) {
    Process* p = ps.front(); ps.pop();
    time += (p->time > q) ? q : p->time;
    p->time -= q;
    if (p->time <= 0)
      std::cout << p->name << " " << time << std::endl;
    else
      ps.push(p);
  }
}

Measured memory_bytes: 7464
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int h[n];
  for(int i=0;i<n;i++)cin>>h[i];
  int ans=0,max=1;
  for(int i=0;i<n;i++){
    if(h[i]>=max){
      max=h[i];
      ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

const int64_t kMod = 1000000007LL;
// const int64_t kMod = 998244353LL;
struct Mint {
  int64_t value;
  Mint(int64_t value = 0LL) : value((value % kMod + kMod) % kMod) {}
  Mint operator-() const {
    return Mint(-value);
  }
  Mint &operator+=(const Mint rhs) {
    if ((value += rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator-=(const Mint rhs) {
    if ((value += kMod - rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator*=(const Mint rhs) {
    (value *= rhs.value) %= kMod;
    return *this;
  }
  Mint operator+(const Mint rhs) const {
    return Mint(*this) += rhs;
  }
  Mint operator-(const Mint rhs) const {
    return Mint(*this) -= rhs;
  }
  Mint operator*(const Mint rhs) const {
    return Mint(*this) *= rhs;
  }
  Mint Pow(int64_t p) const {
    if (p == 0LL) {
      return 1LL;
    } else if (p < 0LL) {
      return Pow(-p).Pow(kMod - 2LL);
    }
    Mint temp = Pow(p >> 1LL);
    temp *= temp;
    if (p & 1LL) {
      temp *= (*this);
    }
    return temp;
  }
  Mint Inv() const {
    return Pow(kMod - 2LL);
  }
  Mint &operator/=(const Mint a) {
    return *this *= a.Inv();
  }
  Mint operator/(const Mint a) const {
    return Mint(*this) /= a;
  }
};
std::ostream &operator<<(std::ostream &os, const Mint &a) {
  os << a.value;
  return os;
}

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

  int64_t N;
  cin >> N;
  for (int64_t h = 1; h <= 3500; ++h) {
    for (int64_t n = 1; n <= 3500; ++n) {
      const int64_t w = (Mint(4 * h * n - N * (h + n) + kMod).Inv() * h * n * N).value;
      if (h * n * w * 4 == N * (n * w + h * w + h * n)) {
        cout << h << " " << n << " " << w << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3676
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, s: str):
    r = 0
    for c in s:
        if c == 'R':
            r += 1
    if r * 2 > N:
        ret = YES
    else:
        ret = NO
    print(ret)
    return


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
    s = next(tokens)  # type: str
    solve(N, s)

if __name__ == '__main__':
    main()


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

lis=[]
hantei = True
for _ in range(N):
    s = False
    for j,k in enumerate(b[::-1]):
        if len(b)-j== k:
            lis.append(b.pop(len(b)-j-1))
            s =True
            break
    if not s:
        hantei =False

lis = [str(i)for i in lis]

if hantei:
    for i in lis[::-1]:
        print(i)
else:
    print(-1)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main( void )
{
	int t = 0;
	int h = 0;
	while ( !cin.eof() )
	{
		int a, b, c;
		char d, e;
		cin >> a >> d >> b >> e >> c;
		if ( cin.eof() )
			break;

		if ( a * a + b * b == c * c )
			t++;
		else if ( a == b )
			h++;
	}

	cout << t << endl;
	cout << h << endl;
	
	return 0;
}

Measured memory_bytes: 0
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<string> s(N);
    vector<ll> num(5);
    string x = "MARCH";
    rep(0, i, N)
    {
        cin >> s.at(i);
        rep(0, j, 5)
        {
            if (s.at(i).at(0) == x.at(j))
            {
                num.at(j)++;
            }
        }
    }

    ll ans = 0;
    rep(0, i, 5)
    {
        rep(i + 1, j, 5)
        {
            rep(j + 1, k, 5)
            {
                ans += num.at(i) * num.at(j) * num.at(k);
            }
        }
    }

    cout << ans << endl;
}

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

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  int count = 0;
  while(x > 0){
    if(count == 0){
      x -= y+2*z;
      count++;
    }
    x -= y+z;
    if(x >= 0){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
function Main(input) {
  var input = input.split(" ");
  var a = parseInt(input[0]);
  var b = parseInt(input[1]);
  var c = parseInt(input[2]);
  var d = parseInt(input[3]);
  var e = a + b;
  var f = c + d;
  if (e > f) {
    result = 'Left';
  } else if (f > e) {
    result = 'Right';
  } else {
    result = 'Balanced';
  }
  console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.Scanner;

/**
 * https://abc063.contest.atcoder.jp/tasks/abc063_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		
		String ans = a+b < 10 ? String.valueOf(a+b) : "error";
		System.out.println(ans);
	}
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

int n,k,q,t;
vector<int> a;
vector<int> b;

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

  vector<int> a(n);
  vector<int> b(n,k-q);

  for(int i = 0; i < q; ++i){
    cin >> t;
    b[t-1]++;
  }

  for(int i = 0; i < n; ++i){
    if(b[i]<=0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <map>
#include <set>
#include <cstring>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
 
 vector<int>aminai;
 vector<int>pb;
 vector<int>fuckoff;
 vector<int>life;
 vector<char>who;
 
int main(){
	string s,ss;
	cin>>s>>ss;
	if(s>ss) cout<<">"<<endl;
	else if(s<ss) cout<<"<"<<endl;
	else cout<<"="<<endl;
//	cerr<<"time elapsed: "<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<"\n";
	return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    int A,B;
    cin>>A>>B;
    cout<<(A-1)*(B-1)<<endl;
}


Measured memory_bytes: 3576
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    n, c, k = ns()
    t = [ni() for _ in range(n)]
    t.sort()

    ans = 0
    idx = 0
    while True:
        ans += 1

        k_idx = bisect.bisect_right(t, t[idx] + k)
        c_idx = idx + c

        idx = min(k_idx, c_idx)
        if idx > n-1:
            break

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9552
n = gets.chomp.to_i
b = gets.chomp.split(" ").map{|i|i = i.to_i}

sum = b[0]
(n-2).times{|i|
  if(b[i] <= b[i+1])then
    sum+= b[i]
  else
    sum+= b[i+1]
  end
}
sum += b[n-2]
puts sum



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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

double dp[3000][3000];

int main(){

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

    int n;
    cin >> n;

    vector<double> p(n);
    rep(i, n){
        cin >> p[i];
    }

    dp[0][0] = 1.0;

    for(int i = 0; i < n; ++i){
        for(int j = 0; j <= i; ++j){
            dp[i+1][j+1] += dp[i][j]*p[i];
            dp[i+1][j] += dp[i][j]*(1.0-p[i]);
        }
    }

    double ans = 0.0;
    for(int i = n/2+1; i <= n; ++i){
        ans += dp[n][i];
    }
    cout << setprecision(10) << fixed << ans << endl;



    return 0;
}


Measured memory_bytes: 68992
import bisect

N = int(input())
A = [-int(input()) for i in range(N)]
X = []
for i in range(N):
    a = A[i]
    idx = bisect.bisect_left(X, a+0.1)
    if idx == len(X):
        X.append(a)
    else:
        X[idx] = a
print(len(X))

Measured memory_bytes: 55896
let input = readLine()!
let splitInput = input.split(separator: " ")
var n = Int(splitInput[0])!
var k = Int(splitInput[1])!

var rest = n % k

if rest == 0 {
    print(0)
} else {
    rest -= k
    if rest < 0 {
        rest *= -1
    }

    if n < rest {
        rest = n
    }
    print(rest)
}


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

#define ntest 0

using namespace std;
string ans[10];
int n;
void solve() {
    ans[2] = ans[4] = ans[5] = ans[7] = ans[9] = "hon";
    ans[0] = ans[1] = ans[6] = ans[8] = "pon";
    ans[3] = "bon";
    cin >> n;
    cout << ans[n%10];
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    if(ntest){
        int t;
        cin >> t;
        while(t--) solve();
    } else {
        solve();
    }

}




Measured memory_bytes: 3636
import java.util.Scanner;

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

		int n = sc.nextInt(), k = sc.nextInt();
		
		String ans = "NO";
		
		if (n % 2 == 0) {
			if (n / 2 >= k) {
				ans = "YES";
			}
		} else if (n / 2 + 1 >= k) {
			ans = "YES";
		}
		
		System.out.println(ans);
		
		sc.close();
	}

}

Measured memory_bytes: 22740
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,a) for(int i=0;i<a;i++)
#define RREP(i,a) for(int i=a;i>=0;i--)

int main()
{
	long long k,sum,nagasa=0,nagasamax;
	int n,joi[65001],pipe[65000];

	cin>>n;
	while(n!=0){
		REP(i,n){
			cin>>pipe[i];
			nagasa+=pipe[i];
		}
		REP(i,n-1){
			cin>>joi[i];
		}
		sort(joi,joi+n-1);
		nagasamax=nagasa;
		sum=n;
		RREP(i,n-2){
			if(nagasamax*sum<(nagasamax+joi[i])*(i+1)){
				nagasamax=nagasamax+joi[i];
				sum=i+1;
			}

		}
		cout<<nagasamax*sum<<endl;
		cin>>n;
		nagasa=0;
	}
}

Measured memory_bytes: 1676
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;


#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll h;cin>>h;
  ll num[1000010];
  ll ans=0;

  while(h){
    h/=2;
    ans++;
  }
  ll res=1;
  rep(i,0,ans){
    res*=2;
  }
  out(res-1);



  // num[0]=0;
  // num[1]=1;
  // num[2]=3;
  // // num[3]=3;

  // rep(i,3,1000010){
  //   num[i]=2*num[i/2]+1;
  // }

  // // out(num[h/2]*2+1);

  // rep(i,0,20){
  //   cout<<i<<":"<<num[i]<<endl;
  // }


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define MOD 2019LL
typedef long long LL;
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const LL LLINF = 1000000000;

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

	string S;
	cin >> S;

	int ans = 0;
	for (int i = 0; i < S.size(); i++)
	{
		set<char> left;
		set<char> right;

		for (int j = 0; j < i; j++)
		{
			left.insert(S[j]);
		}

		for (int j = i; j < S.size(); j++)
		{
			right.insert(S[j]);
		}

		int count = 0;
		for (char v:left)
		{
			if (right.find(v) != end(right)) {
				count++;
			}
		}

		chmax(ans,count);
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))
A = [(a-1) % K for a in A]
S = [0 for i in range(N+1)]
for i in range(1, N+1):
	S[i] = (S[i-1] + A[i-1]) % K

kinds = set(S)
counts = {}
ans = 0
for k in kinds:
	counts[k] = 0
for i in range(N+1):
	counts[S[i]] += 1
	if i >= K:
		counts[S[i-K]] -= 1
	ans += (counts[S[i]] - 1)
print(ans)

Measured memory_bytes: 52004
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
    int n, k; cin >> n >> k;
    vector<int> hs(n);
    for(int i=0; i<n; ++i){
        cin >> hs[i];
    }
    sort(hs.rbegin(), hs.rend());
    long long ans=0;
    for(int i=k; i<n; ++i){
        ans+=hs[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

N = int(input())
D = list(map(int,input().split()))
D = sorted(D)
left = D[int(N/2)-1]
right = D[int(N/2)]
if left == right:
    print(0)
else:
    print(right-left)


Measured memory_bytes: 15536
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define llinf LONG_LONG_MAX
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rrep(i,a,b) for(i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define pf push_front
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
const ll mod=1000000007;
 
using namespace std;


void solve(){
    ll n, x, i, prob = 0;
    cin >> n;
    
    vector<ll>p;
    vector<ll>p1;
    
    rep(i, 0, n-1){
    	cin >> x;
    	p.pb(x);
    	p1.pb(x);
    }
    
    sort(all(p1));
    
    rep(i, 0, n-1){
    	if(p1[i] != p[i])
    	prob++;
    }
    
    if(prob <= 2){
    	cout << "YES" << endl;
    }
    
    else{
    	cout << "NO" << endl;
    }
    
    
    
    
    
    
   }
 
int main() {
   solve();
   }
 
 
 
 

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
 
N , M = (int(a) for a in input().split())
stair = [1]
brake = []
for i in range(0, N + 1):
    brake.append(False)
for i in range(1 , M+1) :
    a = int(input())
    brake[a] = True

for i in range(1, N+1) :
    if brake[i] :
        stair.append(0)
    elif i == 1 : 
        stair.append(1) 
    else : stair.append((stair[i-1] + stair[i-2]) % (10**9+7))
         
print(stair[N])

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

int main() {
    string S;
    cin >> S;
    int num_x = 0;
    for (int i=0; i<S.size(); ++i) {
        if (S[i] == 'x') {
            num_x++;
        }
    }
    cout << (num_x >= 8 ? "NO" : "YES") << endl;
    return 0;
}

Measured memory_bytes: 384
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var S = inputStr[0];
  //文字列を,で分割して配列化し、その配列をJOINで結合して結果とする。
  var tmp = S.split(",");
  console.log(tmp.join(" "));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
/*"-Aria on the Planetes-"*/
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double D;
typedef pair<int,int> Pii;
#define mp(a,b) make_pair(a,b)
#define fir first
#define sec second
inline int min(int _a,int _b){return _a<_b?_a:_b;}
inline int max(int _a,int _b){return _a>_b?_a:_b;}
template<class _T>inline void rd(_T &_a){int _f=0,_ch=getchar();_a=0;while(_ch<'0' || _ch>'9'){if(_ch=='-')_f=1;_ch=getchar();}while(_ch>='0' && _ch<='9')_a=(_a<<1)+(_a<<3)+_ch-'0',_ch=getchar();if(_f)_a=-_a;}
const int inf=0x3f3f3f3f;
const D eps=1e-8;
const int N=1e5+5;
int a[N],b[N];
int main(){
	//clock_t start=clock();
	//freopen("test.in","r",stdin);
	//freopen("test.out","w",stdout);
	int n,ans=0;rd(n);
	for(int i=1;i<=n;i++)rd(a[i]),a[i]+=a[i-1];
	for(int i=1;i<=n;i++)rd(b[i]);for(int i=n;i;i--)b[i]+=b[i+1];
	for(int i=1;i<=n;i++)ans=max(ans,a[i]+b[i]);
	printf("%d",ans);
	//printf("\n%dms",(int)((double)(clock()-start)/CLOCKS_PER_SEC*1000));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#define N 8
#define FREE -1
#define NOT_FREE 1
using namespace std;
int k;
bool X[N][N];
char m[N][N];
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

void init(){
  for(int i=0;i<N;i++){row[i]=FREE;col[i]=FREE;}
  for(int i=0;i<2*N-1;i++){dpos[i]=FREE;dneg[i]=FREE;}
}

void printBoard(){
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(X[i][j]){
	if(row[i]!=j)return ;
      }
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cout << ( (row[i]==j)?"Q":".");
    }
    cout << endl;
  }
}

void rec(int i){
  if(i==N){
    printBoard();
    return ;
  }
  for(int j=0;j<N;j++){
    if(NOT_FREE==col[j] ||
       NOT_FREE==dpos[i+j] ||
       NOT_FREE==dneg[i-j+N-1])continue;
    row[i]=j;col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;

    rec(i+1);
    row[i]=j;col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

int main(){
  init();
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      X[i][j]=false;
  
  cin >> k;
  for(int i=0;i<k;i++){
    int r,c;
    cin >> r >> c;
    X[r][c]=true;
  }

  rec(0);
  
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int gcd(int a,int b) {
  return (b? gcd(b,a%b):a);
}

int main(){
  int k;
  cin>>k;
  ll ans=0;
  rep(i,k) rep(j,k) rep(l,k){
    ans+=gcd(gcd(i+1,j+1),l+1);
  }
  cout<<ans<<endl;
  return 0;
}


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

#define FOR(i,a,n) for (int i = a; i < n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = long long;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  int a, b, c; cin >> a >> b >> c;
  if (a%2 == 0 && a == b && b == c) {
    cout << -1 << endl;
    return 0;
  }
  int ans = 0;
  while (a%2 == 0 && b%2 == 0 && c%2 == 0) {
    ans++;
    int na = (b+c)/2;
    int nb = (c+a)/2;
    int nc = (a+b)/2;
    a = na;
    b = nb;
    c = nc;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(raw_input())
M=map(int,raw_input().split())

while min(M) != sum(M):
    M.sort()
    m =  M[0]
#    print M, m, sum(M)
    for i, a in enumerate(M):
        if i == 0:
            continue
        else:
            M[i] = a % m
            
#        print M, min(M), sum(M), "end"

#    print M, min(M), sum(M), "e"
    M = [i for i in M if i != 0]
#    print M, min(M), sum(M), "N"

print sum(M)


Measured memory_bytes: 11296
#

import sys
from math import ceil
input=sys.stdin.readline

def main():
    t=[int(input()) for i in range(5)]
    tp10=[t[i]%10 for i in range(5) if t[i]%10!=0]
    ans=0
    for i in range(5):
        ans+=ceil(t[i]/10)*10
    if len(tp10)>0:
      	print(ans-10+min(tp10))
    else:
      	print(ans)
    
if __name__=="__main__":
    main()


Measured memory_bytes: 3060
s=[int(x) for x in reversed(list(input()))]
n=len(s)
x=[0]*2019
dp = 0
dim = 1
for si in s:
  dp = (dp + si*dim) % 2019
  x[dp] += 1
  dim = dim * 10 % 2019
ans = x[0]
for i in range(2019):
  ans += x[i]*(x[i]-1)//2
print(ans)

Measured memory_bytes: 12140
#!/usr/bin/env python3
import sys


def main():

    n, k = map(int, input().split())    

    if n < k:
        print(min(n,abs(n-k)))
        sys.exit(0)
    if n % k == 0:
        print(0)
        sys.exit(0)
    
    print(min(abs(n%k-k),n%k))


main()


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

const int N = 220000;

char str[N];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	cin >> str;
	int len = strlen(str);
	for (int i = 0; i < len; i++) cout << ((str[i] == '?') ? 'D' : str[i]);
	cout << "\n";
	
	return 0;
}


Measured memory_bytes: 3808
from sys import exit
import math
import collections
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

w,h,x,y = mi()
ans = w * h / 2
check = 0
if x == w / 2 and y == h / 2:
    check = 1

print('{} {}'.format(ans,check))

Measured memory_bytes: 9388
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define ld long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
#define MOD 1000000007
#define INF 1000000000000000007LL


const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int h1, m1, h2, m2, k; cin>>h1>>m1>>h2>>m2>>k;
    int v1 = h1*60+m1;
    int v2 = h2*60+m2;
    int ans = v2-v1-k;
    cout<<ans;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(i64 i = 0; i < N; i++)
#define Rep(i, k, N) for(i64 i = k; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    i64 A, B;
    cin >> A >> B;
    cout << A * B << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s;
    cin >> s;
    int h=0,t=s.length();
    for (int i=0;i<s.length();i++){
	if (s[i] == 'A'){
	    h=i;
	    break;
	}
    }
    for (int i=(s.length()-1);i>0;i--){
	if (s[i] == 'Z'){
	    t=i;
	    break;
	}
    }

    cout << t-h+1 << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include<set>
using namespace std;
long long int mpown(long long int m, int n);
long long int bign=1000000007;
int bitCount(int bits);
int main()
{
    long long int r,d,x;
    cin >> r >> d>> x;
    for(int i=0;i<10;i++){
        x=r*x-d;
        cout << x << endl;
    }
    return 0;
}

int bitCount(int bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); //  2bitごとに計算
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); //  4bitごとに計算
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); //  8bitごとに計算
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); //  16ビットごとに計算
    return (bits & 0x0000ffff) + (bits >> 16);             //  32ビット分を計算
}
long long int mpown(long long int m, int n)
{
    if (n == 0)
        return 1;
    else if (n == 1)
        return m;
    else
    {
        long long int temp = mpown(m, n / 2);
        return temp * temp * (n & 1 ? m : 1);
    }
}

Measured memory_bytes: 3128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N = 100000;
  vi primes(N + 1, 1);
  //素数ふるい
  for(int i=2; i <= sqrt(N) + 1; i++) {
    int k = i * 2;
    while(k <= N) {
      primes[k] = 0;
      k += i;
    }
  }
  
  vi hurui(N + 1, 0);
  //さらに落とす
  for(int i=2; i<=N; i++) {
    if(i%2==1 && primes[i] && primes[(i+1)/2]) {
      hurui[i] = 1;
    }
  }
  
  vi acc(N + 1);
  int ct = 0;
  for(int i=2; i <= N; i++) {
    if(hurui[i]) {
      ct ++;
    }
    
    acc[i] = ct;
  }
  
  int Q;
  cin >> Q;
  rep(i, Q) {
    int l, r;
    cin >> l >> r;
    //素数
    int ans = acc[r] - acc[l - 1];
    fin(ans); 
  }
}

Measured memory_bytes: 1792
n,k = list(map(int, input().split()))
r,s,p = list(map(int, input().split()))
t = input()

counter = 0
flag = -1

for i in range(k):
    flag = -1
    for j in range(i,n,k):
        if flag != 0 and t[j] == "r":
            flag = 0
            counter += p
            #print(counter,i,j,t[j])

        elif flag != 1 and t[j] == "s":
            flag = 1
            counter += r
            #print(counter,i,j,t[j])
            

        elif flag != 2 and t[j] == "p":
            flag = 2
            counter += s
            #print(counter,i,j,t[j])

        else:
            flag = -1

print(counter)

Measured memory_bytes: 42736
#include <bits/stdc++.h>
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define foreach(i, vec) for(auto &&i : vec)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#if ONLINE_JUDGE
#define debug(x)
#else
#define debug(x) cerr << #x << ": " << (x) << endl
#endif
using namespace std;
typedef long long LL;
typedef long long int64;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
template<class T,class U>bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>void vcin(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;
// M_PI 3.1415...
int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cill(n);
    cill(k);
    LL ans = 0;
    LL min = 0;
    LL max = 0;
    rep(j, k-1){
        min += j;
        max += n - j;
    }
    for (LL i = k; i <= n+1; ++i) {
        min += i-1;
        max += n-(i-1);
        if (min > max){
            continue;
        }
        ans += max - min + 1;
        ans = ans % MOD;
    }
    debug(ans);
    co(ans);
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<int>;


const ll MAX = 200005;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

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()
{
	ll N, M, K;
	cin >> N >> M >> K;

	COMinit();
	ll ans = 0;
	
	ll C = COM(N*M - 2, K - 2);

	for (int x = 1; x <= N; ++x)for (int y = 1; y <= M; ++y)
	{
		ll tmp = (((-x)*((N - x) - (x - 1))*M) % MOD)*C % MOD;
		ans += tmp + MOD;
		ans %= MOD;
		tmp = (((-y)*((M - y) - (y - 1))*N) % MOD)*C % MOD;
		ans += tmp + MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#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>
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-3;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int n; ll a[400];
ll s[401];
bool chked[400][400];
ll ans[400][400];
ll dfs(int le, int ri) {
	if (le == ri)return 0;
	if (chked[le][ri])return ans[le][ri];
	chked[le][ri] = true;
	ll res = INF;
	Rep(i, le, ri) {
		ll sum = dfs(le, i) + dfs(i + 1, ri);
		res = min(res, sum);
	}
	res += s[ri + 1] - s[le];
	return ans[le][ri] = res;
}

int main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	s[0] = 0;
	rep(i, n)s[i + 1] = s[i] + a[i];
	cout << dfs(0, n - 1) << endl;
	//stop
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 28)

template<typename T>
void remove(vector<T>& vector, unsigned int index){
vector.erase(vector.begin() + index);
}

typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

string s[] = {"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};

int main(void){
	int n;
	cin >> n;
	rep(k,n){
		string L;
		cin >> L;
		int count = 0;
		for(int i = 0; i < L.size(); i++){
			if(L[i] == '0'){
				if(count == 0)continue;
				int type = L[i-1]-'0';
				if(L[i-1] != '0')cout << s[type][(count-1)%s[type].size()];
				count = 0;
				continue;
			}
			count++;
		}
		cout << endl;
	}
	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int ll;
#define ull unsigned long long int
#define all(a) a.begin(),a.end()s
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define hell 1000000007
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define pb push_back
#define MAX 10000001
int main()
{
  ll a,b;
  cin>>a>>b;
  cout<<a*b<<endl;
}

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

struct Card {
    char suit;
    char value;
};

void bubble(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        for (int j = N - 1; j >  i; j--) {
            if (A[j].value < A[j - 1].value) {
                Card temp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = temp;
            }
        }
    }
}

void selection(struct Card A[], int N) {
    int minj;
    for (int i = 0; i < N; i++) {
        minj = i;
        for (int j = i + 1; j < N; j++) {
            if (A[j].value < A[minj].value) {
                minj = j;
            }
        }
        if (minj != i) {
            Card temp = A[minj];
            A[minj] = A[i];
            A[i] = temp;
        }
    }
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for (int i = 0; i < N; i++) {
        if (C1[i].suit != C2[i].suit) {
            return false;
        }
    }
    return true;
}

int main(int argc, char const *argv[])
{
    struct Card C1[100];
    struct Card C2[100];
    int N;

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> C1[i].suit >> C1[i].value;
        C2[i].suit = C1[i].suit;
        C2[i].value = C1[i].value;
    }

    bubble(C1, N);
    selection(C2, N);

    for (int i = 0; i < N; i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << C1[i].suit << C1[i].value;
    }
    cout << endl;
    cout << "Stable" << endl;
    for (int i = 0; i < N; i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << C2[i].suit << C2[i].value;
    }
    cout << endl;
    if (isStable(C1, C2, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main(){
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    if(N>=M){
        cout << 0 << endl;
        return 0;
    }
    vi X(M), D(M-1);
    for (auto &i : X){
        cin >> i;
    }
    sort(X.begin(), X.end());
    for(int i=1;i<M;i++){
        D[i-1] = X[i]-X[i-1];
    }
    sort(D.begin(), D.end(), greater<int>());
    cout << accumulate(D.begin()+N-1, D.end(), 0) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
  int n,k;
  cin>>n>>k;
  long long data[n+1];
  long long answer[n+1];
  for(int i=1;i<=n;i++)
  {
      cin>>data[i];
  }

  for(int i=1;i<=n-k;i++)
   {
      if(data[i+k]>data[i])
      cout<<"Yes";
      else
      cout<<"No";
      cout<<endl;
   }

}


Measured memory_bytes: 4684
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, M, X = MAP()
CA = [LIST() for _ in range(N)]

ans = INF
for x in product([0, 1], repeat=N):
	#print(x)
	s = np.zeros((M,))
	tmp = 0
	for i in range(N):
		if x[i]:
			C, *A = CA[i]
			#print(C)
			#print(A)
			tmp += C
			#print(np.array(A))
			s += np.array(A)
			#print(s)
	s = s.tolist()
	#print("s={}".format(s))
	#print(skill, cost)
	if all(p >= X for p in s):
		ans = min(ans, tmp)

print(ans if ans != INF else -1)


Measured memory_bytes: 27272
#include <iostream>

using namespace std::literals;

namespace abc086
{
	namespace task_A
	{
		struct PairIntegers
		{
			private: unsigned int a;
			private: unsigned int b;

			private: unsigned int Product (/* no argument */)
			{
				return (this->a) * (this->b);
			}

			private: bool IsProductEven (/* No argument */)
			{
				return (this->Product() % 2U) == 0U;
			}

			public: void cin (/* No argument */)
			{
				std::cin >> this->a >> this->b;
			}

			public: void Answerer (/* No argument */)
			{
				if   ( this->IsProductEven() ) std::cout << "Even"s;
				else                           std::cout << "Odd"s;

				std::cout << "\n"s;
			}
		};
	} // namespace task_A
	
} // namespace abc086


int main (void)
{
	// variables for main process
	abc086::task_A::PairIntegers given_data;

	// STEP.01
	// read out the given data
	given_data.cin();

	// STEP.02
	// output the answer of this task
	given_data.Answerer();

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 256