akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

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

    int l, r;
    int lmax = 1;
    int rmin = n;
    for (size_t i = 0; i < m; i++)
    {
        cin >> l >> r;
        lmax = max(l, lmax);
        rmin = min(r, rmin);
    }

    int ans = rmin - lmax + 1;
    if (ans < 0)
    {
        ans = 0;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<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 (b<a) { a=b; return 1; } return 0; }



void solve() {
    LL n;
    cin >> n;
    LL ans = 0;
    REP(i,1,n+1) {
        LL num = n / i;
        ans += num * (num + 1) / 2 * i;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
char chess (int h, int w){
    if((h+w)%2 == 0){
        return '#';
    }
    return '.';
}
 
int main(void){
   int H , W;
   while(true){
        cin >> H >> W;
        if(W == 0 && H == 0){
            break;
        }
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                cout << chess(i, j);
            }
            cout << endl;
        }
        cout << endl;
   }
}
//ITP1_5_C*


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

const int MAX = 100010;
const int INF = 1e9;
int dp[MAX]; // dp[i]: i円を払うのに必要な最小の紙幣の枚数

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

    int n;
    cin >> n;

    vector<int> A;
    A.push_back(1);
    int t = 6;
    while(t <= MAX){
        A.push_back(t);
        t *= 6;
    }
    t = 9;
    while(t <= MAX){
        A.push_back(t);
        t *= 9;
    }
    
    sort(A.begin(), A.end());

    for(int i = 0; i <= n; i++){
        dp[i] = INF;
    }

    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < (int)A.size(); j++){
            if(i - A[j] < 0) continue;
            dp[i] = min(dp[i], dp[i - A[j]] + 1);
        }
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
/****************************/
int n,k;
int a[200010];
int main()
{
	cin>>n>>k;
	rep(i,n)
	{
		cin>>a[i];
	}
	rep3(i,k,n)
	{
		if(a[i]>a[i-k])
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		 } 
	}
	return 0;
}

Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
ll L[100005],R[100005];
int main() {
	int N,M;
	cin>>N>>M;
	rep(i,M){
		cin>>L[i]>>R[i];
	}
	int l0 = L[0],r0 = R[0];
	int ln = L[0],rn = R[0];
	int ans = 0;
	rep1(i,M){
		if(l0<=L[i] && L[i]<=r0){
			ln = L[i];
		}
		if(l0<=R[i] && R[i]<=r0){
			rn = R[i];
		}
		if(R[i]<l0||r0<L[i]){
			cout<<ans<<endl;
			return 0;
		}
	l0 = ln;
	r0 = rn;
	}
	cerr<<l0<<" "<<r0<<endl;;
	ans = r0 - l0 + 1;
	cout<<ans<<endl;
}

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

  int main() {
    string s;
    getline(cin, s, 'q');
    int n;
    vector<int> count(26);
    vector<char> vc(s.size());

    for(int i = 0; i < s.size(); ++i) {
      vc.at(i) = s[i];
    }

    for(int i = 0; i < vc.size(); ++i) {
      if(vc.at(i) >= 65 && vc.at(i) <= 90) {
        n = vc.at(i) - 'A';
        count.at(n)++;
      }
      if(vc.at(i) >= 97 && vc.at(i) <= 122) {
        n = vc.at(i) - 'a';
        count.at(n)++;
      }
    }

    for(int i = 0; i < count.size(); ++i) {
      cout << char('a' + i) << " : " << count.at(i) << endl;
    }
  }



Measured memory_bytes: 3136
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#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() {
  vector<int>a(3);
  cin >> a.at(0) >> a.at(1) >> a.at(2);
  sort(a.begin(),a.end());
  int sa1 = a.at(2)-a.at(1);
  int sa2 = a.at(2)-a.at(0);
//  cout << sa1 << sa2 << endl;
  if(sa1%2 ==sa2%2) cout << (sa1+sa2)/2 << endl;
  else{
    if(sa1%2==0) cout<< sa1/2 + (sa2+1)/2 + 1 <<endl;
    else cout << (sa1+1)/2 + sa2/2 + 1 <<endl;
  }
}

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

#define ll long long 
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define pl pair<long long ,long long >
#define pi pair<int ,int >
#define lb(v,x) lower_bound(v.begin(),v.end(),x)-v.begin()
#define ub(v,x) upper_bound(v.begin(),v.end(),x)-v.begin()
#define ct(i) cout<< i << "\n"
#define sv(v) sort(v.begin(),v.end())
#define mod 1000000007
#define M 100005
#define endl "\n"


void solve(){
    ll n,m,ans=0,x,y;
    cin>>n;
    vector<ll> a(n+1);
    for(int i=0;i<n;i++) cin>>a[i];
    a[n]=mod;
    for(int i=0;i<n;i++){
        if(a[i]>a[i+1]){
            ans+=(a[i]-a[i+1]);
            //cout<<a[i]-a[i+1]<<" ";
            a[i+1] = a[i];
        }
        //cout<<a[i]<<" ";
    }
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int q;
    //cin>>q; while(q--)
        solve();
    return 0;
}


Measured memory_bytes: 4752
s = list(input())
for i in range(int(input())):
  cmd, a, b, *c = input().split()
  a = int(a); b = int(b)
  if cmd == "print":
    print(*s[a:b+1], sep='')
  elif cmd == "reverse":
    s[a:b+1] = reversed(s[a:b+1])
  else:
    s[a:b+1] = c[0]


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

int main(void){
    int a = 0, b = 0, c = 0, k = 0; 
    int ans = 0;

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

    if(k >= a){
        ans = 1 * a;
        k -= a;
    }else if(k > 0){
        ans = 1 * k;
        printf("%d\n", ans);
        return 0;
    }
//    printf("a %d %d\n", ans, k);
    if(k >= b){
        ans += 0 * b;
        k -= b;
    }else if(k > 0){
        ans += 0 * k;
        printf("%d\n", ans);
        return 0;
    }
//    printf("b %d %d\n", ans, k);

    if(k >= c){
        ans += (-1) * c;
        k -= c;
    }else if(k > 0){
        ans += (-1) * k;
    }

    printf("%d\n", ans);

    return 0;

} 


Measured memory_bytes: 3816
#include<bits/stdc++.h>
#include<vector>
#include<deque>
#include<cmath>
#include<math.h>
#include<cstdlib>
#include<assert.h>
#include<string>
#include<sstream>
#include<algorithm>
#include<ctime>
#include<iostream>
#define ll long long 
#define ld long double
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BP(n) __builtin_popcount(n)
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(j,n) for (j=i;j<n;j++)
#define Unique(v) vector<ll>::iterator it; sort(all(v)); it= unique(all(v)); v.resize(distance(v.begin(),it))
#define PI 3.14159265358979323846
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL) 
using namespace std;
void input(vector<string>& v,int n){ int i; string io; rep(i,n) { cin>>io; v.pb(io);} }
void output(vector<int> v) { int i; rep(i,v.size()) cout<<v.at(i)<<" "; }
/*map<string,int>  frequency(vector<string> v){  int i; map<string,int> m; rep (i,v.size()) {  if (m.find(v[i])==m.end()) m.insert({v.at(i),1}); else m[v.at(i)]++; } return m; }
bool perfsq(ll n){ return (ceil(sqrt(n))==floor(sqrt(n))); }
bool ispower2(ll n) { if (n&(n-1)==0) return true; else return false; }
bool binary_pred(int a,int b){ return a==b; }*/

int main()
{
	fastio;
	int n;
	cin>>n;
	vector<string> v;
	input(v,n);
	int x= count(all(v),"AC");
	int y= count(all(v),"WA");
	int z= count(all(v),"TLE");
	int w= count(all(v),"RE");
	cout<<"AC"<<" "<<"x"<<" "<<x<<endl;
	cout<<"WA"<<" "<<"x"<<" "<<y<<endl;
	cout<<"TLE"<<" "<<"x"<<" "<<z<<endl;
	cout<<"RE"<<" "<<"x"<<" "<<w<<endl;
}


Measured memory_bytes: 7424
# coding:utf-8

def main():
    N = int(input())
    s = input()
    count_white = 0
    count_black = 0
    count_border = N
    # patern_border_white = [0]*N
    # patern_border_black = [0]*N

    if (not "." in s) or (not "#" in s):
        print(0)
        return

    for i in s:
        if i == ".":
            count_white += 1
        elif i == "#":
            count_black += 1

    patern_border_white = 0
    patern_border_black = 0
    temp_border_white = 0
    temp_border_black = 0
    
    for i in range(N-1):
        if i == 0:
            if s[0] == "#":
                # patern_border_white[0] = 1
                # patern_border_black[0] = count_white
                temp_border_white = 1
                temp_border_black = count_white

            else:
                # patern_border_white[0] = 0
                # patern_border_black[0] = count_white -1
                temp_border_white = 0
                temp_border_black = count_white -1

        else :
            if s[i] == "#":
                # patern_border_white[i] = patern_border_white[i-1] + 1
                # patern_border_black[i] = patern_border_black[i-1]
                temp_border_white = patern_border_white + 1
                temp_border_black = patern_border_black
            else :
                # patern_border_white[i] = patern_border_white[i-1]
                # patern_border_black[i] = patern_border_black[i-1] - 1
                temp_border_white = patern_border_white
                temp_border_black = patern_border_black - 1

        if count_border > temp_border_white + temp_border_black :
            count_border = temp_border_white + temp_border_black

        patern_border_white = temp_border_white
        patern_border_black = temp_border_black

    print(min(count_white,count_black,count_border))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3500
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
//#define double float

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const double EPS = 1e-6;
const int MAX = 1000 * 100 + 47;
const int MIN = 50 + 7;
const int MOD = INF;


PII A[MAX];
int x, y, z;
set<PII> X, XX, Y;
int UA[MAX], UB[MAX];
LL SX, SY;
int SZX, SZY;

void addX(int id)
{
    int val = A[id].first + A[id].second;
    PII v = MP(val, id);
    
    if (SZ(X) < x)
    {
        SX += val;
        X.insert(v);
        return ;
    }
    PII m = *X.begin();
    if (m < v)
    {
        XX.insert(m);
        SX -= m.first;
        X.erase(X.begin());
        X.insert(v);
        SX += val;

    }
    else
    {
        XX.insert(v);
    }
}


void delX(int id)
{
    int val = A[id].first + A[id].second;
    PII v = MP(val, id);
    if (XX.count(v))
    {
        XX.erase(v);
        return ;
    }
    X.erase(v);
    SX -= val;
    if (SZ(XX))
    {
        PII m = *XX.rbegin();
        X.insert(m);
        SX += m.first;
        XX.erase(m);
    }
}


void addY(int id)
{
    int val = A[id].second;
    PII v = MP(val, id);
    if (SZ(Y) == y &&  *Y.begin() < v)
    {
        SY -= Y.begin()->first;
        Y.erase(Y.begin());
    }
    if (SZ(Y) < y)
        Y.insert(v), SY += val;
}


bool valid()
{
    return SZ(X) == x && SZ(Y) == y;
}





int main()
{
    scanf("%d%d%d", &x, &y, &z);
    int n = x + y + z;
    LL sum = 0;
    FOR(i, 0, n)
    {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        sum += c;
        a -= c;
        b -= c;
        A[i] = MP(a - b, b);
    }

    sort(A, A + n);
    FOR(i, 0, n)addX(i);
    
    LL ans = -1;
    FOR(i, 0, n)
    {
        delX(i);
        addY(i);
        if (valid())
            ans = max(ans, sum + SX + SY);
    }
    
    cout << ans << endl;
    
    
    
}


Measured memory_bytes: 5760
ans=0
#n=int(input())
n,k=map(int,input().split())
v=[int(i) for i in input().split()]
b=sum(v)
f=[0]*(n+1)
ne=[i for i in v if i<0]
acn=[0]*(1+len(ne))
pre=0
for i in range(n):
    f[i+1]=f[i]+v[i]
    if i<len(ne):
        acn[i+1]=acn[i]+ne[i]

for lp in range(k+1):
    for rp in range(k+1):
        for back in range(lp+rp+1):
            if lp+rp+back>k or lp+rp>n:# or back>len(ne):
                break
            tmp=v[:lp]+v[len(v)-rp:]
            tmp.sort(reverse=True)
            ans=max(ans,sum(tmp[:len(tmp)-back])) 
print(ans)




Measured memory_bytes: 44892
#include <stdio.h>
int main()
{
  int a = 1,b = 0, c = 0,t;
  char i,j;
  while((scanf("%c,%c",&i,&j)) != EOF){
    if (i == 'A' && j == 'B' || i == 'B' && j == 'A'){
      t = a; a = b; b = t;
    }else if(i == 'A' && j == 'C' || i == 'C' && j == 'A'){
      t = a; a = c; c = t;
    }else{
      t = b; b = c; c = t;
    }
  }
  if(a==1) printf("A\n");
  else if(b==1) printf("B\n");
  else printf("C\n");
  return 0;
}

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

typedef long long ll;
using namespace std;
int main()
{
  ll x;
  cin>>x;
  if(x<11){
    if(x<=6){
      cout<<1<<endl;
    }else{
      cout<<2<<endl;
    }
  }else{
    if(x%11==0){
      cout<<2*(x/11)<<endl;
    }else if(x%11<=6){
      cout<<2*(x/11)+1<<endl;
    }else{
      cout<<2*(x/11)+2<<endl;
    }
  }


  return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
 
 
signed main()
{
  int n;cin>>n;
  vector<pii> xy(n);
  rep(i,n){
    cin>>xy[i].first>>xy[i].second;
  }
  vsort(xy);
  double ans=0;
  do {
    int prex=INF;
    int prey=INF;
    rep(i,n){
      if(prex==INF){
        prex=xy[i].first;
        prey=xy[i].second;
        continue;
      }
      ans+=sqrt((double)(prex-xy[i].first)*(prex-xy[i].first)+(prey-xy[i].second)*(prey-xy[i].second));
    }
  } while (next_permutation(xy.begin(), xy.end()));
  double tmp=1;
  reps(i,n){
    tmp*=i;
  }
  ans/=tmp;
  coutd(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	
	int n;
	int a[100011],ans=0;
	cin>>n;
	a[0]=0;
	a[n+1]=0;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		ans+=abs(a[i]-a[i-1]);
	}
	ans+=abs(a[n]);
	for(int i=1;i<=n;i++){
		cout<<ans-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1])-abs(a[i+1]-a[i-1]))<<endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

const int mod = 1000000007;

struct Mod {
  int n;
  Mod () : n(0) {;}
  Mod (int m) : n(m) {
    if (n >= mod) n %= mod;
    else if (n < 0) n = (n % mod + mod) % mod;
  }
  operator int() { return n; }
};

bool operator==(Mod a, Mod b) { return a.n == b.n; }
Mod operator+=(Mod &a, Mod b) { a.n += b.n; if (a.n >= mod) a.n -= mod; return a; }
Mod operator-=(Mod &a, Mod b) { a.n -= b.n; if (a.n < 0) a.n += mod; return a; }
Mod operator*=(Mod &a, Mod b) { a.n = ((long long)a.n * b.n) % mod; return a; }
Mod operator+(Mod a, Mod b) { return a += b; }
Mod operator-(Mod a, Mod b) { return a -= b; }
Mod operator*(Mod a, Mod b) { return a *= b; }
Mod operator^(Mod a, int n) {
  if (n == 0) return Mod(1);
  Mod res = (a * a) ^ (n / 2);
  if (n % 2) res = res * a;
  return res;
}

int main()
{
  ll n,k;
  cin>>n>>k;
  vector<vector<Mod>> dp(2501, vector<Mod>(51));
  dp[0][0] = 1;
  REP(idx,n) {
    vector<vector<Mod>> tmp(2501, vector<Mod>(51));
    REP(i,k+1)REP(j,n+1) {
      if (i+2*j<=k) tmp[i+2*j][j] += dp[i][j];
      if (j&&i+2*j<=k) tmp[i+2*j][j] += dp[i][j] * Mod(j);
      if (j&&i+2*j-2<=k) tmp[i+2*j-2][j-1] += dp[i][j] * Mod(j*j);
      if (i+2*j+2<=k) tmp[i+2*j+2][j+1] += dp[i][j];
      if (j&&i+2*j<=k) tmp[i+2*j][j] += dp[i][j] * Mod(j);
    }
    swap(dp, tmp);
  }
  cout<<dp[k][0]<<endl;
  return 0;
}


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

int cntcommonchar(string s1, string s2) {
	set<char> c1, c2, r;
	for (int i = 0; i < s1.size(); i++) {
		c1.insert(s1[i]);
	}
	for (int i = 0; i < s2.size(); i++) {
		c2.insert(s2[i]);
	}
	set_intersection(c1.begin(), c1.end(), c2.begin(), c2.end(), inserter(r, r.end()));
	return r.size();
}

int main() {
	int N;
	string S;
	cin >> N >> S;
	int ans = INT_MIN;
	for (int i = 1; i < N; i++) {
		ans = max(ans, cntcommonchar(S.substr(0, i), S.substr(i, N - i)));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif


void solve()
{
    int r , d , x ; //lmao ;
    cin >> r >> d>> x ;
    repA(i,1,10)
        cout << (x = r*x - d) << endl ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 256
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)


Measured memory_bytes: 9136
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n,c;
    cin >> n >> c;
    vector<vector<ll>> color(c+1,vector<ll>(c+1));
    for (int z=1;z<=c;z++){
        for (int x=1;x<=c;x++){
            cin >> color[z][x];
        }
    }
    vector<vector<ll>> grid(n,vector<ll>(n));
    for (int z=0;z<n;z++){
        for (int x=0;x<n;x++){
            cin >> grid[z][x];
        }
    }
    vector<vector<ll>> arr(c+1,vector<ll>(3));
    for (int col = 1;col<=c;col++){
        for (int z=0;z<n;z++){
            for (int x=0;x<n;x++){
                arr[col][(z+x+2)%3] += color[grid[z][x]][col];
            }
        }
    }
    ll ans = LLONG_MAX;
    for (int z=1;z<=c;z++){
        for (int x=z+1;x<=c;x++){
            for (int y=x+1;y<=c;y++){
                ans = min(ans,arr[z][0]+arr[x][1]+arr[y][2]);
                ans = min(ans,arr[z][0]+arr[x][2]+arr[y][1]);
                ans = min(ans,arr[z][1]+arr[x][0]+arr[y][2]);
                ans = min(ans,arr[z][1]+arr[x][2]+arr[y][0]);
                ans = min(ans,arr[z][2]+arr[x][0]+arr[y][1]);
                ans = min(ans,arr[z][2]+arr[x][1]+arr[y][0]);
            }
        }
    }
    cout << ans << endl;
} 

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, ans = 1, ct = 0;
    cin >> n;
    vector<lf> a(n);
    fr(i, 0, n)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            ct = 1;
        }
    }
    if (ct)
    {
        cout << 0 << endl;
        return 0;
    }
    fr(i, 0, n)
    {
        lf now = (lf)1e18 / ans;
        if (a[i] <= now)
        {
            ans *= a[i];
        }
        else
        {
            ans = -1;
            break;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >>A[i];
  }
  vector<int> ans(N);
  for(int i=0; i<N; i++){
    ans[A[i]-1]=i+1;
  }
  for(int i=0; i<N; i++){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 1664
/*pata hai na?*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

//#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const ld pi=acos(-1);
//const int inf=1e18,M=1e9+7;
const int N=1;

set<int> st[26];

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

    string s;
    cin>>s;

    for(int i=0;i<n;++i)
        st[s[i]-'a'].ins(i+1);

    int q;
    cin>>q;

    int t,x,l,r,cnt;
    char ch;
    set<int>::iterator it;

    for(;q;--q)
    {
        cin>>t;

        if(t==1)
        {
            cin>>x>>ch;

            st[s[x-1]-'a'].erase(x);
            st[ch-'a'].ins(x);
            s[x-1]=ch;
        }
        else
        {
            cin>>l>>r;

            cnt=0;
            for(int i=0;i<26;++i)
            {
                it=st[i].lower_bound(l);
                if(it!=st[i].end() && *it<=r)
                    ++cnt;
            }

            cout<<cnt<<"\n";
        }
    }
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 26268
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int S;
    cin >> S;
    
    int h,m,s;
    h = S / 60 / 60;
    m = (S / 60) % 60;
    s = S % 60;
    
    cout << h << ":" << m << ":" << s << endl; 
}


Measured memory_bytes: 3100
#include <iostream>

#include <map>
#include <string>

#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cinttypes>


using namespace std;

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

	bool ans;

	if (a + b < c)
	{
		uint64_t x = c - a - b;
		ans = 4 * a * b < x * x;
	}
	else
	{
		ans = false;
	}

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// union-find tree

const int max_n = 100005;

int par[max_n];
int rnk[max_n];

void init(int n){
	rep(i,n){
		par[i+1] = i+1;
		rnk[i+1] = 0;
	}
}

// find root of tree with x
int find(int x){
	if(par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;

	if(rnk[x] < rnk[y]) par[x] = y;
	else{
		par[y] = x;
		if(rnk[x] == rnk[y]) rnk[x]++;
	}
}

bool same(int x, int y){
	return find(x) == find(y);
}

// end union-find tree

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

	int n,m;
	cin >> n >> m;

	int p[n+1];
	rep(i,n) cin >> p[i+1];

	init(n);

	rep(i,m){
		int x, y;
		cin >> x >> y;
		unite(x,y);
	}

	int ans = 0;
	rep(i,n){
		if(same(i+1,p[i+1])){
			ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 1408
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
max_a = min(X // 500, A)
for i in range(max_a+1):
  x = X - 500 * i
  max_b = min(x // 100, B)
  for j in range(max_b+1):
    y = x - 100 * j
    c = y // 50
    if c <= C:
      count += 1
print(count)

Measured memory_bytes: 3064
import scala.annotation.tailrec
import scala.io.StdIn

object Main extends App {
  val c_price = 7
  val d_price = 4
  val N = StdIn.readInt()

  @tailrec
  def rec(c_count: Int = 0): Boolean = {
    if (c_count * c_price > N) {
      false
    } else {
      if ((N - (c_count * c_price)) % d_price == 0) {
        true
      } else {
        rec(c_count + 1)
      }
    }
  }

  val result = rec()
  if (result) {
    println("Yes")
  } else {
    println("No")
  }
}

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

int main()
{
  int x ;
  cin >> x ;
  int judge = x / 100 ;
  int calcu = x % 100 ;
  int count = 0 ;

  bool answer = true ;
  for(int i = 5 ; i != 0; i--)
  {
    count += calcu / i ;
    if(count > judge)
    {
      answer = false ;
      break ;
    }
    else if(calcu == 0)
    {
      answer = true ;
      break ;
    }
    else
    {
      calcu %= i ;
    }
  }  

  if(answer)
  {
    cout << 1 << endl ;
  }
  else
  {
    cout << 0 << endl ;
  }
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

int res;

void solve(vi& hist,int i,int remain,int cur)
{
	res=max(res,cur);
	if(i==10)
		return;
	
	int x=0;
	repi(j,1,10) x+=hist[j]*j;
	if(cur+x/10<res)
		return;
	
	if(remain==0){
		remain=10;
		cur++;
		i=1;
	}
	
	solve(hist,i+1,remain,cur);
	if(hist[i]>0 && remain>=i){
		hist[i]--;
		solve(hist,i,remain-i,cur);
		hist[i]++;
	}
}

int main()
{
	for(int n;scanf("%d",&n),n;){
		vi hist(10);
		rep(i,n){
			int m; scanf("%d",&m);
			hist[m]++;
		}
		
		int sum=hist[5]/2;
		hist[5]%=2;
		repi(i,1,5)
			while(hist[i] && hist[10-i]){
				sum++;
				hist[i]--;
				hist[10-i]--;
			}
		
		res=0;
		solve(hist,1,10,0);
		printf("%d\n",res+sum);
	}
	
	return 0;
}

Measured memory_bytes: 1192
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] L = new int[N];
		for(int i = 0; i < N; i++) {
			L[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 0; i < N; i++) {
			for(int j = i + 1; j < N; j++) {
				for(int k = j + 1; k < N; k++) {
					if(L[i] != L[j] && L[j] != L[k] && L[i] != L[k]) {
						if(L[i]+L[j]>L[k] && L[i]+L[k]>L[j] &&L[k]+L[j]>L[i]){
							ans++;
						}
					}
				}
			}
		}
		System.out.print(ans);
		
	}
}


Measured memory_bytes: 36844
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    sort(A.rbegin(), A.rend());
    int sum = accumulate(A.begin() + 1, A.end(), 0);
    if(A.front() < sum) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import math
import sys
sys.setrecursionlimit(10 ** 6 + 10)
from collections import defaultdict

def kari():
    map(int, input().split())

    num, num2 = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num2)]

def main():
    num, num2 = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num2)]

    pre, aft = data[0][0], data[0][1]
    for i in range(num2):
        pre = max(data[i][0], pre)
        aft = min(aft, data[i][1])

    ans = min(num, aft) - pre + 1
    if ans < 0:
        ans = 0
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 60248
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	var a = Number(tmp[0])
	var b = Number(tmp[1]);

    console.log(Math.max(a+b, a-b, a*b))
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;

// エラトステネスの篩(蟻本p112)
int prime[1002];         // i番目の素数
bool is_prime[1003]; // is_prime[i]がtrueならiは素数

int sieve(int n) { // n以下の素数の数を返す
  int p = 0;
  for (int i = 0; i <= n; i++)
    is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime[p++] = i;
      for (int j = 2 * i; j <= n; j += i)
        is_prime[j] = false;
    }
  }
  return p;
}

int main() {
  int64_t LA=1000000007, ans=1;
  int n;
  cin >> n;
  int p=sieve(n);
  int ct[p]={0};
  for(int i=2; i<=n; i++){
    int tmp=i;
    for(int j=0; j<p; j++){
      while(tmp%prime[j]==0){
        tmp/=prime[j];
        ct[j]++;
      }
    }
  }
  for(int i=0; i<p; i++){
    ans*=(ct[i]+1);
    ans%=LA;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2005;
int n, x, y, b[N];

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

	for(int i=1;i<=n;i++)
		for(int j=i+1; j<=n;j++)
		{
			int k=min(min(abs(j-i),abs(i-x)+1+abs(j-y)),abs(i-y)+1+abs(j-x));
			b[k]++;
		}
			
	for(int i=1; i<=n-1; i++)
		cout<<b[i]<<endl;
		
	return 0;
}



Measured memory_bytes: 256
n = gets.to_i
as = gets.split.map(&:to_i)

cs = as.each_with_object(Hash.new(0)) do |a, h|
  h[a] += 1
end

sum = cs.values.inject(0) do |r, v|
  r + v * (v - 1) / 2
end

as.each do |a|
  c = cs[a]
  diff = (c - 1) # c * (c - 1) / 2 - (c - 1) * (c - 2) / 2

  puts sum - diff
end


Measured memory_bytes: 29700
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
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; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  if(N<112)
  {
    cout << 111 << endl;
  }
  else if(N<223)
  {
    cout << 222 << endl;
  }
  else if(N<334)
  {
    cout << 333 << endl;
  }
  else if(N<445)
  {
    cout << 444 << endl;
  }
  else if(N<556)
  {
    cout << 555 << endl;
  }
  else if(N<667)
  {
    cout << 666 << endl;
  }
  else if(N<778)
  {
    cout << 777 << endl;
  }
  else if(N<889)
  {
    cout << 888 << endl;
  }
  else
  {
    cout << 999 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
const int N=3;

int main() {
  std::ios::sync_with_stdio(false);
  cout.tie(0); cin.tie(0);
  int Triangle=0,RightangledTriangle=0,AcuteangleTriangle=0,ObtuseTriangle=0;
  int threeSides[N];
  bool flag=true;
  while (flag) {
    cin>>threeSides[0]>>threeSides[1]>>threeSides[2];
    sort(threeSides,threeSides+N);
    if (threeSides[1]+threeSides[2]>threeSides[0]&&threeSides[0]+threeSides[2]>threeSides[1]&&threeSides[0]+threeSides[1]>threeSides[2]) {
      Triangle++;
      if (pow(threeSides[2],2)==pow(threeSides[0],2)+pow(threeSides[1],2)) {
	RightangledTriangle++;
      }
      else if (pow(threeSides[2],2)<pow(threeSides[0],2)+pow(threeSides[1],2)) {
	AcuteangleTriangle++;
      }
      else {
	ObtuseTriangle++;
      }
    }
    else flag=false;
  }
  cout<<Triangle<<" "<<RightangledTriangle<<" "<<AcuteangleTriangle<<" "<<ObtuseTriangle<<endl;
  return 0;
}



Measured memory_bytes: 3136
#include <cstdio>
#include <set>
#include <algorithm>
#include <cstdlib>

using namespace std;

const int N = 100'009;

int l[N];
int r[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", l + i, r + i);
  }
  auto cmpr = [](int i, int j) {
    return r[i] != r[j] ? r[i] < r[j] : i < j;
  };
  auto cmpl = [](int i, int j) {
    return l[i] != l[j] ? l[i] > l[j] : i < j;
  };
  long long ans = 0;
  for (int ro = 0; ro < 2; ++ro) {
    set<int, decltype(cmpr)> sr(cmpr);
    set<int, decltype(cmpl)> sl(cmpl);
    for (int i = 0; i < n; ++i) {
      sr.insert(i);
      sl.insert(i);
    }
    long long cur = 0;
    int pos = 0;
    for (int i = 0; i < n; ++i) {
      int j = (i + ro) % 2 == 0 ? *sl.begin() : *sr.begin();
      sl.erase(j);
      sr.erase(j);
      if (pos < l[j]) {
        cur += l[j] - pos;
        pos = l[j];
      } else
      if (pos > r[j]) {
        cur += pos - r[j];
        pos = r[j];
      }
    }
    cur += abs(pos);
    ans = max(ans, cur);
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 12416
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
 
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;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  int X = input();
  
  int a1 = X / 500;
  int a2 = (X - a1*500)/5;

  output(a1 * 1000 + a2 * 5);
 
  return 0;
}


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

namespace ABC114A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a = int.Parse(Console.ReadLine());
			if (a == 3 || a == 5 || a == 7)
				Console.WriteLine("YES");
			else
				Console.WriteLine("NO");
		}
	}
}

Measured memory_bytes: 27320
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
char ch[N];
int main()
{
	scanf("%s",ch);
	int i=0,k=0,ans=0;
	while(i<strlen(ch))
	{
		if(k==0)ans++,k=1,i++;else
			{
				if(!((ch[i]==ch[i-1])&&(i==strlen(ch)-1)))ans++;
				if(ch[i]==ch[i-1])i+=2,k=0;else i++;
			}
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define NIL -1
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<char>>;
using P =pair<int,int>;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const ll mod=1000000007;

ll n;
ll ans=0;

void check(ll x){
    if(x>n)return;
    int cnt[3]={};
    while(x){
        if(x%10==3)cnt[0]++;
        if(x%10==5)cnt[1]++;
        if(x%10==7)cnt[2]++;
        x/=10;
    }
    if(cnt[0]>0&&cnt[1]>0&&cnt[2]>0)++ans;
}
void dfs(ll x){
    check(x);
    if(x<=1000000000){
        dfs(10*x+3);
        dfs(10*x+5);
        dfs(10*x+7);
    }
}


int main(){
    cin>>n;
    dfs(0);
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end() 

int const N = 400001;
int n, e[N], w[N];

int main(){
    scanf("%d", &n);
    string s;
    cin >> s;
    int x = 0;
    for(int i = 0; i<n; ++i){
       w[i] = x;
       x += (s[i] == 'W');
    }
    x = 0;
    for(int i = n-1; i>=0; --i){
       e[i] = x;
       x += (s[i] == 'E');
    }
    int an = -1, c = 0, g = 0;
    for(int i = 0; i<n; ++i){
        if(~an)an = min(an, w[i]+e[i]);
        else an = w[i]+e[i];
    }
    printf("%d\n", an);
}


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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}

int main(int, char**)
{
	ll N, Y;
	cin >> N >> Y;
	for (ll i = 0; i <= N; ++i)
	{
		for (ll j = 0; i + j <= N; ++j)
		{
			auto k = N - (i + j);
			if (k >= 0 && 10000 * i + 5000 * j + 1000 * k == Y)
			{
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}


Measured memory_bytes: 256