akhauriyash/Code-Regression huggingface dataset:
/*------U Have To DO It------*/
/*      BY-> RicoProg        */
/*        ___ 
           __|__|
          |  |___           */
#include <bits/stdc++.h>
using namespace std;
 
/**/
 
//---------------------------------------------------MACROS----------------------------------------------------------
#define ll long long
#define ld long double
#define beg(i ,n) for(ll i=0;i<n;i++)
#define beg1(i ,n) for(ll i=1;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define nl "\n" 
#define sp " "
#define vec(v , n) vector<ll> v(n)
#define all(x) x.begin() , x.end()
#define pii pair<int , int>
#define pll pair<ll , ll>
#define mii map<int , int>
#define mll map<ll , ll>
#define mlb map<ll , bool>
#define msi map<string , int>
#define mci map<char , int>
#define f1 first
#define f2 second

//---------------------------------------------------GLOBAL----------------------------------------------------------
const ll MOD2 = 998244353 ;
const ll MOD = 1e9 + 7 ;
const ll MAX = 1e5 + 7 ;
const ll inf = 1e18L + 5 ;
const double pi = 3.14159265358979323846 ;
ll fpow(ll n , ll m ){ll res=1 ;while(m>0){if(m&1){res*=n ;}m/=2 ;n*=n ;}return res;}
ll modInv(ll n){return fpow(n , MOD-2);}
//---------------------------------------------------FUNCTIONS-------------------------------------------------------

const ll nax = 1e5 + 5 ;

void solve(){
	ll n , x ;
    cin >> x >> n ;
    vector<ll> v(n) ;
    beg(i , n) cin >> v[i] ;
    sort(all(v)) ;
    vector<ll> :: iterator itr , bitr ;
    itr = upper_bound(all(v) , x) ;
    if(itr==v.begin()){
        // cout << "A" << nl ;
        cout << x ;
    }
    else{
        // cout << "C" << nl ;
        ll right = x+1 ;
        ll left = x ;
        bitr = itr ;
        while(itr!=v.end()){
            if(*itr!=right){
                break ;
            }
            ++itr ;
            ++right ;
        }
        itr = bitr ;
        --itr ;
        while(true){
            // cout << *itr << sp << left << nl ;
            if(*itr!=left){
                break ;
            }
            --left ;
            if(itr == v.begin()){
                break ;
            }
            --itr ;
        }
        // cout << left << sp << right << nl ;
        if(abs(x - left) > abs(x - right)) cout << right ;
        else cout << left ;
    }
}

//---------------------------------------------------DRIVER----------------------------------------------------------
int main(){
    fast ;
    int t=1 ;  
    //cin >> t ;
    while(t--){
        solve() ;
    }
    return 0;
}   

Measured memory_bytes: 3660
{-# LANGUAGE BangPatterns #-}
 
module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
 
parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine
 
main = do
  [h, n] <- readIntList
  arr <- readIntList
  let s = sum arr
  putStrLn $ if s >= h then "Yes" else "No"



Measured memory_bytes: 2172
let a, b, s = Scanf.scanf " %d %d %s" @@ fun a b c -> a, b, c
let f s x = let n = ref 0 in String.iter (fun c -> if c = x then incr n) s; !n
let _ = print_endline @@ if s.[a] = '-' && f s '-' = 1 then "Yes" else "No"

Measured memory_bytes: 2432
def read_int():
    return int(input().strip())
 
 
def read_ints():
    return list(map(int, input().strip().split(' ')))
 
 
def solve():
    """
    OPT[N][W] = maximum value obtained with first N items and weights up to W
    OPT[N][W] = max(OPT[N-1][W-w[N]]+v[N], OPT[N-1][W])
    OPT[0][0] = 0
    """
    N, W = read_ints()
    w, v = [], []
    for _ in range(N):
        w0, v0 = read_ints()
        w.append(w0)
        v.append(v0)
    OPT = [[0]*(W+1) for _ in range(N+1)]
    for i in range(1,N+1):
        for j in range(1,W+1):
            OPT[i][j]=OPT[i-1][j]
            if j-w[i-1]>=0:
                OPT[i][j]=max(OPT[i][j],OPT[i-1][j-w[i-1]]+v[i-1])
    return OPT[-1][-1]
if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 118512
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while(1) {
        C -= B;
        if(C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if(A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
using namespace std;

#define int long long
#define inf 1000000000
typedef pair<int, int> P;//to,1=cost

signed main() {
	int n;
	cin >> n;
	if (90 <= n&&n <= 99)cout << "Yes" << endl;
	else if (n % 10 == 9)cout << "Yes" << endl;
	else puts("No");
}

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


int main()
{
	string s,t;
	cin>>s>>t;
	int m = s.length();
	int n = t.length();
	int arr[m+1][n+1];
	for(int i=0;i<m+1;i++)
	{
		for(int j=0;j<n+1;j++)
		{
				arr[i][j]=0;
		}
	}
	for(int i=1;i<m+1;i++)
	{
		for(int j=1;j<n+1;j++)
		{
			if(s[i-1]==t[j-1])
			{
				arr[i][j] = arr[i-1][j-1] + 1;
			}
			else
				arr[i][j] = max(arr[i-1][j], arr[i][j-1]);
		}
	}
	int g = arr[m][n];
	char ans[g+1];
	ans[g] = '\0';
	int i=m,j=n;
	while(i>0 && j>0)
	{
		if(s[i-1]==t[j-1])
		{
			ans[g-1] =  s[i-1];
			i--;j--;g--;
		}
		else if(arr[i-1][j]>arr[i][j-1])
				i--;
			else
				j--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35456
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	for(int i=0; i<n; i++)
		cin >> h[i];
	vector<int> f(n);
	int ans=0;
	while(f!=h){
		int l,r;
		for(int i=0; i<n; i++){
			if(f[i]<h[i]){
				l=i;
				r=i;
				break;
			}
		}
		while(r+1<n && f[r+1]<h[r+1])
			r++;
		for(int i=l; i<=r; i++)
			f[i]++;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

ll sum[100001];
int up[100001];
int down[100001];
int main()
{
  int N, L;
  N = in(), L = in();
  vector<int> v;
  inpt(v, N, in);
  if (N == 2){
    printf("%d\n", 2 * L - v[0] + v[1]);
    return 0;
  }
  for (int i = 0; i < N; i++){
    sum[i + 1] = sum[i] + (L - v[i]);
  }
  //[i, j) -> sum[j] - sum[i]
  for (int i = 1; i < N; i++){
    if (v[i] < v[i - 1]) up[i] = up[i - 1] + 1;
    else up[i] = 0;
  }
  for (int i = N - 2; i >= 0; i--){
    if (v[i] < v[i + 1]) down[i] = down[i + 1] + 1;
    else down[i] = 0;
  }
  ll maxi = 0;
  for (int i = 0; i < N; i++){
    ll a = sum[i + 1] - sum[i - up[i]];
    ll b = sum[i + down[i] + 1] - sum[i];
    maxi = max(maxi, max(a, b));
  }
  printf("%lld\n", maxi);
  return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return kai(n - 1)*n;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}

signed main() {
	int h, w, x, y;
	cin >> h >> w >> x >> y;
	if (h*w % 2 && (x + y) % 2)cout << "No" << endl;
	else cout << "Yes" << endl;
	endre;
}


Measured memory_bytes: 3108
#include <iostream>
#define MAX (10000)
#define NIL (-1)
using namespace std;
struct Node{
    int parent;
    int left,right;
};
Node T[MAX];
int n,D[MAX],H[MAX];
void setDepth(int u,int d){
    if(u==NIL)return;
    D[u]=d;
    setDepth(T[u].left,d+1);
    setDepth(T[u].right,d+1);
}
int setHeight(int u){
    int h1=0,h2=0;
    if(T[u].left!=NIL){
        h1=setHeight(T[u].left)+1;
    }
    if(T[u].right!=NIL){
        h2=setHeight(T[u].right)+1;
    }
    if(h1>=h2)return H[u]=h1;
    else return H[u]=h2;
}
int main(void){
    int k,l,r;
    int d;
    cin>>n;
    for(int i=0;i<n;i++){
        T[i].parent=T[i].left=T[i].right=NIL;
    }
    for(int i=0;i<n;i++){
        cin>>k>>l>>r;
        T[k].left=l;
        T[k].right=r;
        if(l!=NIL)T[l].parent=k;
        if(r!=NIL)T[r].parent=k;
    }
    for(int i=0;i<n;i++)if(T[i].parent==NIL)d=i;
    setDepth(d,0);
    setHeight(d);
    
    for(int i=0;i<n;i++){
        cout<<"node "<<i<<": parent = "<<T[i].parent<<", sibling = ";
        if(T[i].parent==NIL)cout<<-1;
        else if(i==T[T[i].parent].left)cout<<T[T[i].parent].right;
        else if(i==T[T[i].parent].right)cout<<T[T[i].parent].left;
        else cout<<-1;
        cout<<", degree = ";
        if(T[i].left!=NIL&&T[i].right!=NIL)cout<<2;
        else if(T[i].left!=NIL||T[i].right!=NIL)cout<<1;
        else cout<<0;
        cout<<", depth = "<<D[i]<<", height = "<<H[i]<<", ";
        if(T[i].parent==NIL)cout<<"root"<<endl;
        else if(T[i].left!=NIL||T[i].right!=NIL)cout<<"internal node"<<endl;
        else cout<<"leaf"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3132
#include <cstdio>
#include <complex>
#include <iostream>
#include <utility>
#include <vector>
#define EPS (1e-10)
#define X real()
#define Y imag()
using namespace std;
typedef complex<double> P;
typedef pair<P, double> Rope;

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

Rope integrate2(Rope x, Rope y){
  P s = x.first, t = y.first;
  double a = x.second, b = y.second, c_square = norm(s-t);
  if(c_square < EPS) return Rope(s,min(a,b));
  double k = (a*a - b*b + c_square)/c_square/2.0;
  P p = (1-k)*s + k*t;
  double h_square = a*a - norm(p-s);
  return Rope(p, sqrt(max(h_square,0.0)));
}

Rope integrate3(Rope x, Rope y, Rope z){
  //??????????????¬????????¨??????
  P s = x.first, t = y.first, u = z.first;
  double a = x.second, b = y.second, c = z.second;
  if(norm(s-t) < EPS) return integrate2(z, Rope(s,min(a,b)));
  if(norm(t-u) < EPS) return integrate2(x, Rope(t,min(b,c)));
  if(norm(u-s) < EPS) return integrate2(y, Rope(u,min(c,a)));
  double px = ((norm(t) - norm(s) + a*a - b*b)*(u.Y-s.Y) - (norm(u) - norm(s) + a*a - c*c)*(t.Y-s.Y)) / 2.0 / cross(t-s,u-s);
  double py = ((norm(t) - norm(s) + a*a - b*b)*(u.X-s.X) - (norm(u) - norm(s) + a*a - c*c)*(t.X-s.X)) / 2.0 / cross(u-s,t-s);
  P p = P(px, py);
  double h_square = a*a - norm(p-s);
  return Rope(p, sqrt(max(h_square, 0.0)));
}

double solve(vector<Rope> r){
  int n = r.size();
  double ret = -1;
  for(int i = 0; i < n; ++i){
    for(int j = i; j < n; ++j){
      for(int k = j; k < n; ++k){
	Rope x = integrate3(r[i], r[j], r[k]);//?????¬????????????????????¨??????
	double h = x.second;
	if(h < ret) continue;
	P p = x.first;
	bool f = true;
	for(int l = 0; l < n; ++l){
	  if(h*h + norm(p-r[l].first) > r[l].second*r[l].second + EPS){
	    f = false;
	    break;
	  }
	}
	if(f) ret = max(ret, h);
      }
    }
  }
  return ret;
}


int main(){
  int n;
  while(cin >> n, n){
    vector<Rope> R(n);
    double x, y, l;
    for(int i = 0; i < n; ++i){
      cin >> x >> y >> l;
      R[i] = Rope(P(x,y),l);
    }
    printf("%.10lf\n", solve(R));
  }
  return 0;
}

Measured memory_bytes: 3268
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5
int main(){
	int n;
	cin>>n;
	vl h(n);
	rep(i,n){
		cin>>h[i];
	}
	int ans=0;
	int now=0;
	rep(i,n-1){
		if(h[i+1]<=h[i]){now++;}
		else{
			ans=max(ans,now);
			now=0;
		}
		ans=max(ans,now);
	}
		
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#C
n, m = map(int, input().split())

ans = 0

if n == 2 or m == 2:
    ans = 0
elif n == 1 and m == 1:
    ans = 1
elif (n == 1 and m == 2) or (n == 2 and m == 1):
    ans = 0
elif n == 1:
    ans = m-2
elif m == 1:
    ans = n-2
else:
    ans = (n-2) * (m-2)
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ll a[111];
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll x,y;
    for(ll i=0;i<k;i++)
    {
        cin>>x;
        for(ll j=0;j<x;j++)
        {
            cin>>y;
            a[y]++;
        }
    }
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        if(a[i]==0)
            ans++;
    }
    cout<<ans;
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
}

Measured memory_bytes: 3652
#include<stdio.h>


int main(){

	char c;
	while((c=getchar())!=EOF){
	if(c>64&&c<91)
		putchar(c+32);
	else if(c>96&&c<123)
		putchar(c-32);
	else putchar(c);}
//	printf("\n");
	return 0;
}


Measured memory_bytes: 2100
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, m; rd(n, m);

  writeln((m*1900+(n-m)*100)*(1<<m));
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

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

int main() {
  int a,b,d,e;
  double f;
  cin>>a>>b;
  d=a/b;
  e=a%b;
  f=(double)a/b;
  cout<<fixed<<setprecision(20);
  cout<<d<<" "<<e<<" "<<f<<endl;
}


Measured memory_bytes: 3232
//
// Created by yamunaku on 2019/12/29.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int n;
    ll y;
    cin >> n >> y;
    vl a(2 * n);
    ll s = 0;
    rep(i, n){
        cin >> a[i];
        s += a[i];
        a[n + i] = a[i];
    }
    s = s / 5 - y;
    vl l(n, n + 1);
    rep(i, n){
        ll sum = 0;
        repl(j, i, n){
            sum += a[j];
            if(sum >= s){
                l[i] = j;
                break;
            }
        }
    }
    ll ans = 0;
    rep(i, n){
        mtl dp(n, vl(5, 0));
        dp[i][0] = 1;
        repl(j, i + 1, n){
            repl(k, i, j){
                if(j >= l[k + 1]){
                    repl(x, 1, 5){
                        dp[j][x] += dp[k][x - 1];
                    }
                }
            }
        }
        ll sum = 0;
        rep(j, i + 1){
            sum += a[j];
        }
        per(j, n){
            if(sum >= s) ans += dp[j][4];
            sum += a[j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
typedef long long ll;
using namespace std;

int main(){
  ll i,j,k,n,m;
  cin >> n;
  string s,t;
  cin >> s;
  t=s;
  ll ret=0,sum=0;
  ll cnt[n+1]={};
  if(s[0]=='.')cnt[1]++;
  for(i=2;i<=n;i++){
    if(s[i-1]=='.'){
      cnt[i]++;
    }
    cnt[i]+=cnt[i-1];
  }
  ret=cnt[n];
  for(i=1;i<=n;i++){
    //cout << i-cnt[i] << endl;//黒の数
    //cout << cnt[n]-cnt[i] << endl << endl; //白の数
    ret=min(i-cnt[i]+cnt[n]-cnt[i],ret);
  }

  cout << ret << endl;
  return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 5e2;
const int LOG = 61;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int D = 700;
const ll LLMOD = 1e9 + 7;
const ll LLINF = 1e18;

void mult(ll &a, ll b) {
    a = (a * b) % MOD;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 1;
    vi dp(2 * n);
    forn(i, 2 * n) {
        if (!i) dp[i] = (s[i] == 'W');
        else dp[i] = (s[i] == s[i - 1]);

    }
    ll cnt = 0;
    forn(i, 2 * n) {
        if (dp[i]) {
            if (!cnt) {
                cout << "0\n";
                return 0;
            } else {
                mult(ans, cnt);
                cnt--;
                if (i + 1 < 2 * n) dp[i + 1] ^= 1;
            }
        } else {
            cnt++;
        }
    }
    if (cnt) ans = 0;
    forn(i, n) mult(ans, i + 1);
    cout << ans << "\n";
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  if (S.size() < 4) cout << "No" << endl;
  else if (S.substr(0, 4) != "YAKI") cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3628
import collections
from math import factorial
def comb(n,r):
    return factorial(n)//factorial(n-r)//factorial(r)
n,a,b=map(int,input().split())
v=list(map(int,input().split()))
v.sort(reverse=True)
c=collections.Counter(v)
k=min(v[:a])
if c[max(v)]<a:
    ans=comb(c[k],v[:a].count(k))
else:
    ans=0
    for i in range(a,min(b,c[k])+1):
        ans+=comb(c[k],i)
print(sum(v[:a])/a)
print(ans)

Measured memory_bytes: 3316
// Lets go to the next level 
// AIM CM at CF *__* asap 
// Hit A,B,C and D faster and reach Candidate Master
// Remember you were also a novice when you started, 
// hence never be rude to anyone who wants to learn something
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure.  


#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
// Big two primes 
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long 
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e6+5); 


signed main(){
//   #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
//   #endif
  fio;
    string s;
    cin>>s;

    if(s == "Sunny"){
        cout<<"Cloudy";
    }
    else if(s == "Cloudy"){
        cout<<"Rainy";
    }
    else{
        cout<<"Sunny";
    }
  rr;
}

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

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    ll cnt = 0;
    bool flag = 1;
    if (a == b && a == c){
        if (a%2 == 1) cnt = 0;
        else cnt = -1;
        flag = 0;
    }
    ll x, y, z;
    while (flag){
        if (a%2 == 1 || b%2 == 1 || c%2 == 1) break;
        x = a;
        y = b;
        z = c;
        a = (x+z)/2;
        b = (y+z)/2;
        c = (x+y)/2;
        cnt ++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;

int main(){
    string S, T, tmp;
    cin >> S;
    cin >> T;
    tmp = S;
    for(int i=0; i<S.size(); ++i){
        if(tmp == T){
            cout << "Yes" << endl;
            return 0;
        }
        tmp = "";
        tmp = S[S.size()-1] + S;
        tmp.pop_back();
        S = tmp;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

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

    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    
    printf("%lf\n", sqrt(pow((x2-x1),2)+pow((y2-y1),2)));

    return 0;
}

Measured memory_bytes: 652
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <functional>
#include <cstring>
#include <queue>
#include <cmath>
#include <deque>
#include <list>
#include <iomanip>
#include <fstream>
#include <string>
#include <iterator>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
#define mp make_pair
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, N) FOR(i, 0, N)
#define SZ(x) ((int)(x).size())

const int MAXN = 100007, MOD = 1000000007;

int main()
{		
	set <int> S;
	multiset <int> M;
	int n, a;
	ll ans = 1;
	cin >> n;
	REP(i, n){
		cin >> a;
		if (S.find(a) == S.end()) S.insert(a);
		else{
			S.erase(a);
			M.insert(-a);
		}
	}
	if (SZ(M) <= 1)
		cout << 0;
	else {
		ans *= *M.begin();
		M.erase(M.begin());
		ans *= *M.begin();
		cout << ans;
	}
	//cout << endl; system("pause");//please
	return 0;
}

Measured memory_bytes: 4992
/* ***********************************************
Author        :yang12138
Created Time  :2018年08月18日 星期六 20时04分08秒
File Name     :A.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)



int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	int n,m;
	scanf("%d%d",&n,&m);
	printf("%d\n",n*m-n-m+1);

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int64_t solve(const vector<int>& a, int ra) {
  int64_t ans = 0;
  int64_t s = 0;
  for (int i = 0; i < a.size(); i++) {
    auto e = a[i];
    if (i % 2 == ra) {
      // s + e <= -1?
      if (s + e >= 0) {
        ans += abs(-1 - s - e);
        s = -1;
        continue;
      }
    } else {
      // s + e >= 1?
      if (s + e <= 0) {
        ans += abs(1 - s - e);
        s = 1;
        continue;
      }
    }
    s += e;
  }
  return ans;
}

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

  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int64_t ans = min(solve(a, 0), solve(a, 1));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b ==c) {
    cout << "Yes" << endl;
    return 0;
  }
  if(a+c ==b) {
    cout << "Yes" << endl;
    return 0;
  }
  if(c+b ==a) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    ll n, m; cin >> n >> m;
    if (m <= 2*n) cout << m/2 << endl;
    else {
        cout << n+(m-2*n)/4 << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static boolean debug = true;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int p = a + b;
        int m = a - b;
        int d = a * b;

        if(p>m){
            if(p>d) {
                System.out.println(p);
            }else{
                System.out.println(d);
            }
        }else{
            if(m>d) {
                System.out.println(m);
            }else{
                System.out.println(d);
            }

        }


    }
}


Measured memory_bytes: 21972
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string s;
    cin>>s;
    int n = s.length();
    int cnt = 0;
    int i=0, j=n-1;
    while(i<j){
        if(s[i]!=s[j])  cnt++;
        i++, j--;
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 256
num = int(input())
word = {"AC":0, "WA":0, "TLE":0, "RE":0}
 
for i in range(num):
    judge = input()
    if judge in word:
        word[str(judge)] += 1
    else:
        pass
        
        
print("AC x " + str(word["AC"]))
print("WA x " + str(word["WA"]))
print("TLE x " + str(word["TLE"]))
print("RE x " + str(word["RE"]))

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


def solve(N: int):
    return N**3


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(solve(N))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import time
import random

timestart = time.time() 
D = int(input())
c = list(map(int,input().rstrip().split(" ")))
s = []
ta = []
ta_buf = [0 for i in range(D)]

man = 0
man_buf = 0
kankaku = [0 for i in range(27)]
last = [0 for i in range(27)]
for i in range(D):
    s.append(list(map(int,input().rstrip().split(" "))))

for i in range(D):
    p = 0
    t = 0
    for i2 in range(26):
        if p < s[i][i2] + c[i2] * kankaku[i2] * (kankaku[i2] * 2) // 2:
            p = s[i][i2] + c[i2] * kankaku[i2] * (kankaku[i2] * 2) // 2
            t = i2 + 1
    kankaku[t - 1] = -1
    ta.append(t -1)
    for i in range(26):
        kankaku[i] += 1

ta.append(-1)

for i in range(D):
    man += s[i][ta[i]]
    last[ta[i]] = i + 1
    for i2 in range(26):
        man -= (i + 1 - last[i2]) * c[i2]

while timestart + 1.900 > time.time():
    man_buf = 0
    for i in range(D):
        ta_buf[i] = ta[i]
    a = random.randint(0,360)
    b = a + random.randint(1,4)
    ta_buf[a], ta_buf[b] = ta_buf[b],ta_buf[a]

    for i in range(D):
        man_buf += s[i][ta_buf[i]]
        last[ta_buf[i]] = i + 1
        for i2 in range(26):
            man_buf -= (i + 1 - last[i2]) * c[i2]

    if man_buf > man:
        man = man_buf
        for i in range(D):
            ta[i] = ta_buf[i]

for i in range(D):
    print(ta[i] + 1)


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

int main(){
    long long n, a, b = -1000000000, s, i;
    cin >> n >> s;
    for(a = s, i = 1; i < n; i++){
        cin >> s;
        b = max(b, s -a);
        a = min(a, s);
    }
    cout << b << endl;
    return 0;
}


Measured memory_bytes: 3128
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    String T = sc.next();
    for(int i = 0; i < N; i++){
      System.out.print(S.charAt(i)+""+T.charAt(i));
    }
    System.out.println();
  }
}

Measured memory_bytes: 21716
#include<stdio.h>
#include<string.h>
int main(){
  int i,j;
  int n,x,y;
  for(;;){
    scanf("%d",&n);
    if(n==0)
      break;
    int a[n][n];
    memset(a,0,sizeof(a));
    x=n/2;
    y=n/2+1;
    a[x][y]=1;
    for(i=2;i<n*n+1;i++){
      x++;
      y++;
      for(;;){
	if(x>=n)
	  x=0;
	if(y>=n)
	  y=0;
	if(x<0)
	  x=n-1;
	if(a[x][y]){
	  x--;
	  y++;
	}else{
	  a[x][y]=i;
	  break;
	}
      }
    }	  
    for(i=0;i<n;i++){
      for(j=0;j<n;j++)
	printf("%4d",a[j][i]);
      puts("");
    }
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc  = new Scanner(System.in);
        
        int K = sc.nextInt();
        int N = sc.nextInt();
        
        int []A = new int[N];
        int []leng = new int[N];
        
        for (int i = 0; i < N; i++)
        {
            A[i] = sc.nextInt();
        }
        
        for (int i = 0; i < N; i++)
        {
            if ((i+1) == N)
            {
                leng[i] = A[0] + (K - A[i]); 
                break;
            }
            
            leng[i] = A[i+1] - A[i];
        }
        
        Arrays.sort(leng);
        
        int total = 0;
        for (int i = 0; i < N-1; i++)
        {
            total += leng[i];
        }
        
        System.out.println(total);
    }
}


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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

const int dxs[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dys[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

ll dp[3010][3010][4];
int RC[3001][3001];

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

  int R,C,K;
  cin >> R >> C >> K;
  REP(i,K) {
    int r,c,v;
    cin >> r >> c >> v;
    RC[r][c] = v;
  }
  dp[1][1][1] = dp[1][1][2] = dp[1][1][3] = RC[1][1];

  EACH(i,1,R) {
    EACH(j,1,C) {
      REP(k,4) {
        chmax<ll>(dp[i+1][j][0], dp[i][j][k]);
        chmax<ll>(dp[i+1][j][1], dp[i][j][k] + RC[i+1][j]);
      }
      chmax<ll>(dp[i][j+1][0], dp[i][j][0]);
      chmax<ll>(dp[i][j+1][1], max(dp[i][j][1], dp[i][j][0] + RC[i][j+1]));
      chmax<ll>(dp[i][j+1][2], max(dp[i][j][2], dp[i][j][1] + RC[i][j+1]));
      chmax<ll>(dp[i][j+1][3], max(dp[i][j][3], dp[i][j][2] + RC[i][j+1]));
    }
  }

  ll ans = 0;
  REP(k,4) chmax(ans, dp[R][C][k]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 321068
/*
 * a.c
 *
 *  Created on: 2017/06/13
 *      Author: AWV060608
 */

#include	<stdio.h>

#define		MXRC		100
#define		ULONG		unsigned long

int		main(void)
{
	int		n, m, l;
	int		i, j, k;
	int		x;
	ULONG	sum, tmp1, tmp2;
	ULONG	mt1[MXRC][MXRC];
	ULONG	mt2[MXRC][MXRC];
	ULONG	mt3[MXRC][MXRC];

	scanf("%d",&n);
	scanf("%d",&m);
	scanf("%d",&l);

	for(i=0; i<n; i++)
	{
		for(j=0; j<m; j++)
		{
			scanf("%d",&x);
			mt1[i][j] = x;
			//printf("x=%d\n",x);
		}
	}
	for(i=0; i<m; i++)
	{
		for(j=0; j<l; j++)
		{
			scanf("%d",&x);
			mt2[i][j] = x;
		}
	}
	sum = 0;
	//for(i=0; i<50; i++)
	for(i=0; i<n; i++)
	{
		//for(j=0; j<100; j++)
		for(j=0; j<l; j++)
		{
			for(k=0; k<m; k++)
			{
				tmp1 = mt1[i][k];
				tmp2 = mt2[k][j];
				sum = sum + tmp1*tmp2;
				//printf("mt1[i][%d]=%d mt2[%d][j]=%d \n",k,mt1[i][k],k, mt2[k][j]);
			}
			mt3[i][j] = sum;
			//printf("mt3[i][j] = %lu\n",mt3[i][j]);
			//printf("sum=%lu\n",sum);
			sum =0;
		}
	}

	for(i=0; i<n; i++)
	{
		for(j=0; j<l; j++)
		{
			printf("%lu",mt3[i][j]);
			if( j != l-1 )
				printf(" ");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 840
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

int main() {
    long long A,B,N;

    cin >> A >> B >> N;

    if(N >= B){
        cout << A*(B-1)/B - A*((B-1)/B) << endl;
    }else{
        cout << A*N/B - A*((N-1)/B) << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<set>

using namespace std;

int main(){
    int N;
    bool flag=false;
    cin >> N;
    set<char> S;
    for(int i = 0; i < N; i++){
        char a;
        cin >> a;
        if(a=='Y')flag=true;
    }
    if(flag){
        cout << "Four" << endl;
    }else{
        cout << "Three" << endl;
    }
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define INF 1000000000
using namespace std;
typedef pair<int, int> pii;
typedef pair<pii, int> score;

int T, P, R;
int w[50][10];
score s[50];

int main(void) {
  while(cin >> T >> P >> R, T || P || R) {
    REP(i, 0, T) {
      REP(j, 0, P) w[i][j] = 0;
      s[i] = score(pii(0, 0), -i);
    }

    REP(i, 0, R) {
      int tid, pid, time;
      string message;
      cin >> tid >> pid >> time >> message;
      tid--;
      pid--;
      if(message == "CORRECT") {
        s[tid].first.first++;
        s[tid].first.second -= w[tid][pid] * 1200 + time;
      } else {
        w[tid][pid]++;
      }
    }

    sort(s, s + T);
    reverse(s, s + T);

    REP(i, 0, T) cout << (-s[i].second + 1) << " " << s[i].first.first << " " << -s[i].first.second << endl;
  }
}

Measured memory_bytes: 3192
#include<iostream>
//#include<string>
#include<vector>


using namespace std;


int main(){
    int N,K;
    long long buff=0;
    int sum=0;
    cin >> N >>K;
    for(int j=K;j<N+2;j++){
            buff=(N-j+1)%1000000007;
            buff=(buff*(j%1000000007))%1000000007;
            sum=(sum+buff+1)%1000000007;
    }

    cout << sum << endl;
    return 0;

}

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

namespace abc157_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var M = CIn.ReadInt();
      var a = Enumerable.Repeat(-1, N).ToArray();

      for (int i = 0; i < M; i++)
      {
        var s = CIn.ReadInt() - 1;
        var c = CIn.ReadInt();

        if (a[s] == -1 || a[s] == c)
        {
          a[s] = c;
        }
        else
        {
          Console.WriteLine(-1);
          return;
        }
      }

      if (N != 1 && (M == 0 || a[0] == -1)) a[0] = 1;

      if (N != 1 && a[0] == 0)
      {
        Console.WriteLine(-1);
        return;
      }


      var ans = int.Parse(String.Join("", a.Select(e => e != -1 ? e : 0)));
      Console.WriteLine(ans);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 13524
import scala.collection.mutable._
import io.StdIn.readLine

object Main extends App {
  val map = new HashMap[String,Int]
  val s = readLine.split(" ")
  s.foreach(e => {
    if(!map.contains(e)) map.put(e,1)
    else map.put(e,map(e)+1)
  })
  val maxF = map.maxBy(_._2)._1
  val l = s.map(_.length).max
  val maxL = s.find(_.length == l).get

  println(maxF + " " + maxL)
}


Measured memory_bytes: 43896
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

const int ids = 26;
ll calc(vector<vector<int>> &score, vector<int> &del, vector<int> &selected) {
    vector<int> last(ids, 0);
    ll res = 0;
    REP(i, 0, selected.size()) {
        int s = selected[i];
        last[s] = i + 1;
        res += score[i][s];
        REP(j, 0, ids) {
            res -= del[j] * (i + 1 - last[j]);
        }
    }
    return res;
}

#include <random>
#include <ctime>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int d;
    cin, d;

    vector<int> c(ids);
    REP(i, 0, ids) {
        cin, c[i];
    }
    auto score = make_v(d, ids, 0);
    REP(i, 0, d) {
        REP(j, 0, ids) {
            cin, score[i][j];
        }
    }

    const int repeat = 1000;
    const int trials = 100;
    vector<int> selected(d);

    auto rd = random_device();
    auto gen = mt19937(rd());
    uniform_int_distribution<int> contest(1, 26);
    uniform_int_distribution<int> days(1, d);

    {
        int a = time(NULL) % 1000;
        REP(i, 0, a) {
            gen();
        }
    }

    REP(i, 0, d) {
        selected[i] = contest(gen) - 1;
    }

    const ll inf = 1LL << 60;

    REP(_, 0, repeat) {
        ll s = -inf;
        int best_c, best_d;
        REP(_t, 0, trials) {
            int sc = contest(gen) - 1;
            int sd = days(gen) - 1;
            int save = selected[sd];
            selected[sd] = sc;
            ll tmp = calc(score, c, selected);
            if (chmax(s, tmp)) {
                best_c = sc;
                best_d = sd;
            }
            selected[sd] = save;
        }
        dump(s);
        selected[best_d] = best_c;
    }

    REP(i, 0, d) {
        print(selected[i] + 1);
    }

    return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    int food[m];
    for (int i = 0; i < m; i++) {
        food[i] = 0;
    }

    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int a;
            cin >> a;
            food[--a]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < m; i++) {
        if (food[i] == n) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = [0.0]
for i in range(N):
    ans.append(ans[-1]+A[i]/2.0+0.5)
ANS = 0

for i in range(K,N+1):
    tmp = ans[i] - ans[i-K]
    ANS = max(ANS,tmp)
print(ANS)

Measured memory_bytes: 76040