akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;


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

	int n, x;
	cin >> n;
	set<int> st;
	forn(i, 0, n){
		cin >> x;
		st.insert(x);
	}
	cout << st.size() << endl;



}




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

namespace Atc_0043
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            var C = int.Parse(Console.ReadLine());
            var D = int.Parse(Console.ReadLine());

            int result = 0;
            if (A <= B)
            {
                result += A;
            }
            else
            {
                result += B;
            }

            if (C <= D)
            {
                result += C;
            }
            else
            {
                result += D;
            }

            Console.WriteLine(result);

        }
    }
}


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

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

  if(N==1){
    cout << "ACL" << endl;
  
  }
  else if(N==2){
  cout << "ACLACL" << endl;
  }
  else if(N==3){
  cout << "ACLACLACL" << endl;
  }
  else if(N==4){
  cout << "ACLACLACLACL" << endl;
  }
  else{
  cout << "ACLACLACLACLACL" << endl;
  }

return 0;  
}

Measured memory_bytes: 3640
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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<set<ll>> dict;
vector<char> S;
ll N, Q;

void query(){
    int type;
    REP(i, Q){
        cin >> type;
        if(type == 1){
            ll i; char c;
            cin >> i >> c;
            i--;

            if (S[i] == c) continue;
            dict[S[i]-'a'].erase(i);
            dict[c- 'a'].insert(i);
            S[i] = c;
        } else{
            ll l, r;
            cin >> l >> r;
            l--; r;

            ll cnt = 0;
            REP(i, 26){
                if (dict[i].empty()) continue;
                auto a = *dict[i].lower_bound(l);
                auto b = *dict[i].lower_bound(r);
                if(b > a) cnt++;
            }

            cout << cnt << endl;

        }

    }
}

int main(){

    string tmp;
    cin >> N;
    cin >> tmp;
    cin >> Q;

    for(char c: tmp){
        S.push_back(c);
    }

    dict.assign(26, set<ll>{1<<30});

    REP(i, N){
        dict[S[i] - 'a'].insert(i);
    }

    query();

    return 0;
}


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

using namespace std;

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


Measured memory_bytes: 3900
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>
#include<limits.h>

using namespace std;



int main() {


	int n;

	cin >> n;

	vector<int> w;
	int sum = 0;
	int wk;
	for (int i = 0; i < n; i++) {
		cin >> wk;
		sum += wk;
		w.push_back(wk);
	}

	int ans = sum;
	int sum2 = 0;
	for (int i = 0; i < n; i++) {
		
		sum -= w[i];
		sum2 += w[i];

		if (abs(sum - sum2) < ans) {
			ans = abs(sum - sum2);
		}
		if (sum2 > sum)break;



	}

	cout << ans << endl;




}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define prDouble(x) cout<<fixed<<setprecision(10)<<x
using namespace std;
double ans(vector<vector<double>> &dp,vector<double>& prob,int n,int k){
    if(k==0){
        return 1.0;
    }
    if(n==0){
        return 0.0;
    }
    if(dp[n][k] > -0.9){
        return dp[n][k];
    }
    return dp[n][k] = (prob[n-1])*ans(dp,prob,n-1,k-1) + (1-prob[n-1])*ans(dp,prob,n-1,k);
    
}
int main() {
	int n;
	cin>>n;
	vector<double> prob(n);
	for(int i=0;i<n;i++){
	    cin>>prob[i];
	}
	int k = n/2 + 1;
	vector<vector<double>> dp(n+1,vector<double>(n+1,-1));
	prDouble(ans(dp,prob,n,k));

}

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

int main() {
	int r,c;
	cin>>r>>c;
	int matrix[r+1][c+1];
	for(int i=0; i<r; i++){
		int sum=0;
		for(int j=0; j<c; j++){
			cin>>matrix[i][j];
			sum+=matrix[i][j];
		}
		matrix[i][c]=sum;
	}
	for(int i=0; i<c+1; i++){
		int sum=0;
		for(int j=0; j<r; j++){
			sum+=matrix[j][i];
		}
		matrix[r][i]=sum;
	}
	for(int i=0; i<r+1; i++){
		for(int j=0; j<c+1; j++){
			cout<<matrix[i][j];
			if(j!=c) cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int H, W;
  string GetPicture;
  cin >> H >> W;
  
  W = W + 2;
  
  
  
 
  
  for (int i = 0; i < W; i++) {
    
    cout << "#";
    
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    
    cin >> GetPicture;
    cout << "#" << GetPicture << "#" << endl;
    
  }
  
  
  
  for (int i = 0; i < W; i++) {
    
    cout << "#";
    
  }
  cout << endl;
  
  
}

Measured memory_bytes: 3600
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
BC = [[int(x) for x in input().split()] for _ in range(M)]
BC = sorted(BC, reverse = True, key = lambda x:x[1])
N2 = N
D = []
for i in BC:
    temp = min(N2,i[0])
    D += [i[1]] * temp
    N2 -= temp
    if not N2:
        break
A += D
A.sort()
print(sum(A[len(A) - N:]))

Measured memory_bytes: 82584
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define rep(I, N) for (int I = 1; I <= (N); ++I)
#define repp(I, N) for (int I = 0; I < (N); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORR(I, A, B) for (int I = (A); I >= (B); I--)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
const int N = 2e5 + 5;
const double eps = 1e-7;
const int mod = 1e9 + 7;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
LL a[N], d[N];
int main() {
    LL n,x;
    cin >> n >> x;
    for (int i = 1;i <= n;i++) cin >> a[i];
    d[1] = 0;
    for (int i = 2;i <= n + 1;i++) 
      d[i] = a[i - 1] + d[i - 1];
    int ans = 0;
    for (int i = 1; i <= n + 1;i ++)
    {
        if(d[i] <= x)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
import java.lang

import scala.collection.mutable.ArrayBuffer
import scala.reflect.ClassTag

object Main {
  def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {
    converter(in.readLine)
  }

  def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {
    get[String].split("\\s+").map[T](converter)
  }

  implicit val idConverter: String => String = s => s
  implicit val intConverter: String => Int = s => Integer.parseInt(s)
  implicit val longConverter: String => Long = s => lang.Long.parseLong(s)

  def get[T1, T2](
                   implicit in: BufferedReader,
                   converter1: String => T1,
                   converter2: String => T2
                 ): (T1, T2) = {
    getArray[String] match {
      case Array(v1, v2) => (converter1(v1), converter2(v2))
    }
  }

  def get[T1, T2, T3](
                       implicit in: BufferedReader,
                       converter1: String => T1,
                       converter2: String => T2,
                       converter3: String => T3
                     ): (T1, T2, T3) = {
    getArray[String] match {
      case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))
    }
  }

  implicit class TimesInt(val n: Int) {
    def times(f: Int => Unit): Unit = {
      for (i <- 0 until n) {
        f(i)
      }
    }
  }

  def primes(n: Long): ArrayBuffer[Long] = {
    val buf = ArrayBuffer.empty[Long]
    val s = Math.sqrt(n).toInt

    var v = n
    for (i <- 2 to s) {
      if (v == 1 || v == 0) {
        return buf
      } else {
        while (v % i == 0) {
          buf.append(i)
          v /= i
        }
      }
    }
    if (v > s) {
      buf.append(v)
    }
    buf
  }

  def main(args: Array[String]): Unit = {
    implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val (x, n) = get[Int, Int]

    if (n == 0) {
      out.println(x)
      out.flush()
      return
    }

    val ps = getArray[Int].sorted

    ps.zipWithIndex.find {
      case (p, i) => p == x
    } match {
      case Some((p, i)) =>
        var d = 1
        while (true) {
          ps.find(_ == x - d) match {
            case Some(p) =>
            case None =>
              out.println(x - d)
              out.flush()
              return
          }
          ps.find(_ == x + d) match {
            case Some(p) =>
            case None =>
              out.println(x + d)
              out.flush()
              return
          }
          d += 1
        }
      case None =>
        out.println(x)
        out.flush()
        return
    }

    out.flush()
  }
}

Measured memory_bytes: 57252
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
using namespace std;
static const int MAX = 100000;

int main()
{

    int n;
    long long int count = 0;
    char c[10];
    long long int D[5];

    int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
    int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
    int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};

    int mnum = 0, anum = 0, rnum = 0, cnum = 0, hnum = 0;

    scanf("%d", &n);

    for (int i = 0; i < n; i++)
    {
        scanf("%s", c);

        if (c[0] == 'M'){ mnum++;}
        if (c[0] == 'A'){ anum++;}
        if (c[0] == 'R'){ rnum++;}
        if (c[0] == 'C'){ cnum++;}
        if (c[0] == 'H'){ hnum++;}
    }
    D[0] = mnum;
    D[1] = anum;
    D[2] = rnum;
    D[3] = cnum;
    D[4] = hnum;

    for (int i = 0; i < 10; i++)
    {
        count += D[P[i]] * D[Q[i]] * D[R[i]];
    }

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

    return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^18 -> 18回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s.at(i);

    map<string, int> words;
    rep(i, n) {
        if(words.count(s.at(i)) == 0) {
            words[s.at(i)] = 1;
        } else {
            words[s.at(i)]++;
        }
    }

    int maxCount = 0;
    for (pair<string, int> word : words) {
        maxCount = max(maxCount, word.second);
    }

    for (pair<string, int> word : words) {
        if(word.second == maxCount) {
            cout << word.first << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 25148
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
int main(){
    string s;
    
    std::cin >> s;
    sort(all(s));
    if(s=="abc")std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
int main() {
	int a, ans = 0, max = 0;
	for (int i = 0; i < 3; i++) {
		cin >> a;
		ans += a;
		if (a > max)
			max = a;
	}
	ans += max * 9;
  cout<<ans<<endl;
}


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

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


Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e4;
int n;
string s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  int ans = 0, _a = 0, b_ = 0, b_a = 0;
  FOR(i, 0, n){
    cin >> s;
    int l = sz(s);
    s = regex_replace(s, regex("AB"), "");
    int l2 = sz(s);
    ans += (l-l2)/2;
    if(s[0]=='B'){
      if(s[sz(s)-1]=='A'){
        b_a++;
      }else{
        b_++;
      }
    }else{
      if(s[sz(s)-1]=='A'){
        _a++;
      }
    }
  }
  if(b_a) ans += b_a-1;
  if(b_a&&_a){
    ans ++;
    _a--;
  }
  if(b_a&&b_){
    ans ++;
    b_--;
  }
  ans += min(_a, b_);
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

ll dp[301][301];

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


	int N, M;
	scanf("%d %d", &N, &M);

	int xm[301][4], xM[301][4];
	rep1(i, N) {
		xm[i][1] = N;
		xm[i][2] = N;
		xM[i][2] = -1;
		xM[i][3] = -1;
	}
	rep(i, M) {
		int l, r, x;
		scanf("%d %d %d", &l, &r, &x);
		chmin(xm[r][x], l);
		chmax(xM[r][x], l);
	}

	const int mod = 1e9 + 7;
	dp[0][0] = 1;
	int mj = 0;
	int mk = 0;
	rep1(i, N) {
		for (int j = i - 1; j >= mj; j--) {
			auto dpj = dp[j];
			for (int k = i - 1; k >= max(j, mk); k--) {
				dpj[i] += dpj[k];
				dp[k][i] += dpj[k];
			}
		}

		for (int j = i; j > xm[i][2]; j--) {
			for (int k = i; k >= max(j, mk); k--) dp[j][k] = 0;
		}
		for (int j = xm[i][2]; j > xM[i][3]; j--) {
			for (int k = i; k > xm[i][1]; k--) dp[j][k] = 0;
			if (i % 3 == 0) {
				for (int k = xm[i][1]; k > xM[i][2]; k--) {
					dp[j][k] %= mod;
				}
			}
			for (int k = xM[i][2]; k >= mk; k--) dp[j][k] = 0;
		}
		for (int j = xM[i][3]; j >= mj; j--) {
			for (int k = i; k >= max(j, mk); k--) dp[j][k] = 0;
		}
		if (mj <= xM[i][3]) mj = xM[i][3] + 1;
		if (mk <= xM[i][2]) mk = xM[i][2] + 1;
	}

	ll kotae = 0;
	rep(j, N + 1) rep(k, N + 1) {
		kotae += dp[j][k] % mod;
	}
	printf("%lld", kotae% mod);

	Would you please return 0;
}

Measured memory_bytes: 896
// {{{ include
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
// }}}

using namespace std;

typedef long long ll;
inline int in(){int x;scanf("%d",&x);return x;}

const int INF = (1 << 29);

int getCoin(int x, int i, int j, int k, int m)
{
  int r = 0;
  while (x >= 500) {
    x -= 500, r++;
    if (i) return INF;
  }
  while (x >= 100) {
    x -= 100, r++;
    if (j) return INF;
  }
  while (x >= 50) {
    x -= 50, r++;
    if (k) return INF;
  }
  while (x >= 10) {
    x -= 10, r++;
    if (m) return INF;
  }
  return r;
}

int main()
{
  int X;
  int F = 0;
  while (X = in()){
    if (F++) printf("\n");
    int c10 = in(), c50 = in(), c100 = in(), c500 = in();
    tuple<int, int, int, int> mini;
    int mini_count = INF;

    for (int i = 0; i <= c500; i++){
      for (int j = 0; j <= c100; j++){
        for (int k = 0; k <= c50; k++){
          for (int m = 0; m <= c10; m++){
            int Y = (500 * i + 100 * j + 50 * k + 10 * m);
            if (Y < X) continue;
            int C = getCoin(Y - X, i, j, k, m) + (c500 - i) + (c100 - j) + (c50 - k) + (c10 - m);
            if (mini_count > C){
              mini_count = C;
              mini = tie(i, j, k, m);
            }
          }
        }
      }
    }
    int output[4];
    output[0] = get<3>(mini);
    output[1] = get<2>(mini);
    output[2] = get<1>(mini);
    output[3] = get<0>(mini);
    const int coin[4] = {10, 50, 100, 500};
    for (int i = 0; i < 4; i++){
      if (output[i] == 0) continue;
      printf("%d %d\n", coin[i], output[i]);
    }
  }

  return 0;
}

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


int main() {
    string s;
    int n,ans=0;
    cin>>n>>s;
    rep(i,n-2){
        if(s.substr(i,3)=="ABC")ans++;
    }
    cout << ans <<endl;
}

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

using namespace std;

const int maxn = 310;
const int mod = 998244353;

char str[maxn];
int a[maxn], s[maxn], m, len, K, ans;
int f[maxn][maxn<<1], g[maxn][maxn<<1], h[maxn][maxn<<1];

int mo(int x) {
	return x >= mod ? (x - mod) : x;
}

int main() {
	scanf("%s", str+1); scanf("%d", &K);
	len = int (strlen (str+1));
	str[len + 1] = '0';
	int c = 0;
	for (int i = 1; i <= len+1; i++) {
		if (str[i] == '0') {
			a[++ m] = c;
			c = 0;
		} else ++ c;
	}
	for (int i = 1; i <= m; i++) s[i] = s[i-1] + a[i];
	f[0][0] = 1;
	for (int i = 1; i <= m; i++) {
		for (int j = 0; j <= s[m]; j++) {
			for (int k = 0; k <= s[m]; k++) {
				if (j) g[j][k] = mo(g[j-1][k] + f[j][k]);
				else g[j][k] = f[j][k];
				if (j && k) {
					h[j][k] = mo(h[j-1][k-1] + f[j][k]);
				} else {
					h[j][k] = f[j][k];
				}
			}
		}
		for (int j = 0; j < s[i]; j++) {
			for (int k = 0; k <= s[m]; k++) {
				f[j][k] = 0;
			}
		}
		for (int j = s[i]; j <= s[m]; j++) {
			for (int k = 0; k <= s[m]; k++) {
				f[j][k] = g[j][k];
				if (j >= a[i]) {
					f[j][k] = mo(f[j][k] + h[j-a[i]][k]);
					f[j][k] = mo(f[j][k] + mod - g[j-a[i]][k]);
				}
			}
		}
	}
	for (int i = 0; i <= min(K, s[m]); i++) ans = mo(ans + f[s[m]][i]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5976
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  int ma=max({a,b,c}),mi=min({a,b,c}),me=a+b+c-ma-mi;
  if((ma-me)%2)mi++;
  if((ma-mi)%2)cout<<(ma-me+1)/2+(ma-mi)/2+2<<endl;
  else cout<<(ma-me+1)/2+(ma-mi)/2<<endl;
}


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

int main() {
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  for(int i=0;i<b;i++){
    for(int j=0;j<w;j++){
      if(j<a)cout<<1;
      else cout<<0;
    }
    cout<<endl;
  }
  for(int i=0;i<h-b;i++){
    for(int j=0;j<w;j++){
      if(j<a)cout<<0;
      else cout<<1;
    }
    cout<<endl;
  }
}


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

int main() {
	string A, B, C; cin >> A >> B >> C;
	char x = 'a';
	while(1){
		if(x == 'a'){
			if(A.empty()){
				cout << 'A' << endl;
				return 0;
			}
			x = *A.begin();
			A.erase(A.begin());
			continue;
		}
		if(x == 'b'){
			if(B.empty()){
				cout << 'B' << endl;
				return 0;
			}
			x = *B.begin();
			B.erase(B.begin());
			continue;
		}
		if(x == 'c'){
			if(C.empty() ){
				cout << 'C' << endl;
				return 0;
			}
			x = *C.begin();
			C.erase(C.begin());
			continue;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <regex>

using namespace std;

int main()
{
  string text, pattern;
  cin >> text >> pattern;

  regex reggie {pattern};
  smatch matches;
  text = text + text;
  if (regex_search(text, matches, reggie)) {
    cout << "Yes\n"; 
  } else cout << "No\n";

}


Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
int b[100];
int main(){
  int n,m;
  cin>>n>>m;
  int a[100];
    for(int i=0;i<m;i++){
    cin>>a[i];
  }
  int cou=0;
  for(int i=0;i<m;i++){
    cou=0;
    for(int j=0;j<n;j++){
      int x;
      cin>>x;
      if(a[i]==x) b[j]++;
      else cou++;
    }
    int x;
    x=a[i];
    b[x-1]+=cou;
  }
  for(int i=0;i<n;i++){
    cout<<b[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3108
M, N = map(int, input().split())
G = "JOI".index
L = [list(map(G, input())) for i in range(M)]
F = [list(map(G, input())), list(map(G, input()))]
f = F[0][0] + F[0][1]*3 + F[1][0]*9 + F[1][1]*27

S = [0, 1]
D = [[-1000]*N for i in range(M)]
res = 0
for i in range(M-1):
    for j in range(N-1):
        r = D[i][j] = L[i][j] + L[i][j+1]*3 + L[i+1][j]*9 + L[i+1][j+1]*27
        if r == f:
            res += 1
ans = res
R = [0, 1, 2]
for i in range(M):
    for j in range(N):
        e = L[i][j]
        a = D[i-1][j-1]; b = D[i-1][j]; c = D[i][j-1]; d = D[i][j]
        C = (a == f) + (b == f) + (c == f) + (d == f)
        cnt = max((a + 27*(p-e) == f) + (b + 9*(p-e) == f) + (c + 3*(p-e) == f) + (d + (p-e) == f) for p in R)
        ans = max(ans, res + (cnt - C))
print(ans)


Measured memory_bytes: 21876
/*Stay true to yourself, yet always be open to learn. Work hard, and never give up on your dreams, 
even when nobody else believes they can come true but you. These are not cliches but real tools you 
need no matter what you do in life to stay focused on your path.
*/
 
 /*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pp          UU      UU     CC          CC           HH     HH     UU      UU
   pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
   */
 
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define ford(i,a,b) for(int i=b;i>=a;i--)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
 int gcd(int a,int b){
 	if(b==0) return a;
 	return gcd(b,a%b);
 }
 

signed main()
{
 
    fast;
  
    double r;
    cin >> r;
    double p = 2*3.14*r;
    cout<<p<<endl;
    
    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
//constexpr auto MAX = 100000;

// ──────────────────────────────────────────────────────────────────

int dp[20001][256];

int main() {
	vi ans;

	while (true) {

		int n, m;
		cin >> n >> m;

		if (!n && !m) break;

		vi c(m), x(n);
		rep(i, m) cin >> c[i];
		rep(i, n) cin >> x[i];

		memset(dp, inf, sizeof(dp));
		dp[0][128] = 0;

		Rep(i, n + 1) {
			rep(j, 256) {
				rep(k, m) {
					if (dp[i][j] == inf) continue;

					int a = j + c[k];

					if (a < 0) a = 0;
					else if (a > 255) a = 255;

					int b = (x[i - 1] - a) * (x[i - 1] - a);

					chmin(dp[i][a], dp[i - 1][j] + b);
				}
			}
		}

		ans.push_back(*min_element(dp[n], dp[n] + 256));
	}
	rep(i, ans.size()) cout << ans[i] << endl;
}


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

int main(int argc, char **argv)
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

    int N; cin >> N;
    long long K; cin >> K;

    vector<long long> A(N), F(N);

    for(auto &a: A) cin >> a;
    for(auto &f: F) cin >> f;

    sort(A.rbegin(), A.rend());
    sort(F.begin(), F.end());

    long long high = A[0]*F.back(), low = -1;

    while(high - low > 1)
    {
        long long required = 0, mid = (high + low)/2;

        for(int i = 0; i < N; ++i) required += max(0LL, A[i] - (mid/F[i]));

        if(required <= K) high = mid;
        else low = mid;
    }
    cout << high << endl;

    return 0;
}

//cikisir



Measured memory_bytes: 3456
n,a,b = map(int,input().split())
m = 10**9+7

def cmb(n,r,m):
    X = Y = 1
    r = min(r,n-r)
    for i in range(1,r+1):
        Y = Y*i%m
        X = X*(n-i+1)%m
    Y = pow(Y,m-2,m)
    return X*Y
print((pow(2,n,m)-1-cmb(n,a,m)-cmb(n,b,m))%m)

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

int main(){
	int N;
	cin >> N;
	int h;
	for(int i=0;i<N;i++){
		int H;
		cin >> H;
		if(i==0)h=H;
		else{
			if(H>h)H--;
			if(H<h){
				cout << "No" << endl;
				return 0;
			}
			else h=H;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

class Tree {
    public:
    struct Node {
        std::vector<int> edge;
        int rank;
        int direction;
    };
    std::vector<Node> node;
    Tree() {}
    Tree(const int node_num_max) {
        node.resize(node_num_max);
    }
    void add_directed_edge(const int from, const int to) {
        node[from].edge.push_back(to);
    }
    void add_undirected_edge(const int node1, const int node2) {
        add_directed_edge(node1, node2);
        add_directed_edge(node2, node1);
    }
};

const int MAX_N = 200050;
Tree tree = Tree(MAX_N);

void set_rank(int n, int rank, int parent, int direction) {
    tree.node[n].rank = rank;
    tree.node[n].direction = direction;

    for (int c : tree.node[n].edge) {
        if (c != parent) {
            set_rank(c, rank + 1, n, direction);
        }
    }
}


int length_of_direction[MAX_N] = {};

int N, a[MAX_N], b[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i < N; i++) {
        std::cin >> a[i] >> b[i];
    }

    if (N == 1) {
        std::cout << "First" << std::endl;
        return 0;
    }

    for (int i = 1; i < N; i++) {
        tree.add_undirected_edge(a[i], b[i]);
    }

    tree.node[1].rank = 0;
    for (int i = 0; i < tree.node[1].edge.size(); i++) {
        set_rank(tree.node[1].edge[i], 1, 1, i);
    }

    int max_tmp = 0;
    int max_idx = 1;
    for (int i = 2; i <= N; i++) {
        if (max_tmp < tree.node[i].rank) {
            max_idx = i;
            max_tmp = tree.node[i].rank;
        }
        //length_of_direction[tree.node[i].direction] = std::max(length_of_direction[tree.node[i].direction], tree.node[i].rank);
        //std::cout << i << " " << tree.node[i].direction << " " << tree.node[i].rank << " " << length_of_direction[tree.node[i].direction] << std::endl;
    }

    tree.node[max_idx].rank = 0;
    for (int i = 0; i < tree.node[max_idx].edge.size(); i++) {
        set_rank(tree.node[max_idx].edge[i], 1, max_idx, i);
    }

    int diameter = 0;
    for (int i = 1; i <= N; i++) {
        diameter = std::max(diameter, tree.node[i].rank);
    }

    if (diameter % 3 == 1) {
        std::cout << "Second" << std::endl;
    } else {
        std::cout << "First" << std::endl;
    }

    return 0;
}



Measured memory_bytes: 26752
package main

import "fmt"

func main() {
	var str1, str2, str3 string
	fmt.Scan(&str1, &str2, &str3)

	fnum := 0
	snum := 0
	for _, str := range []string{str1, str2, str3} {
		if str == "5" {
			fnum++
		} else if str == "7" {
			snum++
		}
	}
	if fnum == 2 && snum == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)







int main(){
    int a, b;
    cin >> a >> b;
    cout << a * b << " " << a * 2 + b * 2 << endl;
}


Measured memory_bytes: 3084
#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>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
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-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int a, b; cin >> a >> b;
    if(a==1)a+=13;if(b==1)b+=13;
	if (a > b)cout << "Alice" << endl;
	else if (a < b)cout << "Bob" << endl;
	else cout << "Draw" << endl;
	stop
	return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()

ls = [0 for i in range(len(S)+1)]
for i in range(1, len(S)):
    if S[i-1] == "A" and S[i] == "C":
        ls[i+1] = ls[i] + 1
    else:
        ls[i+1] = ls[i]

for i in range(Q):
    l, r = map(int, input().split())
    print(ls[r]-ls[l])

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

int main(){
  while(1){
    int count=0;
    int flag[2]={0};
    string str;
    int temp;

    cin>>str;
    
    if(str[0]=='#'){
      str.clear();
      break;
    }

    for(int i=0;i<str.size();i++){
      if(('h'<=str[i] && str[i]<='p') || (str[i]=='u') || (str[i]=='y')){
        if(i>=1){
          flag[0]=flag[1];
        }
        flag[1]=1;
        if(((flag[1]-flag[0])==1) || ((flag[0]-flag[1])==1)){
          count++;
          if(i==0)
            count=0;
        }
      }
      else{
        if(i>=1){
          flag[0]=flag[1];
        }
        flag[1]=0;
        if(((flag[1]-flag[0])==1) || ((flag[0]-flag[1])==1)){
          count++;
          if(i==0)
            count=0;
        }
      }
    }

    cout<<count<<endl;

    str.clear();
  }
}



Measured memory_bytes: 3168
#!/usr/bin/python

import sys

def main(argv):
    line = sys.stdin.readline()
    while line:
        n, a, b = map(lambda x: int(x), line.rstrip("\n").split(" ", 3))
        print(min(n * a, b))
        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 2568
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto X = RD;
	auto Y = RD;
	auto Z = RD;

	writeln(Z, " ", X, " ", Y);
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type AB struct {
	a int
	b int
}

type ABS []AB

func (a ABS) Less(i, j int) bool {
	return a[i].a < a[j].a
}

func (a ABS) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func (a ABS) Len() int {
	return len(a)
}

func main() {
	sc.Split(bufio.ScanWords)
	n, m := nextInt(), nextInt()

	ab := make([]AB, n)
	for i := 0; i < n; i++ {
		ab[i].a, ab[i].b = nextInt(), nextInt()
	}

	sort.Sort(ABS(ab))
	count := 0
	ans := 0
	for i := 0; i < n; i++ {
		if count < m {
			c := min(m-count, ab[i].b)
			ans += ab[i].a * c
			count += c

		}
	}
	fmt.Println(ans)

}

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


Measured memory_bytes: 3840
cards = []
for pic in ['S', 'H', 'C', 'D']:
    for i in range(1, 14):
        cards.append('%s %d' % (pic, i))

c = int(input())
for i in range(c):
    k = input()
    if k in cards:
        del cards[cards.index(k)]

for card in cards:
    print(card)

Measured memory_bytes: 7780
N, M = gets.split.map(&:to_i)
S = []
N.times do
  S << gets.split.map(&:to_i)
end
C = []
M.times do
  C << gets.split.map(&:to_i)
end
S.each do |xs, ys|
  ds = C.map {|xc, yc| (xs - xc).abs + (ys - yc).abs}
  puts ds.index(ds.min) + 1
end


Measured memory_bytes: 1916
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int H1, H2, M1, M2, K;
	int A, B;
	
	cin>>H1>>M1>>H2>>M2>>K;
	
	A = H1 * 60 + M1;
	B = H2 * 60 + M2;
	
	cout<<B - A - K<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint k, q;
    cin >> k >> q;
    vector<lint> d(k);
    for (int i = 0; i < k; ++i) {
        cin >> d[i];
    }
    vector<lint> n(q), x(q), m(q);
    for (int i = 0; i < q; ++i) {
        cin >> n[i] >> x[i] >> m[i];
    }
    for (int i = 0; i < q; ++i) {
        lint x0         = x[i] % m[i];
        vector<lint> d0 = d;
        lint mtot       = 0;
        lint zeros      = 0;
        for (int j = 0; j < k; ++j) {
            d0[j] %= m[i];
            mtot += d0[j];
            if (d0[j] == 0)
                zeros++;
        }
        lint tot = x0 + mtot * ((n[i] - 1) / k);
        lint z   = zeros * ((n[i] - 1) / k);
        for (int j = 0; j < (n[i] - 1) % k; ++j) {
            tot += d0[j];
            if (d0[j] == 0)
                z++;
        }
        lint ret = n[i] - 1 - (tot) / m[i] - z;

        cout << ret << "\n";
    }
    return 0;
}

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

int C[510][510];
bool U[510][510];
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int M = N * N;
    vector<int> P(M);
    for (auto &x: P) cin >> x;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            C[i][j] = min({i-1, j-1, N-i, N-j});
        }
    }
    auto X = [&](auto x) { return (x - 1) / N + 1; };
    auto Y = [&](auto x) { return (x - 1) % N + 1; };    
    
    long long ans = 0;

    auto bfs = [&](int x, int y) {
        ans += C[x][y];
        U[x][y] = 1;
        queue<tuple<int, int, int>> Q;
        Q.emplace(C[x][y]--, x, y);
        while (!Q.empty()) {
            auto [z, x, y] = Q.front(); Q.pop();
            for (int i = 0; i < 4; i++) {
                int xt = x + dx[i], yt = y + dy[i];
                if (z+1 == C[xt][yt]) {
                    Q.emplace(C[xt][yt]--, xt, yt);
                }
                if (U[xt][yt] && z == C[xt][yt]) {
                    Q.emplace(C[xt][yt]--, xt, yt);
                }
            }
        }
    };

    for (int i = 0; i < M; i++) {
        bfs(X(P[i]), Y(P[i]));
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 5568
#include<cstdio>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a==1&&b!=1)
	{
		printf("Alice");
		return 0;
	}
	if(a!=1&&b==1)
	{
		printf("Bob");
		return 0;
	}
	if (a==1&&b==1) 
	{
		printf("Draw");
		return 0;
	}
	if(a!=1&&b!=1)
	{
		if(a==b)
		{
			printf("Draw");
			return 0;
		}
		else 
		{
			if(a<b)
			{
				printf("Bob");
				return 0;
			}
			printf("Alice");
			return 0;
		}
	}
}

Measured memory_bytes: 888
import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val Array(x, y) = readLine.trim.split(' ').map(_.toInt)
  val changers = Array.tabulate(n){_ ⇒
    val Array(a, b, c, d) = readLine.trim.split(' ').map(_.toInt)
    Changer(a, b, c, d)
  }
  val sumC = changers.map{_.c}.sum
  val memo = Array.fill(2){Array.fill(x + 1){Array.fill(changers.map{c ⇒ c.b + c.c}.sum + y + 1){-1L}}}
  memo(0)(x)(y + sumC) = 0L
  for ((changer, i) ← changers.zipWithIndex) {
    for (u ← memo(i%2).indices; f ← memo(i%2)(u).indices; if memo(i%2)(u)(f) != -1L) {
      if (memo((i+1)%2)(u)(f) < memo(i%2)(u)(f)) memo((i+1)%2)(u)(f) = memo(i%2)(u)(f)
      if (u - changer.a >= 0 && memo((i+1)%2)(u - changer.a)(f + changer.b) < memo(i%2)(u)(f)) {
        memo((i+1)%2)(u - changer.a)(f + changer.b) = memo(i%2)(u)(f)
      }
      if (memo((i+1)%2)(u)(f - changer.c) < memo(i%2)(u)(f) + changer.d){
        memo((i+1)%2)(u)(f - changer.c) = memo(i%2)(u)(f) + changer.d
      }
    }
  }
  println(memo(n % 2).map{a ⇒ (sumC until a.length).map(a).max}.max)
  case class Changer(a: Int, b: Int, c: Int, d: Int)
}


Measured memory_bytes: 333248
n, m = map(int, input().split())

a = set()
for i in range(m):
    a_tmp = int(input())  # int(input())
    a.add(a_tmp)

# a = [1 for i in range(m)]

dp = [0] * (n + 1)
for i in range(n + 1):
    if i in a:
        dp[i] = 0
    else:
        if i == 0:
            dp[i] = 1
        elif i == 1:
            dp[i] = 1
        else:
            dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007
print(dp[n])


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

int main(){

    int x;
    cin >> x;

    int i=2;
    int ans=1;
    int num;
    
    while(i*i<=x){
        num=i;
        while(num<=x){
            ans=max(ans,num);
            num*=i;
        }
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int [,,] oh = new int[4, 3, 10];
            for (int i = 0; i < n; i++)
            {
                int[] line = Console.ReadLine()
                    .Split(' ')
                    .Select(x => int.Parse(x))
                    .ToArray();

                int b = line[0] - 1;
                int r = line[1] - 1;
                int v = line[2] - 1;
                oh[b, r, v] += line[3];
            }

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 10; k++)
                        Console.Write(" {0}",oh[i,j,k]);
                    Console.WriteLine();
                }

                if (i != 3)
                    Console.WriteLine("####################");
            }
        }
    }
}

Measured memory_bytes: 9660
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    A=[]
    for i in range(2):
        li=list(map(int,readline().split()))
        A.append(li)
    
    up=[0]*N
    up[0]=A[0][0]
    down=[0]*N
    down[-1]=A[1][-1]
    for i in range(1,N):
        up[i]+=up[i-1]+A[0][i]
    for i in range(N-2,-1,-1):
        down[i]+=down[i+1]+A[1][i]

    res=0
    for i in range(N):
        res=max(res,up[i]+down[i])

    print(res)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 3064