akhauriyash/Code-Regression huggingface dataset:
class NormalInput {
  input: string[];
  pointer: number;
  constructor(raw: string) {
    this.input = raw.split(/ |\n/);
    this.pointer = 0;
  }
  read<T>(parser: (v: string) => T): () => T {
    return () => {
      const ret = parser(this.input[this.pointer]);
      this.pointer++;
      return ret;
    };
  }
  int = this.read((str) => parseInt(str, 10));
  ints = (length: number): number[] => {
    let ret: number[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.int());
    }
    return ret;
  };
  str = (): string => {
    const ret = this.input[this.pointer];
    this.pointer++;
    return ret;
  };
  strs = (length: number): string[] => {
    let ret: string[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.str());
    }
    return ret;
  };
  bint = (): bigint => {
    const ret = BigInt(this.input[this.pointer]);
    this.pointer++;
    return ret;
  };
  bints = (length: number): bigint[] => {
    let ret: bigint[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.bint());
    }
    return ret;
  };
}
function rep(a: number, b: number) {
  let arr = [];
  for (let i = a; i < b; i++) arr.push(i);
  return arr;
}

function Main({ int, str, strs, ints, bint }: NormalInput) {
  const X = bint();
  for (let a = BigInt(-120); a < 120; a++)
    for (let b = BigInt(-120); b < 120; b++) {
      if (X === a * a * a * a * a - b * b * b * b * b) {
        console.log(""+a, ""+b);
        return;
      }
    }
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 35320
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main()
{
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.length();i++){
        int cnt=0;
        for(int j=i;j<s.length();j++){
            if(s[j]=='A'||s[j]=='C'||s[j]=='G'||s[j]=='T'){
                cnt++;
            }else{
                i=j;
                break;
            }
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}

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

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim().Split(' ').Select(n => long.Parse(n)).ToArray();
            long ans = Lcm(line[0], line[1]);
            Console.WriteLine(ans);
        }
        // 最小公倍数
        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        // ユークリッドの互除法 
        public static long Gcd(long a, long b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
/*!* [binsearch] *!*/
/*+* 二分探索 *+*/
// judge を満たすような下限を求める
// l:[X] 定義域外部の上限
// r:[X] 定義域外部の下限
// judge:[X -> bool] X を評価する関数
// lower:[bool] falseにすると代わりに上限を求める
// eps:[X] 終了距離

template <typename X>
X BinSearch(X l, X r, function<bool(X)> judge, bool lower = true, X eps = 1) {
    while (r - l > eps) {
        X m = (r + l) / 2;
        if (judge(m) == lower) {
            r = m;
        } else {
            l = m;
        }
    }
    return lower ? r : l;
}

int main() {
    i64 N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<i64> A(N), S(N);
    for(i64 &x : A) cin >> x;
    sort(REV_WHOLE(A));
    for(int i = 0; i < N; i++) {
        S[i] = A[i] + (i ? S[i - 1] : 0);
    }
    int ans = P;
    for(i64 i = P; i < N; i++) {
        i64 v = V * M;
        v -= (P - 1) * M;
        int j = BinSearch<int>(P - 2, N, [&](int k) -> bool {
            return A[k] > A[i] + M;
        }, false);
        v -= (M + A[i]) * (i - j) - (S[i] - (j < 0 ? 0 : S[j]));
        v -= (N - 1 - i) * M;
        if(v <= 0 && A[i] + M >= A[P - 1]) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int p1[10];
int p2[100];
int p3[1000];
char s[30004];

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

    memset(p1, 0, sizeof(p1));
    memset(p2, 0, sizeof(p2));
    memset(p3, 0, sizeof(p3));
    int n = gi();
    scanf("%s", s);
    for (int i = 0; i < n; i++) {
        int d = s[i] - '0';
        for (int k = 0; k < 100; k++)
            if (p2[k])
                p3[d*100+k] = 1;
        for (int k = 0; k < 10; k++)
            if (p1[k])
                p2[d*10+k] = 1;
        p1[d] = 1;
    }

    int c = 0;
    for (int i = 0; i < 1000; i++)
        c += p3[i];

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <list>
#include <math.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

/*******-c++14 don't include-*******/
template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
void printArr(int *a, int len){for(int i=0; i<len; i++){if(i)cout << " ";cout << a[i];}cout << endl;}
/*******---------------------*******/

static const int INTINF = (2147483647);
static const ll LLINF = (1ll<<32);
static const int MAX = 100001;

int arr[MAX];

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    string s;
    cin >> s;
    int now = 7;
    if(s == "MON"){
        now = 6;
    }else if(s == "TUE"){
        now = 5;
        
    }else if(s == "WED"){
        now = 4;
    }else if(s == "THU"){
        now = 3;
    }else if(s == "FRI"){
        now = 2;
    }else if(s == "SAT"){
        now = 1;
    }
    cout << now << endl;
    
    
    return 0;
}


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

int main() {
  int H, W, A, B, C;
  cin >> H >> W;
  A = (H % 3 && W % 3) ? min(H, W) : 0;
  int w = W / 3, h = H / 3;
  B = min((H - H / 2) * (W - w) - w * H, (w + 1) * H - H / 2 * (W - w - 1));
  C = min((W - W / 2) * (H - h) - h * W, (h + 1) * W - W / 2 * (H - h - 1));
  cout << min({A, B, C}) << 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(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int h, w,n,tmp=0;
	cin >> h >> w >> n;
	REP(i, max(h,w)) {
		tmp += max(h, w);
		if (n <= tmp) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    ll x; cin >> x;

    ll res = 0;
    for (ll i = 1; i < 1001001; i++) {
        if (x <= res) {
            cout << i-1 << endl;
            break;
        } 
        res += i;
    }

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
struct Query{
  lint idx;
  lint B;
  bool operator < (const Query &other) const { return B < other.B; }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N;
  cin >> N;
  vector<lint> A(N);
  vector<lint> B(N);
  REP(i, N) cin >> A[i];
  REP(i, N) cin >> B[i];
  priority_queue<Query, vector<Query>> pq;
  REP(i, N) {
    if(A[i] < B[i]) {
      Query o;
      o.idx = i;
      o.B = B[i];
      pq.push(o);
    }
  }
  lint ans = 0;
  while(!pq.empty()) {
    Query o = pq.top();
    pq.pop();
    lint num1 = (B[o.idx] - (B[(o.idx-1+N)%N] + B[(o.idx+1)%N]) - 1) / (B[(o.idx-1+N)%N] + B[(o.idx+1)%N]) + 1;
    lint num2 = (B[o.idx] - A[o.idx] - 1) / (B[(o.idx-1+N)%N] + B[(o.idx+1)%N]) + 1;
    lint num = min(num1, num2);
    if(num <= 0) {
      cout << -1 << endl;
      return 0;
    }
    B[o.idx] -= num * (B[(o.idx-1+N)%N] + B[(o.idx+1)%N]);
    ans += num;
    if(B[o.idx] < A[o.idx]) {
      cout << -1 << endl;
      return 0;
    } else if(B[o.idx] > A[o.idx]) {
      o.B = B[o.idx];
      pq.push(o);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 9584
#!/usr/bin/python3

import math
import os
import sys


sys.setrecursionlimit(1000000)


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, M, E):
    G = [set() for _ in range(N)]
    for a, b in E:
        G[a].add(b)

    visited = set()
    stk = []
    stki = {}

    def dfs(i):
        if i in visited:
            return

        stki[i] = len(stk)
        stk.append(i)

        for j in G[i]:
            if j in visited:
                continue
            if j in stki:
                si = stki[j]
                vset = set(stk[si:])
                loopd = {}
                for k in range(si, len(stk) - 1):
                    loopd[stk[k]] = stk[k + 1]
                loopd[stk[-1]] = stk[si]
                return slim_loop(vset, loopd)
            result = dfs(j)
            if result:
                return result

        stk.pop()
        del stki[i]
        visited.add(i)
        return None

    def slim_loop(vset, loopd):
        i = next(iter(vset))
        endi = i
        while True:
            jset = G[i] & vset
            if len(jset) > 1:
                oj = loopd[i]
                for j in jset:
                    if j == oj or j not in vset:
                        continue
                    k = loopd[i]
                    while k != j:
                        vset.remove(k)
                        k = loopd[k]
                    loopd[i] = j
                endi = i

            i = loopd[i]
            if i == endi:
                break

        return vset

    for i in range(N):
        if i not in visited:
            result = dfs(i)
            if result:
                return result

    return None


def main():
    N, M = [int(e) for e in inp().split()]
    E = []
    for _ in range(M):
        a, b = [int(e) - 1 for e in inp().split()]
        E.append((a, b))

    result = solve(N, M, E)
    if not result:
        print('-1')
    else:
        print(len(result))
        for v in result:
            print(v + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41712
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    double a[n];
    vector<string> str;
    for(int i = 0;i < n;i++) {
        string x;
        cin >> a[i] >> x;
        str.push_back(x);
    }
    double result = 0.0;
    for(int i = 0;i < n;i++) {
        if(str[i] == "JPY") {
            result+=a[i];
        } else {
            result+=a[i]*380000;
        }
    }
    cout << fixed<< setprecision(10)<<result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define MOD 1000000007LL

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

  ll n, k; cin >> n >> k;

  auto pow = [](ll a, int n) {
    ll res = 1;
    for (; n; n >>= 1) {
      if (n & 1) res = res * a % MOD;
      a = a * a % MOD;
    }
    return res;
  };

  vector<ll> table(n+1), invTable(n+1);
  table[0] = 1;
  for (int i = 1; i <= n; i++) {
    table[i] = table[i-1] * i % MOD;
  }
  invTable[n] = pow(table[n], MOD-2);
  for (int i = n; i > 0; i--) {
    invTable[i-1] = invTable[i] * i % MOD;
  }

  auto comb = [&](int n, int r) {
    ll tmp = invTable[n-r] * invTable[r] % MOD;
    return table[n] * tmp % MOD;
  };

  ll ans = 0;
  for (int i = 0; i <= min(k, n-1); i++)  {
    ans += comb(n, i) * comb(n-1, i) % MOD;
    ans %= MOD;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);
    rep(i, n) cin >> p[i];
    vector<double> kc(n), dp(n + 1, 0);
    rep(i, n) {
        kc[i] = (1 + p[i]) / 2.0;
        dp[i + 1] = dp[i] + kc[i];
    }
    double ans = -1;
    reps(i, k - 1, n) {
        ans = max(ans, dp[i + 1] - dp[i + 1 - k]);
    }
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>
#include <regex>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = int64_t;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};

int toDigit(int n){
    int ans = 0;
    while(n > 9){
        ans += n%10;
        n /= 10;
    }
    ans += n;
    return ans;
}

void solve(){
    int n;
    cin >> n;
    
    int ans = INF;
    for(int i = 1; i < n/2+1; i++){
        int temp = toDigit(i) + toDigit(n-i);
        if(temp < ans) ans = temp;
    }
    cout << ans << endl;
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	int N;
	string S;
	cin >> N >> S;
	map<char, int>mp;
	for (int i = 0; i < N; ++i) {
		mp[S[i]]++;
	}
	LL ans = 1;
	const LL P = 1000000007;
	for (auto p : mp) {
		ans *= (p.second + 1);
		ans %= P;
	}
	ans += (P - 1);
	ans %= P;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
/* amitdwivedi */
#include <bits/stdc++.h>
using namespace std;
using ll = long long int; 
#define fr(i,b) for (ll i = 0; i < b; ++i)
#define tr(x,cont) for(auto x:cont)
#define c(x) cout << x << endl;
const ll mxn = 2e5+1;
 ll zeros(ll n) 
{ 
    ll count = 0; 
 
    for (ll i = 5; n / i>= 1; i *= 5) 
        count += n / i; 
  
    return count; 
} 
int main(){ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll n;
    cin>>n;
    if(n&1) {c(0);
    	return 0;
    }
    cout <<zeros(n/2) <<endl;
}

Measured memory_bytes: 256
mod = 1000000007
fact = []
fact_inv = []
pow_ = []
pow25_ = []
pow26_ = []

def pow_ini(nn):
	global pow_
	pow_.append(nn)
	for j in range(62):
		nxt = pow_[j] * pow_[j]
		nxt %= mod
		pow_.append(nxt)
	return

def pow_ini25(nn):
	global pow25_
	pow25_.append(nn)
	for j in range(62):
		nxt = pow25_[j] * pow25_[j]
		nxt %= mod
		pow25_.append(nxt)
	return

def pow_ini26(nn):
	global pow26_
	pow26_.append(nn)
	for j in range(62):
		nxt = pow26_[j] * pow26_[j]
		nxt %= mod
		pow26_.append(nxt)
	return

def pow1(k):
	ansk = 1
	for ntmp in range(62):
		if((k >> ntmp) % 2 == 1):
			ansk *= pow_[ntmp]
			ansk %= mod
	return ansk

def pow25(k):
	ansk = 1
	for ntmp in range(31):
		if((k >> ntmp) % 2 == 1):
			ansk *= pow25_[ntmp]
			ansk %= mod
	return ansk

def pow26(k):
	ansk = 1
	for ntmp in range(31):
		if((k >> ntmp) % 2 == 1):
			ansk *= pow26_[ntmp]
			ansk %= mod
	return ansk

def fact_ini(n):
	global fact
	global fact_inv
	global pow_
	for i in range(n + 1):
		fact.append(0)
		fact_inv.append(0)
	fact[0] = 1
	for i in range(1, n + 1, 1):
		fact_tmp = fact[i - 1] * i
		fact_tmp %= mod
		fact[i] = fact_tmp
	pow_ini(fact[n])
	fact_inv[n] = pow1(mod - 2)
	for i in range(n - 1, -1, -1):
		fact_inv[i] = fact_inv[i + 1] * (i + 1)
		fact_inv[i] %= mod
	return

def nCm(n, m):
	assert(m >= 0)
	assert(n >= m)
	ans = fact[n] * fact_inv[m]
	ans %= mod
	ans *= fact_inv[n - m]
	ans %= mod
	return ans;

fact_ini(2200000)
pow_ini25(25)
pow_ini26(26)
K = int(input())
S = input()
N = len(S)
ans = 0
for k in range(0, K+1, 1):
	n = N + K - k
	anstmp = 1
	anstmp *= pow26(k)
	anstmp %= mod
	anstmp *= nCm(n - 1, N - 1)
	anstmp %= mod
	anstmp *= pow25(n - N)
	anstmp %= mod
	ans += anstmp
	ans %= mod
print(ans)

Measured memory_bytes: 208144
#include <bits/stdc++.h>
#define N 55
using namespace std;
const int INF = 1e9;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef priority_queue<PP,vector<PP>,greater<PP> > PQ;
int n, fee[N], height[N],G[2][N][N];
int D[N][N][1<<10];

int Push(PQ &Q,int cost,int p1,int p2,int bit){
  if(D[p1][p2][bit] <= cost) return 0 ;
  D[p1][p2][bit] = cost;
  Q.push(PP(P(cost,p1),P(p2,bit)));
  return 1;
}

int dijkstra(){

  int idx[N];
  map<int,int> cnt;
  for(int i=0;i<n;i++) idx[i] = cnt[height[i]]++;

  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      for(int k=0;k<(1<<10);k++) D[i][j][k] = INF;
  PQ Q;
  Push(Q,0,0,0,1<<idx[0]);
  
  while(!Q.empty()){
    PP t = Q.top();Q.pop();
    int cost = t.first.first;
    int p1 = t.first.second;
    int p2 = t.second.first;
    int bit = t.second.second;
    if(D[p1][p2][bit] < cost) continue;
    if(p1 == n-1 && p2 == n-1) return cost;
    
    for(int to=0;to<n;to++){
      int ncost = cost + G[0][p1][to] + fee[to];
      int nbit = bit;
      if(height[p1] == height[to] && bit>>idx[to]&1) ncost -= fee[to] ;
      if(height[p1] == height[to]) nbit |= 1<<idx[to];
      else nbit = 1<<idx[to];
      Push(Q,ncost,to,p2,nbit);
    }
    
    for(int to=0;to<n;to++){
      int ncost = cost + G[1][p2][to] + fee[to];
      if(height[p1] == height[to] && bit>>idx[to]&1) ncost -= fee[to];
      Push(Q,ncost,p1,to,bit);
    }
  }
  return -1;
}

signed main(){
  while(1){
  int m;
  cin>>n>>m;
  if(n == 0 && m == 0) return 0;
  memset(fee,0,sizeof(fee));
  memset(height,0,sizeof(height));
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++) G[0][i][j] = G[1][i][j] = INF;
  
  height[0] = 0;
  height[n-1] = 1000;
  for(int i=1;i<n-1;i++) cin>>fee[i]>>height[i];
  
  for(int i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c; a--, b--;
    if(height[a] <= height[b]) Min(G[0][a][b],c);
    if(height[a] >= height[b]) Min(G[1][b][a],c);
  }
  cout<<dijkstra()<<endl;
  }
  return 0;
}

Measured memory_bytes: 47884
def convert_to_int(day):
    day_int_conversion = {"SUN": 0, "MON": 1, "TUE": 2, "WED": 3, "THU": 4, "FRI": 5, "SAT": 6}
    today = day_int_conversion[day]
    # mon->6, sun->7, sat->1
    return 7-today


if __name__ == "__main__":
    test1 = "SAT"
    test2 = "SUN"
    testcustom3 = "TUE"
    print(convert_to_int(input()))

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

#define ll long long
ll n, p;

int main()
{
    while (scanf("%lld%lld", &n, &p) != EOF)
    {
        if (n == 1)
        {
            printf("%lld\n", p);
            continue;
        }
        ll res = 1;
        for (ll i = 2; i * i <= p; ++i)
        {
            ll tmp = 0;
            while (p % i == 0)
            {
                ++tmp;
                p /= i;
            }
            while (tmp >= n)
            {
                tmp -= n;
                res *= i;
            }
        }
        printf("%lld\n", res);
    }
    return 0;
}

Measured memory_bytes: 256
use std::cmp::Ordering;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let  s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: i32, b: i32, c: i32, d: i32
    }
    println!("{}",
    match (a+b).cmp(&(c+d)) {
        Ordering::Greater => "Left",
        Ordering::Equal => "Balanced",
        Ordering::Less => "Right"
    });
}


Measured memory_bytes: 4352
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def main():
    n = int(input())
    s,t = input().split()
    ans = []
    for i in range(n):
        ans.append(s[i])
        ans.append(t[i])
    print(''.join(ans))
    return

if __name__=='__main__':
    main()

Measured memory_bytes: 38508
while True:
    a,b=map(int,input().split())
    if a==0 and b==0:
        break
    for i in range(a):
        for j in range(b):
            if (i+j)%2==0:
                print('#',end='')
            else:
                print('.',end='')
        print()    
    print()


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


int f(int n) {
    if (n % 2 == 0) {
        return n / 2;
    }
    return 3 * n + 1;
}

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

    vector<int> a;

    a.push_back(s);

    for (int i = 1; i < 1000000; i++) {
        int x = f(a.at(i-1));
        a.push_back(x);
        if (count(a.begin(), a.end(), x) == 2) {
            cout << i + 1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ll INF = 1e15;
const ld eps = 1e-9;
const db PI = atan(1) * 4;

template<typename T, typename S>inline bool upmin(T&a, const S&b) { return a > b ? a = b, 1 : 0; }
template<typename T, typename S>inline bool upmax(T&a, const S&b) { return a < b ? a = b, 1 : 0; }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
ll pow(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	if (b == 1) {
		return a;
	}
	ll ans = pow(a, b / 2);
	ans *= ans;
	ans *= b % 2 == 1 ? a : 1;
	return ans;
}

#define MAXN 10000

namespace SOLVE {
	struct edge {
		ll to, weight;
		edge(ll a, ll b) { to = a, weight = b; }
	};

	int visited[MAXN];
	int maxweight[MAXN];
	vector<edge> es[MAXN];
	int far, maxdistance;

	void dfs(int v,  int distance) {
		visited[v] = 1;
		maxweight[v] = max(maxweight[v], distance);

		for (edge e : es[v]) {
			if (!visited[e.to]) {
				dfs(e.to, distance + e.weight);
			}
		}
	}


	void main() {
		int n, a, b, c;
		scanf("%d", &n);

		REP(i, 0, n - 1) {
			scanf("%d%d%d", &a, &b, &c);
			es[a].push_back(edge(b,c));
			es[b].push_back(edge(a,c));
		}

		REP(i, 0, n) {
			if (es[i].size() == 1) {
				memset(visited, 0, sizeof(visited));
				dfs(i, 0);
			}
		}
		REP(i, 0, n) {
			printf("%d\n", maxweight[i]);
		}

	
	}
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t;
	//    in(t);
	t = 1;
	while (t--) {
		SOLVE::main();

	}

	return 0;
}



Measured memory_bytes: 4328
n, q = map(int, raw_input().split())
S = raw_input()
appearance = [0] * n
for i in range(1, n):
    appearance[i] = appearance[i-1]
    if S[i-1] == "A" and S[i] == "C":
        appearance[i] += 1
for _ in range(q):
    l, r = map(int, raw_input().split())
    print appearance[r-1] - appearance[l-1]

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

int main() {
    ll n,k,c;
    std::cin >> n>>k>>c;
    
    string s;
    std::cin >> s;
    vector<ll> l(n,-1),r(n,-1);
    ll last = -1e15;
    ll now = 0;
    for (ll i = 0; i < n; i++) {
        if(now==k)break;
        if(s[i]=='o'&&last+c<i){
            l[i] = now;
            last = i;
            now++;
        }
    }
    now = k-1;
    last = -1e15;
    for (ll i = 0; i < n; i++) {
        if(s[n-1-i]=='o'&&last+c<i){
            r[n-1-i] = now;
            last = i;
            now--;
        }
    }
    
    for (int i = 0; i < n; i++) {
        // std::cout << l[i] <<" "<<r[i] << std::endl;
        if(r[i]!=-1&&r[i]==l[i]){
            std::cout << i+1 << std::endl;
        }
    }
}


Measured memory_bytes: 6816
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC137D();

#if 1
int main()
{
	ABC137D();
	fflush(stdout);
	return 0;
}
#endif


static void ABC137D()
{
	int N, M;
	getint(N, M);
	
	std::vector<std::vector<int>> data(M + 1);
	for (int i = 0; i < N; i++) {
		int day, money;
		getint(day, money);
		if (day <= M) {
			data[day].push_back(money);
		}
	}

	std::vector<int> money(M + 1, 0);
	std::priority_queue<int> pque;
	for (int i = 0; i <= M; i++) {
		for (auto it = data[i].begin(); it != data[i].end(); it++) {
			pque.push(*it);
		}
		if (!pque.empty()) {
			money[i] = pque.top(); pque.pop();
		}
	}

	LLONG ans = 0;
	for (int i = 0; i <= M; i++) {
		ans += (LLONG)money[i];
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
int INF = 1e9;
 
int main(){
  int H, W, K;
  cin >> H >> W >> K;
  
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  vector<vector<int>> dist(H+2,vector<int>(W+2,INF));
  vector<vector<char>> vec(H+2,vector<char>(W+2,'@'));
  for(int i=1; i<=H; i++){
    for(int j=1; j<=W; j++){
      cin >> vec[i][j];
    }
  }
  
  vector<int> dx = {0,1,0,-1};
  vector<int> dy = {1,0,-1,0};
  P start = {x1,y1};
  queue<P> Q;
  Q.push(start);
  dist[x1][y1] = 0;
  while(Q.size()){
    P p = Q.front();
    Q.pop();
    int nx = p.first;
    int ny = p.second;
    for(int i=0; i<4; i++){
      for(int j=1; j<=K; j++){
        if(vec[nx + dx[i]*j][ny + dy[i]*j] == '@'){
          break;
        }
        else if(dist[nx + dx[i]*j][ny + dy[i]*j] <= dist[nx][ny]){
          break;
        }
        else if(dist[nx + dx[i]*j][ny + dy[i]*j] > dist[nx][ny] + 1){
          dist[nx + dx[i]*j][ny + dy[i]*j] = dist[nx][ny] + 1;
          P q = {nx + dx[i]*j, ny + dy[i]*j};
          Q.push(q);
        }
      }
    }
  }
  if(dist[x2][y2] == INF){
    dist[x2][y2] = -1;
  }
  cout << dist[x2][y2] << endl;
}

Measured memory_bytes: 18840
import java.util.Scanner;

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

		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26100
#![allow(unused_imports)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt;
use std::io::{self, BufWriter, Read, StdinLock, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};


fn solve(x: u32, y: u32, z: u32) -> u32 {
    (x - z) / (y + z)
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    println!("{}", solve(sc.next(), sc.next(), sc.next()));
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(1024),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        let buf = &mut self.buf;
        buf.clear();
        self.bytes
            .by_ref()
            .map(Result::unwrap)
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
            .foreach(|c| buf.push(c));
        str::from_utf8(&buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
        <T3 as FromStr>::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }
}


trait Foreach {
    type Item;
    fn foreach<F: FnMut(Self::Item)>(self, f: F);
}

impl<T, I: Iterator<Item = T>> Foreach for I {
    type Item = T;

    fn foreach<F: FnMut(T)>(self, mut f: F) {
        self.fold((), move |(), x| f(x));
    }
}


#[allow(dead_code)]
fn print_yesno(x: bool, yes: &'static str, no: &'static str) {
    println!("{}", if x { yes } else { no });
}


#[allow(dead_code)]
fn print_foreach<T: fmt::Display, I: IntoIterator<Item = T>>(xs: I) {
    let stdout = io::stdout();
    let mut stdout = BufWriter::new(stdout.lock());
    for x in xs.into_iter() {
        writeln!(stdout, "{}", x).unwrap();
    }
    stdout.flush().unwrap();
}


#[allow(dead_code)]
fn print_or<T: fmt::Display>(x: Option<T>, or: &'static str) {
    if let Some(x) = x {
        println!("{}", x);
    } else {
        println!("{}", or);
    }
}


Measured memory_bytes: 4352
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node {
    int value;
    struct node* parent;
    struct node* left;
    struct node* right;
};

static struct node* insert(struct node* root, int value) {
    struct node *x, *y;
    x = root;
    y = NULL;
    while (x != NULL) {
        y = x;  // 親を覚えておく
        if (value < x->value) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    x = (struct node*)malloc(sizeof(struct node));
    x->value = value;
    x->parent = y;
    x->left = x->right = NULL;

    if (y == NULL) {
        return x;
    } else if (x->value < y->value) {
        y->left = x;
    } else {
        y->right = x;
    }
    return root;
}
static void print_in_order(struct node* root) {
    if (root->left != NULL) {
        print_in_order(root->left);
    }
    printf(" %d", root->value);
    if (root->right != NULL) {
        print_in_order(root->right);
    }
}
static void print_pre_order(struct node* root) {
    printf(" %d", root->value);
    if (root->left != NULL) {
        print_pre_order(root->left);
    }
    if (root->right != NULL) {
        print_pre_order(root->right);
    }
}
static void eFgets(char* buf, size_t size, FILE* fp) {
    if (fgets(buf, size, fp) == NULL) {
        fprintf(stderr, "fgets error:%s\n", strerror(errno));
        exit(1);
    }
    // LF削除
    buf[strlen(buf) - 1] = '\0';
    // CR削除
    if (buf[strlen(buf) - 1] == '\r') {
        buf[strlen(buf) - 1] = '\0';
    }
}
int main(int argc, char const* argv[]) {
    struct node* root;
    char buf[255];

    fgets(buf, sizeof(buf), stdin);
    int m = atoi(buf);

    root = NULL;
    for (int i = 0; i < m; i++) {
        fgets(buf, sizeof(buf), stdin);
        if (buf[0] == 'i') {
            int v = atoi(&buf[7]);
            root = insert(root, v);
        } else {
            print_in_order(root);
            puts("");
            print_pre_order(root);
            puts("");
        }
    }
    return 0;
}



Measured memory_bytes: 25120
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	int N;
	string s;

	cin >> N >> s;
	s += s;

	rep(fc,2) rep(fp,2){
		string ans;
		ans += (fc ? 'S' : 'W' );
		ans += (fp ? 'S' : 'W' );
		rep(i,N+5) if(i){
			if( ((ans[i] == 'S') && (s[i] == 'o')) ||
				((ans[i] == 'W') && (s[i] == 'x')) ){
				ans += ans[i-1];
			}else{
				ans += (ans[i-1] == 'S' ? 'W' : 'S');
			}
		}
		if( ans[0] == ans[N] && ans[1] == ans[N+1]){
			cout << ans.substr(0,N) << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 824
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int m, n;
    cin >> m >> n;
    int ans = 0;
    for(int i = 0; i < m; i++){
        int cnt = 0;
        for(int j = 0; j < n; j++){
            int a;
            cin >> a;
            cnt += a;
        }
        ans = max(ans, cnt);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3108
N = gets.chomp

arr = [N[0], N[1], N[2]]

if N[0] != '7' then
    if N[1] != '7' then
        if N[2] != '7' then
            puts 'No'
        else
            puts 'Yes'
        end
    else
        puts 'Yes'
    end
else
    puts 'Yes'
end


Measured memory_bytes: 14388
#ifndef CLASS_MODINT
#define CLASS_MODINT

#include <cstdint>

template <std::uint32_t mod>
class modint {
private:
	std::uint32_t n;
public:
	modint() : n(0) {};
	modint(std::int64_t n_) : n((n_ >= 0 ? n_ : mod - (-n_) % mod) % mod) {};
	static constexpr std::uint32_t get_mod() { return mod; }
	std::uint32_t get() const { return n; }
	bool operator==(const modint& m) const { return n == m.n; }
	bool operator!=(const modint& m) const { return n != m.n; }
	modint& operator+=(const modint& m) { n += m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator-=(const modint& m) { n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator*=(const modint& m) { n = std::uint64_t(n) * m.n % mod; return *this; }
	modint operator+(const modint& m) const { return modint(*this) += m; }
	modint operator-(const modint& m) const { return modint(*this) -= m; }
	modint operator*(const modint& m) const { return modint(*this) *= m; }
	modint inv() const { return (*this).pow(mod - 2); }
	modint pow(std::uint64_t b) const {
		modint ans = 1, m = modint(*this);
		while (b) {
			if (b & 1) ans *= m;
			m *= m;
			b >>= 1;
		}
		return ans;
	}
};

#endif // CLASS_MODINT

#include <vector>
#include <iostream>
using namespace std;
using mint = modint<1000000007>;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	mint pa = mint(K) * mint(K + 1) * mint(2).inv();
	mint pb = mint(K - 1) * mint(K) * mint(2).inv();
	mint ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < i; ++j) {
			if (A[i] == A[j]) continue;
			if (A[i] < A[j]) {
				ans += pa;
			}
			else {
				ans += pb;
			}
		}
	}
	cout << ans.get() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl
int gcd(int x, int y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}
int main() {
    IN(int, n);
    vi a(n);
    REP(i, n){
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 1; i < n-1; i++) {
        if ((a[i-1]-a[i])*(a[i+1]-a[i])<0) {
            ans++;
        }
    }
    COUT(ans);
}


Measured memory_bytes: 256
import Data.List
main = do
  n <- readLn :: IO Int
  xs <- reverse . sort . map read . words <$> getLine
  let alice = sum $ map fst $ filter (\(_,i) -> even i) $ zip xs [0..]
  let bob = sum $ map fst $ filter (\(_,i) -> odd i) $ zip xs [0..]
  print $ alice  - bob

Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int R,G,B,N;
  cin>>R>>G>>B>>N;

  ll ans=0;
  for(int i=0;R*i<=N;i++){
    for(int j=0;R*i+j*G<=N;j++){
      int rest=N-R*i-j*G;
      if(rest%B==0) ans++;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int a,b,t;
int main()
{
    cin>>a;
    b=a;
    while(b)
    {
        t=t*10+b%10;
        b/=10;
    }
    if(a==t) cout<<"Yes";
    else  cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)
#define AAA (1000000007)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


//int A[MMM][MMM] = { 0 };

int main() {
	int i, j, k;
	ll N, M;

	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	if (a != c)cout << 1;
	else
		cout << 0;
	
	return 0;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            char[] c = in.next().toCharArray();
            Arrays.sort(c);
            char[] abc = {'a', 'b', 'c'};
            for (int i = 0; i < 3; i++) {
                if (c[i] != abc[i]) {
                    out.println("No");
                    return;
                }
            }
            out.println("Yes");
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

    }
}



Measured memory_bytes: 21332