akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

template <class Integer>
auto boost_irange(Integer last) { return boost::irange(static_cast<Integer>(0), last); }
template <class Integer>
auto boost_irange(Integer first, Integer last) { return boost::irange(first, last); }

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }
};

int main()
{
    input in;
    output out;

    int a, b, c;
    in >> a, b, c;

    out << std::max(c - (a - b), 0);

    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int n,m;
  cin>>n>>m;
  vector<int>s(m);
  vector<int>c(m);
  for(int i=0;i<m;i++)cin>>s[i]>>c[i];
  if(m==0){
    if(n==1){
      cout<<0<<endl;
      return 0;
    }
    if(n==2){
      cout<<10<<endl;
      return 0;
    }
    if(n==3){
      cout<<100<<endl;
      return 0;
    }
  }
  for(int i=1;i<m;i++){
    for(int j=0;j<i;j++){
      if(s[i]==s[j] && c[i]!=c[j]){
        cout<<-1<<endl;
        return 0;
      }
    }
  }
  for(int i=0;i<m;i++){
    if(n>=2 &&s[i]==1&& c[i]==0){
      cout<<-1<<endl;
      return 0;
    }
  }

  if(n==1){
    
    cout<<c[0]<<endl;
    
  }
  if(n==2){
    int a=1;
    int b=0;
    for(int i=0;i<m;i++){
      if(s[i]==1)a=c[i];
      if(s[i]==2)b=c[i];
    }
      cout<<10*a+b<<endl;
    
  }
  if(n==3){
    int p=1;
    int q=0;
    int r=0;
    for(int i=0;i<m;i++){
       if(s[i]==1)p=c[i];
      if(s[i]==2)q=c[i];
    if(s[i]==3)r=c[i];
    }
    cout<<100*p+10*q+r<<endl;
  }
}
                              

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  998244353
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
bool isvalid(ll x,ll y,ll n, ll m) { return (x>=0&&x<n&&y>=0&&y<m); }
vector<ll>v[100011];

int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;

    cin>>s;

    if(s[0] - 'a' < 0){

        cout<<'A';
        return 0;
    }
    cout<<'a';
    return 0;
}

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

typedef struct{
	int height;
	int p;
	int q;
}info;

int main(){
	while(1){
		int n, m, a;
		info b[1000];
		
		scanf(" %d %d %d", &n, &m, &a);	
		if(n==0) break;
		for(int i=0; i<m; ++i) scanf(" %d %d %d", &b[i].height, &b[i].p, &b[i].q);
		
		for(int i=0; i<m; ++i){
			for(int j=i; j<m; ++j){
				if(b[i].height < b[j].height) swap(b[i], b[j]);		
			}
		}
		
		int amida[101];
		for(int i=1; i<=n; ++i) amida[i]=i;
		
		//高い方から順に処理
		for(int i=0; i<m; ++i)
			swap( amida[b[i].p], amida[b[i].q] );		
			
		for(int i=1; i<=n; ++i){
			if(a==amida[i]){
				printf("%d\n", i);
				break;	
			}	
		}
		
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

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

  cout << b * a / 2 << endl;

  return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()

#define uint8_t unsigned char
#define uint16_t unsigned short
#define uint32_t unsigned int
#define uint64_t unsigned long long

#define int8_t signed char
#define int16_t signed short
#define int32_t signed int
#define int64_t signed long long

using namespace std;

int main(int argc, char const* argv[])
{
    int N = 0;
    cin >> N;

    int value[N][3];
    REP(i, N) REP(j, 3) cin >> value[i][j];
 
    int dp[N][3] = {};
    REP(i, N) REP(j,3){dp[i][j] = INT_MIN;}

    dp[0][0] = value[0][0];
    dp[0][1] = value[0][1];
    dp[0][2] = value[0][2];
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j != k) {
                    dp[i][j] = max(dp[i][j], dp[i-1][k]+value[i][j]);
                    //cout << "dp[" << i << "][" << j << "]" << dp [i][j] << endl;
                }
            }
        }
    }

    int max_dp =  max(dp[N-1][0], max(dp[N-1][1],dp[N-1][2]));
    cout << max_dp << endl;

    return 0;
}



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

int main(void){
    int n;
    cin >> n;
    
    long long sum[200000] = {0};
    int i;
    for(i = 0; i < n; i++){
        cin >> sum[i];
        if(i != 0){
            sum[i] += sum[i - 1];
        }
    }
    
    long long end = sum[n - 1];
    
    sort(sum + 1, sum + n - 1);
    i = 1;
    while(sum[i] < end / 2 && i <= n - 2){
        i++;
    }
    
    if(i == n - 1){
        cout << abs(end - 2 * sum[n - 2]) << endl;
        return 0;
    }
    
    if(i >= 2 && abs(end - 2 * sum[i]) <= abs(end - 2 * sum[i - 1])){
        cout << abs(end - 2 * sum[i]) << endl;
    }else{
        cout << abs(end - 2 * sum[i - 1]) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1792
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum E = 18;

void main() {
  try {
    for (; ; ) {
      const N = readInt();
      auto A = new string[N];
      foreach (i; 0 .. N) {
        A[i] = readToken();
      }
      
      auto xs = new int[N];
      auto ys = new int[N];
      foreach (i; 0 .. N) {
        string a = A[i];
        if (a[$ - 1] != '.') {
          a ~= '.';
        }
        auto as = a.split(".");
        for (; as[1].length < 9; ) {
          as[1] ~= '0';
        }
        long val;
        val += as[0].to!long;
        val *= 10^^9;
        val += as[1].to!long;
        debug {
          writeln("val = ", val);
        }
        for (; val % 2 == 0; val /= 2) {
          ++xs[i];
        }
        for (; val % 5 == 0; val /= 5) {
          ++ys[i];
        }
      }
      debug {
        writeln("xs = ", xs);
        writeln("ys = ", ys);
      }
      
      auto freq = new long[][](E + 1, E + 1);
      foreach (i; 0 .. N) {
        ++freq[min(xs[i], E)][min(ys[i], E)];
      }
      long ans;
      foreach (x; 0 .. E + 1) foreach (y; 0 .. E + 1) {
        foreach (xx; 0 .. E + 1) foreach (yy; 0 .. E + 1) {
          if (x + xx >= E && y + yy >= E) {
            if ([x, y] == [xx, yy]) {
              ans += freq[x][y] * (freq[x][y] - 1) / 2;
            } else if ([x, y] < [xx, yy]) {
              ans += freq[x][y] * freq[xx][yy];
            }
          }
        }
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 16144
#include<iostream>
#include<cstdio>
using namespace std;
int a,b,c;
int k; 
int main()
{
	cin>>a>>b>>c>>k;
	while(a>=b) b*=2,k--;
	while(b>=c) c*=2,k--;
	if(k<0) puts("No");
	else puts("Yes");
	return 0;
} 

Measured memory_bytes: 3628
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];

    ll sum=0;
    ll idx0=-1,idxp=-1,idxn=-1;
    rep(i,n){
        if(a[i]==0)idx0=i;
        if(a[i]>0&&(idxp==-1||a[i]<a[idxp]))idxp=i;
        if(a[i]<0&&(idxn==-1||a[i]>a[idxn]))idxn=i;
        sum+=abs(a[i]);
    }

    if(idxp==-1&&idxn==-1){
        cout<<0<<endl;
        rep(i,n-1)cout<<"0 0"<<endl;
        return;
    }

    if(idxp==-1&&idx0==-1){
        cout<<sum+2*a[idxn]<<endl;
        rep(i,n){
            if(i==idxn)continue;
            cout<<a[idxn]<<' '<<a[i]<<endl;
            a[idxn]-=a[i];
        }
        return;
    }

    if(idxn==-1&&idx0==-1){
        cout<<sum-2*a[idxp]<<endl;
        rep(i,n){
            if(i==idxp||i==(idxp==0))continue;
            cout<<a[idxp]<<' '<<a[i]<<endl;
            a[idxp]-=a[i];
        }
        cout<<a[idxp==0]<<' '<<a[idxp]<<endl;
        return;
    }

    if(idxp==-1)idxp=idx0;
    if(idxn==-1)idxn=idx0;
    cout<<sum<<endl;
    rep(i,n){
        if(i==idxp||i==idxn)continue;
        if(a[i]>0){
            cout<<a[idxn]<<' '<<a[i]<<endl;
            a[idxn]-=a[i];
        }else{
            cout<<a[idxp]<<' '<<a[i]<<endl;
            a[idxp]-=a[i];
        }
    }
    cout<<a[idxp]<<' '<<a[idxn]<<endl;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define ll long long

using namespace std;
const int MAXN = 100005;

ll a[MAXN],b[MAXN];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	for(int i=0;i<n;i++) cin >> a[i] >> b[i];
	ll ans = 0 , cur = 0;
	for(int i=n-1;i>=0;i--){
		a[i] += cur;
		ll k = (a[i] + b[i] - 1) / b[i] * b[i] - a[i];
		ans += k;
		cur += k;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1792
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_APPLE_MAX		300000									// 最大リンゴ数
#define D_COLOR_CNT		3										// 色数

// 内部構造体 - リンゴ情報
typedef struct Apple {
	int miVal;													// 美味しさ
	int miColor;												// 色
} Apple;

// 内部変数
static FILE *szpFpI;											// 入力
static Apple sz1Apple[D_APPLE_MAX];								// リンゴ
static int siACnt;												// リンゴ数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 比較関数 - 美味しさ降順
int
fCmpFnc(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	Apple *lzpVal1 = (Apple *)pzpVal1;
	Apple *lzpVal2 = (Apple *)pzpVal2;

	// 美味しさ降順
	if (lzpVal1->miVal > lzpVal2->miVal) {
		return -1;
	}
	else if (lzpVal1->miVal < lzpVal2->miVal) {
		return 1;
	}

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i, j;
	char lc1Buf[1024];

	// データ - 初期化
	siACnt = 0;

	// 食べる数上限・リンゴ数 - 取得
	int li1LCnt[D_COLOR_CNT], li1ACnt[D_COLOR_CNT];
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d%d%d%d", &li1LCnt[0], &li1LCnt[1], &li1ACnt[0], &li1ACnt[1], &li1ACnt[2]);
	li1LCnt[2] = INT_MAX;

	// リンゴ - 取得
	for (i = 0; i < D_COLOR_CNT; i++) {
		for (j = 0; j < li1ACnt[i]; j++) {
			fscanf(szpFpI, "%d", &sz1Apple[siACnt].miVal);
			sz1Apple[siACnt].miColor = i;
			siACnt++;
		}
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	}
	qsort(sz1Apple, siACnt, sizeof(Apple), fCmpFnc);

	// 食べる
	int li1ECnt[D_COLOR_CNT];
	memset(li1ECnt, 0, sizeof(li1ECnt));
	long long llSum = 0;
	int liECnt = 0;
	for (i = 0; liECnt < li1LCnt[0] + li1LCnt[1]; i++) {
		int liColor = sz1Apple[i].miColor;
		if (li1ECnt[liColor] < li1LCnt[liColor]) {
			li1ECnt[liColor]++;
			llSum += sz1Apple[i].miVal;
			liECnt++;
		}
	}

	// 出力
	sprintf(lc1Buf, "%lld\n", llSum);
	fOutLine(lc1Buf);

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 4860
package main

import (
	"fmt"
	"strconv"
	"unicode/utf8"
)

const (
	IntMaxValue = int(^uint(0) >> 1)
)

func main() {
	N, M := readInt(), readInt()
	sc := make(map[int]int)

	if N == 1 && M == 0 {
		fmt.Println(0)
		return
	}

	for i := 0; i < M; i++ {
		s, c := readInt(), readInt()

		v, ok := sc[s]
		if ok && v != c {
			fmt.Println(-1)
			return
		}

		sc[s] = c
	}

	answer := ""
	for i := 0; i < N; i++ {
		v, ok := sc[i+1]
		if ok {
			answer += strconv.Itoa(v)
		} else {
			if i == 0 {
				answer += "1"
			} else {
				answer += "0"
			}
		}
	}

	v, _ := strconv.Atoi(answer)
	vstr := strconv.Itoa(v)

	if utf8.RuneCountInString(vstr) != N {
		fmt.Println(-1)
		return
	}

	fmt.Println(v)
}

func readInt() int {
	var v int
	fmt.Scan(&v)
	return v
}


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

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

Measured memory_bytes: 256
def main():
    x, y, a, b, c = list(map(int, input().split()))
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))
    R = list(map(int, input().split()))
    P = sorted(P, reverse = True)[:x]
    Q = sorted(Q, reverse = True)[:y]
    ans = sorted(P + Q + R, reverse = True)
    print(sum(ans[:x + y]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 29364
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

int main()
{
  int x,p[30]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
  int a,b,c,d,e;
  a=0;
  b=0;
  c=0;
  d=0;
  e=0;
  cin >> x;
  rep(i,25){
    if(DIV(x,p[i])>=74)e++;
    if(DIV(x,p[i])>=24)d++;
    if(DIV(x,p[i])>=14)c++;
    if(DIV(x,p[i])>=4)b++;
    if(DIV(x,p[i])>=2)a++;
  }
  printf("%d",b*(b-1)/2*(a-2)+d*(a-1)+c*(b-1)+e); 
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n];
	long ans=0;
	for(int i=0;i<n;i++) cin >> a[i];
	
	for(int i=0;i<n;i++) ans+=abs(a[i]);
	int m=1e9;
	for(int i=0;i<n-1;i++){
		m=min(m,abs(a[i]));
		if(a[i]<0) a[i+1]=-a[i+1];
	}
	m=min(m,abs(a[n-1]));
	if(a[n-1]<0) cout << ans-2*m << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int main()
{
  long n,mon=0;
  cin >> n;
  vector<long> a(n+1),b(n),f(n),g(n);
  rep(i,(n+1)) cin >> a[i];
  rep(i,n) cin >> b[i]; 

  rep(i,n){
  if(i==0){f[0]=min(a[0],b[0]); g[0]=min( a[1],(b[0]-min(a[0],b[0])) ); }
  else{ f[i]=min( (a[i]-g[i-1]),b[i]); g[i]=min( a[i+1],(b[i]-f[i]) ); }
    }
  
  rep(i,n) mon=mon+f[i]+g[i];
  cout << mon;
  
 return 0; 
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    int a[n],b[m];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<m;i++)cin>>b[i];
    long long A[n],B[m];
    A[0]=a[0],B[0]=b[0];
    for(int i=1;i<n;i++)A[i]=A[i-1]+a[i];
    for(int i=1;i<m;i++)B[i]=B[i-1]+b[i];
    int M=upper_bound(B,B+m,k)-B;
    for(int i=0;i<n;i++){
        if(A[i]>k)break;
        M=max(M,i+1+int(upper_bound(B,B+m,k-A[i])-B));
    }
    cout<<M<<endl;
    return 0;
}


Measured memory_bytes: 8312
void main()
{
    string s = readln.chomp;

    int[string] week;
    week["SAT"] = 1;
    week["FRI"] = 2;
    week["THU"] = 3;
    week["WED"] = 4;
    week["TUE"] = 5;
    week["MON"] = 6;
    week["SUN"] = 7;

    week[s].writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;

int main() {
	int K, N;
	cin >> N >> K;
  	if(K==1)
      cout<<0<<endl;
  	else
	  cout << N - K << endl;
	return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
    vector<int> v = {
            1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    };

    int k;
    cin >> k;

    cout << v[--k] << endl;
    return 0;
}

Measured memory_bytes: 3420
n,k = map(int,input().split())
lis = list(map(int,input().split()))
ans = 0
for i in range(n):
    for j in range(n-i+1):
        num = lis[:i]
        if j:
            num += lis[-j:]
        if len(num) <= k:
            spell = min(len(num),k-len(num))
            num.sort()
            for l in range(spell):
                num[l] = max(0,num[l])
            ans = max(ans,sum(num))
print(ans)

Measured memory_bytes: 3064
N, M = map(int,input().split(' '))
maxL=0
minR=N+1
for i in range(M):
    L, R = map(int,input().split(' '))
    if L >= maxL:
        maxL = L
    if R <= minR:
        minR = R
print(max(0,minR-maxL+1))

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

int main() {
  int D, N;
  cin >> D >> N;
  if (N == 100) N++;

  if (D == 0) {
    cout << N << endl;
  } else if (D == 1) {
    cout << N * 100 << endl;
  } else if (D == 2) {
    cout << N * 10000 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
front = [0]
back = [0]
for i in range(len(A)):
    front.append(gcd(A[i], front[i]))
    back.append(gcd(A[len(A) - i - 1], back[i]))
ans = 0
for i in range(len(A)):
    ans = max(gcd(front[i], back[len(A) - i - 1]), ans)
print(ans)


Measured memory_bytes: 16148
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  
  if((scanElem*100+scanElem*10+scanElem)%4==0)end("YES");end("NO");
}


Measured memory_bytes: 256
H,A = map(int, input().split())
t = 0

if H <= A:
    # print(str(t) + 'の攻撃で、〇〇は倒れた')
    print(1)
else:
    while H > 0:
        H -= A
        t += 1
        # print('◆◆の攻撃' + str(A) + 'のダメージ' + '、〇〇の残り体力' + str(H))
    else:
        # print(str(t) + '回の攻撃で、〇〇は倒れた')
        print(t)

Measured memory_bytes: 2940
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.TreeSet;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int A = Integer.parseInt(sl[0]);
            int B = Integer.parseInt(sl[1]);
            int K = Integer.parseInt(sl[2]);

            K = Math.min(B - A + 1, K);

            TreeSet<Integer> ts = new TreeSet<Integer>();

            for (int i = A; i < A + K; i++) ts.add(i);

            for (int i = B - K + 1; i < B + 1; i++) ts.add(i);

            for (int i : ts) System.out.println(i);
        }
    }
}


Measured memory_bytes: 20564
package main

import (
	"fmt"
  	"strings"
)

func main() {
  	var (
		N int
		S string
	)
	const az string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	fmt.Scan(&N, &S)

	Sdiv := strings.Split(S, "")
	for i, s := range Sdiv {
		a := (strings.Index(az, s) + N) % 26
		Sdiv[i] = az[a : a+1]
	}
	fmt.Println(strings.Join(Sdiv, ""))
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
  int n,y;
  cin >> n >> y;
  bool a=false;
  rep(i,n+1){
    rep(j,n+1-i){
        int m=10000*i+5000*j+1000*(n-i-j);
        if(m==y){
          cout << i << " " << j << " " << n-i-j << endl;
          a=true;
          break;
        }
    }
    if(a)break;
  }
  if(!a) cout << -1 << " " << -1 << " " << -1 << endl;
      
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, plan1;
  cin >> a >> b >> c;
  plan1 = a * b;
  if (plan1 < c) {
  cout << plan1 << endl;
  }
  else if (plan1 > c)
    cout << c << endl;
  else
    cout << plan1 << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var h = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

            var flag = true;
            for(var i = h.Length - 1; i > 0; i--){
                if(h[i] < h[i-1]){
                    if(h[i] >= h[i-1] - 1){
                        h[i-1] -= 1;
                    }else{
                        flag = false;
                        break;
                    }
                }                
            }

            Console.WriteLine(flag ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 32220
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String ans = "Three";
        String Y = "Y";
        int N = sc.nextInt();
        for(int i =0;i<N;i++){
          String S = sc.next();
          if(S.equals(Y)){
            ans = "Four";
          }
        }
              System.out.println(ans);
    }
}

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

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	int n,k;
	cin >> n >> k;
	
	if(n/2 + n%2 < k) cout << "NO" << endl;
	else cout << "YES" << endl;
		
    return 0;   
}

Measured memory_bytes: 256
#include <cstdio>

int findFirstDigit(int v) {
    while (v >= 10) {
        v /= 10;
    }
    return v;
}

int findLastDigit(int v) {
    return v % 10;
}

int main() {
    int n;
    scanf("%d", &n);

    int res = 0;
    for (int x = 1; x < 10; x++)
    {
        for (int y = 1; y < 10; y++) {
            int cnt_a = 0;
            int cnt_b = 0;
            for (int v = 1; v <= n; v++) {
                
                if (findFirstDigit(v) == x and findLastDigit(v) == y) {
                    cnt_a += 1;
                }
                if (findFirstDigit(v) == y and findLastDigit(v) == x) {
                    cnt_b += 1;
                }
            }
            res += cnt_a * cnt_b;
        }
    }
    printf("%d\n", res);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  string s;
  cin >> s;
  map<char, int> mp;
  rep(i, s.size()) mp[s[i]]++;
  string ans = "No";
  if (mp['A'] > 0 and mp['B'] > 0) ans = "Yes";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int H,N;
  cin >> H >> N;
  int count = 0;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    count+=a;
  }
  if(count>=H)cout << "Yes" << endl;
  else{
    cout << "No" << endl;
  }
}

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

int main(){
    long long N;
    cin >> N;
    int counter = 0;
    int shisuu = 0;
    int a=2;

    while(N%2==0){
            N/=2;
            shisuu++;
        }
        
        if(shisuu!=0){
          /*  cout << a << ' ' << shisuu << endl; */
            int i=1;
            while(shisuu>=i){
                shisuu-=i;
                counter++;
                i++;
            }
        shisuu=0;
        }

    for(a=3; a<=pow(N, 0.5); a+=2){
        while(N%a==0){
            N/=a;
            shisuu++;
        }

        if(shisuu!=0){
       //     cout << a << ' ' << shisuu << endl;
            int i=1;
            while(shisuu>=i){
                shisuu-=i;
                counter++;
                i++;
            }
        shisuu=0;
        }
        
    }

    if(N!=1) counter++;

    cout << counter << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
  int n;
  scanf("%d", &n);

  int a[n];
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }

  int c = 0;
  bool flag = true;
  while (flag) {
    flag = false;
    for (int j = n - 1; j >= 1; j--) {
      if (a[j] < a[j - 1]) {
        swap(a[j], a[j - 1]);
        c++;
        flag = true;
      }
    }
  }
  for(int i  = 0; i < n; i++){
    if(i != 0) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
  printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 3220
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


bool isHam(int n){
    while(n%2==0)n/=2;
    while(n%3==0)n/=3;
    while(n%5==0)n/=5;
    if(n==1)return true;
    return false;
}

int main() {
    int m,n;
    while(cin>>m){
        if(m==0)break;
        cin>>n;
        
        int sum=0;
        for(int i=m;i<=n;i++){
            if(isHam(i))sum++;
        }
        cout<<sum<<endl;
    }

    return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if ((A == B && A != C) || (A == C && A != B) || (B == C && A != B))
    {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

char s[15][15];

int main() {
	int h, w, k;
	scanf("%d%d%d", &h, &w, &k);
	
	for (int i = 0; i < h; i++) scanf("%s", s[i]);
	
	int res = 0;
	
	for (int i = 0; i < (1 << (h + w)); i++) {
		int cnt = 0;
		for (int j = 0; j < h; j++) {
			for (int k = 0; k < w; k++) {
				if (((i >> j) & 1) || ((i >> (h + k)) & 1)) continue;
				cnt += (s[j][k] == '#');
			}
		}
		res += (cnt == k);
	}
	
	printf("%d\n", res);
}


Measured memory_bytes: 3784
// Author : Radhesh Sarma
   #include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("unroll-loops")
    using namespace std;
  using namespace __gnu_pbds;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define endl "\n"
    #define int long long
    #define all(v) v.begin(),v.end()
    #define rep(i,a,b) for(int i = a; i <=b; i++)
    #define rep2(i,a,b) for(int i = a; i>=b; i--)
    #define f first
    #define s second
    #define PB push_back
    #define MP make_pair
    #define db long double
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define cases int testcases;cin>>testcases; while(testcases--)
    #define INF 2000000000
    const double PI = acos(-1);
    const int N =  200005;


    bool isPrime(int n)
    {
        if(n <=1)
        {
          return false;
        }

        if(n <=3)
        {
          return true;
        }
      if(n%2 == 0 or n %3 == 0 )
      {
        return false;
      }


      for(int i = 2; i*i <= n; i++)
      {
        if(n%i == 0)
        {
          return false;
        }
      }

      return true;
    }
  int32_t main() 
  {
    IOS

      
      int t;
      cin >> t;

      while(!isPrime(t))
      {
        t++;
      }

      cout << t;
    
    return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<int,int>m;
set<int>s;
vector<int>v;
int main(void)
{
    int n,k;
    cin>>n>>k;
    int temp;
    for(int i=0;i<n;++i)
    {
        cin>>temp;
        s.insert(temp);
        m[temp]++;
    }
    if(s.size()<=k)
    {
        cout <<0<<endl;
    }
    else
    {
        int cnt=0;
        for(auto i:m)
        {
            v.push_back(i.second);
        }
        sort(v.begin(),v.end());
        for(int i=0;i<s.size()-k;++i)
        {
            cnt+=v[i];
        }
        cout <<cnt <<endl;
    }
    return 0;
}


Measured memory_bytes: 20092
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string s;
	cin >> n >> s;
	string t1(s, s.size() / 2);
	string t2(s, 0, s.size() / 2);
	if (n % 2 == 0 && t1 == t2)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int N = Integer.parseInt(br.readLine());
	int i = 1;
	double odd = 0.0000000000, even = 0.0000000000;

	while (i <= N) {
	    if (i % 2 == 0)
		even++;
	    else
		odd++;
	    i++;
	}
	System.out.println(odd / (odd + even));
    }
}

Measured memory_bytes: 23124
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]

B=sorted(A,key=lambda x:x[1])
total=0
a=True
for i in range(N):
    total+=B[i][0]
    if total>B[i][1]:
        print("No")
        a=False
        break
if a==True:
    print("Yes")


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

int main(void){
    long long n, a;
    cin >> n >> a;
    
    long long sum[51][2501] = {{0}};
    long long input;
    long long i;
    long long j;
    long long k;
    for(i = 1; i <= n; i++){
        cin >> input;
        for(j = i; j >= 2; j--){
            for(k = 1; k <= 2500 - input; k++){
                sum[j][k + input] += sum[j - 1][k];
            }
        }
        sum[1][input]++;
    }
    
    long long ans = 0;
    for(i = 1; i <= n; i++){
        ans += sum[i][i * a];
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>

int main(){

    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);

    if(a<0 || 100<a){
        return -1;
    }else{
        if(b<0 || 100<b){
            return -1;
        }else{
            if(c<0 || 100<c){
                return -1;
            }else{
                
                if(a<b && b<c){
                    printf("Yes\n");
                }else{
                    printf("No\n");
                }
            }
        }
    }
    return 0;
}

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

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> H >> W;
	vector<string> str(H);
	for (int i = 0; i < H; i++) cin >> str[i];
	H--;
	W--;
	vector<vector<int>>sum(H, vector<int>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if ((str[i][j] ^ str[i][j + 1] ^ str[i + 1][j] ^ str[i + 1][j + 1]) != ('#'^'.')) {
				sum[i][j] = 1;
			}
		}
	}
	for (int i = 1; i < H; i++) {
		for (int j = 0; j < W; j++)sum[i][j] = sum[i - 1][j] * sum[i][j] + sum[i][j];
	}
	int ans = 0;
	for (int i = 0; i < H; i++) {
		stack<int>s;
		vector<int>l(W);
		vector<int>r(W);
		s.push(0);
		for (int j = 1; j < W; j++) {
			if (sum[i][j] > sum[i][j - 1]) {
				s.push(j);
				l[j] = j;
				continue;
			}
			if (sum[i][j] == sum[i][j - 1]) {
				s.pop();
				s.push(j);
				l[j] = l[j - 1];
				continue;
			}
			while (!s.empty() && sum[i][s.top()] > sum[i][j]) {
				s.pop();
			}
			if (s.empty()) {
				l[j] = 0;
			}
			else {
				if (sum[i][s.top()] == sum[i][j]) {
					l[j] = l[s.top()];
					s.pop();
				}
				else {
					l[j] = s.top() + 1;
				}
			}
			s.push(j);
		}
		while (!s.empty())s.pop();
		s.push(W - 1);
		r[W - 1] = W - 1;
		for (int j = W - 2; j >= 0; j--) {
			if (sum[i][j] > sum[i][j + 1]) {
				s.push(j);
				r[j] = j;
				continue;
			}
			if (sum[i][j] == sum[i][j + 1]) {
				s.pop();
				s.push(j);
				r[j] = r[j + 1];
				continue;
			}
			while (!s.empty() && sum[i][s.top()] > sum[i][j]) {
				s.pop();
			}
			if (s.empty()) {
				r[j] = W-1;
			}
			else {
				if (sum[i][s.top()] == sum[i][j]) {
					r[j] = r[s.top()];
					s.pop();
				}
				else {
					r[j] = s.top() - 1;
				}
			}
			s.push(j);
		}
		for (int j = 0; j < W; j++) {
		//	cout << i << " " << j << " " << l[j] << " " << r[j] << " " << sum[i][j] << "  ";
			ans = max(ans, (r[j] - l[j] + 2)*(sum[i][j] + 1));
		}
		//cout << endl;
	}
	cout << max({ (long long int)ans,H+1,W+1 }) << endl;
	return 0;
}

Measured memory_bytes: 20224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int count_odd=0;
		
		for(int i=1;i<=N;i++) {
			if(i%2==1) {
				count_odd++;
			}
		}
		
		double ans = (double)count_odd/N;
		
		System.out.println(ans);
		
	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
int read();
int M(int x) { return x >= mod ? x - mod : x; }
int fsp(int bs, int p) {
    int rt = 1;
    while (p) {
        if (p & 1) rt = 1ll * rt * bs % mod;
        bs = 1ll * bs * bs % mod, p >>= 1;
    }
    return rt;
}

int n, k;
int fac[4000006], caf[4000006];
void init() {
    int lim = 4000000;
    fac[0] = 1;
    for (int i = 1; i <= lim; ++i) fac[i] = 1ll * fac[i - 1] * i % mod;
    caf[lim] = fsp(fac[lim], mod - 2);
    for (int i = lim; i >= 1; --i) caf[i - 1] = 1ll * caf[i] * i % mod;
}
int C(int x, int y) { return 1ll * fac[x] * caf[y] % mod * caf[x - y] % mod; }
int f[2003][2003];

int main() {
    n = read(), k = read(), init();
    if (k == 1) return puts("1"), 0;
    for (int i = 1; i <= n; ++i) f[i][0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= i; ++j)
            f[i][j] = M(f[i - 1][j] +
                        1ll * f[i][j - 1] * (n - j + 1) % mod *
                            C(n - i + (n - j + 1) * (k - 1) - 1, k - 2) % mod);
    printf("%d\n", f[n][n]);
    return 0;
}

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') f = (c == '-') ? -1 : f, c = getchar();
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}


Measured memory_bytes: 46336
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int t = sc.nextInt();
		
		int ans = 2000;
		
		for (int i = 0; i < n; i++) {
			int c = sc.nextInt();
			int t2 = sc.nextInt();
			if (t2 > t) continue;
			ans = Math.min(ans, c);
		}
		
		System.out.println((ans != 2000) ? ans : "TLE");
		
	}

}


Measured memory_bytes: 23636
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>

using namespace std;

int n;
vector<int> w;

int main(void) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		w.push_back(tmp);
	}

	int ret = 100*100;
	for (int i = 0; i < n; i++) {
		int s1 = accumulate(w.begin(), w.begin() + i, 0);
		int s2 = accumulate(w.begin() + i, w.end(), 0);
		int tmp = abs(s1 - s2);
		if (ret > tmp)
			ret = tmp;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> v(n),o(100001),e(100001);
  for(int i=0;i<n;i++){
    cin >> v[i];
    if(i%2==0){
      o[v[i]]++;
    }
    else{
      e[v[i]]++;
    }
  }
  int ans,ce,co,maxe=0,maxo=0,nexte,nexto;
  for(int i=1;i<=100000;i++){
    if(maxe<=e[i]){
      nexte=maxe;
      maxe=e[i];
      ce=i;
    }
    else if(maxe>e[i]&&e[i]>nexte){
      nexte=e[i];
    }
    if(maxo<=o[i]){
      nexto=maxo;
      maxo=o[i];
      co=i;
    }
    else if(maxo>o[i]&&o[i]>nexto){
      nexto=o[i];
    }
  }
  if(ce!=co){
    cout << n-maxe-maxo << endl;
  }
  else{
    cout << n-max(maxe+nexto,maxo+nexte) << endl;
  }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    for(int i = 0; i < N; i++) {
        cin >> L.at(i);
    }
    int bound = 1; int Dis = 0;

    for(int i = 0; i < N; i++) {
        Dis += L.at(i);
        if(Dis <= X) {
            bound++;
        }else {
            break;
        }
    }
    cout << bound << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;

    string WEEK[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

    int ans;
    for (int i = 0; i < 7; i++)
    {
        if (WEEK[i] == s)
        {
            ans = 7 - i;
            break;
        }
    }

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

Measured memory_bytes: 256
# Can you solve this?

N, M, C = map(int, input().split())
B = input().split()
score = 0

for i in range(N):
    state = 0
    A = input().split()
    for j in range(M):
        state = state + int(A[j])*int(B[j])
    if state + C > 0:
        score += 1
print(score)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int N, M;

int parent[200005];

void init()
{
	for(int i = 1; i <= N+M; i++) parent[i] = i;
}

int root(int i)
{
	if(parent[i] == i) return i;
	return parent[i] = root(parent[i]);
}

bool same(int i, int j)
{
	return root(i) == root(j);
}

void unite(int i, int j)
{
	int root_i = root(i);
	int root_j = root(j);
	if(root_i == root_j) return;
	parent[root_i] = root_j;
}

int main(void)
{
	cin >> N >> M;
	init();
	
	int K, L;
	for(int i = 1; i <= N; i++){
		cin >> K;
		for(int j = 0; j < K; j++){
			cin >> L;
			unite(i, N+L);
		}
	}
	
	for(int i = 1; i < N; i++){
		if(!same(i, i+1)){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N,M;
    cin>>N>>M;
    vector<vector<int>> E(N);
    for (int i=0;i<M;i++) {
        int a,b;
        cin>>a>>b;
        E[a-1].pb(b-1);
        E[b-1].pb(a-1);
    }
    


    for (int i=0;i<E[0].size();i++) {
        for (int j=0;j<E[E[0][i]].size();j++) {
          if (E[E[0][i]][j] == N-1) {
            cout<<"POSSIBLE"<<endl;
            return 0;
          }
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 12016
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] array = str.split(" ");

		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);

		if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
			System.out.println("Possible");
		} else {
			System.out.println("Impossible");
		}
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int n;string s,l=" ";map<string,bool>mp;bool f; 
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(!f&&i&&s[0]!=l[l.size()-1]||mp[s])
			f=1;
		mp[s]=1;
		l=s;
	}
	if(f)cout<<"No";else cout<<"Yes";
}

Measured memory_bytes: 256