akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#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 FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int k[150];

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    string s;
    bool letter = true;
    while (cin >> s) {
        int n = s.size();
        int cnt = 0;
        if (s[0] != 'A') 
            letter = false;
        if (s[1] == 'C' || s[n-1] == 'C')
            letter = false;
        if (s[1] == 'A' || s[n-1] == 'A')
            letter = false;
        FOR(i,2,n)
            if (s[i] == 'C')
                cnt++;
        if (cnt != 1)
            letter = false;
        FOR(j,1,n+1) {
            FOR(ascii, 68, 91){
                char c = ascii;
                if (s[j] == c || s[j] == 'B') {
                    letter = false;
                }
            }
        }
        if (letter)
            cout << "AC" << endl;
        else
            cout << "WA" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int am,pm;
	string c;
	for(int i=0; i<9; i++){
		cin >> c >> am >> pm;
		if( (c.size() < 1 && c.size() > 15 ) || am > 400 || pm > 400) return 0;
		cout << c << " " << am+pm  << " " << 200*am+300*pm << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#include <cassert>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
#define vi vector<int>
using namespace std;
using ll = long long;

// ----ここから下は以前競プロをやっていた時に使っていたものです----　

const int MAX = 1000000;

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

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

struct s{
  int p,i,r;
};

//比較関数（降順）
bool cmpP(const s &a, const s &b){
  return a.p > b.p;
}

//比較関数（昇順）
bool cmpI(const s &a, const s &b){
  return a.i < b.i;
}

// ----本問について----
// 問題：最長共通部分列
// 問題文URL：https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_10_C
// 所要時間：30分
// 学んだこと：自分のやってることがDPなのかメモ化再帰（？）なのかよくわからない
// ------------------

// ----ここから本問のソースコード----

// グローバル変数（入力）
ll q, L[1010][1010];
string X,Y;

ll solve(ll i, ll j) {
  if (L[i][j] != -1){return L[i][j];}

  if (i == 0 || j == 0){L[i][j]=0;}
  else if (X[i-1]==Y[j-1]){L[i][j]=solve(i-1,j-1)+1;}
  else {L[i][j]=max(solve(i-1, j), solve(i, j-1));}

  return L[i][j];
}

int main()
{
  //cout << fixed << setprecision(10);
  cin >> q;
  rep(ii,q){
    cin >> X;
    cin >> Y;
    ll x=X.size();
    ll y=Y.size();
    rep(i, 1010){
      rep(j, 1010){
        L[i][j]=-1;
      }
    }
    cout << solve(x, y) << endl;
  }

  return 0;
}



Measured memory_bytes: 11200
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  ll ans = 0;
  for (ll i = 0; i < N - 1; ++i) {
    if (A.at(i + 1) <= A.at(i)) {
      ans += -A.at(i + 1) + A.at(i);
    }
    A.at(i + 1) = max(A.at(i  + 1), A.at(i));
  }
  cout << ans << "\n";
}


Measured memory_bytes: 4784
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
#include <vector>

#define INPUT_FROM_FILE (0)
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif
	int n = 0;

#if INPUT_FROM_FILE
	while(ifs >> n, n != 0){
#else
	while(std::cin >> n, n != 0){
#endif
		double mean = 0;
		double sigma2 = 0;
		std::vector<int> s(n, 0);

		for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
			ifs >> s[i]; 
#else
			std::cin >> s[i]; 
#endif
			mean += s[i];
		}
		mean /= n;

		for(int i = 0; i < n; i++){
			sigma2 += pow(s[i] - mean, 2);
		}
		sigma2 /= n;
		std::cout << std::fixed << std::setprecision(5) << sqrt(sigma2) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3224
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

string s;
vector<string> list;

int solve(vector<bool> used, int k, string t) {
	if (k == s.size()) {
		list.push_back(t);
		return 1;
	}

	int m = s[k] - 'a';

	int res = 0;
	if (m == 0 || used[m]) {
		t.push_back('a' + m);
		res += solve(used, k + 1, t);
		t.pop_back();
	}
	if (m != 'z' - 'a' && !used[m+1]) {
		used[m + 1] = true;
		t.push_back('a' + m + 1);
		res += solve(used, k + 1, t);
	}
	return res;
}

int main() {
	while (true) {
		cin >> s;
		if (s == "#")break;
		vector<bool> u(27, false);
		int ans = solve(u, 0, "");
		cout << ans << endl;
		sort(list.begin(), list.end());
		if (ans <= 10) {
			for (int i = 0; i < ans; i++) {
				cout << list[i] << endl;
			}
		}
		else {
			for (int i = 0; i < 5; i++) {
				cout << list[i] << endl;
			}
			for (int i = 5; i > 0; i--) {
				cout << list[ans-i] << endl;
			}

		}
		list.clear();
	}
	return 0;
	/*
	文字列が20文字以下なので変換される文字列の数は高々2^20=10^6である(実際にはもっと少ない)
	なので全探索して候補をすべて配列に保持しても大丈夫。
	変換したかどうかのusedだけから候補となる文字列を生成しようとすると
	どの'a'を変換するのかわからない(aは変換したりしなかったりする)ので失敗する。
	なのでその都度文字をpush
	最後にsortして出力
	*/
}


Measured memory_bytes: 4376
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using std::cout;
using std::cin;
using std::endl;
using std::pow;
using std::vector;
using std::string;

int fun(int x,int y,int z){
    return x*x+y*y+z*z+x*y+y*z+z*x;
}

int main(){
    int N,i,j,k;
    cin >> N;
    vector<int> a(100000);
    i=1;
    j=1;
    k=1;
    while(fun(i,j,k) <= N){
        while(j<=i && fun(i,j,k) <= N){
            while(k<=j && fun(i,j,k) <= N){
                if(i == j && j == k){
                    a.at(fun(i,j,k))++;
                }else if(i == j || j == k || k == i){
                    a.at(fun(i,j,k)) += 3;
                }else{
                    a.at(fun(i,j,k)) += 6;
                }
                k++;
            }
            j++;
            k=1;
        }
        i++;
        j=1;
    }
    for(i=1;i<=N;i++) cout << a.at(i) << endl;
}

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

using namespace std;

typedef long long ll;

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	cout << min(a, b) + min(c, d) << endl;

}


Measured memory_bytes: 256
n, m = map(int, input().split())
*a, = map(int, input().split())
ans = ''
j = sum(a) / (4 * m)
a.sort()
a.reverse()
#print(a[:m])
cnt = 0
for i in a[:m]:
    if i >= j:
        cnt += 1
    
#print(cnt)
if cnt < m:
    ans = 'No'
else:
    ans = 'Yes'
print(ans)

Measured memory_bytes: 3060
#include <map>
#include <set>
#include <list>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
using namespace std;
int main ( ) {
	string s;
	int i,l;
	cin>>s;
	l=s.length();
	for (i=1;i<l;i++) {
		if (s[i-1]=='A' && s[i]=='C') {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define ub upper_bound
#define lb lower_bound
#define pii pair<int,int>
using namespace std;
signed main()
{
    fast;
    int n,k;
    cin>>n>>k;
    ld ans = 0;
    ld p[n+1];
    for(int i=1;i<=n;i++)
    	cin>>p[i];
    ld temp = 0;
    for(int i=1;i<=k;i++){
    	temp+=(((ld)1/p[i])*((p[i]*(p[i]+(ld)1))/(ld)2));
    }
    ans = max(ans,temp);
    for(int i = k+1;i<=n;i++){
    	int idx = i-k;
    	ld sub = (((ld)1/p[idx])*((p[idx]*(p[idx]+(ld)1))/(ld)2));
    	ld add = (((ld)1/p[i])*((p[i]*(p[i]+(ld)1))/(ld)2));
    	temp+=add;
    	temp-=sub;
    	ans = max(ans,temp);
    }
    cout<<fixed<<setprecision(10)<<ans;
}   

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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define sortv(v) sort(v.begin(),v.end());
#define sorta(a,n) sort(a,a+n);
#define arrayin(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define arrayout(a,n) for(int i=0;i<n;i++) cout<<" ";cout<<"\n";
#define whatIs(x) cout<<#x<<" is "<<x<<endl;
#define fillA(a,value) memset(a,value,sizeof(a));
#define len(s) s.length()
#define reached cout<<"reached "<<endl;
#define INF INT_MAX //Infinity
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define MOD 1000000007
#define fi first
#define se second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vi64 vector<lli>
#define viii vector<tuple<int,int,int>>
#define prq priority_queue<int>
#define mii map<int,int>
#define msi multiset<int>
#define nl "\n"
#define sii set<int,int>
#define sz size

typedef long long int lli;
typedef unsigned long long int ulli;
typedef double ld;

using namespace std;

int main()
{
	fio;
	/*int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
	}*/
	int n,k;
	cin>>n>>k;
	int x[n];
	REP(i,n) cin>>x[i];
	int ans=0;
	REP(i,n)
	{
		ans+=(2*min(x[i],k-x[i]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const long double EPS = 1e-9;

int main()
{
	int N;
	const int M = 256;
	while (cin >> N, N) {
		int ansS, ansA, ansC;
		long double min_H = INT_MAX;
		vi I(N+1);
		REP(i, N) {
			cin >> I[i+1];
		}
		REP(S, 16) {
			REP(A, 16) {
				REP(C, 16) {
					vi R(N+1);
					R[0] = S;
					FOR(i, 1, N+1) {
						R[i] = (A * R[i-1] + C) % M;
					}

					vi O(N+1);
					map<int, int> X;
					FOR(i, 1, N+1) {
						O[i] = (I[i] + R[i]) % M;
						if(EXIST(X, O[i])) {
							X[O[i]]++;
						} else {
							X[O[i]] = 1;
						}
					}

					long double H = 0;
					for (map<int, int>::iterator itr = X.begin(); itr != X.end(); ++itr) {
						long double t = (itr->second / (long double)N);
						H -= t * log(t);
					}

					if(H < min_H - EPS) {
						min_H = H;
						ansS = S, ansA = A, ansC = C;
					}
				}
			}
		}
		cout << ansS << " " << ansA << " " << ansC << endl;
	}
}

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

int main() {
    int A,B,K,buf;
    vector<int> ans;
    cin >> A >> B >> K;
    int a=min(A,B);
    if(A==1){
        cout << 1 << endl;
        return 0;
    }
    for(int i=1;i<=a;i++){
        if(A%i==0&&B%i==0){
            ans.push_back(i);
        }
    }
    reverse(ans.begin(),ans.end());
    cout << ans.at(K-1) << endl;
}

Measured memory_bytes: 3580
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, A):

    sa = [0]
    sa0 = [0]
    for a in A:
        sa.append(sa[-1]+a)
        sa0.append(sa0[-1]+max(0, a))

    ans = 0
    for i in range(N-K+1):
        l = sa0[i]
        r = sa0[-1] - sa0[i+K]
        c = sa[i+K] - sa[i]
        ans = max(ans, l + r)
        ans = max(ans, l + c + r)

    return ans


def main():
    N, K = read_int_n()
    A = read_int_n()
    print(slv(N, K, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 20104
//https://blog.csdn.net/hesorchen
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define endl "\n"
#define INF 0x3f3f3f3f
#define MAX 2710
#define mod 1000000007
#define PI 3.1415926

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    ll sum = 1;
    while (n > 0)
    {
        ans += sum;
        n /= 2;
        sum*=2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N;
    string S;
    ll left[26], right[26];
    cin>>N>>S;
    ll Maxim=0;
    rep(i, N){
        MEMSET(left, 0);
        MEMSET(right, 0);
        rep(j, i+1){
            left[S[j]-'a']++;
        }
        reps(j, i+1, N){
            right[S[j]-'a']++;
        }
        ll count=0;
        rep(j, 26){
            if(left[j]!=0 && right[j]!=0) count++;
        }
        Maxim=max(Maxim, count);
    }
    cout<<Maxim<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;

int h , w , ans , p=0;
char grid[1005][1005];
queue <int> cx;
queue <int> cy;
int main(){
	
	cin>>h>>w;
	for (int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>grid[i][j];
			if (grid[i][j]=='#'){
				p++;
				cx.push(i);
				cy.push(j);
			}
		}
	}
	for (int i=0;i<=h+1;i++){
		for(int j=0;j<=w+1;j++){
			if (grid[i][j]!='.' && grid[i][j]!='#'){
				grid[i][j] = '#';
			}
//			cout<<grid[i][j];
		}
//		cout<<endl;
	}
//	cout<<endl;
	int a , b , c;
	int dx[5] = {0,0,1,-1};
	int dy[5] = {1,-1,0,0};
	c = p;
	while (p!=h*w){
		ans++;
		c = cx.size();
		while(c!=0){
			a = cx.front();
			b = cy.front();
			for(int i=0;i<=3;i++){
				if (grid[a+dx[i]][b+dy[i]] == '.') {
					p++;
					grid[a+dx[i]][b+dy[i]] = '#';
					cx.push(a+dx[i]);
					cy.push(b+dy[i]);
				}
			}
			cx.pop();
			cy.pop();
			c--;
		}
			
//		for(int i=1;i<=h;i++){
//			for(int j=1;j<=w;j++){
//				cout<<grid[i][j];
//			}
//			cout<<endl;
//		}
//		cout<<endl;
	}

	cout<<ans<<endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	FOR(i,S.size()) if(i%2==0) cout<<S[i];
	cout<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 592
d = int(input())
c = list(map(int,input().split()))
like=0
but=0
s=[]
last=[]
for i in range(26):
    last.append(0)
for i in range(d):
    keys=list(map(int,input().split()))
    s.append(keys)
for i in range(d):
    print(s[i].index(max(s[i]))+1)

Measured memory_bytes: 9508
from collections import Counter

N, M = map(int, input().split())
A = [int(i) for i in input().split()]

for i in range(1, N) :
    A[i] += A[i-1]
for i in range(N) :
    A[i] %= M
    
c = Counter(Counter(A + [0]).values())

ret = 0
for i, v in c.items() :
    if i < 2 :
        continue
    
    ret += v * i * (i - 1) // 2
    
print(ret)

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

const int inf = -1000;

int main() {

    ll l,r;
    cin>>l>>r;

    if((l-1)/2019!=r/2019){
        cout<<"0";
        return 0;

    }
    l= l%2019;
    r = r%2019;
    ll ans  = 2018 ;
    for(ll i=l;i<=r;++i){
        for(ll j=i+1;j<=r;++j)
            ans = min(ans,(i*j)%2019);
    }
    cout<<ans;
    return 0;
      }


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

int main(void){
    string W;
    cin>>W;
    vector<string> T(99999);
    for(int i=0;i<99999;i++){
        cin>>T.at(i);
        if(T.at(i)=="END_OF_TEXT")break;
            for(int j=0;j<T.at(i).size();j++){
            if('A'<=T.at(i).at(j) && T.at(i).at(j)<='Z')T.at(i).at(j)+='a'-'A';
            }
        
    }
    int cnt=0;
    
    for(int i=0;i<W.size();i++){
        if('A'<=W.at(i) && W.at(i)<='Z')W.at(i)+='a'-'A';
    }
    for(int i=0;i<99999;i++){
        if(T.at(i)==W)cnt++;
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 3676
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i = 0 ; i < VMAX ; i++) C[i] = 0;

  for(j = 1 ; j <= n ; j++){
    scanf("%hd",&A[j]);
    C[A[j]]++;
  }

for(i = 1 ; i <= VMAX ; i++){
  C[i] = C[i] + C[i - 1];
}
for (j = n; j > 0; j--) {
  B[C[A[j]]] = A[j];
  C[A[j]]--;
}
for(i = 1; i < n ; i++){
  printf("%d ",B[i]);
}
printf("%d\n",B[i]);

  return 0;
}



Measured memory_bytes: 9628
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pque;
    for(int i=0; i<N; i++){
        int A;
        cin >> A;
        pque.push(make_pair(A,i));
    }

    int ans=0;
    for(int i=0; i<N; i++){
        int j=pque.top().second;
        pque.pop();
        if((i%2) ^ (j%2)){
            ans++;
        }
    }

    cout << ans/2 << endl;

}

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

int main()
{
    long long int n;
    cin >> n;
    vector<pair<int, int>> A(n);
    for(int i=0; i<n; i++)
        cin >> A[i].first, 
        A[i].second = i+1;

    sort(A.begin(), A.end());

    for(int i=0; i<n; i++)
    {
        cout << A[i].second << " ";
    }

    cout << endl;


    return 0;
}


Measured memory_bytes: 3980
#include <iostream>
#include <cstring>

int main(){
	int r, c;
	std::cin >> r >> c;
	int table[r+1][c+1];
	memset(table, 0, sizeof(int)*(r+1)*(c+1));
	
	for(int i=0; i<r; i++)
		for(int j=0; j<c; j++)
			std::cin >> table[i][j];
	
	for(int i=0; i<r; i++)
		for(int j=0; j<c; j++)
			table[i][c] += table[i][j];
	for(int i=0; i<r; i++)
		for(int j=0; j<c; j++)
			table[r][j] += table[i][j];
	for(int i=0; i<r; i++)
		table[r][c] += table[i][c];
	
	for(int i=0; i<r+1; i++){
		for(int j=0; j<c+1; j++){
			std::cout << table[i][j];
			if(j<c)
				std::cout << ' ';
		}
		std::cout << std::endl;
	}
	return 0;
}

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


namespace Test1 {

    


    class ClassMain {

       
        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int n = ints[0]; int m = ints[1];
                if (n == 0) { break; }
                int[] anke = new int[m];
                for (int i = 0; i < n; i++) {
                    ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    for (int j = 0; j < m; j++) {
                        anke[j] += ints[j];
                    }
                }

                int cnt=0;
                while (cnt!=m) {
                    int maxAnk = -1;
                    int maxInd = -1;
                    for (int i = 0; i < m; i++) {
                        if (maxAnk < anke[i]) {
                            maxAnk = anke[i];
                            maxInd = i;
                        }
                    }
                    anke[maxInd] = -1;
                    Console.Write(maxInd+1);
                    if (cnt != m - 1) { Console.Write(" "); }
                    cnt++;
                }
                Console.WriteLine();
            }
        }

        
    }



    
}

Measured memory_bytes: 6148
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int mod = 1000000007;
signed main(){
	int n;cin >> n;
	string s;cin >> s;
	int ret = 1;
	vector<int> cnt(26);
	rep(i,n){
		cnt[(int)(s[i] - 'a')]++;
	}
	rep(i,26){
		ret = (ret*(cnt[i]+1))%mod;
	}
	cout << (ret-1+mod)%mod << endl;

	return 0;
}

Measured memory_bytes: 3728
#include<iostream>
using namespace std;
int main() {
    int h, w;
    while (1){
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                cout << "#";
                if (j == w-1) {
                    cout << endl;
                }
            }
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int n,m;
    cin >> n >> m;
    cout << ((n <= m/2) ? (n + m/2) / 2 : m / 2) << '\n';
    return 0;
}


Measured memory_bytes: 256
n,x = map(int,input().split())
a_inputs = sorted([int(i) for i in input().split()])

ans=0
if sum(a_inputs)<x:
    ans=n-1
else:
    while a_inputs:
        a = a_inputs.pop(0)
        if a<=x:
            x-=a
            ans+=1
        else:
            break
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using large = long long;

int main() {
    auto s = vector<char>();
    auto t = vector<char>();
    {
        string raw_s, raw_t;
        cin >> raw_s >> raw_t;

        auto present_s = vector<int>(26);
        auto present_t = vector<int>(26);

        s.resize(raw_s.length());
        t.resize(raw_t.length());

        for (int i = 0; i < raw_s.length(); i++) {
            s[i] = raw_s[i] - 'a';
            present_s[s[i]]++;
        }
        for (int i = 0; i < raw_t.length(); i++) {
            t[i] = raw_t[i] - 'a';
            present_t[t[i]]++;
        }

        for (int c = 0; c < 26; c++) {
            if (present_t[c] && !present_s[c]) {
                cout << "-1" << endl;
                return 0;
            }
        }
    }
    const auto s_len = s.size();
    const auto t_len = t.size();

    auto jump_table = vector<vector<int>>(26);
    auto first_found_pos = vector<int>(26, -1);
    {
        for (auto &x : jump_table) {
            x.resize(s_len, -1);
        }

        auto last_found_pos = vector<int>(26, -1);
        for (int i = 0; i < s.size(); i++) {
            auto c = s[i];
            if (first_found_pos[c] < 0) {
                first_found_pos[c] = i;
                for (int j = 0; j < i; j++)
                    jump_table[c][j] = i;
            } else {
                for (int j = last_found_pos[c]; j < i; j++)
                    jump_table[c][j] = i;
            }
            last_found_pos[c] = i;
        }
        for (int c = 0; c < 26; c++) {
            if (last_found_pos[c] < 0)
                continue;
            for (int j = last_found_pos[c]; j < s_len; j++)
                jump_table[c][j] = first_found_pos[c];
        }
    }

#if 0
    {
        int index = 0;
        for (auto &j : jump_table) {
            cerr << (char)(index++ + 'a') << " >> ";
            for (auto i : j) {
                cerr << i << ", ";
            }
            cerr << "\n";
        }
    }
#endif

    auto wrapcount = large(0);
    auto pos = first_found_pos[t[0]];
    for (int i = 1; i < t_len; i++) {
        auto c = t[i];
        auto jump_to = jump_table[c][pos];
        if (jump_to <= pos)
            wrapcount++;
        pos = jump_to;
    }

    cout << (wrapcount * s_len) + pos + 1;
    return 0;
fail:
    cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 10880
#include<iostream>
#define N 10
using namespace std;
typedef long long LL;
LL a[N+1];
int n;
LL eval(int mask)
{
	LL ans = 0;

	LL curr = a[0];
	for(int i = 0; i < n-1; i++)
		if(mask&(1<<i))
			curr = 10LL*curr+a[i+1];
		else
			ans += curr, curr = a[i+1];
	return ans + curr;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	string s; cin >> s;
	n = s.length();
	for(int i = 0; i < n; i++)
		a[i] = s[i]-'0';

	LL ans = 0;
	for(int mask = 0; mask < (1<<(n-1)); mask++)
		ans += eval(mask);
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    vector<ll> rt, rt_odd;
    rt.push_back(1);
    rt_odd.push_back(1);

    for(int i = 4; i <= 1000; ++i){
        ll s = i * rt.back() / (i-3);
        rt.push_back(s);
    }

    ll rt_len = rt.size();

    //dp[i][0] : 正四面体数でiを作る最小値
    //dp[i][1] : 奇数の正四面体数i作る最小値
    vector<vector<ll>> dp(1000001, vector<ll>(2));
    rep(i, 1000001){
        dp[i][0] = INF;
        dp[i][1] = INF;
    }

    dp[0][0] = 0;
    dp[0][1] = 0;
    rep(i, 1000001)rep(j, rt_len){
        if(rt[j] <= i){
            dp[i][0] = min(dp[i][0], dp[i-rt[j]][0]+1);

            if(rt[j] & 1){
                dp[i][1] = min(dp[i][1], dp[i-rt[j]][1]+1);
            }
        }
    }

    ll n;
    vector<pll> ans;
    while(cin >> n, n != 0){
        cout << dp[n][0] << " " << dp[n][1] << endl;
        // ans.push_back(make_pair(dp[n][0], dp[n][1]));
    }

    // rep(i, ans.size())cout << ans[i].first << ", " << ans[i].second << endl;
}


Measured memory_bytes: 57240
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	class arrow {
		LinkedList<Integer> from = new LinkedList<Integer>();
	}

	void run() {
		for (;;) {
			int n = sc.nextInt();
			int a = sc.nextInt();
			int s = sc.nextInt();
			int g = sc.nextInt();
			if ((n | a | s | g) == 0) {
				break;
			}
			int[] x = new int[a];
			int[] y = new int[a];
			String[] lab = new String[a];
			for (int i = 0; i < a; i++) {
				x[i] = sc.nextInt();
				y[i] = sc.nextInt();
				lab[i] = sc.next();
			}
			String[][] dp = new String[n][n * 6+241];
			boolean[][] visited = new boolean[n][n * 6+241];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n * 6; j++) {
					dp[i][j] = "";
				}
			}
			visited[s][0] = true;
			for (int i = 0; i < n * 6+241; i++) {
				for (int st = 0; st < n; st++) {
					for (int k = 0; k < a; k++) {
						if (st == x[k]) {
							if (i - lab[k].length() < 0)
								continue;
							if (!visited[x[k]][i - lab[k].length()]) {
								continue;
							}
							if(!visited[y[k]][i]){
								dp[y[k]][i] = dp[x[k]][i - lab[k].length()]
														+ lab[k];	
								visited[y[k]][i] = true;
							}
							if (dp[y[k]][i].compareTo(dp[x[k]][i
									- lab[k].length()]
									+ lab[k]) > 0) {
								dp[y[k]][i] = dp[x[k]][i - lab[k].length()]
										+ lab[k];
							}
						}
					}
				}
			}
			String min = "";
			boolean f = false;
			for (int j = 0; j < n * 6+241; j++) {
				if (visited[g][j]) {
					if (!f) {
						min = dp[g][j];
						f = true;
					}
					if (min.compareTo(dp[g][j]) > 0) {
						min = dp[g][j] ;

						if(j >= n*6){
							f = false;
							break;
						}
					}
				}
			}
			if (!f) {
				System.out.println("NO");
			} else {
				System.out.println(min);
			}
		}

	}

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

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

int h1, w1, h2, w2, dis;
string block[4][65];
string board[65];
string cp[65];
int H[4], W[4];

bool check(int &y, int &x){
  return (0<=y&&y<h2&&0<=x&&x<w2);
}

int y, x, idx;

int sim(){
  
  for(int i=0;i<h1;i++){
    for(int j=0;j<w1;j++){
      
      int py=y+i, px=x+j;
      
      if(block[idx][i][j]=='.') continue;      
      if(!check(py,px)&&block[idx][i][j]=='#') return 0;
      if(!check(py,px)) continue;
      if(board[py][px]=='#') return 0;
      
      board[py][px]='#';
    }
  }
  
  dis=1;
  
  int res=0;
  
  for(int i=0;i<h2;i++){
    
    int flag=1;
    
    for(int j=0;j<w2;j++)
      if(board[i][j]=='.'){
	flag=0;
	break;
      }
    
    res+=flag;
  }
 
  return res;
}

void solve(){
  
  int ans=0;
  
  dis=0;
  
  for(int k=0;k<4;k++){
    
    h1=H[k], w1=W[k];
    
    for(int i=-h1+1;i<h2;i++)
      for(int j=-w1+1;j<w2;j++){
	y=i, x=j, idx=k;
	ans=max(ans, sim());
	for(int l=0;l<h2;l++) board[l]=cp[l];
      }
  }
  
  if(!dis) ans=-1;
  
  cout<<ans<<endl;
  
}

void init(){
  
  H[0]=H[2]=h1;
  H[1]=H[3]=w1;
  W[0]=W[2]=w1;
  W[1]=W[3]=h1;
  
  for(int j=0;j<w1;j++)
    for(int i=h1-1;i>=0;i--) block[1][j]+=block[0][i][j];
  
  for(int i=h1-1;i>=0;i--)
    for(int j=w1-1;j>=0;j--) block[2][h1-i-1]+=block[0][i][j];
  
  for(int j=w1-1;j>=0;j--)
    for(int i=0;i<h1;i++) block[3][w1-j-1]+=block[0][i][j];
  
}

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

  while(t--){

    cin>>h1>>w1;
    for(int i=0;i<h1;i++) cin>>block[0][i];
    
    init();
        
    cin>>h2>>w2;
    for(int i=0;i<h2;i++){
      cin>>board[i];
      cp[i]=board[i];
    }
    
    solve();
    
    for(int i=0;i<4;i++)
      for(int j=0;j<65;j++) block[i][j]="";
    
  }
  
  return 0;
}

Measured memory_bytes: 3208
using System;
using System.Linq;

class MainClass
{
    public static void Main(string[] args)
    {
        var input1 = Console.ReadLine().Split(' ');

        var N = int.Parse(input1[0]);

        var K = int.Parse(input1[1]);

        var input2 = Console.ReadLine().Split(' ');

        var heightList = input2.Select(x => int.Parse(x));

        var count = heightList.Count(x => x >= K);

        Console.WriteLine(count);
    }
}



Measured memory_bytes: 15328
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    string s; cin >> s;

    if(s=="SUN"){
        cout << 7 << endl;
    } else if (s=="MON"){
        cout << 6 << endl;
    } else if (s=="TUE"){
        cout << 5 << endl;
    } else if (s=="WED"){
        cout << 4 << endl;        
    } else if (s=="THU"){
        cout << 3 << endl;
    } else if (s=="FRI"){
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>

int main(){
    double x1,y1,x2,y2;
    //double dis;

    std::cin>>x1>>y1>>x2>>y2;
    
    double xp= std::pow(x2-x1, 2);
    double yp= std::pow(y2-y1, 2);
    
    std::cout<<std::fixed<<std::setprecision(4)<<std::sqrt(xp+yp) <<std::endl;

    return 0;
}


Measured memory_bytes: 3292
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100

ll N;
ll divs = 0;
vector<int> v;

void gen_primes() {
  v.push_back(2),v.push_back(3);
  for (int i = 4; i < 1000; ++i) {
    bool flag = true;
    for (int j = 2; j < i; ++j) {
      if (i % j == 0) {
        flag = false;
        break;
      }
    }
    if (flag) v.push_back(i);
  }
}

int main() {
  cin >> N;
  gen_primes();
  vector<int> d;

  for (auto itr = v.begin(); itr != v.end(); itr++) {
    int t = *itr;
    int tt = 0;

    while (t <= N) {
      tt += N / t;
      t *= *itr;
    }

    if (tt != 0){
      d.push_back(++tt);
    }
  }

  ll ans = 1;
  const long MOD = 1000000007;

  for (auto itr = d.begin(); itr != d.end(); ++itr) {
    ans *= *itr;
    ans %= MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
string = input()
a_idx = 10e9
z_idx = 0
for i, char in enumerate(string):
    if (char == "A") & (i < a_idx):
        a_idx = i
    if (char == "Z") & (i > z_idx):
        z_idx = i

print(z_idx - a_idx + 1)

Measured memory_bytes: 3516
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    String s = scan.next();
    System.out.println(s.substring(0, k - 1) + s.substring(k - 1, k).toLowerCase() + s.substring(k));
  }
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define FORE(i,a,b) for (int i=(int)(a);i<=(int)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define REPE(i,n) FOR(i,0,n)

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

int main() {
  int N,K;cin>>N>>K;
  // 全部0か、半分か
  // N以下の自然数で、modKが0もしくはK/2のものを取得する。
  // modが0同士、半分があるなら半分同士で３条する和
  int zero_cnt = N/K;
  if (K%2==0) {
    int half_cnt = (N-K*(N/K) >= K/2) ? N/K+1 : N/K;
    cout << (ll)(pow(zero_cnt,3)+pow(half_cnt,3));
  } else {
    cout << (ll)pow(zero_cnt,3);
  }

  return 0;
}

Measured memory_bytes: 256
while 1:
    n=input()
    if n==0:break
    t=[map(int,raw_input().split()) for i in [1]*n]
    t=sorted(sorted(sorted(t),key=lambda x:x[3])[::-1],key=lambda x:x[2])[::-1]
    u=[0 for i in range(1001)]
    s=0
    for i in t:
    	if (s<10 and u[i[1]]<3) or (s<20 and u[i[1]]<2) or (s<26 and u[i[1]]<1):
    		print i[0]
    		u[i[1]]+=1
    		s+=1
    

Measured memory_bytes: 4284
#![allow(unused_imports)]
use proconio::input;
use std::cmp;

#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        ABC: [[i64; 3]; N],
    }

    let mut dp = vec![[0; 3]; N + 1];

    for i in 1..=N {
        let a = &ABC[i - 1];
        for j in 0..3 {
            dp[i][j] = cmp::max(dp[i - 1][(j + 1) % 3] + a[j], dp[i - 1][(j + 2) % 3] + a[j]);
        }
    }
    println!("{}", dp[N].iter().max().unwrap());
}


Measured memory_bytes: 11564
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;

	vector<int> x(N), y(M);
	for (int i = 0; i < N; i++) cin >> x.at(i);
	for (int i = 0; i < M; i++) cin >> y.at(i);
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());

	int L, R;
	L = x.back() + 1;
	R = y.front();

	for (int i = L; i <= R; i++) {
		if ((i > X) && (i <= Y)) {
			cout << "No War" << endl;
			return 0;
		}
	}
	cout << "War" << endl;
}

Measured memory_bytes: 3608
c = int(input())
values = [input() for i in range(c)]
count = {}
keys = ['AC', 'WA', 'TLE', 'RE']
for key in keys:
        count[key] = 0

for value in values:
        count[value] = count[value] + 1

for key in keys:
        print(key + ' x ' + str(count[key]))

Measured memory_bytes: 16108
#include<stdio.h>
 
int main(void) {
  char s[100000];
  int i, a, b;
 
  scanf("%s", s);
 
  for( i=0; s[i]=='1' || s[i]=='0'; i++ ) {
    if(s[i]=='0') {
      a = a + 1;
    }
    else if(s[i]=='1') {
      b = b + 1;
    }
  }  
    if(a > b) printf("%d\n", b*2);
    else printf("%d\n", a*2);
 
    return 0;
}

Measured memory_bytes: 256
from math import factorial as fact
def comb(n, r):
  if n<=r: return fact(n)//fact(r)
  else: return fact(n)//(fact(r)*fact(n-r))

def main():
    n, k = map(int, input().split())
    for i in range(k): print((comb(n-k+1, i+1) * comb(k-1, i)) % 1000000007)

if __name__=="__main__": main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[200005];
int dp[200005];
int main(){
	scanf("%d",&n);
	repn(i,n) scanf("%d",&a[i]);
	int ans = 0;
	repn(i,n){
		dp[a[i]] = max(dp[a[i]],dp[a[i]-1]+1);
		ans = max(ans,dp[a[i]]);
	}
	cout<<n-ans<<endl;
}

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

using namespace std;

typedef long long ll;

const ll c = 1e9 + 7;

ll bin_pow(ll a, ll b) {
	if (b == 1) {
		return a % c;
	} else {
		if (b % 2 == 0) {
			ll d = bin_pow(a, b / 2) % c;
			return (d * d) % c;
		} else {
			ll d = bin_pow(a, b - 1) % c;
			return (a * d) % c;
		}
	}
}

ll calc(ll a, ll n) {
	ll res = 1;
	for (ll i = n - a + 1; i<=n; i++) {
		res *= i;
		res %= c;
	}
	ll val = 1;
	for (ll i = 1; i <= a; i++) {
		val *= i;
		val %= c;
	}
	val = bin_pow(val, c - 2);
	return (res * val) % c;
}

int main() {
	#ifdef HOME
		freopen("input.txt", "rt", stdin);
	#endif
	ll n, a, b;
	cin >> n >> a >> b;
	/*cout << (bin_pow(2, n) - calc(a, n) - calc(b, n) + 2 * c - 1) % c;
	return 0;*/
	ll ans = bin_pow(2, n);
	ans += 2 * c;
	ans = ans + c -	calc(a, n);
	ans %= c;
	ans = ans - calc(b, n);
	cout << (ans - 1 + c) % c;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=405,mod=998244353;
int n,a[N],f[N][N],g[N][N],h[N],len[N],idn,tf[N],tg[N],C[N][N],pw[N];

void modify(int x,int y){
	for(int i=0;i<=len[x]+len[y];i++) tf[i]=tg[i]=0;
	for(int i=0;i<=len[x];i++) for(int j=0;j<=len[y];j++){
		tf[i+j]=(1ll*f[x][i]*f[y][j]+tf[i+j])%mod;
		tg[i+j]=(1ll*g[x][i]*g[y][j]+tg[i+j])%mod;
	}
	len[x]+=len[y];
	for(int i=0;i<=len[x];i++) f[x][i]=tf[i],g[x][i]=tg[i];
}

int dico(int l,int r,int last){
	if(l>r) return 0;
	int mid=l;
	for(int i=l+1;i<=r;i++) if(h[i]<h[mid]) mid=i;
	int x=++idn,lc=dico(l,mid-1,h[mid]),rc=dico(mid+1,r,h[mid]);
	f[x][0]=g[x][0]=len[x]=1;
	if(lc) modify(x,lc);
	if(rc) modify(x,rc);
	int len=::len[x];
	for(int i=1;i<=h[mid]-last;i++){
		for(int j=0;j<=len;j++) tf[j]=tg[j]=0;
		if(i==1){
			int tot=0;
			for(int j=l;j<=r;j++) tot+=h[j]==h[mid];
			len-=tot;
			for(int j=0;j<=len;j++){
				tf[j+tot]=(1ll*f[x][j]*(pw[j]-1)+tf[j+tot])%mod;
				tg[j]=(1ll*g[x][j]*(pw[j]-1)+tg[j])%mod;
				tf[j]=(tf[j]+g[x][j])%mod;
				tg[j]=(tg[j]+g[x][j])%mod;
				for(int a=0;j+a<=len;a++) for(int b=0;b<=tot;b++) if(a+b){
					int tp=1ll*C[len-j][a]*C[tot][b]%mod*pw[j]%mod;
					tf[j+a+tot]=(1ll*tp*f[x][j]+tf[j+a+tot])%mod;
					tg[j+a+b]=(1ll*tp*g[x][j]+tg[j+a+b])%mod;
				}
			}
			len+=tot;
		}
		else{
			for(int j=0;j<=len;j++){
				tf[j]=(1ll*f[x][j]*(pw[j]-1)+tf[j])%mod;
				tg[j]=(1ll*g[x][j]*(pw[j]-1)+tg[j])%mod;
				tf[j]=(tf[j]+g[x][j])%mod;
				tg[j]=(tg[j]+g[x][j])%mod;
				for(int k=1;j+k<=len;k++){
					tf[j+k]=(1ll*f[x][j]*C[len-j][k]%mod*pw[j]+tf[j+k])%mod;
					tg[j+k]=(1ll*g[x][j]*C[len-j][k]%mod*pw[j]+tg[j+k])%mod;
				}
			}
		}
		for(int j=0;j<=len;j++) f[x][j]=tf[j],g[x][j]=tg[j];
	}
	return x;
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(h[i]);
	pw[0]=1;
	for(int i=1;i<=n;i++) pw[i]=(pw[i-1]+pw[i-1])%mod;
	for(int i=0;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	write(f[dico(1,n,0)][n]);
}

Measured memory_bytes: 5536
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}



int main(){
  int A,B;cin>>A>>B;
  bool ok=true;
  if(A>8||B>8)ok=false;
  if(ok)cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
    

  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	register string st;
	register bool c=false,f=false;
	cin>>st;
	int len=st.length();
	register char ch[len];
	for(int i=0;i<len;i++)ch[i]=st[i];
	for(register int i=0;i<len;i++){
		if(ch[i]=='C')c=true;
		if(c)if(ch[i]=='F')f=true;
		if(c&&f){
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 384
n,t = map(int,input().split())
lis = []
for i in range(n):
    x = list(map(int,input().split()))
    lis.append(x)
ans = 1001    
for j in lis:
    if j[1] <= t and j[0] < ans:
        ans = j[0]
if ans == 1001:
    print("TLE")
else:
    print(ans)

Measured memory_bytes: 3064