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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

ll factional(int n){ll ret = 1; FOR(i, 2, n+1) ret *= i; return ret;}
ll permutation(int n, int r){ll ret = n; FOR(i,1,r) ret *= n-i; return ret;}
ll combination(int n, int r){return permutation(n, r) / factional(r);}
int gcd(int a, int b){if (b == 0) return a; return gcd(b, a % b);}

int n; //2<=n<=1e5
vector<string> s;

int main() {
    cin>>n;
    s.resize(n);
    
    map<string,int> ss{};
    REP(i,n){
        cin>>s[i];
        sort(ALL(s[i]));
        ss[s[i]]++;
    }

    //sort(ALL(s));
    //DEBUG_VEC(s);

    ll ans = 0;

    for( auto i = ss.begin(); i != ss.end() ; ++i ) {
        ans += combination(i->second,2);
    }

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

Measured memory_bytes: 18176
#include <iostream>
#include <queue>
using namespace std;
int n, m;
char a[100][100];
int bio[100][100];
int r, s;
int dx[4] = {-1, 0, 0, 1};
int dy[4] = {0, -1, 1, 0};
queue<pair<int, int> > q;

void bfs (int r, int s) {
	while (!q.empty()) {
	r = q.front().first;
	s = q.front().second;
//	cout << r << " " << s << endl;
	q.pop();
	bio[r][s]=1;
	for (int i = 0; i < 4; i++) {
		if (a[r+dx[i]][s+dy[i]] == '#') {
			if (bio[r+dx[i]][s+dy[i]] == 0) q.push(make_pair(r+dx[i], s+dy[i]));
		}
	}
}
} 

int main () {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
			if (a[i][j]=='#') r=i, s=j;
		}
	}
	
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (a[i][j]=='#') {
				int l=0;
				for (int x = 0; x < 4; x++) {
					if (a[i+dx[x]][j+dy[x]]=='#') {
						l=1;
					}
				}
				if (l==0) {
				cout << "No";	
				return 0;
				}
			}
		}
	//	cout << endl;
	}
	cout << "Yes";





return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define exp pow(10,-9)
#define F first
#define S second
#define PB push_back 
#define MP make_pair
#define daman ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lowercase(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define uppercase(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
main()
{
	int n;
	cin>>n;
	
	int count1 = n/500;
	
	n = n%500;
	
	int count2 = n/5;
	
	cout<<1000*count1 + count2*5<<"\n"; 
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
ll H, N, health[1005], magic[1005];
ll dp[10005][1005];
ll solve(int idx, ll curHealth)
{
    if(curHealth <= 0)
        return 0;
    if(idx >= N)
        return 1e9;
    if(dp[curHealth][idx] != -1)
        return dp[curHealth][idx];
    ll ans = solve(idx + 1, curHealth);
    //for(int i = 0; i < N; i++)
        ans = min(ans, solve(idx, curHealth - health[idx]) + magic[idx]);
    dp[curHealth][idx] = ans;
    return ans;
}
int main()
{
    memset(dp, -1, sizeof dp);
    cin >> H >> N;
    for(int i = 0; i < N; i++)
        cin >> health[i] >> magic[i];
    cout << solve(0, H);
    return 0;
}


Measured memory_bytes: 79360
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    int f = 0;
    imfor(i, n) {
        char c;
        cin >> c;
        if (c == 'Y') {
            f = 1;
        }
    }
    if (f) {
        cout << "Four" << endl;
    }
    else {
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 256
import sys
f = sys.stdin

def unite(x, y):
    global dat
    x, y = find(dat, x), find(dat, y)
    if x == y:
        return True
    if dat[y] < dat[x]:
        x, y = y, x
    dat[x] += dat[y]
    dat[y] = x
    return False
        

def same(x, y):
    global dat
    x, y = find(dat, x), find(dat, y)
    print(1 if x == y else 0)
def find(dat, x):
    if dat[x] < 0:
        return x
    dat[x] = find(dat, dat[x])
    return dat[x]

com = (unite, same)

n, q = map(int, f.readline().split())
dat = [-1] * n

for c, x, y in (map(int, f.readline().split()) for _ in range(q)):
    com[c](x, y)

Measured memory_bytes: 6872
N=int(input())
S=input()
l=0
r=S[1:].count("E")
#print(r)
answer=N

for i in range(N-1):
    if l+r<answer:
        answer=l+r
    if S[i]=="W":
        l+=1
    if S[i+1]=="E":
        r-=1
if l+r<answer:
    answer=l+r
print(answer)


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = 1; i < (ll)(n); i++)
#define P pair<ll, ll>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//nCa 組み合わせ
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(int x, int y){
  if(x % y == 1) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(int x, int y){
  return x * y / gcd(x, y);
}
// n個の最大公約数
ll ngcd(vector<int> a){
  int res;
  res = a[0];
  for(int i=1; i<a.size() && res!=1; i++){
    res = gcd(res, a[i]);
  }
  return res;
}
// n個の最小公倍数
ll nlcm(vector<int> a){
  int res;
  res = a[0];
  REP(i, a.size()){
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(int x){
  int i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
int digsum(int x){
  int res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll ans = pow(3, n);
  int no = 1;
  rep(i, n){
    if(a[i] % 2 == 0){
      no *= 2;
    }
  }
  ans -= no;
  cout << ans << endl;
}






Measured memory_bytes: 256
N,M,X,Y = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
B = list(map(int,input().split()))
B = sorted(B)
if X<Y and A[-1]<B[0]:
    if Y<=A[-1] or X>=B[0]:
        print("War")
    else:
        print("No War")
else:
    print("War")

Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
    
    int i = 1;
    int x,y;
    
    while(i <= 3000){
        scanf("%d %d",&x,&y);
        if(x==0 && y==0)break;
        else if(x>=y)printf("%d %d\n",y,x);
        else if(y>x)printf("%d %d\n",x,y);
        i++;
    }
    
    return 0;
}


Measured memory_bytes: 2032
#include <stdio.h>

int main() {
    int INF = 100000000;
    int n, m; scanf("%d%d", &n, &m);
    int c[30];
    for(int i=0; i<m; i++) scanf("%d", &c[i]);

    int dp[30][50010];
    for(int i=0; i<=m; i++) {
        for(int j=0; j<50010; j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;

    for(int i=1; i<=m; i++) {
        for(int j=0; j<50010; j++) {
            dp[i][j] = dp[i-1][j];
            if(j-c[i-1] < 0) continue;
            if(dp[i][j] > dp[i][j-c[i-1]] + 1) dp[i][j] = dp[i][j-c[i-1]] + 1;
        }
    }
    printf("%d\n", dp[m][n]);
    return 0;
}

Measured memory_bytes: 6844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    int a, b; cin >> a >> b;
    cout << ceil((a + b) / 2.0) << endl;
    return 0;
}

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

using namespace std;

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

  long a,b,k; cin>>a>>b>>k;

  if (k > a) {
    k -= a;
    a = 0;
  } else {
    a -= k;
    k = 0;
  }
  if (k > b) {
    b = 0;
  } else {
    b -= k;
  }
  cout << a << " " << b << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string a,b,c;
    ll n;
    cin>>n>>a>>b>>c;
    ll ans=0;
    for(int i=0;i<n;i++){
        if(a[i]==b[i]&&b[i]==c[i]){
            //3つ同じ
        }
        else if(a[i]==b[i]||b[i]==c[i]||a[i]==c[i]){
            ans++;
        }
        else ans+=2;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;




int main(void) {
  ll N;
  cin >> N;
  ll x[111], y[111], h[111];
  ll i;
  
  for(i=0; i<N; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }
  
  for(ll cx=0; cx<=100; cx++) {
    for(ll cy=0; cy<=100; cy++) {
      
      
      ll t=0;
      for(i=0; i<N; i++) {
        if(h[i]==0) continue;
        t=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
      }
      
      ll f=1;
      for(i=0; i<N; i++) {
        ll tt=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
        
        if(h[i]==0) {
          if(tt<t) f=0;
        }else {
          if(tt!=t) f=0;
        }
        
      }
      
      if(f) {
        pt(cx<<" "<<cy<<" "<<t);
        return 0;
      }
      
      
    }
  }
  
  
  
}






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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int n,k;
	cin >> n >> k;
	vi x(n),y(n),xx,yy;
	rep(i,n) cin >> x[i] >> y[i];
	xx = x,yy = y;
	sort(all(xx)),sort(all(yy));
	ll ans = 4*1e18;
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			for(int l = 0; l < n; l++){
				for(int m = l+1; m < n; m++){
					int cnt = 0;
					for(int z = 0; z < n; z++){
						if(x[z] < xx[i] || xx[j] < x[z]) continue;
						if(y[z] < yy[l] || yy[m] < y[z]) continue;
						cnt++;
					}
					if(cnt >= k) ans = min(ans,abs((ll)(xx[j]-xx[i])*(yy[m]-yy[l])));
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int a,b;
  cin >> a >> b;
  cout << a*b << endl;
  return 0;
}


Measured memory_bytes: 3624
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	q := getNextInt(scanner)

	ggg := make([][][]int, n)
	for i := 0; i < n; i++ {
		ggg[i] = make([][]int, n)
		for j := 0; j < n; j++ {
			ggg[i][j] = make([]int, m+1)
		}
	}
	for i := 0; i < q; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		c := getNextInt(scanner)
		d := getNextInt(scanner)
		ggg[a][b][c] = maxint(ggg[a][b][c], d)
	}

	aa := make([]int, n)
	ans := dfs(0, 1, m, aa, ggg)

	fmt.Fprintln(writer, ans)
}

func maxint(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func dfs(i, x, m int, aa []int, ggg [][][]int) int {
	n := len(aa)
	ans := 0
	if i == n {
		for l := 0; l < n; l++ {
			for r := l + 1; r < n; r++ {
				ans += ggg[l][r][aa[r]-aa[l]]
			}
		}
		return ans
	}
	for now := x; now <= m; now++ {
		aa[i] = now
		ans = maxint(ans, dfs(i+1, now, m, aa, ggg))
	}

	return ans
}


Measured memory_bytes: 1848
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> edge;
typedef vector<edge> ve;
typedef vector<ve> graph;

int main(){
  int n,m,p;
  while(cin >> n >> m >> p, n){
    graph g(n);
    for(int i=0;i<m;i++){
      int a,b,c;
      cin >> a >> b >> c;
      g[a].push_back(edge(c,b));
      g[b].push_back(edge(c,a));
    }

    vi c(p);
    for(int i=0;i<p;i++)cin >> c[i];

    vi d(n,1e9), order;
    d[0] = 0;
    priority_queue< edge,vector<edge>,greater<edge> > pq;
    pq.push(edge(0,0));

    while(pq.size()){
      int dis = pq.top().first, v = pq.top().second; pq.pop();
      if(d[v] < dis)continue;
      order.push_back(v);

      for(edge e : g[v]){
	int nxtd = dis + e.first, u = e.second;
	if(d[u] > nxtd){
	  d[u] = nxtd;
	  pq.push(edge(nxtd,u));
	}
      }
    }

    vector<double> cnt(n,0);
    cnt[n-1] = 1;
    for(int i=order.size()-1;i>=0;i--){
      int v = order[i];
      for(edge e : g[v]){
	int dis = e.first, u = e.second;
	if(d[v] == d[u] + dis)cnt[u] += cnt[v];
      }
    }

    vector<double> prob(n,0);
    prob[0] = 1;
    for(int i=0;i<n;i++){
      int v = order[i];

      for(edge e : g[v]){
	int nxtd = d[v] + e.first, u = e.second;
	if(d[u] == nxtd){
	  prob[u] += prob[v] * cnt[u] / cnt[v];
	}
      }
    }

    for(int i=0;i<p;i++){
      cout << fixed << setprecision(9) << prob[c[i]] << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define REP(i,N) for(int i = 0; i < (int)N; i++)

int main(){
	int n;
	int reta,retb;
	while(cin >> n){
		if(n==0)break;
		reta=retb=0;
		REP(i,n){
			int a,b;
			cin >> a >> b;
			if(a > b){
				reta += a+b;
			}else if(b > a){
				retb += a+b;
			}else{
				reta += a;
				retb += b;
			}
		}
		cout << reta << " " << retb << endl;
	}
	return 0;
}

Measured memory_bytes: 3012
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << ", ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << " ]" ;
}

#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
#define sz(a) (ll)(a).size()
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)
#define pi 3.141592653589793238462643

ll ceil(ll a,ll b){
    return a/b+(a%b!=0);
}

void solve(){
    ll n, x, t;
    cin >> n >> x >> t;
    ll ans = ceil(n, x) * t;
    print(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        start_routine();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    #ifndef ONLINE_JUDGE
        end_routine();
    #endif
}


Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int dp[10][1001];
    MEMSET(dp);
    dp[0][0]=1;
    rep(j,101){
        rev(i,9){
            rep(k,1001-j){
                dp[i+1][k+j]+=dp[i][k];
            }
        }
    }
    int n,s;
    while(cin>>n>>s,n){
        cout<<dp[n][s]<<endl;
    }
}


Measured memory_bytes: 3180
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)
#define clz(n)				__builtin_clzll(n)

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	printf("%d",(c - (a-b) > 0 ? c-(a-b) : 0));
	return 0;
}





Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long ll;
#define pb push_back

const ll MOD = 1e9 + 7;

ll modexpo(ll a, ll b, ll mod)
{
    a %= mod;
    if (b == 0)
        return 1 % mod;
    if ((b & 1) == 1)
        return a * (modexpo(a, b - 1, mod)) % mod;
    else
    {
        ll u = modexpo(a, b >> 1, mod);
        return (u * u) % mod;
    }
}

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

    ll n;
    cin >> n;
    ll a1 = modexpo(10, n, MOD);
    (a1 += MOD) % MOD;
    ll a2 = modexpo(9, n, MOD);
    (a2 *= 2) % MOD;
    (a2 += MOD) % MOD;
    ll a3 = modexpo(8, n, MOD);
    (a3 += MOD) % MOD;

    ll ans = (a1 % MOD - a2 % MOD + a3 % MOD + MOD) % MOD;
    cout << ans % MOD;

    return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 1; ; i++) {
            int x = sc.nextInt();
            if(x == 0){
                break;
            }
            
            System.out.printf("Case %d: %d\n",i,x);
        }
        sc.close();
        
    }
}   


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

#define int long long
#define double long double
#define incin(n) int (n); cin >> (n)
#define uniq(v) sort((v).begin(),(v).end()); (v).erase(unique((v).begin(),(v).end()),(v).end());
#define steprap(i,n,s) for(int (i)=0;i<(s)*(n);(i)+=(s))
#define rap(i,n) steprap((i),(n),1)

using intV = std::vector<int>;

using namespace std;
namespace math
{
	double PI = 3.14159265359;
	int step(int n);
	int ncr(int n,int r);
	int npr(int n,int r);
	int gcm(int a,int b);
	int lcm(int a,int b);

	int step(int n){
		if(n<=1){
			return 1;
		}else{
			return n * step(n-1);
		}
	}
	int ncr(int n,int r){
		for(int i=1;i<r;i++){
			n *= n-i;
		}
		for(int i=1;i<r;i++){
			r *= r-1;
		}
		return n/r;
	}
	int npr(int n,int r){
		for (int i = 1; i < r; ++i)
		{
			n *= n-1;
		}
		return n;
	}
	int gcm(int a,int b){
		int p=max(a,b);
		int q=min(a,b);
		int r;
		while(true){
			if(p%q==0){
				return q;
			}
			r = p%q;
			p=q;
			q=r;
		}
	}
}

using namespace std;
// using StringMap = std::vector<std::vector<char>> map(h+2,vector<char>(w+2,'#'));
namespace tmp {
    template <typename T> bool inArry(T x,vector<T> v);
    template <typename T> void input(int n,vector<T> &v);

    template <typename T> bool inArry(T x,vector<T> v){
        int l = v.size();
        for(int i=0;i<l;i++){
            if(x==v[i]){
                return true;
            }
        }
        return false;
    }
    
    template <typename T> void input(int n,vector<T> &v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
    }
}

using namespace std;

signed main (){
	int a,b,c;
	cin >> a>>b>>c;
	int five=0,seven=0;
	if(a==5){
		five++;
	}else if(a==7){
		seven++;
	}
	if(b==5){
		five++;
	}else if(b==7){
		seven++;
	}
	if(c==5){
		five++;
	}else if(c==7){
		seven++;
	}
	if(five==2 && seven==1){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#A
k = int(input())
a,b = map (int,input().split())
c = 0
for i in range(a,b+1):
    if i%k == 0 :
        c +=1
        break
    else:
        c = 0
if c> 0:
    print("OK")
else:
    print("NG")
    

Measured memory_bytes: 9172
#pragma GCC optimize("Ofast")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

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

    int n, m;
    int64_t k;
    cin >> n >> m >> k;
    vector<int64_t> a;
    vector<int64_t> b;
    a.emplace_back(0);
    b.emplace_back(0);
    int64_t tmp;
    for(int i=0; i < n; ++i){
        cin >> tmp;
        a.emplace_back(tmp);
    }
    for(int i=0, tmp; i < m; ++i){
        cin >> tmp;
        b.emplace_back(tmp);
    }
    for(int i=1; i < n+1; ++i){
        a[i] += a[i-1];
    }
    for(int i=1; i < m+1; ++i){
        b[i] += b[i-1];
    }

    int count = 0;
    int j = m;
    for(int i=0; i <= n; ++i){
        if(a[i] > k) break;
        while(b[j] > k - a[i]){
            --j;
        }
        count = max(count, i+j);
    }
    cout << count << "\n";
    return 0;
}

Measured memory_bytes: 7932
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [None for _ in range(D)]
    for i in range(D):
        s[i] = list(map(int, input().split()))
    
    # 最後に開催した日
    lasts = [-1] * 26
    for d in range(D):
        # 今日の満足度低下率を計算
        satisfies = [None] * 26
        for j in range(26):
            satisfies[j] = c[j] * (d - max(0,lasts[j]))

        # 一番満足度の下がるやつと一番満足度が上がるやつを比較
        dindex = -1
        score = 0
        for j in range(26):
            tmp = satisfies[j] + s[i][j]
            if score < tmp:
                score = tmp
                dindex = j

        lasts[dindex] = d
        print(dindex+1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9836
#include<bits/stdc++.h>
using namespace std;
void mincost(int *h,int n){
	int dp[n] = {0};
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	// I can reach a index i from i-1 or i-2
	// choose the minimum of the two option's results
	for(int i=2;i<n;++i){
		dp[i] = min( abs(h[i]-h[i-1]) + dp[i-1] , abs(h[i]-h[i-2]) + dp[i-2] );
	}
	cout<<dp[n-1];
}
int main(){
	int n; cin>>n;
	int *heights = new int[n];
	for(int i=0;i<n;++i) cin>>heights[i];
	mincost(heights,n);
	delete[] heights;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] num = new int[m];
		String[] s = new String[m];
		
		for (int i = 0; i < m; i++) {
			num[i] = sc.nextInt();
			s[i] = sc.next();
		}
		
		int[] cnt = new int[n];
		int[] wa = new int[n];
		for (int i = 0; i < m; i++) {
			if (s[i].equals("AC") && cnt[num[i] - 1] == 0) {
				cnt[num[i] - 1]++;
				continue;
			}
			
			if (s[i].equals("WA") && cnt[num[i] - 1] == 0) {
				wa[num[i] - 1]++;
			}
		}
		
		int a = 0;
		int w = 0;
		for (int i = 0; i < n; i++) {
			a += cnt[i];
			if (cnt[i] > 0) {
				w += wa[i];
			}
		}
		
		System.out.println(a + " " + w);

	}
}

Measured memory_bytes: 69660
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N, M;
  cin >> N >> M;

  struct Key {
    uint32_t open;
    ll cost;
  };

  constexpr size_t MAXSIZE = (1 << 13);

  // state, cost
  vector<ll> dp(MAXSIZE, -1);
  dp[0] = 0;

  vector<Key> keys(M);
  for (ll i = 0; i < M; i++) {
    ll cost, open_N;
    cin >> cost >> open_N;
    uint32_t open = 0;
    for (ll j = 0; j < open_N; j++) {
      ll x;
      cin >> x;
      x--;
      open |= (1 << x);
    }
    keys[i] = {open, cost};
  }

  for (uint32_t i = 0; i < (1 << N); i++) {
    if (dp[i] == -1) {
      continue;
    }
    for (const auto& key : keys) {
      ll to = (i | key.open);
      if (dp[to] == -1) {
        dp[to] = dp[i] + key.cost;
      } else {
        dp[to] = min(dp[to], dp[i] + key.cost);
      }
    }
  }
  cout << dp[(1 << N) - 1] << endl;

  return 0;
}


Measured memory_bytes: 384
class DisjointSet:
    def __init__(self,size):
        self.rank = [None]*size
        self.p = [None]*size
        for i in range(size):
            self.make_set(i)
        return
    
    def make_set(self,x):
        self.p[x] = x
        self.rank[x] = 0
        return
    
    def same(self,x,y):
        return self.find_set(x) == self.find_set(y)
        
    def unite(self,x,y):
        self.link(self.find_set(x),self.find_set(y))
        return
    
    def link(self,x,y):
        if self.rank[x]>self.rank[y]:
            self.p[y] = x
        else:
            self.p[x] = y
            if self.rank[x]==self.rank[y]:
                self.rank[y] += 1
                
    def find_set(self,x):
        if x != self.p[x]:
            self.p[x] = self.find_set(self.p[x])
        return self.p[x]
        
n,q = map(int,input().split())
djs = DisjointSet(n)

for i in range(q):
    com,x,y = map(int,input().split())
    if com == 0:
        djs.unite(x,y)
    else:
        print(int(djs.same(x,y)))


Measured memory_bytes: 6044
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
    int t, h, m, s;
    cin >> t;
    h = t / 3600;
    m = t % 3600 / 60;
    s = t % 3600 % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}

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

using namespace std;

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

	vector<int> b(n - 1);

	for (int i = 0; i < n - 1; i++)
	{
		cin >> b.at(i);
	}
	b.push_back(INT_MAX);

	int sum = b.at(0);
	for (int i = 1; i < n; i++)
	{
		sum += min(b.at(i - 1), b.at(i));
	}

	cout << sum << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)

{

int a,b,d,r;

double f,x,y;

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

d=a/b;

r=a%b;

x=a;

y=b;


f=x/y;


printf("%d %d %lf",d, r, f);

return 0;

}

Measured memory_bytes: 632
#include<stdio.h>
#define N 100000

typedef struct{
  int pare,fstch,sibling;
}Node;

Node node[N];
int n,dep[N];

void print(int x){
  int i,ch;

  printf("node %d: parent = %d, depth = %d, ",x,node[x].pare,dep[x]);
  if(node[x].pare==-1) printf("root, ");
  else if(node[x].fstch==-1) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i=0,ch=node[x].fstch ; ch!=-1 ; i++,ch=node[ch].sibling){
    if(i>0)printf(", ");
    printf("%d",ch);
  }
  printf("]\n");
}

void depth(int x,int cnt){
  dep[x]=cnt;
  if(node[x].sibling != -1){
    depth(node[x].sibling,cnt);
  }
  if(node[x].fstch != -1){
    depth(node[x].fstch,cnt+1);
  }
}

int main(){

  int i,j,ch,v,digree,first,root,k;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    node[i].pare = node[i].fstch = node[i].sibling = -1;

  for(i=0;i<n;i++){
    scanf("%d %d",&v,&digree);

    for(j=0;j<digree;j++){
      scanf("%d",&ch);
      if(j==0)
	node[v].fstch=ch;
      else
	node[first].sibling=ch;
      first=ch;
      node[ch].pare=v;
    }
  }

  for(k=0;k<n;k++){
    if(node[k].pare==-1)
      root=k;
  }

  depth(root,0);

  for(i=0;i<n;i++) print(i);

  return 0;
}



Measured memory_bytes: 6544
#include<bits/stdc++.h>
#define maxn 2010
#define mod 1000000007
using namespace std;
struct edge{
	int r,nxt;
}e[maxn<<1];
int head[maxn],esz,fac[maxn],dp[maxn][maxn][3],n;
void addedge(int u,int v){
	e[++esz].r=v;e[esz].nxt=head[u];head[u]=esz;
}
int dfs(int u){
	dp[u][0][0]=1;
	int sz=1,s;
	for(int t=head[u],v;t;t=e[t].nxt){
		s=dfs(v=e[t].r);
		for(int i=sz-1;i>=0;--i)
			for(int j=s-1;j>=0;--j){
				int A=(1ll*dp[v][j][0]+dp[v][j][1]+dp[v][j][2])%mod;
				dp[u][i+j+1][1]=(dp[u][i+j+1][1]+1ll*dp[u][i][0]*(2ll*dp[v][j][0]+dp[v][j][1]))%mod;
				dp[u][i+j+1][2]=(dp[u][i+j+1][2]+1ll*dp[u][i][1]*(dp[v][j][0]+1ll*dp[v][j][1]*(mod+1)/2%mod))%mod;
				if(j==0){
					dp[u][i][0]=1ll*dp[u][i][0]*A%mod;
					dp[u][i][1]=1ll*dp[u][i][1]*A%mod;
					dp[u][i][2]=1ll*dp[u][i][2]*A%mod;
				} else {
					dp[u][i+j][0]=(dp[u][i+j][0]+1ll*dp[u][i][0]*A)%mod;
					dp[u][i+j][1]=(dp[u][i+j][1]+1ll*dp[u][i][1]*A)%mod;
					dp[u][i+j][2]=(dp[u][i+j][2]+1ll*dp[u][i][2]*A)%mod;
				}
			}
			
		sz+=s;
	}
	return sz;
}
int main(){
	scanf("%d",&n),fac[0]=1;
	for(int i=1;i<=n;++i)
		fac[i]=1ll*fac[i-1]*i%mod;
	for(int i=2,x;i<=n;++i) 
		scanf("%d",&x),addedge(x,i);
	dfs(1);
	int ans=0;
	for(int i=0;i<n;++i)
		ans=(ans+1ll*(i&1?-1:1)*fac[n-i]*(1ll*dp[1][i][0]+dp[1][i][1]+dp[1][i][2])%mod+mod)%mod;
	printf("%d",ans);
} 

Measured memory_bytes: 47616
/*  Perseverance can make miracle happens  */
/* If u identify me then u r my frnd */

#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define vi vector<int>
#define pq priority_queue<int>
#define mpi map<int,int>
#define pb push_back
#define ff first
#define ss second
#define ppi pair<int,int>
#define forn(i,n) for(int i=0;i<n;i++)
#define M 1000000007
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)

//---------------------------------------------------------------------------------------------------------------------------------//

int mod(long long x) {
	return ((x % M + M) % M);
}
int add(int a, int b) {
	return mod(mod(a) + mod(b));
}
int diff(int a, int b) {
	return mod(mod(a) - mod(b));
}

int mul(int a, int b) {
	return mod(mod(a) * mod(b));
}

//---------------------------------------------------------------------------------------------------------------------------------//

bool f(ppi x, ppi y) {
	if (x.ff == x.ss && y.ff == y.ss) {
		return x < y;
	}
	return x > y;
}



void solve() {

	int n; cin >> n;
	vector<ppi>v;
	for (int i = 0; i < n; ++i)
	{
		int x, y; cin >> x >> y;
		v.pb({x, y});
	}

	// sort(all(v), f);
	bool f = 0;
	int cnt = 0;
	for (auto &x : v) {
		if (x.ff == x.ss)
			cnt++;

		else if (x.ff != x.ss)
			cnt = 0;

		if (cnt >= 3) {
			f = 1;
			break;
		}
	}

	if (f == 1)cout << "Yes" << endl;
	else
		cout << "No" << endl;





}


int32_t main() {

	fastio;

#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif

	// int t; cin >> t;
	int t = 1;

	while (t--) {
		solve();
	}

	return 0;
}

Measured memory_bytes: 3656
// ProblemURL : https://atcoder.jp/contests/abc114/tasks/abc114_c
// ---------------------------------------------
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	ct := 0
	check := func(n int) bool {
		a, b, c := false, false, false
		for i := n; i > 0; i /= 10 {
			switch i % 10 {
			case 3:
				a = true
			case 5:
				b = true
			case 7:
				c = true
			default:
				return false
			}
		}
		if a && b && c {
			return true
		}
		return false
	}
	var dfs func(int)
	dfs = func(x int) {
		if x > n {
			return
		}
		if check(x) {
			ct++
		}
		dfs(x*10 + 3)
		dfs(x*10 + 5)
		dfs(x*10 + 7)
	}
	dfs(0)
	fmt.Println(ct)
}


Measured memory_bytes: 512
#include<stdio.h>

void sancondition();

int main(void){

	sancondition();//三角形か判断する関数
	return 0;
}

void sancondition(){
	int a=0,b=0,c=0,sankaku=0,don=0,ei=0,tyokkaku=0,false=0;//三角形の数、種類の変数

	while(false==0){//繰り返し関数（三角形じゃない値になるまで）

		scanf("%d%d%d",&a,&b,&c);//入力関数（3つの数を入力できるようにする）

		if(a+b>c&&b+c>a&&c+a>b)
		{
			sankaku++;//三角形だと数える
			if(a*a+b*b==c*c||b*b+c*c==a*a||c*c+a*a==b*b){
				tyokkaku++;//直角三角形とカウント
			}else if(a*a+b*b<c*c || b*b+c*c<a*a || c*c+a*a<b*b){
				don++;//鈍角とカウント
			}else if(a*a + b*b > c*c || b*b + c*c > a*a || c*c + a*a > b*b){
				ei++;//鋭角とカウント
			}
		}
		else{
			printf("%d %d %d %d\n",sankaku,tyokkaku,ei,don);
			false=1;//そうでなければ、繰り返し関数を終了させる。
		}
	}

}



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

int main() {
  int n; cin >>n;
  long long l[n];
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  int ret = 0;
  for (int i = 0; i < n - 2; i++) {
    for (int j = i + 1; j < n - 1; j++) {
      if (l[i] == l[j]) continue;
      for (int k = j + 1; k < n ; k++) {
        if (l[i] == l[k]) continue;
        if (l[j] == l[k]) continue;

        if (l[i] < l[j] + l[k] 
         && l[j] < l[i] + l[k]
         && l[k] < l[i] + l[j]
        ) ret++;
      }
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,i,j,c,d,an=0,k,mod;
    mod=1000000007;
    cin>>n;
    ll ar[n+2];
    for(i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    for(i=0;i<60;i++)
    {
        k=(1LL<<i);
        c=0;
        d=0;
        for(j=0;j<n;j++)
        {
            if((ar[j] & k)==0)
                c++;
            else
                d++;
        }
        an=an+((k%mod)*((c*d)%mod))%mod;
        an=an%mod;
    }
     cout<<an<<endl;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    char s[123];
    Scs(s);


    YesNo( s[0] != s[1] || s[1] != s[2] );

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a1,b1;
	cin>>a1>>b1;
	string s,t;
	int a,b;
	a=a1[0]-48;
	b=b1[0]-48;
	for(int i=0;i<b;i++)
	s+=a1;
	for(int i=0;i<a;i++)
	t+=b1;
	if(s>t)
	cout<<t;
	else
	cout<<s;
} 

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 300001
#define int long long
using namespace std;

int read_p,read_ca;
inline int read(){
	read_p=0;read_ca=getchar();
	while(read_ca<'0'||read_ca>'9') read_ca=getchar();
	while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
	return read_p;
}
const int MOD=1e9+7;
int n,a[110000],w=0,mmh=0,A,B,L=0,R=1e9;
inline bool ju(int x){
	int u=B*x,s=0;
	for (int i=1;i<=n;i++)
	if (a[i]>u) s+=(a[i]-u+A-1)/A;
	return s<=x;
}
signed main(){
	int i,j,k;
	n=read();A=read();B=read();A-=B;
	for (i=1;i<=n;i++) a[i]=read();
	while (L<R){
		int mid=L+R>>1;
		if (ju(mid)) R=mid;else L=mid+1;
	}
	printf("%lld\n",L);
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
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 int INF = 0x3fffffff;
const int MOD = 1e9+7;


// n^m%MOD を求める。O( log(m) )
ll modpow(ll n, int m){
	ll ret=1;
	for(int i=1; i<=m; i<<=1, (n*=n)%=MOD){
		if( m&i ) (ret *= n) %= MOD;
	}
	return ret;
}

int memo[405][405][405];

int main(){
	ll N, C, ans=0;
	ll A[405], B[405];

	cin >> N >> C;
	rep(i,N) cin >> A[i];
	rep(i,N) cin >> B[i];

	rep(a,401) rep(k,401){
		memo[a][a][k] = modpow(a, k);
	}
	rep(a,401) for(int b=a; b<400; b++) rep(k,401){
		memo[a][b+1][k] = (memo[a][b][k] + memo[b+1][b+1][k]) % MOD;
	}

	ll dp[2][405] = {};
	dp[0][0] = 1;
	rep(i,N){
		//cout << "i=" << i << endl;
		rep(j,C+1) rep(k,C+1){
			if( j+k <= C ){
				dp[(i%2)^1][j+k] += (dp[i%2][j] * (ll)memo[A[i]][B[i]][k]) % MOD;
				dp[(i%2)^1][j+k] %= MOD;
				//cout << j << " " << k << " " << dp[(i%2)^1][j+k] << endl;
			}
		}
		Fill( dp[i%2], 0 );
	}

	cout << dp[N%2][C] << endl;

	return 0;
}


Measured memory_bytes: 129408
// Created by martinezdiego on 23/4/19

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  int a,b,c;
  cin >> a >> b >> c;
  if (a > b) {
    if (c > b and c < a)
      cout << "Yes" << '\n';
    else
      cout << "No" << '\n';
  }
  else if (a < b) {
    if (c < b and c > a)
      cout << "Yes" << '\n';
    else
      cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>

using namespace std;
typedef long long ll;

struct Num {
	ll val;
	int id;
};

bool lessN(const Num &n1, const Num &n2) { return (n1.val < n2.val); }
bool greaterN(const Num &n1, const Num &n2) { return (n1.val > n2.val); }

int main() {
	int n;
	ll org[300010];
	Num a[200010], b[200010];
	ll pr[100010] = {}, pos[100010] = {};
	bool used_a[200010] = {}, used_b[200010] = {};
	cin >> n;
	for (int i = 0; i < 3*n; i++) {
		ll temp;
		cin >> temp;
		org[i] = temp;
		if (i < 2 * n) {
			a[i].val = temp;
			a[i].id = i;
		}
		if (i >= n) {
			b[3 * n - i - 1].id = 3 * n - i - 1;
			b[3 * n - i - 1].val = temp;
		}
	}
	sort(a, a + 2 * n, greaterN);
	sort(b, b + 2 * n, lessN);
	for (int i = 0; i < n; i++) {
		pr[n] += a[i].val;
		used_a[a[i].id] = true;
		pos[n] += b[i].val;
		used_b[b[i].id] = true;
	}
	int idx_a = n, idx_b = n;
	for (int i = 1; i <= n; i++) {
		if (used_a[2 * n - i]) {
			while (a[idx_a].id >= 2 * n - i)idx_a++;
			used_a[2 * n - i] = false;
			used_a[a[idx_a].id] = true;
			pr[n - i] = pr[n - i + 1] - org[2 * n - i] + a[idx_a++].val;
		}
		else {
			pr[n - i] = pr[n - i + 1];
		}
		if (used_b[2 * n - i]) {
			while (b[idx_b].id >= 2 * n - i)idx_b++;
			used_b[2 * n - i] = false;
			used_b[b[idx_b].id] = true;
			pos[n - i] = pos[n - i + 1] - org[n + i-1] + b[idx_b++].val;
		}
		else {
			pos[n - i] = pos[n - i + 1];
		}
	}
	ll ans = -1000000000000000000;
	for (int i = 0; i <= n; i++) {
		ans = max(ans, pr[i] - pos[n - i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10880
import heapq
def main():
    N,M=map(int,input().split())
    A=list(map(int,input().split()))
    heapq.heapify(A)
    BC=[]
    for i in range(M):
        bc=list(map(int,input().split()))
        BC.append(bc)

    BC.sort(reverse=True,key=lambda x:x[1])
    new_BC=[]
    count=0
    for i in range(M):
        for j in range(BC[i][0]):
            new_BC.append(BC[i][1])
            count+=1
            if count==N:
                break
        if count==N:
            break

    flag=False
    for i in range(len(new_BC)):
        a=heapq.heappop(A)
        if a<new_BC[i]:
            heapq.heappush(A,new_BC[i])
        else:
            heapq.heappush(A,a)
            flag=True
        if flag:
            break
    
    print(sum(A))
if __name__=="__main__":
    main()

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

using namespace std;

int cnt[3005][3005], ans[2005][2005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N, K, x, y;
	char c;
	cin >> N >> K;
	for (int i = 1; i <= N; ++i){
		cin >> x >> y >> c;
		if (c == 'B'){
			x += K;
			//y += K;
		}
		x %= (2*K);
		y %= (2*K);
		cnt[x][y]++;
		cnt[x+K][y]--;
		cnt[x][y+K]--;
		cnt[x+K][y+K]++;
	}
	for (int i = 0; i <= 3*K; ++i){
		int cur = 0;
		for (int j = 0; j <= 3*K; ++j){
			cur += cnt[i][j];
			cnt[i][j] = cur;
		}
	}
	for (int j = 0; j <= 3*K; ++j){
		int cur = 0;
		for (int i = 0; i <= 3*K; ++i){
			cur += cnt[i][j];
			cnt[i][j] = cur;
		}
	}
	int maxi = 0;
	for (int i = 0; i <= 3*K; ++i){
		for (int j = 0; j <= 3*K; ++j){
			ans[i%(2*K)][j%(2*K)] += cnt[i][j];
 		}
	}
	for (int i = 0; i <= K; ++i){
		for (int j = 0; j <= 2*K; ++j){
			//cout << ans[i][j] << ' ';
			if (j < K) maxi = max(maxi,ans[i][j]+ans[i+K][j+K]);
			else maxi = max(maxi,ans[i][j]+ans[i+K][j-K]);
 		}
 		//cout << '\n';
	}
	cout << maxi << '\n';
	cout << flush;
	//for (int i = 0; i < 1e9; ++i){for (int j = 0; j < 1e9; ++j){}}
}

Measured memory_bytes: 51200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//long longのシフト演算には気をつけよう

int main(){
    int N, C; cin >> N >> C;
    int s[N], t[N], c[N], sum[100005], tt[100005]; // tt = time_table
    for(int i=0; i<N; i++) cin >> s[i] >> t[i] >> c[i];
    for(int i=0; i<100005; i++) sum[i] = 0;

    for(int ch=1; ch<=C; ch++){

        for(int i=0; i<100005; i++) tt[i] = 0;
        //for(int i=0; i<N; i++) if(c[i] == ch) tt[s[i]-1]++, tt[t[i]+1]--;
        for(int i=0; i<N; i++) if(c[i] == ch) tt[s[i]-1]++, tt[t[i]]--;
        for(int i=1; i<100005; i++) tt[i] += tt[i-1];
        for(int i=0; i<100005; i++) if(tt[i]>0) sum[i]++;

        // for(int i=0; i<95; i++){
        //     if(i%10 == 0) cout << '|';
        //     cout << tt[i];
        // }
        // cout << endl;
    }

    int ans = 0;
    for(int i=0; i<100005; i++) ans = max(ans, sum[i]);
    cout << ans << endl;

}

Measured memory_bytes: 2176