akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros
template <long long Mod>
struct modint {
    ll n;
    modint(ll x = 0) : n((x + Mod) % Mod) {
    }

    modint operator+(const modint &r) const { return modint(*this) += r; }
    modint operator-(const modint &r) const { return modint(*this) -= r; }
    modint operator*(const modint &r) const { return modint(*this) *= r; }
    modint operator/(const modint &r) const { return modint(*this) /= r; }
    modint operator+=(const modint &r) {
        n += r.n;
        n %= Mod;
        return *this;
    }
    modint operator-=(const modint &r) {
        n -= r.n;
        n += Mod;
        n %= Mod;
        return *this;
    }
    modint operator*=(const modint &r) {
        n *= r.n;
        n %= Mod;
        return *this;
    }
    modint operator/=(const modint &r) {
        *this *= modint(r).inv();
        return *this;
    }

    modint operator=(const modint &r) { return n = r.n; }
    modint operator==(const modint &r) const { return n == r.n; }
    modint operator!=(const modint &r) const { return n != r.n; }

    modint inv() const { return pow(Mod - 2); }

    modint pow(const ll x) const {
        if (n == 0) return modint(0);
        if (x == 0) return modint(1);
        if (x == 1) return modint(n);

        modint a = modint(*this);
        a = (a * a).pow(x / 2);

        if (x % 2 == 1) {
            a *= n;
        }
        return a;
    }

    friend ostream &operator<<(ostream &os, const modint &x) { return os << x.n; }
    friend istream &operator>>(istream &is, modint &x) { return is >> x.n; }
};

using mint = modint<2019>;

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

    int N = S.size();

    vector<mint> m(N); // m[i] : Sの[i,N)の部分文字列を、mod 2019した値

    m[N - 1] = S[N - 1] - '0';

    for (int i = N-2, k=1; i >= 0 ; i--,k++) {
        mint s = mint(S[i] - '0') * mint(10).pow(k);
        m[i] = m[i + 1] + s;
    }

    vector<vector<short>> t(N+1, vector<short>(2020, 0)); //t[i][j] : [i,N)の、mod 2019がjのものの数


    for (int i = N - 1;i>=0;i--){
        t[i][m[i].n]++;
        rep(j, 2020) t[i][j] += t[i + 1][j];
    }

    ll ans = 0;

    for(int i=0;i<N;i++){
        ans += t[i + 1][m[i].n];
        if (m[i].n == 0) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 800272
a, b, m = map(int, input().split())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
xx = [0] * m
yy = [0] * m
cc = [0] * m
for i in range(m):
    xx[i], yy[i], cc[i] = map(int, input().split())

ans = min(aa) + min(bb)
for i in range(m):
    ans = min(ans, aa[xx[i] - 1]+ bb[yy[i] - 1] - cc[i])
print(ans)


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

int main()
{
    int n;
    cin >> n;
    double sum = 0;
    for(int i = 0; i < n; i++){
        double y;
        string s;
        cin >> y >> s;
        if(s[0] == 'J'){
            sum += y;
        }else{
            sum += y * 380000.0;
        }
    }
    cout << sum;
}


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

int n;
ll ans = 0,r = 0, g = 0, b = 0;;
string s;

int main()
{

  cin >> n >> s;
  
  for (char c : s){
    if (c == 'R') r++;
    if (c == 'G') g++;
    if (c == 'B') b++;
  }
  ans = r * g * b;
  rep(i, n){
    for (int j = 1; i+j+j < n; j++){
      if ((s[i] * s[i + j] * s[i + j + j]) == ('R' * 'G' * 'B')){
        ans--;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}

// sum(0), add(0,x) してはいけない
template<typename T>
class BIT{
public:
    vector<T> bit;
    int size;
    BIT(int size):
        bit(vector<T>(size+1,0)),size(size){}
    
    T sum(int i){
        if(!i) return 0;
        return bit[i]+sum(i-(i&(-i)));
    }

    void add(int i,T x){
        if(i>size)return;
        bit[i]+=x;
        add(i+(i&(-i)),x); 
    }   
};

int main(){
    int N; ll D, A; cin >> N >> D >> A;
    vector<pair<ll,ll>> v(N);
    REP(i,N) cin >> v[i].first >> v[i].second;
    sort(all(v));
    BIT<ll> bit(N+10);
    REP(i,N) {
        bit.add(i+2,v[i].second);
        bit.add(i+3,-v[i].second);
    }
    ll ans = 0;
    REP(i,N) {
        ll tairyoku = (bit.sum(i+2));
        if(tairyoku<=0) continue;
        ll kaisuu = (tairyoku%A==0 ? tairyoku/A : tairyoku/A+1);
        ans += kaisuu;
        ll iryoku = kaisuu*A;
        int idx = upper_bound(all(v),make_pair(v[i].first+2*D,INF)) - v.begin();
        bit.add(i+2,-iryoku);
        bit.add(idx+2,iryoku);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
import heapq

class Node():
    def __init__(self, id, w):
        self.id = id
        self.weight = w

    def __str__(self):
        return "id: {}\t weight:{}".format(self.id, self.weight)

    def __lt__(self, other):
        return self.weight < other.weight

class WeightDirectedGraph():    
    def __init__(self, V):
        self.G = {i: [] for i in range(V)}
        self.V = V
        self.INF = 10**10

    def append(self, a, b, w):
        self.G[a].append(Node(b, w))

    def dijkstra(self, s):
        # distance from s
        D = [self.INF] * self.V
        D[s] = 0

        # node with minimum distance
        H = []
        heapq.heappush(H, Node(s, D[s]))

        while len(H) > 0:
            u = heapq.heappop(H)
            if D[u.id] >= u.weight:
                # update distance
                for v in self.G[u.id]:
                    w = u.weight + v.weight
                    if D[v.id] > w:
                        D[v.id] = w
                        heapq.heappush(H, Node(v.id, D[v.id]))
        return D


V,E,r = map(int, raw_input().split())
G = WeightDirectedGraph(V)
for i in range(E):
    s,t,d = map(int, raw_input().split())
    G.append(s,t,d)

for d in G.dijkstra(r):
    if d == G.INF:
        print "INF"
    else:
        print d


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

using namespace std;

#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forlr(i, l, r) for (int i = int(l); i < int(r); i++)
#define repeat(n) for (int hjfjke = 0; hjfjke < int(n); hjfjke++)
#define all(c) c.begin(), c.end()
#define ll long long

const int mod = 1000000007;


int dp[10005][100][2];

int add(int a, int b);
int sub(int a, int b);

int32_t main() {
    std::iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);
    string s;
    int n, d;
    cin >> s;
    n = s.size();

    cin >> d;

    dp[0][0][1] = true;

    forn(i, n)
    forn(j, d)
    forn(k, 2)
    if (dp[i][j][k] != 0) {
        int lim;
        if (k)
            lim = s[i] - '0';
        else
            lim = 10;

        forn(dig, lim)
            dp[i + 1][(j + dig) % d][0] = add(dp[i + 1][(j + dig) % d][0],  dp[i][j][k]);

        if (k)
            dp[i + 1][(j + s[i] - '0') % d][1] = add(dp[i + 1][(j + s[i] - '0') % d][1],  dp[i][j][k]);
    }

    cout << sub(add(dp[n][0][1], dp[n][0][0]), 1);

    return 0;
}

int add(int a, int b) {
    int result = a + b;
    if (result >= mod)
        result -= mod;
    return result;
}

int sub(int a, int b) {
    int result = a - b;
    if (result < 0)
        result += mod;
    return result;
}

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

using namespace std;

int main() {
    set<string> s;
    int n;
    cin >> n;
    for(int i = 0;i< n; i++) {
        string str;
        cin >> str;
        // cout << 
        s.insert(str);
    }

    cout << s.size() << endl;
}

Measured memory_bytes: 19200
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
  vector<int>b(n-1);
  for(int i; i<n-1; i++) cin >> b[i];
  int rsl=0;
  rsl += b[0];
  for (int i=0; i<n-2; i++){
  	rsl += min(b[i],b[i+1]);
  }
  rsl += b[n-2];
  cout << rsl << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	v, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic("Atoi failed")
	}
	return v
}

func white_sum(bitmap [][]int, W, H int) int {
	black_sum := 0
	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			black_sum += bitmap[y][x]
		}
	}
	return (W)*(H) - black_sum
}
func fill(bitmap [][]int, sx, sy, ex, ey int) {
	for x := sx; x < ex; x++ {
		for y := sy; y < ey; y++ {
			bitmap[y][x] = 1
		}
	}
}

func show(bitmap [][]int, W, H int) {
	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			fmt.Print(bitmap[y][x])
		}
		fmt.Println()
	}
}
func main() {
	sc.Split(bufio.ScanWords)
	W, H, N := nextInt(), nextInt(), nextInt()
	bitmap := make([][]int, H)
	for y := 0; y < H; y++ {
		bitmap[y] = make([]int, W)
	}

	for i := 0; i < N; i++ {
		x, y, a := nextInt(), nextInt(), nextInt()
		switch a {
		case 1:
			fill(bitmap, 0, 0, x, H)
		case 2:
			fill(bitmap, x, 0, W, H)
		case 3:
			fill(bitmap, 0, 0, W, y)
		case 4:
			fill(bitmap, 0, y, W, H)
		default:
			panic("get invalid a")
		}
	}
	fmt.Println(white_sum(bitmap, W, H))

}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long LL;

struct complex{
	int re, im;
	complex(LL r, LL i): re(r), im(i){
		if(abs(r) > 10000 || abs(i) > 10000)
			throw 0;
	}

	complex operator+ (const complex &c) const{
		return complex(re + c.re, im + c.im);
	}
	
	complex operator- (const complex &c) const{
		return complex(re - c.re, im - c.im);
	}
	
	complex operator* (const complex &c) const{
		LL r = re * c.re - im * c.im;
		LL i = re * c.im + im * c.re;
		return complex(r, i);
	}
};

const char *p;

complex expr();

complex factor(){
	if(*p == '('){
		++p;
		complex c = expr();
		++p;
		return c;
	}
	if(*p == 'i'){
		++p;
		return complex(0, 1);
	}

	char *endp;
	LL r = strtol(p, &endp, 10);
	p = endp;
	return complex(r, 0);
}

complex term(){
	complex c = factor();
	while(*p == '*'){
		++p;
		c = c * factor();
	}
	return c;
}

complex expr(){
	complex c = term();
	while(1){
		if(*p == '+'){
			++p;
			c = c + term();
		}
		else if(*p == '-'){
			++p;
			c = c - term();
		}
		else{
			break;
		}
	}
	return c;
}

int main(){
	string s;
	while(cin >> s){
		p = s.c_str();
		try{
			complex c = expr();

			if(c.re != 0){
				printf("%d", c.re);
				if(c.im != 0){
					printf("%+di", c.im);
				}
			}
			else{
				if(c.im == 0){
					printf("0");
				}
				else{
					printf("%di", c.im);
				}
			}
			puts("");
		} catch(...){
			puts("overflow");
		}
	}
}

Measured memory_bytes: 1264
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, K): (usize, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let A: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    let F: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    fn bis<P>(ok: i64, ng: i64, p: P) -> i64
        where P: Fn(i64) -> bool {
        let mid = (ok + ng) / 2;
        if (ok - ng).abs() == 1 {
            ok
        } else if p(mid) {
            bis(mid, ng, p)
        } else {
            bis(ok, mid, p)
        }
    }

    let B = {
        let mut B = A.clone();
        B.sort();
        B
    };
    // println!("{:?}", B);
    let G = {
        let mut G = F.clone();
        G.sort();
        G.reverse();
        G
    };
    // println!("{:?}", G);

    let ans = bis(1_000_000_000_000_000, -1, |c| (0..N).map(|i| std::cmp::max(0, B[i] - c / G[i])).sum::<i64>() <= K);

    println!("{}", ans);
}

Measured memory_bytes: 13560
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<queue>
#include<functional>
using namespace std;
#define MAX 100000
int main() {
	int s, l, c = 0, x, y, z;
	cin >> s >> l;
	set<int> set;
	for (int i = 0; i <= s; i++) {
		for (int j = 0; j <= s; j++) {
			if (l - i - j >= 0 && l - i - j <= s) {
				c++;
			}
		}
	}
	cout << c << endl;
	return 0;

}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int R[4000], B[4000];
ll dp[4000][4001];
int main() {
	string S;
	cin >> S;
	int N = S.size();
	for (int i = 0; i < N; i++) {
		if (S[i] == '0') R[i] = 2;
		else if (S[i] == '1') R[i] = B[i] = 1;
		else B[i] = 2;
	}
	for (int i = 1; i < N; i++) {
		R[i] += R[i - 1];
		B[i] += B[i - 1];
	}
	if (R[0] > 0) dp[0][1] = 1;
	if (B[0] > 0) dp[0][0] = 1;
	for (int i = 1; i < 2 * N; i++) {
		int red = R[min(i, N - 1)];
		int blue = B[min(i, N - 1)];
		int m = min(i, R[min(i - 1, N - 1)]);
		for (int j = 0; j <= m; j++) {
			if (j < red) (dp[i][j + 1] += dp[i - 1][j]) %= MOD;
			if (i - j < blue) (dp[i][j] += dp[i - 1][j]) %= MOD;
		}
	}
	cout << dp[2 * N - 1][R[N - 1]] << endl;
}

Measured memory_bytes: 123520
function main(arg) {
  const input = arg.split('\n');
  const a = Number(input[0]);
  const s = input[1];
  
  if(a >= 3200){
    console.log(s);
  }else{
    console.log('red');
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
def readinput():
    s=input()
    return s

def main(s):
    ans=0
    cont=0
    for c in s:
        if c=='S':
            cont=0
        else:
            cont+=1
            ans=max(cont,ans)
    return ans

if __name__=='__main__':
    s=readinput()
    ans=main(s)
    print(ans)


Measured memory_bytes: 9104
n[]={0,31,29,31,30,31,30,31,31,30,31,30,31};char *w[]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};main(m,d){for(m=2;m<13;m++)n[m]+=n[m-1];while(scanf("%d%d",&m,&d),m)puts(w[(n[m-1]+d)%7]);exit(0);}

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

int main()
{
  int N;
  cin>>N;
  vector <int> A(N);
  vector <int> B(N);
  for(int i=0;i<N;i++)
  {
   cin>>A.at(i);
   B.at((A.at(i)-1))=i+1;
  }
  for(int i=0;i<N;i++)
  {
   cout<<B.at(i)<<" ";
  }
}

Measured memory_bytes: 1536
S = list(input())

flag = True
while flag == True:
    if len(S) == 0:
        break
    if len(S) >= 5:
        if S[-5:] == list("dream"): del S[-5:]
        elif S[-5:] == list("erase"): del S[-5:]
        elif len(S)>=6 and S[-6:] == list("eraser"): del S[-6:]
        elif len(S)>=7 and S[-7:] == list("dreamer"): del S[-7:]
        else:
            flag = False
    else:
        flag = False
if flag:
    print("YES")
else:print("NO")

Measured memory_bytes: 9900
#include "bits/stdc++.h"
#include <chrono>
#include <random>
#include <cstdio>
#define ll long long int
#define endl '\n'
#define pb push_back
#define mp make_pair
// #define mod 998244353
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
const int N=1000001;
// vector<pair<ll, ll> > adj[N];
// bool vis[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
#define pi 3.14159265358979323846264338
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
ll inf = 100000000000000000;
vector <int> adj[N];


void solve() 
{
    int n;
    cin>>n;

    vl a(n);
    rep(i, n) cin>>a[i];

    ll ans = 0;

    ll h = a[0];

    rep(i, n)
    {
        if(a[i] >= h)
        {
            h = a[i];
            continue;
        }
        else
        {
            ans += (h - a[i]);
        }
    }
    cout<<ans<<endl;

}

int main()
{
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)

    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 28276
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);//証言a[i]は
    vector<vector<int>>x(n,vector<int>(0));//人間x[i][j]を
    vector<vector<int>>y(n,vector<int>(0));//y[i][j]であると述べる
    for(int i=0;i<n;i++){
        cin>>a[i];
        x[i].resize(a[i]);
        y[i].resize(a[i]);
        for(int j=0;j<a[i];j++){
            cin>>x[i][j]>>y[i][j];
            x[i][j]--;
        }
    }
    int p=1;//全探索の数
    for(int i=0;i<n;i++)p*=2;
    int m=0;
    for(int i=0;i<p;i++){
        int hone=0;
        int q=i;
        vector<int>jud(n);//人間の真偽判定
        for(int j=0;j<n;j++){
            if(q%2==1){
                hone++;
                jud[j]=1;
            }
            else jud[j]=0;
            q/=2;
        }
        for(int j=0;j<n;j++){
            if(jud[j]){
                for(int k=0;k<a[j];k++){
                    if(y[j][k]==1 && jud[x[j][k]]==0)hone=0;
                    if(y[j][k]==0 && jud[x[j][k]]==1)hone=0;
                }
            }
        }
        m=max(m,hone);
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<map>
#include<bitset>
#include<utility>
//#include<unordered_map>
#ifdef LOCAL
#include"file.h"
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
const double eps = 1e-12;
const double Pi = 3.1415926535897932;
const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };
//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };





const int maxn = 1e5 + 5;
LL f[maxn];


int main() {
#ifdef LOCAL
	fileopen();
#endif
	int n, C;
	scanf("%d%d", &n, &C);
	memset(f, -1, sizeof(f));
	f[0] = 0;
	for (int i = 1; i <= n; i++) {
		int w, v;
		scanf("%d%d", &w, &v);
		for (int i = C; i >= w; i--)if(f[i-w]!=-1) {
			f[i] = max(f[i], f[i - w] + v);
		}
	}
	LL ans = 0;
	for (int i = 0; i <= C; i++)ans = max(ans, f[i]);
	printf("%lld\n", ans);

#ifdef LOCAL
	fileclose();
#endif
	return 0;
}

Measured memory_bytes: 1024
import Control.Applicative
import Control.Monad
import Data.List (sortBy,intersperse)
data TeamResult = TR { name :: String
                     , win :: Int
                     , lose :: Int
                     , draw :: Int
                     , point :: Int
                     }

main = do
    n <- readLn
    showLeagues n

showLeagues :: Int -> IO ()
showLeagues 0 = return ()
showLeagues n = do
    teams <- replicateM n (team.words<$>getLine)
    mapM_ putStrLn $ map (concat.intersperse ",".(\tr -> [name tr, show.point $ tr])).ordTeams.map calcWinPoint $ teams
    n <- readLn
    unless (n==0) $ putStrLn "" >> showLeagues n


team :: [String] -> TeamResult
team [n,w,l,d] = TR n (read w) (read l) (read d) 0

calcWinPoint :: TeamResult -> TeamResult
calcWinPoint tr = tr { point = (win tr)*3 + (draw tr) }

ordTeams :: [TeamResult] -> [TeamResult]
ordTeams = sortBy (flip ordByWinPoint).map calcWinPoint

ordByWinPoint :: TeamResult -> TeamResult -> Ordering
ordByWinPoint tr1 tr2 = point tr1 `compare` point tr2



Measured memory_bytes: 3972
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
from math import gcd 
x=N()
print(x*360//gcd(x,360)//x)

Measured memory_bytes: 9188
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int N;
    int A[200000];

    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }

    map<int,int> m;

    for(int i=0;i<N;i++){
        int n=-A[i]+1;
        n+=i-1;
        m[n]++;
        //cout<<i<<"+"<<n<<endl;
    }

    int ans=0;
    for(int i=0;i<N;i++){
        ans+=m[A[i]+i];
        int n=-A[i]+1;
        n+=i-1;
        m[n]--;
        //cout<<i<<","<<ans<<endl;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 27788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  string s;
  cin>>s;
  vector<int> a(s.size(),0);
  int c=0,mb,mf;
  bool f=false;
  for(int i=0;i<s.size();i++){
    if(!f){
      if(s[i]=='R'){
        c++;
      }else{
        a[i]+=c/2;mf=i;
        a[i-1]+=c-c/2;mb=i-1;
        c=1;
        f=true;
        if(i==s.size()-1)a[i]++;
      }
    }else{
      if(i==s.size()-1){
        c++;
      }
      if(i==s.size()-1||s[i]=='R'){
        a[mb]+=c/2;
        a[mf]+=c-c/2;
        c=1;
        f=false;
      }else{
        c++;
      }
    }
  }
  for(int i=0;i<s.size();i++){
    cout<<a[i]<<" ";
  }
}

Measured memory_bytes: 1024
import numpy as np

n = int(input())
f = np.zeros((n, 10), dtype=np.int64)
p = np.zeros((n, 11), dtype=np.int64)

for i in range(n):
  tmp = list(map(int, input().split()))
  for j in range(10):
      f[i][j] = tmp[j]
for i in range(n):
  tmp = list(map(int, input().split()))
  for j in range(11):
    p[i][j] = tmp[j]

r = -1e18
for b in range(1, 1<<10):
  s = 0
  for i in range(n):
    c = 0
    for j in range(10):
      if (b >> j) & 1 == 1 and f[i][j]:
        c += 1
    s += p[i][c]
  if r < s:
    r = s

print(r)


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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
  int N, M;
  cin >> N >> M;
  LL a[100010];
  rep(i,N){
    cin >> a[i];
    a[i]/=2;
  }
  int num=0;
  while(1){
    int k=0;
    rep(i,N){
      if(a[i]%2==0){
        a[i]/=2;
        k++;
      }
    }
    if(k==0) break;
    else if(k!=N){
      cout << 0 << endl;
      return 0;
    }
    num++;
  }
  LL lcm=a[0];
  rep(i,N-1){
    lcm=lcm*a[i+1]/__gcd(lcm,a[i+1]);
    if(lcm>M){
      cout << 0 << endl;
      return 0;
    }
  }
  LL ans=(M/(lcm*pow(2,num))+1)/2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <cctype>
#include <cmath>
#include <math.h>
using namespace std;

void bubsort(string a[], int n) {
  for (int i=0;i<n;i++) {
    for (int j=n-1;i<j;j--) {
      if ((a[j][1]-'0')<(a[j-1][1]-'0')) {
        swap(a[j],a[j-1]);
      }
    }
  }
}

void selsort(string a[], int n) {
  for (int i=0;i<n;i++) {
    int min = i;
    for (int j=i;j<n;j++) {
      if ((a[min][1]-'0')>(a[j][1]-'0')){
        min = j;
      }
    }
    swap(a[min],a[i]);
  }
}

int main(){
  int n;
  bool same=1;
  string tmp;
  string a[100],b[100];
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> tmp;
    a[i]=b[i]=tmp;
  }
  bubsort(a,n);
  for (int i=0;i<n;i++) {
    if (i==(n-1)) {
      cout << a[i] << endl;
    } else { cout << a[i] << " "; }
  }
  cout << "Stable" << endl;
  selsort(b,n);
  for (int i=0;i<n;i++) {
    if(b[i]!=a[i]){
      same = 0;
    }
    if (i==(n-1)) {
      cout << b[i] << endl;
    } else { cout << b[i] << " "; }
  }
  if (same) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
}



Measured memory_bytes: 3180
lr = [int(i) for i in input().split()]
res = []
for i in range(lr[0], lr[1]+1):
    for j in range(i+1, lr[1]+1):
        tmp = (i*j) % 2019
        if tmp == 0:
            print(0)
            exit()
        res.append(tmp)
print(min(res))


Measured memory_bytes: 6788
import sys
input = sys.stdin.readline


class UnionFind:
    def __init__(self, size):
        """
        size:頂点の数
        """
        self.parent = [i for i in range(size)]
        self.rank = [0 for _ in range(size)]

    def find(self, x):
        """
        xのrootを返す
        """
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])

    def union(self, x, y):
        """
        x,yを同じグループとしてまとめる
        """
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        """
        xとyが同じグループならTrue
        """
        return self.find(x) == self.find(y)

    def component(self):
        """
        各連結成分のrootの集合を返す
        len()をとれば連結成分の数が求められる
        return-> set()
        """
        comp = set()
        for i in self.parent:
            p = self.find(i)
            comp.add(p)
        return comp

    def __str__(self):
        """
        for debug
        クラスのlistの情報を出力
        """
        ret = "parents\n"
        ret += " ".join(map(str, self.parent))
        ret += '\n'
        ret += " ".join(map(str, self.rank))
        return ret


n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ans = 0

for i in ab:
    uf = UnionFind(n)
    for j in ab:
        if i == j:
            continue
        uf.union(j[0] - 1, j[1] - 1)
    if not uf.same(i[0] - 1, i[1] - 1):
        ans += 1

print(ans)


Measured memory_bytes: 3188
import statistics

N = int(input())

A = list(map(int, input().split(' ')))
for i in range(N):
    A[i] = A[i] - (i + 1)

sum_r2 = 0
median = statistics.median(A)
for i in range(N):
    sum_r2 += abs(A[i] - (median))

print(int(sum_r2))

Measured memory_bytes: 27244
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};



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

    cout << endl;
    return 0;
}


Measured memory_bytes: 3784
n=int(input())
a=list(map(int,input().split()))

ans=a.copy()


#-1したもの
for i in range(n):
    if a[i]>=1:
        ans.append(a[i]-1)

for j in range(n):
    if a[j]<10**5:
        ans.append(a[j]+1)

from collections import Counter

c=Counter(ans)

v=max(c.values())

print(v)

Measured memory_bytes: 30424
MOD = 1E9.to_i + 7

def mpow(x, n, acc = 1)
  return acc if n.zero?
  n.even? ? mpow(x * x % MOD, n >> 1, acc) : mpow(x, n - 1, acc * x % MOD)
end

def comb(n, c)
  return 0 if c > n
  @fact[n] * @inv[n-c] * @inv[c] % MOD
end

n = gets.to_i
a = gets.split.map(&:to_i)

@fact = (1..n).inject([x=1]) { |r, a| r << x = x * a % MOD }
@inv = [].tap do |y|
  y[n] = mpow(@fact[n], MOD-2)
  n.downto(1) { |a| y[a-1] = y[a] * a % MOD }
end

dup = a.group_by { |x| x }
       .select { |k, v| v.size == 2 }
       .first.first

x, y = a.index(dup), a.rindex(dup)

(1..n+1).each do |i|
  if i == 1
    puts n
    next
  end
  
  sum  = 0
  
  sum += comb(n-1, i)
  sum += comb(x+n-y, i-1)
  sum += 2 * (comb(n-1, i-1) - comb(x+n-y, i-1))
  sum += comb(n-1, i-2)
  
  puts sum % MOD
end

Measured memory_bytes: 24716
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
constexpr long double eps = 1e-9;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, k;
	scanf("%d%d", &n, &k);
	vector<bool> b(n);
	rep(i, k) {
		int d, a;
		scanf("%d", &d);
		rep(j, d) {
			scanf("%d", &a);
			--a;
			b[a] = true;
		}
	}
	int ans = 0;
	rep(i, n)ans += not b[i];
	printf("%d\n", ans);

	Please AC;
}


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

count = 0
for i in range(N-1, -1, -1):
	A[i] = A[i]+count
	if A[i]%B[i]==0:
		c = 0
	else:
		c = B[i] - (A[i])%B[i]
	count = count+c
print(count)


Measured memory_bytes: 15016
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int l, r;
  cin >> l >> r;

  vector< int > a;
  for(int i = l; i <= min(r, l + 2019); i++){
    a.push_back(i % 2019);
  }


  int ans = 2018;
  for(int i = 0; i < a.size(); i++){
    for(int j = i + 1; j < a.size(); j++){
      ans = min(ans, (a[i] * a[j]) % 2019);
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(void) {
  int N;
  cin >> N;
  set<int> mochi;
  rep(i,N) {
    int d;
    cin >> d;
    mochi.insert(d);
  }
  cout << mochi.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair< ll , ll> pll;


ll n;
ll a[2000005];
pll dp[2000005];
const ll inf = 1e16;
int main()
{
        cin >> n;
        for(ll i=0;i<(1LL << n);i++) {
                cin >> a[i];
                dp[i] = make_pair(a[i] , -inf);
        }
        for(ll i=0;i<19;i++) {
                for(ll j=0;j<(1LL << n);j++) {

                        if((j&(1LL << i)) == 0) {
                                vector< ll > v = {dp[j].first, dp[j].second , dp[(j|(1LL << i))].first, dp[(j|(1LL << i))].second};
                                sort(v.begin(), v.end());
                                dp[(j|(1LL << i))] = {v.back() , v[v.size()-2]};
                        }
                }
        }
        ll ans = 0;
        for(ll i=1;i<(1LL << n);i++) {
                ans = max(ans , dp[i].first + dp[i].second);
                cout << ans << "\n";
        }
        return 0;
}


Measured memory_bytes: 17408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> & vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec1(std::vector<string>& vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec2(std::vector<Int>& vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}

Int gcd(Int a, Int b)
{
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b)
{
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool integer(double num)
{
	return floor(num) == num;
}

Int fact(int num)
{
	if (num == 0)
		return 1;
	else
		return num * fact(num - 1);
}

vector<int> data[200005];
int ans[200005];
void dfs(int root,int child){
	ans[child] += ans[root];
	for(int i:data[child]){
		if(i!=root){
			dfs(child, i);
		}
	}

}


int main(){
	int n, q;
	cin >> n >> q;
	int a, b;
	for (int i = 0; i < n - 1;i++){
		cin >> a >> b;
		a--;
		b--;
		data[a].push_back(b);
		data[b].push_back(a);
	}
	for (int i = 0; i < q;i++){
		cin >> a >> b;
		a--;
		ans[a]+=b;
	}
	for (int i:data[0]){
		dfs(0, i);
	}

	for (int i = 0; i < n;i++){
		cout << ans[i];
		if(i!=n-1)
			cout << " ";
	}

		cout << endl;
	return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 23424
/*
Dice III
ITP1_11_C
サイコロの同一チェック
*/

package main

import "fmt"

/*
出目を含む面番号のスライスを返す

(引数)
dice	: ダイス配列
fig		: 数字

(戻り値)
面番号	: 0~5
		: 6のとき	存在しない
*/
func fno(dice [6]int, fig int) []int {
	var i int
	deme := []int{}

	for i = 0; i < 6; i++ {
		if dice[i] == fig {
			deme = append(deme, i)
		}
	}

	return deme
}

/*
ダイスの裏面の数字を取得する
(引数)
dice	: ダイス配列
no		: 面番号(0~5)

(戻り値)
裏面の数字
*/
func tail(dice [6]int, no int) int {
	return dice[5-no]
}

/*
ダイスの側面の数字を配列で取得する
(引数)
dice	: ダイス配列
no		: 面番号(0~5)

(戻り値)
裏面数字の配列
*/
func side(dice [6]int, no int) [4]int {
	// 面に対する側面の配列(時計回り)
	side_no_idx := map[int][4]int{
		0: {1, 3, 4, 2},
		1: {2, 5, 3, 0},
		2: {0, 4, 5, 1},
		3: {0, 1, 5, 4},
		4: {0, 3, 5, 2},
		5: {1, 2, 4, 3},
	}

	var side_no [4]int

	for i := 0; i < 4; i++ {
		side_no[i] = dice[side_no_idx[no][i]]
	}

	return side_no
}

func is_same_slice(s1 []int, s2 []int) bool {
	for i := 0; i < len(s1); i++ {
		if s1[i] != s2[i] {
			return false
		}
	}

	return true
}

/*
側面の数字が同じか調べる
(引数)
side	: 側面の数字×4面

(戻り値)
true	: 側面は同じ
fals	: 側面は違う
*/
func is_same_side(side1 [4]int, side2 [4]int) bool {
	is_same := false
	for i := 0; i < 4; i++ {
		if is_same_slice(side1[:], append(side2[i:], side2[:i]...)) {
			is_same = true
			break
		}
	}

	return is_same
}

func is_same(dice1 [6]int, dice2 [6]int) bool {
	d2top := fno(dice2, dice1[0])
	if len(d2top) == 0 {
		return false
	}

	yes_or_no := false
	for i := 0; i < len(d2top); i++ {
		var side1, side2 [4]int
		side1 = side(dice1, 0)
		side2 = side(dice2, d2top[i])

		if is_same_side(side1, side2) && tail(dice1, 0) == tail(dice2, d2top[i]) {
			yes_or_no = true
			break
		}
	}

	return yes_or_no
}

func main() {
	var all_dice [100][6]int
	var num int

	fmt.Scanf("%d", &num)
	for i := 0; i < num; i++ {
		for j := 0; j < 6; j++ {
			fmt.Scanf("%d", &all_dice[i][j])
		}
	}

	is_different := true
LOOP:
	for i := 0; i < num-1; i++ {
		for j := i + 1; j < num; j++ {
			if is_same(all_dice[i], all_dice[j]) {
				/*
					fmt.Printf("i=%d j=%d\n", i, j)
					fmt.Println(all_dice[i])
					fmt.Println(all_dice[j])
				*/
				is_different = false
				break LOOP
			}
		}
	}

	if is_different {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ip pair<ll,ll>
#define vii vector<ll>
#define vpp vector<ip>
#define vdd vector<ld>
#define vb vector<bool>
#define pi  pair<ll,ip>
#define sc(x) scanf("%lli",&x)
#define c(x) cin >> x
#define fo(i,k,n) for( int i=k;i<n;i++)
#define hu 200010
#define pq priotity_queue<ll>
#define pqs priority_queue<ll,vii,greater<ll>>
#define ppq priority_queue<ip,vpp,greater<ip>>
#define INF INT_MAX
#define ff first
#define ss second
using namespace std;
const ll M = 1000000000+7;
//Grid Movement
ll dx[] = {-1, 0, 1, 0};
ll dy[] = {0, -1, 0, 1};

ld Pi= acos(-1);

ll lcm(ll a,ll b)
{
    return (a*b)/(__gcd(a,b));
}

ll mex(ll x, ll y) 
{ 
	ll res = 1;	  
	x = x % M; 
	if (x == 0) return 0; 
	while (y > 0) 
	{ 
		if (y & 1) 
		res = (res*x) % M; 
		y = y>>1; 
		x = (x*x) % M; 
	} 
	return res; 
} 

bool comp(ll comp1,ll comp2)
{
    return comp1>comp2;
}

void yes()
{
    printf("YES\n");
}

void no()
{
    printf("NO\n");
}

ll inv(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
 
    if (x < 0)
       x += m0;
 
    return x;
}

void sieve(ll n)
{
    vii primes(n+1);
    vb is_prime(n+1);
	is_prime.resize(n+1);
	primes.resize(n+1);
 
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i<=n; i++)
	{
	    if(is_prime[i])
	    {
	    	primes.pb(i);
	        for (int j = i*i; j<=n; j+=i)
	            is_prime[j] = false;
	    }
	}
}

void solve()
{
   ll n;
   sc(n);
   ll a[n];
   fo(i,0,n) sc(a[i]);
   sort(a,a+n);
   ll ans = 0;
//   map<pi,ll>mp;
   fo(i,0,n)
   {
       fo(j,i+1,n)
       {
           fo(k,j+1,n)
           {
               if(a[i]+a[j]>a[k]){
                   if(a[i]==a[j] or a[j]==a[k] or a[i]==a[k]) continue;
                //    cout << a[i] << ","<<a[j]<<","<<a[k]<<endl; 
                  //  if(!mp.count({a[i],{a[j],a[k]}}))
                    ans++;
                   // mp[{a[i],{a[j],a[k]}}]++;
               } 
           }
       }
   }
   cout << ans<<endl;
}

int main()
{
//	ios_base::sync_with_stdio(0); cin.tie(0);
    ll t=1;
 //   sc(t);
    while(t--) solve();
}





Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int W, H, x, y, r;

		Scanner scan = new Scanner(System.in);

		W = scan.nextInt();
		H = scan.nextInt();
		x = scan.nextInt();
		y = scan.nextInt();
		r = scan.nextInt();

		if (0 <= x-r && x+r <= W) {
			if(0 <= y-r && y+r <= H){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			if(0 <= y-r && y+r <= H){
				System.out.println("No");
			} else {
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 26232
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func()
    top_str = input_raw.strip().split()
    [W, a, b] = [int(top_str[0]), int(top_str[1]), int(top_str[2])]
    if a < b:
        rect1_s = a
        rect1_e = a + W
        rect2_s = b
        rect2_e = b + W
    else:
        rect1_s = b
        rect1_e = b + W
        rect2_s = a
        rect2_e = a + W

    print max(0, rect2_s - rect1_e)




if __name__ == '__main__':
    main()

Measured memory_bytes: 2692
#include <iostream>
using ll = long long;
using namespace std;

ll a,b,c;
ll MAX = 0;
ll ret;

void input(){
    cin >> a >> b >> c;
}

void solve(){
    if(a>=b && a>=c){
        MAX = a;
    }else if(b>=a && b>=c){
        MAX = b;
    }else if(c>=a && c>=b){
        MAX = c;
    }
    ret = a * b * c / (MAX * 2);
}

int main(void){
    // Your code here!
    input();
    solve();
    cout << ret << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	int a[4],b[4];
	while(cin>>a[0]){
		int h=0,r=0;
	for(int i=1;i<4;i++)
		cin>>a[i];
	for(int i=0;i<4;i++){
		cin>>b[i];
		if(a[i]==b[i])
			h++;
		for(int j=0;j<4;j++){
			if(a[j]==b[i])
				r++;
		}
	}
	r-=h;
	cout<<h<<" "<<r<<endl;
	}
	return 0;
}

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

int main() {
    int N,M,X,i,A,c=0;
    cin >> N >> M >> X;

    for(i=0; i<M; i++) {
        cin >> A;
        if(A < X)
            c++;
    }

    cout << min(c,M-c) << endl;
}

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

#define ll             long long
#define LL             long long
#define gcd(a,b)       __gcd(a, b)
#define lcm(a,b)       a * (b / gcd(a, b))
#define pii            pair<int, int>
#define pll            pair<ll, ll>
#define pil            pair<int, ll>
#define pli            pair<ll, int>
#define vi             vector<int>
#define vl             vector<ll>
#define vii            vector<pii>
#define vll            vector<pll>
#define vil            vector<pil>
#define vli            vector<pli>
#define pb             push_back
#define ppb            pop_back
#define mp             make_pair
#define ff             first
#define ss             second
#define all(v)         v.begin(), v.end()
#define fill(a, b)     memset(a, b, sizeof a)
#define smax(a, b)     a = max(a, b)
#define smin(a, b)     a = min(a, b)
#define sqr(x)         x * x
#define cube(x)        x * x * x
#define endl           '\n'

int in() {
	int n;
	scanf("%d", &n);
	return n;
}

ll Lin() {
	ll n;
	scanf("%lld", &n);
	return n;
}

double Din() {
	double n;
	scanf("%lf", &n);
	return n;
}

const ll inf = (ll)1e17;
const ll mod = (ll)1e9 + 7;
const int N = 1e5 + 5;

ll dp[N], a[N];
int n, k;

ll call(int pos) {
	if (pos < 1) return 2e9;
	if (pos == 1) return 0;
	if (dp[pos] != -1) return dp[pos];
	ll ans = 2e9;
	for (int i = 1; i <= k; i++) {
		ans = min(ans, call(pos - i) + abs(a[pos] - a[pos - i]));
	}
	return dp[pos] = ans;
}


int solve() {
	n = in(), k = in();
	for (int i = 1; i <= n; i++) {
		a[i] = Lin();
	}
	fill(dp, -1);
	printf("%lld\n", call(n));
	return 0;
}

int main() {
	int test = 1, tc = 0;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
	return 0;
}


Measured memory_bytes: 6528
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll x, y, a, b, c;
    ll n;
    priority_queue<ll> sum;
    ll ans = 0;

    cin >> x >> y >> a >> b >> c;

    priority_queue<ll> p, q, r;

    for (int i = 0; i < a; i++)
    {
        cin >> n;
        p.push(n);
    }

    for (int i = 0; i < x; i++)
    {
        sum.push(p.top());
        p.pop();
    }

    for (int i = 0; i < b; i++)
    {
        cin >> n;
        q.push(n);
    }

    for (int i = 0; i < y; i++)
    {
        sum.push(q.top());
        q.pop();
    }

    for (int i = 0; i < c; i++)
    {
        cin >> n;
        sum.push(n);
    }

    for (int i = 0; i < x + y; i++)
    {
        ans += sum.top();
        sum.pop();
    }

    cout << ans << endl;
}

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

int main(){
int n;
scanf("%d",&n);
long long s=0;
  for(int i=1;i<=n;i++){
    if(i%3!=0 && i%5!=0)
      s+=i;
  }
  printf("%lld\n",s);
}

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

int main() {
    int n;
    cin >> n;
    cout << (n+2-1)/2 << endl;
}

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

#define N_MAX 45

int table[N_MAX];

int fib(int n){
	if(n==0 || n==1) return 1;
	if(table[n]) return table[n];
	return (table[n]= fib(n-2)+fib(n-1));
}

int main()
{
	for(int i=0; i<N_MAX; i++) table[i] = 0;
	
	int n;
	cin >> n;
	cout << fib(n) << endl;

	return 0;
}

Measured memory_bytes: 1160
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T
{
    std::io::Read::bytes(std::io::stdin())
                    .map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>()
                    .parse().ok().unwrap()
}

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let _: i64 = read();
    let k: i64 = read();

    if k % 2 == 0 {
        println!("{}", a - b);
    } else {
        println!("{}", b - a);
    }
}


Measured memory_bytes: 4352