akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
class dice{
	int a;
public :
	void N(int *up,int *back,int *right , int *left,int *front,int *under){
		a=*up;
		*up=*back;
		*back=*under;
		*under=*front;
		*front=a;
	}
	void E(int *up,int *back,int *right , int *left,int *front,int *under){
		a=*up;
		*up=*left;
		*left=*under;
		*under=*right;
		*right=a;
	}
	void W(int *up,int *back,int *right , int *left,int *front,int *under){
		a=*up;
		*up=*right;
		*right=*under;
		*under=*left;
		*left=a;
	}
	void S(int *up,int *back,int *right , int *left,int *front,int *under){
		a=*up;
		*up=*front;
		*front=*under;
		*under=*back;
		*back=a;
	}
	void right(int *up,int *back,int *right , int *left,int *front,int *under){
		a=*front;
		*front=*left;
		*left=*back;
		*back=*right;
		*right=a;
	}
	void left(int *up,int *back,int *right , int *left,int *front,int *under){
		a=*front;
		*front=*right;
		*right=*back;
		*back=*left;
		*left=a;
	}
};
int main(){
	int up=1,back=2,right=3,left=4,front=5,under=6;
	int q,up1,back1;
	char ch;
	bool bo=false;
	dice die;
	cin>>up>>back>>right>>left>>front>>under;
	cin>>q;
	int count=0;
	for(int i=0;i<q;i++){
		cin>>up1>>back1;
		for(int j=1;;j++){
			if(j<17){
				die.N(&up,&back,&right,&left,&front,&under);
			}
			else if(j>18){
				die.E(&up,&back,&right,&left,&front,&under);
			}
			if(up1==up && back1==back){
				bo=true;
				break;
			}
			if(j%4==0){
				die.right(&up,&back,&right,&left,&front,&under);
				continue;
			}

		}
		cout<<right<<endl;
	}
	/*
	cin>>ch;
	if(ch=='N'){die.N(&up,&back,&right,&left,&front,&under);
	}
	else if(ch=='E'){ die.E(&up,&back,&right,&left,&front,&under); 
	}
	else if(ch=='W'){die.W(&up,&back,&right,&left,&front,&under); 
	}
	else if(ch=='S'){die.S(&up,&back,&right,&left,&front,&under); 
	}
	cout<<up<<endl;
	*/

	return 0;
}

Measured memory_bytes: 3080
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define test ll t; cin>>t; while(t--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
#define MAX 1000005
#define forci(p,q) for(int i=p;i<q;i++)
bool prime[MAX];
/*ull sieve()
{
	memset(prime,true,sizeof(prime));
	for(ull p=2;p*p<MAX;p++)
	{
		if(prime[p]==true){
			for(ull i=2*p;i<MAX;i+=p)
			{
				prime[i]=false;
			}
		}
	}
	prime[0]=0;
	prime[1]=0;
}*/
using namespace std;
signed main()
{
	fastio;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int cnt=0;
	while(a>0 && c>0)
	{
		if(cnt%2==0)
			c-=b;
		else
			a-=d;
		cnt++;
	}
	if(a>0)
		cout<<"Yes";
	else
		cout<<"No";
	
	
}










Measured memory_bytes: 3644
import itertools
N, C = map(int, input().split())
D = []
for i in range(C):
  Ds = list(map(int, input().split()))
  D.append(Ds)
c = []
for i in range(N):
  cs = list(map(int, input().split()))
  cs = [c-1 for c in cs]
  c.append(cs)
ns = [[0]*C for i in range(3)]
for i in range(N):
  for j in range(N):
    ns[(i+j)%3][c[i][j]] += 1
#print(ns)
rs = []
for c0, c1, c2 in itertools.permutations(range(C), 3):
  r = 0
  for i in range(C):
    r += D[i][c0]*ns[0][i]
    r += D[i][c1]*ns[1][i]
    r += D[i][c2]*ns[2][i]
  rs.append(r)
r = min(rs)
print(r)


Measured memory_bytes: 6488
from math import sqrt, factorial

n = int(input())

MAX_VAL = n
prime = [1] * (MAX_VAL+1)
prime[0] = prime[1] = 0
for i in range(2, int(sqrt(MAX_VAL))+1):
    if prime[i]:
        for k in range(2*i, MAX_VAL+1, i):
            prime[k] = 0

res = 1
for i, p in enumerate(prime):
    m = factorial(n)
    if p:
        cnt = 0
        while m % i == 0:
            cnt += 1
            m //= i
        res *= cnt + 1
        res %= 10**9+7

print(res)


Measured memory_bytes: 3064
using System;
using System.Linq;

class A
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		Console.WriteLine(Enumerable.Range(1, a[1]).Select(j => new { d = j % 10, e = j / 10 }).Count(_ => _.d >= 2 && _.e >= 2 && _.d * _.e <= a[0]));
	}
}


Measured memory_bytes: 13396
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(void) {

  int k, i, len;
  char s[100];

  scanf("%d\n", &k);
  scanf("%s", s);

  len = strlen(s);

  if ( (k<1)||(100<k)||(len<1)||(100<len) ) {
    printf("error\n");
  }

  if ( len<=k ) {
    printf("%s\n", s);
  } else {
    s[k] = '\0';
    printf("%s...\n", s);
  }

  return 0;
}

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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) (__gcd(a, b))
#define LCM(a, b) ((a)/GCD(a,b)*(b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define ALL(x) (x).begin(), (x).end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const db eps = 0.000001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 450555;
const int M = 1125;

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

    int ac = 0, wa = 0, tle = 0, re = 0;
    while (q--){
        string s;
        cin >> s;
        if (s == "AC") ac++;
        if (s == "WA") wa++;
        if (s == "TLE") tle++;
        if (s == "RE") re++;
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

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

    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n,m;
  cin>>n>>m;
  priority_queue<int> q;
  for(int i = 0; i < n; i++){
    int a;
    cin>>a;
    q.push(a);
  }
  for(int i = 0; i < m; i++){
    int mx = q.top();
    q.pop();
    q.push(mx/2);
  }
  ll sum = 0;
  for(int i = 0; i<n; i++){
    sum+=q.top();
    q.pop();
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> x(n),y(m);
    rep(i,n) cin >> x[i];
    rep(i,m) cin >> y[i];
    ll A = 0,B = 0;
    rep(i,n-1){
        A += (((i+1) * (n - (i+1)))%MOD * (x[i+1]-x[i]))%MOD;
        A %= MOD;
    }
    rep(i,m-1){
        B += (((i+1) * (m - (i+1)))%MOD * (y[i+1]-y[i]))%MOD;
        B %= MOD;
    }
    cout << (A * B)%MOD << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
vector <int> a;
int cunt;
int main(){
    int N;
    cin>>N;
    
    a.push_back(-1);

    int ac;
    for(int i=1;i<=N;i++){
        cin>>ac;
        a.push_back(ac);
    }
    int c=1;
    while(c!=2){
         c=a[c];
         cunt++;
         if(c==1||cunt>N){
            cout<<-1<<"\n"; 
            return 0;
         } 
    }
    cout<<cunt<<"\n";

    return 0;

}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int A[100005][3];
    REP(i,n) REP(j,3) cin >> A[i][j];

    int dp[100005][3];

    REP(i,3) dp[0][i] = 0;
    REP(i,n){
        REP(j,3){
            dp[i+1][j] = - INF;
            REP(k,3){
                if(j == k ) continue;
                dp[i+1][j] = max( dp[i+1][j] ,dp[i][k] +  A[i][j]);
            }
        }
    }
    int ans = - INF;
    REP(i,3) ans = max(ans, dp[n][i]);
    cout << ans << endl;
}

Measured memory_bytes: 4992
// atcoder/m-solutions2020/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  while (cin >> n) {
    if (400 <= n && n <= 599) cout << 8 << endl;
    if (600 <= n && n <= 799) cout << 7 << endl;
    if (800 <= n && n <= 999) cout << 6 << endl;
    if (1000 <= n && n <= 1199) cout << 5 << endl;
    if (1200 <= n && n <= 1399) cout << 4 << endl;
    if (1400 <= n && n <= 1599) cout << 3 << endl;
    if (1600 <= n && n <= 1799) cout << 2 << endl;
    if (1800 <= n && n <= 1999) cout << 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int n;
string s;

struct animal{
    char sheep,wolf;
};

ll comb(int a,int b){
    if(a<b)return 0;
    if(b>a-b) return comb(a,a-b);
    ll rtn=1;
    REP(i,b){
        rtn *= (a-i);
        rtn /= (i+1);
    }
    return rtn;
}

char rev(char c,char st,char an){
    if(an=='S'){
        if(st=='o'){
            if(c=='S'){
                return 'S';
            }else{
                return 'W';
            }
        }else{
            if(c=='S'){
                return 'W';
            }else{
                return 'S';
            }
        }
    }else{
        if(st=='o'){
            if(c=='S'){
                return 'W';
            }else{
                return 'S';
            }
        }else{
            if(c=='S'){
                return 'S';
            }else{
                return 'W';
            }
        }
    }
}

int main() {
    cin >> n >> s;
    //1番目と2番目をSまたはWと仮定するとそれに応じて1周分のSWが確定し、矛盾があるかどうかもわかる
    char sw[2][4] = {{'S','S','W','W'},{'S','W','S','W'}};
    string res;
    REP(i,4){
        res = "";
        res += sw[0][i];
        res += sw[1][i];
        FOR(j,1,n-1){
            res += rev(res[j-1],s[j],res[j]);
        }
        if(rev(res[n-2],s[n-1],res[n-1])==res[0]){
            if(rev(res[n-1],s[0],res[0])==res[1]){
                put(res);
                return 0;
            }
        }
    }
    put("-1");
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
scanf("%d %d",&a,&b);

    if(a<b){
        printf("a < b\n");
    }else if(a>b){
    printf("a > b\n");

        
    }else {
        
        printf("a == b\n");
    }
    
}



Measured memory_bytes: 2680
//#include<atcoder/all>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
//using namespace atcoder;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
    ll h,w,k;
    cin >> h >> w >> k;
    int c[h][w];
    for(ll i=0;i<h;i++){
		string s;
		cin >> s;
        for(ll j=0;j<w;j++){
            c[i][j]=s[j]-'0';
        }
    }

    ll ans=INF;
    for (int bit = 0; bit < (1 << h); ++bit) { //全部でN個
        ll yoko= __builtin_popcount(bit);
        
        ll tate=0;
        ll row=0;
        bool f=true;
        vector<int> cnt(h,0);
        for(ll t=0;t<w;t++){
            row++;
            ll tmp=0;
            for (int i = 0; i < h; ++i) {
                if(c[i][t]==1) cnt[tmp]++;
                if(cnt[tmp]>k){
                    if(row!=1){
                        t--;
                        row=0;
                        tate++;
                        fill(cnt.begin(),cnt.end(),0);
                    }else{
                        f=false;
                    }
                    
                    break;
                }
        	    if (bit & (1 << i)){
			        tmp++;//bitが立った要素に対してやること
	    	    }
            }
        }
        if(f) chmin(ans,tate+yoko);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
#include <numeric>
using namespace std;

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

    int N, K;
    cin >> N >> K;

    double ans = 0.0;
    long long cnt_abs_win = 0LL;
    int mx_bunbo = 0;
    vector<int> bunbo, bunsi;
    for (int i = 1; i <= N; i++)
    {
        if (i >= K)
        {
            cnt_abs_win++;
            // ans += 1.0 / N;
        }
        else
        {
            int tmp = i;
            int cnt = 0;
            while (tmp < K)
            {
                tmp *= 2;
                cnt++;
            }

            int tmp_bunbo = pow(2, cnt);
            if (tmp_bunbo >= mx_bunbo)
            {
                bunbo.push_back(tmp_bunbo);
                bunsi.push_back(1);
                mx_bunbo = tmp_bunbo;
            }
            else
            {
                int tmp_bunsi = 1;
                while (tmp_bunbo != mx_bunbo)
                {
                    tmp_bunbo *= 2;
                    tmp_bunsi *= 2;
                }
                bunbo.push_back(tmp_bunbo);
                bunsi.push_back(tmp_bunsi);
            }
        }
    }

    int ans_bunbo;
    int ans_bunsi;

    if (bunbo.size() > 0)
    {
        ans_bunbo = bunbo[0] * N;
        ans_bunsi = accumulate(bunsi.begin(), bunsi.end(), 0) + cnt_abs_win * bunbo[0];
    }
    else
    {
        ans_bunbo = 1;
        ans_bunsi = 1;
    }

    cout << fixed << setprecision(12) << (double)ans_bunsi / (double)ans_bunbo << endl;

    return 0;
}


Measured memory_bytes: 384
H,W=list(map(int,input().split()))

def score(_list):
  return max(_list)-min(_list)

answer=H*W

# 縦割り
for i in range(1,W//2+1):
  a=score([H*i, (W-i)*(H//2), (W-i)*(H-H//2)])
  b=score([H*i, H*((W-i)//2), H*(W-i-(W-i)//2)])
  answer=min(a,b,answer)
  
# 横割り
for i in range(1,H//2+1):
  a=score([W*i, (H-i)*(W//2), (H-i)*(W-W//2)])
  b=score([W*i, W*((H-i)//2), W*(H-i-(H-i)//2)])
  answer=min(a,b,answer)
  
print(answer)


Measured memory_bytes: 3064
import math

n, m = map(int, input().split())

jobs = []
for i in range(n):
	day, reward = map(int, input().split())
	if m- day + 1 > 0:
		jobs.append((m - day + 1, reward))

jobs.sort(key = lambda x:(-x[1],-x[0]))

def find(i):
	global parent
	while i != parent[i]:
		parent[i] = parent[parent[i]]
		i = parent[i]
	return i 

def union(x, y):	# small, big
	global parent
	parent_x = find(x)
	parent_y = find(y)
	parent[parent_y] = parent_x

parent = [i for i in range(m+1)]

def job_sequencing(jobs):
	global parent 
	n = len(jobs)

	total_rewards = 0
	for job in jobs:
		available_slot = find(job[0])
		if available_slot > 0:
			union(available_slot-1, available_slot)
			total_rewards += job[1]
	return total_rewards
print(job_sequencing(jobs))

Measured memory_bytes: 30812
char s[999],t[999],*T;
r;main(n,i,j){for(scanf("%d%s",&n,s);n--;){
	for(scanf("%s",t),T=t-1;;){
		if(!(T=strchr(T+1,s[0])))break;
		for(i=1;T[i];i++)
			if(T[i]==s[1]){
				for(j=2;j<strlen(s);j++)if(i*j>=strlen(T)||T[i*j]!=s[j])break;
				if(j==strlen(s)){r++;goto next;}
			}
	}
	next:;
}printf("%d\n",r);exit(0);}

Measured memory_bytes: 612
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    check=[0]*8
    tuyo=0
    for i in l:
        x=i//400
        if x>=8:
            tuyo+=1
        else:
            check[x]+=1
    if tuyo==n:
        print(1,tuyo)
    else:
        cnt=0
        for j in check:
            if j>0:
                cnt+=1
        print(cnt,cnt+tuyo)
resolve()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int r;
    cin >> r;
    cout << r * r << endl;
} 

Measured memory_bytes: 3632
'use strict'

function main(input) {
  input = input
    .trim()
    .split('\n')
    .map(v => v.split(' '))
  const N = parseInt(input[0][0], 10)
  const D = parseInt(input[0][1], 10)
  const p = input.slice(1)
  let count = 0
  for (let i = 0; i < N; i++) {
    for (let j = i + 1; j < N; j++) {
      let sum = 0
      for (let k = 0; k < D; k++) {
        sum += Math.pow(p[i][k] - p[j][k], 2)
      }
      // const sqrt = Math.sqrt(sum)
      // if (sqrt === Math.floor(sqrt)) count++
      if (Number.isInteger(Math.sqrt(sum))) count++
    }
  }
  console.log(count)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

/*x >= y の時 */
int64_t gcd(int64_t x, int64_t y){
    if(y == 0){
        return x;
    }
    else{
        return(gcd(y, x%y));
    }
}
int64_t lcm(int64_t x, int64_t y){
    return x * y /gcd(max(x,y), min(x,y));
}

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    int64_t L = a.at(0);
    if(N != 1){
        for (int i = 1; i < N; i++){
            if (L % a.at(i) != 0){
                L = lcm(L, a.at(i));
            }
        }
    }
    bool T = true;
    for (int i = 0; i < N; i++){
        if((L / a.at(i)) % 2 == 0){
            T = false;
            break;
        }
    }
    if(T){
        int64_t ans;
        ans = 2 * M / L;
        ans = (ans+1) / 2;
        cout << ans << endl;
    }
    else{
        cout << 0 << endl;
    }


    /*
    2から2Mまでかぞえあげる方針
    時間が間に合わない
    int ans = 0;
    for (int i = 2; i <= 2 * M; i+=2){
        bool T = true;
        for (int j = 0; j < N; j++){
            if(i % a.at(j) == 0 && (i/a.at(j)) % 2 == 1){
                continue;
            }  
            else{
                T = false;
            }
        }
        if(T){
            ans++;
        }
    }
    cout << ans << endl;
    */
}

Measured memory_bytes: 640
#include <stdio.h>

int gcd(int a, int b) {
  int t;
  while(b) {
    t = a % b, a = b, b = t;
  }
  return a;
}

int main(void) {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if(!(c % gcd(a, b))) printf("YES");
  else printf("NO");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
typedef unsigned long long ll;
int ans,n;
char s[100005];
vector<int>x;
int main(void){
   cin>>s;
   n=strlen(s);
   char p=s[0];
   x.push_back(1);
   for(int i=1;i<n;i++){
       if(s[i]==p){
           x.back()++;
       }else{
           x.push_back(1);
           p=s[i];
       }
   }
   int s=0,t=x.size()-1;
   ans=n;
   while(s<t){
       if(x[s]<x[t]){
           ans=min(ans,n-x[s]);
           s++;
           x[s]+=x[s-1];
       }else{
           ans=min(ans,n-x[t]);
           t--;
           x[t]+=x[t+1];
       }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 768
<?php
  list($n, $m, $x, $y) = explode(" ", trim(fgets(STDIN)));

  $xa = array_map('intval', explode(" ", trim(fgets(STDIN))));
  $ya = array_map('intval', explode(" ", trim(fgets(STDIN))));

  rsort($xa);
  sort($ya);

  if($xa[0] < $ya[0] && $ya[0] > $x && $xa[0] < $y){
    echo "No War";
  }else{
    echo "War";
  }

Measured memory_bytes: 16288
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	long long x, y, z;
	scanf("%lld %lld", &x, &y);
	z = (x + y) / 2;
	if(abs(x-z)==abs(y-z))printf("%lld\n", z);
	else printf("IMPOSSIBLE\n");

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<vector<pair<int, int>>> a(n);
  for (int i = 0; i < n; i++) {
    int an;
    cin >> an;
    vector<pair<int, int>> xy(an);
    for (int j = 0; j < an; j++) {
      cin >> xy.at(j).first >> xy.at(j).second;
      xy.at(j).first--;
    }
    a.at(i) = xy;
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool flag = true;
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        for (int j = 0; j < a.at(i).size(); j++) {
          int x = a.at(i).at(j).first;
          int y = a.at(i).at(j).second;
          if (y == 1 && !(bit & (1 << x))) {
            flag = false;
            break;
          }
          if (y == 0 && bit & (1 << x)) {
            flag = false;
            break;
          }
        }
      }
    }
    if (flag) {
      int cnt = 0;
      for (int i = 0; i < n; i++) {
        if (bit & (1 << i)) {
          cnt++;
        }
      }
      ans = max(ans, cnt);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3568
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <queue>
#include <math.h>
#include <map>

#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;


int main() {
    FASTIO
    int row,col,c;cin >> row >> col >> c;
    int arr[row];memset(arr,0,sizeof arr);
    int b[col];
    for(int i=0;i<col;i++) cin >> b[i];
    int cnt=0,x;
    for(int i=0;i<row;i++){

        for(int j=0;j<col;j++){
            cin >> x;
            arr[i] += b[j]*x;
        }
        if(arr[i]+c > 0) cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 256
n = int(input())
a = [i for i in map(int, input().split())]
 
if a.count(0) != 0:
  print(0)
else:
  result = 1
  for i in range(n):
    result *= a[i]
    if result > (10**18):
      print(-1)
      break
    else:
      continue
  else:
    print(result)

Measured memory_bytes: 21600
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int a=s.length()-1;int z=0;
  for(int i=0;i<s.length();i++)
  {
    if(s[i]=='A')a=min(a,i);
    if(s[i]=='Z')z=max(z,i);
  }
  cout<<z-a+1;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int k[n],a[n][m];
    for (int i=0;i<n;i++){
        scanf("%d",&k[i]);
        for (int j=0;j<k[i];j++){
            scanf("%d",&a[i][j]);
        }
    }
    int count=0,flag[k[0]];
    for (int i=0;i<k[0];i++){
        flag[i]=0;
        for (int j=1;j<n;j++){
            for (int l=0;l<k[j];l++){
                if (a[0][i]==a[j][l]){
                    flag[i]++;
                    break;
                }
            }
        }
        if (flag[i]==n-1){
            count++;
        }
    }
    printf("%d",count);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

int main() {
  int k;
  cin >> k;
  int data[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

  std::vector<int> data1(data, data + 32);

  cout << data1[k-1] << endl;

  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split(" "))
a = [0] * m
b = [0] * m
c = [[]] * m
INF = int(10e8)
dp = [INF] * (2 ** n)
dp[0] = 0
for i in range(m):
    a[i], b[i] = map(int, input().split(" "))
    c[i] = list(map(int, input().split(" ")))

for i in range(m):
    keyState = 0
    for j in c[i]:
        key = 1 << j - 1
        keyState = keyState | key
    for k in range(2**n):
        nextState = k | keyState
        dp[nextState] = min(dp[nextState], dp[k] + a[i])
if dp[-1] == INF:
    print(-1)
else:
    print(dp[-1])

Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }


// 一次元累積和
template<class T>
class Ruiseki
{
private:
	int num;

public:
	vector<T> sumVal;
	Ruiseki(const vector<T> &srcVal)
	{
		num = srcVal.size();
		sumVal.resize(num + 1, 0);
		for (int i = 0; i < num; i++) {
			sumVal[i + 1] = sumVal[i] + srcVal[i];
		}
	}

	T GetSumAll()
	{
		return sumVal[num];
	}

	// [start, endIdx) ※endIdxは含まない
	T GetSumRange(int startIdx, int endIdx)
	{
		return sumVal[endIdx] - sumVal[startIdx];
	}

	// [0, endIdx) ※endIdxは含まない
	T GetSumFromTop(int endIdx)
	{
		return sumVal[endIdx] - sumVal[0];
	}

	// [startIdx, N] ※startIdxは含む
	T GetSumFromEnd(int startIdx)
	{
		return sumVal[num] - sumVal[startIdx];
	}
};

void Solve()
{
	ll N, M;
	cin >> N >> M;
	VL SA(N);
	REP(i, N) cin >> SA[i];
	sort(ALL(SA), greater<ll>());
	VL GA = SA;
	reverse(ALL(SA));

	// a   = aa,                                = 2
	// ab  = aa, ab,     ba, bb,                = 4
	// abc = aa, ab, ac, ba, bb, bc, ca, cb, cc = 6

	auto compExec = [&](ll mid, ll &res) {
		ll cnt = 0;
		for (auto &g : GA) {
			ll nokori = mid - g;
			ll numOne = SA.end() - lower_bound(ALL(SA), nokori);
			if (numOne == 0) break;
			cnt += numOne;
		}
		res = cnt;
		return (M <= cnt);
	};

	ll lb = 0;//SA[0] * 2;
	ll lu = 200010;//GA[0] * 2;
	ll mid = 0;
	ll res;
	while ((lb + 1) != lu) {
		mid = (lb + lu) / 2;
		if (compExec(mid, res)) {
			lb = mid;
		} else {
			lu = mid;
		}
	}

	ll ans = 0;
	ll cnt = 0;
	Ruiseki<ll> rui(SA);
	for (auto &g : GA) {
		ll nokori = lu - g;
		auto it = lower_bound(ALL(SA), nokori);
		if (it == SA.end()) continue;
		ll pos = it - SA.begin();
		ll ansOne = rui.GetSumFromEnd(pos);
		ans += (ansOne + g * (N - pos));
		cnt += (N - pos);
	}

	ll nokori = M - cnt;
	ans += nokori * lb;

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 5548
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep1(i,n) for(int i=1; i<=(n); i++)
#define mst(x,i) memset(x, i, sizeof(x))
#define X first
#define Y second
#define PB push_back
#define ls(o) (o<<1)
#define rs(o) (o<<1|1)
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define dbg(a) cout << #a": " << a << endl;
#define IOS ios::sync_with_stdio(false),cin.tie(0)
typedef long long LL;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
const double dinf = inf;
using namespace std;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ull,ull> puu;

const int N = 100+10;
const int M = N<<1;
const int mod = (int)1e9+7;
const double eps = 1e-8;
const double PI = acos(-1.0);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};



int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // LOCAL
    //IOS;

    LL x,y;
    cin>>x>>y;
    int cnt = 0;
    while(x<=y){
        cnt++;
        x *= 2;
    }
    cout<<cnt<<endl;

    return 0;
}
//orz


Measured memory_bytes: 256
fn main() {
    let s = read::<String>();
    let len = s.len();

    let mut ans = 0;
    for i in 0..1 << len - 1 {
        let mut start = 0;
        let mut sum = 0;

        for j in 0..len - 1 {
            if (1 << j) & i != 0 {
                sum += s[start..j + 1].parse::<u64>().unwrap();
                start = j + 1;
            }
        }
        sum += s[start..len].parse::<u64>().unwrap();
        ans += sum;
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main(void){
    int n ;
    cin >> n ;
    vector<string> s ;
    for (int i=0; i<n; i++){
        char x[15] ;
        cin >> x ;
        sort(x,x+strlen(x));
        s.push_back(x) ;
    }
    sort (s.begin(),s.end()) ;
    long long ans=0,count=1;
    for (int i=1; i<n; i++){
        if (s[i]==s[i-1]){
            count++ ;    
        } else {
            ans+=count*(count-1)/2 ;
            count=1 ;
        }
    }
    ans+=count*(count-1)/2 ;
    cout << ans << endl ;
}

Measured memory_bytes: 5748
require 'pp'

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end

def min(a, b)
  return a < b ? a : b
end

n, hlist = gets_n_and_i_list
INF = Float::INFINITY

dp = Array.new(n, INF)
dp[0] = 0

0.upto(n-1) do |i|
  if i + 1 < n
    diff1 = (hlist[i + 1] - hlist[i]).abs + dp[i]
    dp[i + 1] = min(diff1, dp[i+1])
  end

  if i + 2 < n
    diff2 = (hlist[i + 2] - hlist[i]).abs + dp[i]
    dp[i + 2] = min(diff2, dp[i+2])
  end

end

puts dp.last

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

int main(){
	int a,b;
	string s,s1,s2;
	
	while(cin>>s){
		if(s=="-")break;
		cin>>a;
		for(int i=0;i<a;i++){
			cin>>b;
			for(int j=0;j<s.size();j++){
				if(j<b){
					s1+=s[j];
				}else{
					s2+=s[j];
				}
			}
			s=s2+s1;
			s1="";
			s2="";
		}
		cout<<s<<endl;
	}
	return 0;
}
	

Measured memory_bytes: 1216
#include<stdio.h>
int main(void)
{
  long long p=1,n,a,i,t=1000000000000000000;
	double m=1;
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%lld",&a);
    p*=a;
    m*=a;
  }
  if(p>t||m>t){
    printf("-1\n");
  }
  else{
    printf("%lld\n",p);
  }
  return 0;
}


Measured memory_bytes: 1720
#include<iostream>
#include<string>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main()
{
	string str;
	cin >> str;
	int w;
	cin >> w;
	for (int i = 0; i < str.size(); i += w)
	{
		cout << str[i];
	}

	cout << endl;
	return 0;
}

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

template <typename T>
void floyd_warshall(vector<vector<T>> &dist) {
    const T INF = numeric_limits<T>::max();
    size_t V = dist.size();
    for(size_t k = 0; k < V; ++k) {
        for(size_t i = 0; i < V; ++i) {
            for(size_t j = 0; j < V; ++j) {
                if(dist[i][k] == INF || dist[k][j] == INF) continue;
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

#include <iostream>
int main() {
    int V, E;
    cin >> V >> E;
    vector<vector<int>> dist(V, vector<int>(V, numeric_limits<int>::max()));
    for(int i=0; i<V; ++i) dist[i][i] = 0;

    for(int i=0; i<E; ++i) {
        int s,t,d;
        cin >> s >> t >> d;
        dist[s][t] = d;
    }

    floyd_warshall<int>(dist);
    for(int i=0; i<V; ++i) {
        if(dist[i][i] < 0) {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }

    for(int i=0; i<V; ++i) {
        for(int j=0; j<V; ++j) {
            if(dist[i][j] == numeric_limits<int>::max()) cout << "INF";
            else cout << dist[i][j];
            cout << (j+1==V ? '\n' : ' ');
        }
    }
}


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int h,w;
  cin>>h>>w;
  vector<vector<char>> grid(h,vector<char>(w));
  long long int black=0;
  long long int white=0;
  for(long long int i=0; i<h; i++){
    for(long long int j=0; j<w; j++){
      cin>>grid.at(i).at(j);
      if(grid.at(i).at(j)=='.'){
        white++;
      }else{
        black++;
      }
    }
  }

  vector<vector<long long int>> dist(h,vector<long long int>(w,-1));
  dist.at(0).at(0)=0;
  queue<pair<long long int,long long int>> que;
  que.push(make_pair(0,0));
  while(!que.empty()){
    long long int x=que.front().second;
    long long int y=que.front().first;
    que.pop();
    if(x!=0&&grid.at(y).at(x-1)=='.'&&dist.at(y).at(x-1)==-1){
      que.push(make_pair(y,x-1));
      dist.at(y).at(x-1)=dist.at(y).at(x)+1;
    }
    if(x!=w-1&&grid.at(y).at(x+1)=='.'&&dist.at(y).at(x+1)==-1){
      que.push(make_pair(y,x+1));
      dist.at(y).at(x+1)=dist.at(y).at(x)+1;
    }
    if(y!=0&&grid.at(y-1).at(x)=='.'&&dist.at(y-1).at(x)==-1){
      que.push(make_pair(y-1,x));
      dist.at(y-1).at(x)=dist.at(y).at(x)+1;
    }
    if(y!=h-1&&grid.at(y+1).at(x)=='.'&&dist.at(y+1).at(x)==-1){
      que.push(make_pair(y+1,x));
      dist.at(y+1).at(x)=dist.at(y).at(x)+1;
    }
  }
  if(dist.at(h-1).at(w-1)==-1){
    cout<<-1<<endl;
  }else{
    long long int ans=white-dist.at(h-1).at(w-1)-1;
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X,Y;
  cin >> X >> Y;
  int c=0;
  if(2*X==Y ||4*X==Y){
    cout << "Yes";
    c=1;
  }else{
    for(int t=1; t<=X; t++){
       for(int k=1; k+t<=X; k++){
         if(2*t+4*k==Y && t+k==X){
           cout << "Yes";
           c=2;
           break;
         }
       }
    }
    if(c==0){
      cout << "No";
    }
  }
}

Measured memory_bytes: 3520
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll done[1000][1000];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll h,w;
	cin>>h>>w;
	ll arr[h][w];
	vector<pair<pair<ll,ll>,pair<ll,ll> > > ans;
	for(ll i=0;i<h;i++)
		for(ll j=0;j<w;j++)
			cin>>arr[i][j];
	for(ll i=0;i<h;i++)
	{
		for(ll j=0;j<w;j++)
		{
			if(arr[i][j]%2==0) continue;
			if(j+1<w&&arr[i][j+1]%2)
			{
				arr[i][j+1]++;arr[i][j]--;
				ans.push_back({{i,j},{i,j+1}});
			}
			else if(i+1<h&&arr[i+1][j]%2)
			{
				arr[i+1][j]++;arr[i][j]--;
				ans.push_back({{i,j},{i+1,j}});
			}
			else if(j+1<w)
			{
				arr[i][j+1]++;arr[i][j]--;
				ans.push_back({{i,j},{i,j+1}});
			}
			else if(i+1<h)
			{
				arr[i+1][j]++;arr[i][j]--;
				ans.push_back({{i,j},{i+1,j}});
			}
		}
	}
	cout<<ans.size()<<endl;
	for(auto i:ans)
		cout<<i.first.first+1<<' '<<i.first.second+1<<' '<<i.second.first+1<<' '<<i.second.second+1<<endl;
}

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

int main() {
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;
  
  rep(i,n-2){
   if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
import math
a, b, h, m = map(int, input().split())
HM = 60*h+m
atheta = 0.5*HM
btheta = (6*HM)%360
theta = min(abs(atheta-btheta), 360-abs(atheta - btheta))
c = a**2 + b**2 - 2*a*b*math.cos(math.radians(theta))
print(c**0.5)


Measured memory_bytes: 9500
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define MAXN 2001
#define MAXM 4001
using namespace std;
int n,m;
int lin[MAXM],pre[MAXN],to[MAXM],tot,quan[MAXM];
int h[MAXN][MAXN],fa[MAXN][MAXN];
bool vis[MAXN];
queue <int> q;
void add(int x,int y,int z)
{
    tot++;
    lin[tot]=pre[x];
    pre[x]=tot;
    to[tot]=y;
    quan[tot]=z;
}
void SPFA(int S)
{
    memset(vis,0,sizeof(vis));
    h[S][S]=0;
    q.push(S);
    while(!q.empty())
    {
        int u=q.front();q.pop();vis[u]=0;
        for(int i=pre[u];i;i=lin[i])
        {
            int v=to[i];
            if(h[S][v]==-1||h[S][v]>h[S][u]+quan[i])
            {
                h[S][v]=h[S][u]+quan[i];
                fa[S][v]=u;
                if(!vis[v])
                {
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
}
int main()
{
    memset(h,-1,sizeof(h));
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int tx,ty;
        scanf("%d%d",&tx,&ty);
        add(tx,ty+n,1);
    }
    for(int i=1;i<=n;i++)add(i+n,i,0);
    for(int i=1;i<=n;i++)SPFA(i);
    int loc=-1,minn=n*n;
    for(int i=1;i<=n;i++)
    {
        if(h[i][i+n]>0&&h[i][i+n]<minn)
        {
            minn=h[i][i+n];
            loc=i;
        }
    }
    if(loc==-1)cout<<-1<<endl;
    else
    {
        cout<<minn<<endl;
        for(int i=loc+n;i;i=fa[loc][i])
        {
            if(i<=n)cout<<i<<endl;
        }
    }
    
    
    
    return 0;
}


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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
#define check cout<<"?\n";
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    ll a, b; cin >> a >> b;
    ll gc = __gcd(a,b);
    set<ll> s;
    for(ll i = 2; i * i <= gc; ++i){
        while(gc % i == 0){
            s.insert(i);
            gc /= i;
        }
    }
    if(gc > 1) s.insert(gc);
    cout << s.size() + 1 << '\n';
    return  0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define int long long
int abs(int a,int b){
  int c=max(a,b)-min(a,b);
  return c;
}
signed  main(){
  int a,c=0,d=0,x=1;
  int q,w;
  int b[1000000];
  int z=10000000;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b[i];
    if(i==0) c=b[0];
    else d+=b[i];
  }
  z=abs(c,d);
  for(int i=1;i<a-1;i++){
    q=c,w=d;
    c+=b[i];
    d-=b[i];
z=min(abs(c,d),z);
    x++;
  }
  cout<<z<<"\n";
}


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



void dfs(int now, vector<int>& cnts, map<int, set<int>>& conn, vector<bool>& visited){
    visited[now] = true;
    for(auto next: conn[now]){
        if(visited[next]){
            continue;
        }
        cnts[next] += cnts[now];
        dfs(next, cnts, conn, visited);
    }
}

void solve(long long N, long long Q, std::vector<long long> a, std::vector<long long> b, std::vector<long long> p, std::vector<long long> x){
    // グラフ接続をつくる
    map<int, set<int>> conn;
    for(int i=0; i < N; i++){
        conn[a[i]].insert(b[i]);
        conn[b[i]].insert(a[i]);
    }

    // 各頂点にカウント命令をのせる
    vector<int> cnts(N + 1, 0);
    for(int i=0; i < Q; i++){
        cnts[p[i]] += x[i];
    }


    // DFSで伝播させる
    vector<bool> visited(N+1, false);
    dfs(1, cnts, conn, visited);

    // print
    for(int i=1; i <= N; i++){
        cout << cnts[i];
        if(i == N){
            cout << endl;
        }else{
            cout << " ";
        }
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    std::vector<long long> p(Q);
    std::vector<long long> x(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&p[i]);
        scanf("%lld",&x[i]);
    }
    solve(N, Q, std::move(a), std::move(b), std::move(p), std::move(x));
    return 0;
}


Measured memory_bytes: 62592
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int r = scan.nextInt();
        int n = scan.nextInt();

        while (n != 0 || r != 0) {
            for (int i = 0; i < r; i++) {
                for (int t = 0; t < n; t++) {
                    System.out.print("#");
                }
                System.out.println("");
            }
            System.out.println("");
            r = scan.nextInt();
            n = scan.nextInt();
        }

    }
}


Measured memory_bytes: 33008
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll a[100005];
ll n;

int main()
{
    for(ll i=0;i<5;i++)
    cin>>a[i];
    ll k;
    cin>>k;
    sort(a,a+n);
    if((a[4]-a[0])<=k)
    cout<<"Yay!";
    else
    cout<<":(";
    
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
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 long long INF = 1LL << 60;

int main(){
  string t, p;
  cin >> t >> p;

  int n = p.size();
  int pos = t.find(p);
  vector<int> ans;
  while(pos != -1){
    ans.push_back(pos);
    pos = t.find(p, pos + 1);
  }

  rep(i, ans.size()) cout << ans[i] << endl;

  return 0;
}




Measured memory_bytes: 3220