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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
#define int long long

signed main(){
    int h, w;
    cin >> h >> w;
    int c[10][10];
    rep(i,10)rep(j,10) cin >> c[i][j];
    
    rep(k,10)rep(i,10)rep(j,10){
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    }
    
    int ans = 0;
    rep(i,h*w){
        int a; cin >> a;
        if(a == -1) continue;
        ans += c[a][1];
    }
    
    cout << ans << endl;
}

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

int main() {
    int cardA, cardB, cardC;
    
    cin >> cardA >> cardB >> cardC;
    
    int sum = cardA + cardB + cardC;
    
    if(sum > 21){
        cout << "bust";
    }
    else{
        cout << "win";
    }
    
	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int main(){
int t=0;
string s,o,x;
cin>>s;

if(s[0]=='o'){t=t+100;}
if(s[1]=='o'){t=t+100;}
if(s[2]=='o'){t=t+100;}
cout<<t+700<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <array>
#include <bitset>
#include <iomanip>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int N,v,u,w;
    cin>>N;
    vector<pair<int,int>> vec[100000];
    rep(i,N-1){
        cin>>v>>u>>w;
        vec[v-1].push_back(make_pair(u-1,w%2));
        vec[u-1].push_back(make_pair(v-1,w%2));
    }
    int val[100000];
    bool done[100000];
    queue<pair<int,int>> q;
    int l;
    q.push(make_pair(0,0));
    int n;
    while(true){
        l=q.size();
        if(l==0) break;
        rep(i,l){
            n=q.front().first;
            val[n]=q.front().second;
            q.pop();
            done[n]=true;
            rep(j,vec[n].size()){
                if(done[vec[n][j].first]) continue;
                q.push(make_pair(vec[n][j].first,(val[n]+vec[n][j].second)%2));
            }
        }
    }
    rep(i,N){
        cout<<val[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 33003;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;

int main(){
int x,a;
cin>>x>>a;
if(x<a)
cout<<"0";
else
cout<<"10";
}

Measured memory_bytes: 256
using System;

namespace _9_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char[] str = new char[s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                str[i] = s[i];
            }
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string[] x = Console.ReadLine().Split();
                if (x[0] == "print")
                {
                    for (int j = int.Parse(x[1]); j <= int.Parse(x[2]); j++)
                    {
                        Console.Write(str[j]);
                    }
                    Console.WriteLine();
                }
                else if (x[0] == "replace")
                {
                    int a = 0;
                    for (int j = int.Parse(x[1]); j <= int.Parse(x[2]); j++)
                    {
                        str[j] = x[3][a];
                        a++;
                    }
                }
                else
                {
                    char[] now = new char[int.Parse(x[2]) - int.Parse(x[1]) + 1];
                    int a = 0;
                    for (int j = int.Parse(x[1]); j <= int.Parse(x[2]); j++)
                    {
                        now[a] = str[j];
                        a++;
                    }
                    a = 0;
                    Array.Reverse(now);
                    for (int j = int.Parse(x[1]); j <= int.Parse(x[2]); j++)
                    {
                        str[j] = now[a];
                        a++;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 8888
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;
int n, k;
llong T[MAX];
int check(llong P) {
    int i=0;
    for(int j=0;j<k;j++){
        llong s = 0; 
        while(s+T[i]<=P){
            s += T[i];
            i++;
            if ( i == n ) return n;    
        } 
    }
    return i;
}

int solve() {
    llong left=0;
    llong right=100000*10000;
    llong mid;
    while(right-left>1){
        mid = (left + right) / 2;
        int v = check(mid); 
        if(v>=n)right=mid;
        else left = mid;
    } 
    return right;
}

int main() {
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>T[i];
    llong ans = solve();
    cout << ans << endl;
    return 0;
}


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

int main(){
    string s;
    cin>>s;
    if(s=="Sunny"){
        cout<<"Cloudy"<<endl;
    }
    else if(s=="Cloudy"){
        cout<<"Rainy"<<endl;
    }
    else if(s=="Rainy"){
        cout<<"Sunny"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

using namespace std;
typedef pair<int,int> Pair;
typedef long double ld;
typedef long long ll;

const int mod = 998244353, MAX = 1e5, N = 50005;
//template{{{
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

/*char buf[1<<23],obuf[1<<23],*p1=buf,*p2=buf, *O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void print(int x) {
    if(x > 9) print(x / 10);
    *O++=x%10+'0';
} */

template <class T> inline T	input() {
	T x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read; //}}}

int k;
char s[N];

int main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

	cin >> k >> (s + 1);

	for (int i = 1; i <= k; ++i) {
		if (!s[i]) return puts(""), 0;
		putchar(s[i]);
	}
	if (s[k + 1]) puts("...");
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){
    cout << "Yes" << endl;
}
void no(){
    cout << "No" << endl;
}
//-----------------------------------------

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

    int h1, m1, h2, m2, k ;
    cin >> h1 >> m1 >> h2 >> m2 >> k ;
    cout << h2*60 + m2 - h1*60 - m1 -k <<endl ;
    

    return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
long long psum[200010], ssum[200010];
long long p[2][200010], s[2][200010];
const long long inf = 1e16;
int a[200010];

int main (int argc, char const* argv[])
{
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	long long sum = 0;
	long long part = 0;
	int l = 0;
	for(int i = 0; i < n; i++) {
		sum += a[i];
		while(l < i && part + a[l] <= sum - a[l]) {
			part += a[l];
			sum -= a[l];
			++l;
		}
		p[0][i] = part;
		p[1][i] = part + a[l];
		if(i == 0) psum[i] = a[i];
		else psum[i] = psum[i - 1] + a[i];
	}
	sum = 0;
	part = 0;
	l = n-1;
	for(int i = n-1; i >= 0; i--) {
		sum += a[i];
		while(i < l && part + a[l] <= sum - a[l]) {
			part += a[l];
			sum -= a[l];
			--l;
		}
		s[0][i] = part;
		s[1][i] = part + a[l];
		if(i == n-1) ssum[i] = a[i];
		else ssum[i] = ssum[i + 1] + a[i];
	}
	long long ans = inf;
	for(int i = 1; i < n-1; i++) {
		for(int j = 0; j < 2; j++) {
			for(int k = 0; k < 2; k++) {
				vector <long long> v;
				v.emplace_back(p[j][i]);
				v.emplace_back(psum[i] - p[j][i]);
				v.emplace_back(s[k][i + 1]);
				v.emplace_back(ssum[i + 1] - s[k][i + 1]);
				long long res = 0;
				bool bad = false;
				for(auto x : v) {
					if(x == 0) {
						bad = true;
					}
				}
				if(bad) continue;
				for(auto x : v) {
					for(auto y : v) {
						res = max(res, abs(x - y));
					}
				}
				ans = min(ans, res);
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

long long dist(int x, int y) {
  long long d = (1LL * x * x) + (1LL * y * y);
  return ceil(sqrt(1.00 * d));
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, d;
  cin >> n >> d;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    if (dist(x, y) <= d) {
      cnt += 1;
    }
  }
  cout << cnt << '\n';
}


Measured memory_bytes: 3696
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <string>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <set>
# include <map>
# include <stack>
using namespace std;
# define M_PI 3.141592
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define pri_max 60000
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
int a[1000001] = {};
int main()
{
	set<pii, greater<pii> > s;
	set<pii, greater<pii> >::iterator it;
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < q; i++)
	{
		pii now;
		cin >> now.second >> now.first;
		now.second = -now.second;

		it = s.find(pii(a[-now.second], now.second));

		a[-now.second] += now.first;

		if (it == s.end())
		{
			s.insert(now);
		}
		else
		{
			s.erase(it);
			s.insert(pii(a[-now.second], now.second));
		}
		now = *s.begin();
		cout << -now.second << " " << now.first << endl;;
	}

}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	int p, q, r;
	cin >> p >> q >> r;
	cout << min ( {p+q, q+r, r+p} );
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int> > A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i].first;
        A[i].second = i;
    }

    sort(A.begin(), A.end());

    for (int i = 0; i < n; i++) {
        if (A[n-1].second == i)
            cout << A[n-2].first << endl;
        else
            cout << A[n-1].first << endl;
    }

    return 0;
}

Measured memory_bytes: 3200
// This template code suggested by KT BYTE Computer Science Academy
//   for use in reading and writing files for USACO problems.

// https://content.ktbyte.com/problem.java

import java.util.*;
import java.io.*;

public class Main {

    static StreamTokenizer in;

    static int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    public static void main(String[] args) throws Exception {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = nextInt();

        int[] heights = new int[n];

        for (int i = 0; i < n; i++) {
            heights[i] = nextInt();
        }

        int[] dp = new int[n + 1];

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

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

        for (int i = 2; i <= n; i++) {

            if (i == 2) dp[i] = dp[i-1] + Math.abs(heights[i-2] - heights[i - 1]);

            else {
                dp[i] = Math.min(dp[i-1] + Math.abs(heights[i-2] - heights[i - 1]),
                        dp[i-2] + Math.abs(heights[i-3] - heights[i - 1]));
            }
        }

        out.println(dp[n]);

        out.close();
    }
}




Measured memory_bytes: 37472
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ii pair<int, int>
#define iii tuple<int, int, int>
#define iiii tuple<int, int, int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define fi first
#define se second
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define uni(v) v.erase(unique(v.begin(), v.end()), v.end())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (ll) a / __gcd(a, b) * b
#define rep(i, a, b) for (auto i = a; i != b; i += 1 - 2 * (a > b))

using namespace std;

const int M = 1e9 + 7;
vi fac(2e6 + 7, 1);

ll fpow(ll b, ll n, ll m = M) {
    ll res = 1;
    while (n) {
        if (n & 1) res = (res * b) % m;
        n >>= 1;
        b = (b * b) % m;
    }
    return res;
}

ll gcdex(ll x, ll m = M) { return fpow(x, m - 2, m); }
ll f(int i, int j) {
    return (((1LL * fac[i + j] * gcdex(fac[i])) % M) * gcdex(fac[j])) % M;
}

void solve() {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    for (int i = 2; i < int(2e6 + 7); ++i) fac[i] = (1LL * fac[i - 1] * i) % M;
    // f[i, x..y] = f[i + 1, y] - f[i + 1, x - 1]
    // f[x..y, j] = f[y, j + 1] - f[x - 1, j + 1]


    r2++, c2++;
    cout << (1LL * f(r2, c2) + M - f(r2, c1) + M - f(r1, c2) + f(r1, c1)) % M
         << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

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

    while (t--) solve();
    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 100000000;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 998244353;
const ll maxn = 2000005;
int a[200005];
map<int,int>m;
int main(){
    int n;
    ll ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
    	scanf("%d",&a[i]);
    	if(i>a[i]) ans+=m[i-a[i]];
    	m[a[i]+i]++;
    }
    printf("%lld",ans);

 	return 0;
}




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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

char s[200005];
char m[200005];

int main(){
	int n,k;

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


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string S;
long long total = 0;
int scount[10] = {0};
long long temp = 0;


main(){

    cin >> S;

    for (int i = 0; i < S.length(); i++) scount[i] = S[i]-'0';

    int n = S.length();
    for (int bit = 0; bit < (1<<n-1); bit++){
        temp = scount[0];
        for (int i = 0; i < n-1; i++){
            if (bit & (1<<i)){
                total += temp;
                temp = scount[i+1];
            } else {
                temp = temp * 10 + scount[i+1];
            }
            
        }
        total += temp;
    }

    cout << total << endl;

    return 0;
}

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

#define x first
#define y second

pair<int,int> dat[200005];
int n;

long long solve1()
{
	int Bmax = dat[n - 1].x;
	int Bmin = dat[0].y;
	if (Bmax < Bmin) swap(Bmax, Bmin);

	for (int i = 1; i < n - 1; i++)
	{
		Bmin = min(Bmin, dat[i].y);
		Bmax = max(Bmax, dat[i].x);
	}

	vector<pair<int, int>> vt;

	for (int i = 1; i < n - 1; i++)
	{
		if (Bmin <= dat[i].x && dat[i].x <= Bmax) continue;
		if (Bmin <= dat[i].y && dat[i].y <= Bmax) continue;

		vt.push_back(dat[i]);
	}

	if (vt.empty())
	{
		return (dat[n - 1].y - dat[0].x) * 1ll * (Bmax - Bmin);
	}

	int Blen = Bmax - vt[0].first;

	for (int i = 0, j; i < vt.size(); i = j)
	{
		for (j = i; j < vt.size() && vt[i].first == vt[j].first; j++)
			Bmax = max(Bmax, vt[j].second);

		Blen = min(Blen, Bmax - (j == vt.size() ? Bmin : vt[i].first));
	}

	return (dat[n - 1].y - dat[0].x) * 1ll * Blen;
}

long long solve2()
{
	int Rmax, Rmin, Bmax, Bmin;
	Rmax = Rmin = dat[0].y;
	Bmax = Bmin = dat[0].x;

	for (int i = 1; i < n; i++)
	{
		Rmin = min(Rmin, dat[i].y);
		Rmax = max(Rmax, dat[i].y);
		Bmin = min(Bmin, dat[i].x);
		Bmax = max(Bmax, dat[i].x);
	}

	return (Rmax - Rmin) * 1ll * (Bmax - Bmin);
}

int main()
{
	scanf("%d",&n);

	if (n == 1)
	{
		printf("0\n");
		return 0;
	}

	for (int i = 0; i < n; i++)
	{
		scanf("%d%d",&dat[i].x,&dat[i].y);
		if (dat[i].x > dat[i].y) swap(dat[i].x, dat[i].y);
	}

	int maxidx = 0;
	for (int i = 1; i < n; i++)
		if (dat[maxidx].y < dat[i].y) maxidx = i;

	swap(dat[maxidx], dat[n - 1]);
	sort(dat, dat + n - 1);

	printf("%lld\n", min(solve1(), solve2()));
}


Measured memory_bytes: 1792
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}

ll N;
vector<string> S;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    S = vector<string>(N);
    for(int i = 0; i < N; ++i){
        cin >> S[i];
    }
    solve();
}

// 1 <= N <= 10^5
// S_i は AC, WA, TLE, RE のいずれか

// ll N, vector<string> S
// AC, WA, TLE, RE のテストケースの個数をそれぞれ C_0, C_1, C_2, C_3 としたとき、以下の形式で出力せよ。
void solve(){
    map<string,ll> mp;
    rep(i,N)mp[S[i]]++;

    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
}


Measured memory_bytes: 6352
# Problem - ミンコフスキー距離

def minkowski(x_list, y_list, p):
    tmp_ans = 0
    for i in range(len(x_list)):
        tmp = abs(x_list[i] - y_list[i])**p
        tmp_ans += tmp
    tmp_ans = tmp_ans**(1/p)
    return tmp_ans

def minkowski_max(x_list, y_list):
    tmp_ans = 0
    for i in range(len(x_list)):
        tmp = abs(x_list[i] - y_list[i])
        tmp_ans = max(tmp_ans, tmp)
    return tmp_ans

# input
n = int(input())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))

# output
print(minkowski(x_list, y_list, 1))
print(minkowski(x_list, y_list, 2))
print(minkowski(x_list, y_list, 3))
print(minkowski_max(x_list, y_list))



Measured memory_bytes: 5644
#include<stdio.h>

int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  int cnt=0;
  for(int i=a;i<=b;i++){
    if(i/10000==i%10&&(i%10000)/1000==(i%100)/10) cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

const int M = 1e9+7;

string k;
int d;

long long dp[10005][100][2];

int main()
{
  cin >> k >> d;

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

  for (int i = 0; i < k.length(); i++) {
    for (int j = 0; j < d; j++) {
      dp[i+1][(j+(k[i]-'0'))%d][0] += dp[i][j][0];
      for (int l = 0; l < k[i]-'0'; l++) {
        dp[i+1][(j+l)%d][1] += dp[i][j][0];
      }
      for (int l = 0; l < 10; l++) {
        dp[i+1][(j+l)%d][1] += dp[i][j][1];
      }
    }
    for (int j = 0; j < d; j++) {
      dp[i+1][j][0] %= M;
      dp[i+1][j][1] %= M;
    }
  }

  int ans = (dp[k.length()][0][0] + dp[k.length()][0][1]-1+M) % M;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15872
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define mp make_pair
#define rep(a,b,c) for(int a=1;a<=b;a+=c)
#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)

const double PI=acos(-1);
const double EPS=1e-12;
const int MOD=1e9+7;
const int INF=1<<30;


using namespace std;


int main(){
	ios::sync_with_stdio(false);cin.tie(NULL);	cout.tie(NULL);
	int a,b,c,t,sum=0;
	vector<int>v;
	cin>>a>>b>>c;
	rep(i,a,1){
		cin>>t;
		v.pb(t);
	}
	sort(v.begin(),v.end());
	repp(i,0,a-1,1){
		if(v[i]<b||v[i]>=c){
			sum++;
		}
	}
	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



char A[105],B[105];

int main(){

	scanf("%s %s",A,B);

	int len_A,len_B;

	for(len_A = 0;A[len_A] != '\0'; len_A++);
	for(len_B = 0;B[len_B] != '\0'; len_B++);

	if(len_A > len_B){

		printf("GREATER\n");

	}else if(len_A < len_B){

		printf("LESS\n");

	}else{

		for(int i = 0; i < len_A; i++){
			if(A[i] != B[i]){
				if(A[i] > B[i]){

					printf("GREATER\n");

				}else{

					printf("LESS\n");
				}
				return 0;
			}
		}

		printf("EQUAL\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll LINF=5e18;
#define chmin(a,b) a=min(a,b);

ll a, b, c, d;
map<ll, ll> mp;

ll dfs(ll n) {
  if (!mp.count(n)) {
    if (n == 0) {
      mp[n] = 0;
    } else {
      ll res = LINF;
      if (n <= res / d) chmin(res, d * n);
      chmin(res, dfs(n / 2) + a + d * (n % 2));
      chmin(res, dfs(n / 3) + b + d * (n % 3));
      chmin(res, dfs(n / 5) + c + d * (n % 5));
      if (n > 2) chmin(res, dfs(1 + n / 2) + a + d * (2 - (n % 2)));
      if (n > 1) chmin(res, dfs(1 + n / 3) + b + d * (3 - (n % 3)));
      if (n > 1) chmin(res, dfs(1 + n / 5) + c + d * (5 - (n % 5)));
      mp[n] = res;
    }
  }
  return mp[n];
}

int main(){
  int t;
  cin >> t;
  while (t--) {
    mp = {};
    ll n;
    cin >> n >> a >> b >> c >> d;
    cout << dfs(n) << endl;
  }
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using ld=long double;

pair<ld,pair<ld,ld>> rad[210];
void solve(int N, std::vector<ld> x, std::vector<ld> y){
  REP(i,N){
    if(x[i]==0&&y[i]==0){
      rad[i]=make_pair(0.0l,make_pair(x[i],y[i]));
    }else{
      rad[i]=make_pair(atan2(y[i],x[i]),make_pair(x[i],y[i]));
    }
  }
  sort(rad,rad+N);
  REP(i,N){
    rad[N+i]=rad[i];
  }
  ld result=0;
  for(int s=0;s<N;s++){
    auto c=complex<ld>(rad[s].second.first,rad[s].second.second);
    ld maxsize=abs(c);
    for(int t=s+1;t<s+N;t++){
      c+=complex<ld>(rad[t].second.first,rad[t].second.second);
      ld sz=abs(c);
      maxsize=max(maxsize,sz);
    }
    result=max(result,maxsize);
  }
  cout<<fixed<<setprecision(20)<<result<<endl;
}

int main(){_;
  int N;cin>>N;
  std::vector<ld> x(N);
  std::vector<ld> y(N);
  REP(i,N)cin>>x[i]>>y[i];
  solve(N, std::move(x), std::move(y));
  return 0;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
H, W = map(int, input().split())
A, B = [None] * H, [None] * H
for i in range(H):
    A[i] = list(map(int, input().split()))
for i in range(H):
    B[i] = list(map(int, input().split()))
C = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]
dp = [[0 for j in range(W+1)] for i in range(H+1)]
dp[0][1] = 1
dp[1][0] = 1
for i in range(1, H+1):
    for j in range(1, W+1):
        d = C[i-1][j-1]
        x = int('0'+bin((dp[i-1][j]&(2**d-1))+2**d)[::-1][:d], 2)<<1
        y = int('0'+bin((dp[i][j-1]&(2**d-1))+2**d)[::-1][:d], 2)<<1
        dp[i][j] = (dp[i-1][j] >> d) | (dp[i-1][j] << d) | (dp[i][j-1] >> d) | (dp[i][j-1] << d) | x | y
for i, v in enumerate(bin(dp[H][W])[::-1]):
    if v == '1':
        print(i)
        break


Measured memory_bytes: 49368
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())

//変数
string S;


//解法
void solve() {

	if (S.size() == 2) {
		cout << S;
		return;
	}

	char tmp = S[0];
	S[0] = S[2];
	S[2] = tmp;

	cout << S;

	return;
}

int main() {
	//入力
	cin >> S;

	solve();
	cout << endl;
	return 0;
}



Measured memory_bytes: 256
N = int(input())
H = [int(i) for i in input().split(" ")]

cost = [0 for _ in range(N)]
for i in range(N-1):
    if i+1 == 1:
        cost[i+1] = abs(H[i+1] - H[i])
    else:
        cost[i+1] = min(abs(H[i+1] - H[i])+cost[i], abs(H[i+1] - H[i-1])+cost[i-1])
print(cost[-1])

Measured memory_bytes: 13772
#include <bits/stdc++.h>
using namespace std;
int main(){
    string str;
	getline(cin, str);
    for(int i=0; i<str.size(); i++){
        if(islower(str.at(i))){
            str.at(i) = toupper(str.at(i));
        }else if(isupper(str.at(i))){
            str.at(i) = tolower(str.at(i));
        }
    }
    cout << str << endl;
    return 0;
}


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

int main(){
int n,m,a;

  cin>>n>>m;
    vector<int> vec(n);
  for(int i=0;i<2*m;i++){
    cin>>a;
    vec.at(a-1)++;
  }
  for(int i=0;i<n;i++){
    cout<<vec.at(i)<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

int main(void)
{
    int X, T;
    cin >> X >> T;

    int ans;
    if (X < T)
    {
        ans = 0;
    }
    else
    {
        ans = X - T;
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
n=int(input())
l=[[]for _ in range(n)]
for i in range(n-1):
  a,b,c=map(int,input().split())
  l[a-1]+=[[b-1,c]]
  l[b-1]+=[[a-1,c]]
q,k=map(int,input().split())
k-=1
Q=[[k,0]]
c=[0]*n;c[k]=-1
while Q:
  p=[]
  for i,j in Q:
    for x,y in l[i]:
      if c[x]==0:
        c[x]=j+y
        p+=[[x,c[x]]]
  Q=p
c[k]=0
for i in range(q):
  x,y=map(int,input().split())
  print(c[x-1]+c[y-1])

Measured memory_bytes: 55388
#include <cstdio>

using namespace std;

int main() {
  double a;
  while (scanf("%lf", &a) == 1) {
    double s = a;
    for (int i = 2; i <= 10; i++) {
      if (i % 2)
        a /= 3;
      else
        a *= 2;
      s += a;
    }
    printf("%.8f\n", s);
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
	int a,b,c;
	int i,j=0;
	scanf("%d %d %d",&a,&b,&c);

	for(i=a;i<=b;i++){
		if(c%i==0){
			j++;
		}
	}
	printf("%d\n",j);
	return 0;
}



Measured memory_bytes: 2148
#include <stdio.h>
#include <math.h>

int main(void)
{

    char c_finishFlag = 0;
    int i_attackCount = 0;
    double d_monsterHP, d_totalAttackCount = 0;

    scanf("%lf", &d_monsterHP);

    if (d_monsterHP == 1)
    {
        printf("1");
    }
    else
    {
        while (c_finishFlag == 0)
        {
            i_attackCount++;
            d_monsterHP = floor(d_monsterHP / 2);
            if (d_monsterHP <= 1)
            {
                break;
            }
        }
        for (int count = 0; count <= i_attackCount; count++)
        {
            if (count == 0)
            {
                d_totalAttackCount += 1;
            }
            else
            {
                d_totalAttackCount += pow(2, count);
            }
        }
        printf("%.0lf", d_totalAttackCount);
    }

    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  ll X; scanf("%lld", &X);
  X *= 2;
  ll ans = sqrt(X);
  if (ans * (ans + 1) < X) { ++ans; }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int n,m,i,a[1005],b[1005],x,z;

int main(){
	scanf("%d%d",&n,&m);
	while(n!=0 && m!=0){
		z=x=0;
		for(i=0;i<n;i++)scanf("%d",&a[i]);
		for(i=0;i<m;i++)scanf("%d",&b[i]);
		while(x<n-1){
			x+=b[z]+a[b[z]+x];
			z++;
		}
		printf("%d\n",z);
		scanf("%d%d",&n,&m);
	}
	return 0;
}

Measured memory_bytes: 0
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()
    H = LIST()

    cnt = 1
    for i in range(N-1):
        if H[i+1] >= H[i]: cnt += 1
        else: H[i+1] = H[i]

    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)

#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = 3.14159265358979;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Short Functions ---------- */

template <typename T>
T square(T a) {
    return a * a;
}


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
#define testP(p) cout << GET_VAR_NAME(p) << " = (" << (p).fst << ", " << (p).snd << ")" << endl;


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */


/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

    int N;
    cin >> N;

    int odd = 0;
    REP(i, N) {
        ll A;
        cin >> A;
        odd += (A % 2);
    }

    if (odd % 2 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

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

const int MOD = 1000000007;
#define p(var) std::cout<<#var" = "<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for (int i = 0; i <  (n); i++)
#define repeq(i, n) for (int i = 1; i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
using ll = long long;
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a;}
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b;}

int main(){
    double b;
    vector<double> a(5,0);//
    cin >> b;
    for (int i = 0; i <=4; i++){
        cin >> a[i];
    }
    sort(all(a));


    printf("%.0f\n",ceil(b/a[0])+4);
    //cout << (b/a[0])+5 <<endl;

    return 0;
    
}






Measured memory_bytes: 256
// Written By NewbieChd
#include <cstdio>
using namespace std;

const int maxN = 100003;
char s[maxN];

int main() {
    scanf("%s", s + 1);
    for (int i = 1; i < 4; ++i)
        if (s[i] == s[i + 1]) {
            printf("Bad\n");
            return 0;
        }
    printf("Good\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>

constexpr long long int MOD = 1000000007;
struct Coordinate {
	long long int a, b;
	bool operator<(const Coordinate& that) const {
		return a == that.a ? b < that.b : a < that.a;
	}
};
long long int gcd(const long long int a, const long long int b) {
	return b == 0 ? a : gcd(b, a % b);
}
long long int power(const long long int base, const long long int exp) {
	switch (exp) {
	case 0: return 1L;
	case 1: return base % MOD;
	default: return power(base * base % MOD, exp >> 1)* power(base, exp & 1) % MOD;
	}
}
int main() {
	std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
	int n; std::cin >> n;
	std::vector<Coordinate> points(n);
	for (auto& point : points) {
		long long int a, b; std::cin >> a >> b;
		const auto g = a == 0 && b == 0 ? 1 : gcd(a, b);
		point.a = a / g; point.b = b / g;
	}
	std::map<Coordinate, long long int> appear;
	long long int both_zero{ 0 }, a_zero{ 0 }, b_zero{ 0 };
	for (const auto& point : points) {
		if (point.a == 0 && point.b == 0) {
			++both_zero;
		}
		else if (point.a == 0) {
			++a_zero;
		}
		else if (point.b == 0) {
			++b_zero;
		}
		else {
			appear[point]++;
		}
	}
	long long int valid_pattern = (power(2, a_zero) + power(2, b_zero) - 1) % MOD;
	while (!appear.empty()) {
		const auto first = *appear.begin();
		const auto origin = first.first;
		const auto opposite = Coordinate{ -origin.a, -origin.b };
		const auto rightA = Coordinate{ -origin.b, origin.a };
		const auto rightB = Coordinate{ origin.b, -origin.a };
		const auto parallel = first.second + appear[opposite];
		const auto right = appear[rightA] + appear[rightB];
		valid_pattern *= (power(2, parallel) + power(2, right) - 1) % MOD;
		valid_pattern %= MOD;
		appear.erase(origin);
		appear.erase(opposite);
		appear.erase(rightA);
		appear.erase(rightB);
	}
	valid_pattern += both_zero - 1;
	std::cout << (valid_pattern % MOD + MOD) % MOD << '\n';
}


Measured memory_bytes: 18660
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int h, w, i, j;
    long int n = 0;
    scanf("%d %d", &h, &w);
    int a[h][w], aa[h][w];
    for(i=0; i<h; i++){
        for(j=0; j<w; j++){
            scanf("%d", &a[i][j]);
            aa[i][j] = a[i][j];
        }
    }
    for(i=0; i<h; i++){
        for(j=0; j<w; j++){
            if(aa[i][j]%2==1){
                if(j<w-1){
                    aa[i][j+1]++;
                    n++;
                }else if(i<h-1){
                    aa[i+1][j]++;
                    n++;
                }
            }
        }
    }
    printf("%ld\n", n);
    for(i=0; i<h; i++){
        for(j=0; j<w; j++){
            if(aa[i][j]%2==1){
                if(j<w-1){
                    printf("%d %d %d %d\n", i+1, j+1, i+1, j+2);
                }else if(i<h-1){
                    printf("%d %d %d %d\n", i+1, j+1, i+2, j+1);
                }
            }
        }
    }
/*    for(i=0; i<h; i++){
        for(j=0; j<w; j++){
            printf("%d ", a[i][j]);
        }
        printf("\n");
    }*/
}

Measured memory_bytes: 3968
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int main(){
  int n,m; cin >> n >> m;
  vector<pair<int,int>> v(m);
  rep(i,m){
    int a,b; cin >> a >> b;
    v[i] = {b,a};
  }
  
  sort(v.begin(),v.end());
  
  int t = 0;
  int ans = 0;
  rep(i,m){
    if(v[i].second >= t){
      ans++;
      t = v[i].first;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

vector<int> seen;
void dfs(const Graph &G, int v,int &c) {
    seen[v] = c; // v を訪問済にする
    c++;
    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]>=0) continue; // next_v が探索済だったらスルー
        dfs(G, next_v,c); // 再帰的に探索
    }
}

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

    int n,m;
    cin>>n>>m;
    int a[m],b[m];
    Graph G(n);
    rep(i,m){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }

    seen.assign(n,-1);
    int ans=0;
    rep(i,n){
        if(seen[i]==-1){
            int x=1;
            dfs(G,i,x);
            //ans++;
        }
    }
    rep(i,n)ans=max(ans,seen[i]);
    cout<<ans<<endl;




}


Measured memory_bytes: 28208
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}

int n;
int a[N];
bool st[N];

bool check(int x){
	for(int i=2;i<=x/i;++i){
		if(x%i==0){
			if(st[i]) return false;
			while(x%i==0) x/=i;
			st[i]=true;
		}
	}
	if(x>1){
		if(st[x]) return false;
		st[x]=true;
	}
	return true;
}


int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	n=read();
	bool flag=true;
	for(int i=1;i<=n;++i){
		a[i]=read();
		if(!check(a[i])) flag=false;
	}
	int gcd=a[1];
	for(int i=2;i<=n;++i){
		gcd=__gcd(gcd,a[i]);
	}

	if(flag) puts("pairwise coprime");
	else if(gcd==1) puts("setwise coprime");
	else puts("not coprime");

    return 0;
}

Measured memory_bytes: 8464
N = int(input())
A = list(map(int, input().split()))

m = max(A)

L = [3] + [0] * (m + 1)
K = [0] * len(A)
count = 3
for i in range(len(A)):
    K[i] = L[A[i]]
    L[A[i]] -= 1
    L[A[i] + 1] += 1

count = 1
for k in K:
    count *= k

print(count % 1000000007)

Measured memory_bytes: 13964
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct Node { int parent, left, right; };
Node T[25];

void Preorder(int node) {
  if (node == -1) return;
  cout << " " << node;
  Preorder(T[node].left);
  Preorder(T[node].right);
}

void Inorder(int node) {
  if (node == -1) return;
  Inorder(T[node].left);
  cout << " " << node;
  Inorder(T[node].right);
}

void Postorder(int node) {
  if (node == -1) return;
  Postorder(T[node].left);
  Postorder(T[node].right);
  cout << " " << node;
}

int main() {
  int n; cin >> n;
  for (int i = 0; i < n; i++) T[i] = {-1,-1,-1};
  for (int i = 0; i < n; i++) {
    int id, left, right; cin >> id >> left >> right;
    T[id] = {-1,left,right};
  }

  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) if (T[i].left == j || T[i].right == j) T[j].parent = i;

  int root = -1;
  for (int i = 0; i < n; i++) if (T[i].parent == -1) root = i;

  cout << "Preorder" << endl;
  Preorder(root);
  cout << endl;

  cout << "Inorder" << endl;
  Inorder(root);
  cout << endl;

  cout << "Postorder" << endl;
  Postorder(root);
  cout << endl;
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int n;
	cin >> n;
	int p[n];
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		if (mp[p[i] - 1]) {
			mp[p[i]] = mp[p[i] - 1] + 1;
		} else {
			mp[p[i]] = 1;
		}
	}
	int ans = -1;
	for (auto i : mp) {
		//cout << "i.first: " << i.first << " i.second:" << i.second << endl;
		ans = max(ans, i.second);
	}
	cout << n - ans << endl;
	return 0;
}

Measured memory_bytes: 14848
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		int result = 24 - n + 24;
		
		
		// 出力
		System.out.println(result);
	}
}




Measured memory_bytes: 23764
from collections import defaultdict

MOD = 10 ** 9 + 7


def main():
    n, m = map(int, input().split())
    x_list = list(map(int, input().split()))
    y_list = list(map(int, input().split()))

    a = 0
    for k in range(1, n + 1):
        a += (k - 1) * x_list[k - 1] - (n - k) * x_list[k - 1]

    b = 0
    for k in range(1, m + 1):
        b += (k - 1) * y_list[k - 1] - (m - k) * y_list[k - 1]

    print((a % MOD * b % MOD) % MOD)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19008
data = input().split()
a = int(data[0])
b = int(data[1])
c = int(data[2])
d = int(data[3])


while True:
    #print(a,c)
    if c <= 0:
        print("Yes")
        break
    elif a <= 0:
        print("No")
        break
    a -= d
    c -= b

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

using ll = long long;

const ll MOD = 998244353;

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    rep(i, N + 1) {
        rep(j, M + 1) {
            if (i * (M - j) + j * (N - i) == K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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


int main(){
    int k,t;
    cin >> k >> t;
    multiset<int> s;
    rep(i,t){
        int temp;
        cin >> temp;
        s.insert(temp);
    }
    int st = 0;
    rep(i,k){
        if(s.size()==0){
            cout << st << endl;
            return 0;
        }
 
 
        int temp = *(--s.end());
        --temp;
        //cout << " " << temp << endl;
        s.erase(--s.end());
        //cout << "  " << s.size() << endl;
        if(st>0&&i>0) s.insert(st);
        st = temp;
    }

    cout << 0 << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <set>
#include <map>
using namespace std;
using T=tuple<int,int,int>; //x,S,T;
int main(){
    int N,Q;
    cin>>N>>Q;
    vector<T> V;
    for(int i=0;i<N;i++){
        int s,t,x;
        cin>>s>>t>>x;
        V.emplace_back(x,s,t);
    }
    sort(V.begin(), V.end());
    set<int> D;
    map<int,int> M;
    for(int i=0;i<Q;i++){
        int d;
        cin>>d;
        D.insert(d);
        M[d]=i;
    }
    vector<int> ans(Q,-1);
    for(auto v:V){
        int s,t,x;
        tie(x,s,t)=v;
        vector<int> DD;
        for(auto ite=D.lower_bound(s-x);ite!=D.end();++ite){
            if(*ite<t-x){
                DD.push_back(*ite);
            }else{
                break;
            }
        }
        for(auto dd:DD){
            ans[M[dd]]=x;
            D.erase(dd);
        }
    }
    for(auto a:ans){
        cout<<a<<endl;
    }
    return 0;
}

Measured memory_bytes: 24816