akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

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

	if (x > 399 && x < 600)
		cout << 8;
	else if (x > 599 && x < 800)
		cout << 7;
	else if (x > 799 && x < 1000)
		cout << 6;
	else if (x > 999 && x < 1200)
		cout << 5;
	else if (x > 1199 && x < 1400)
		cout << 4;
	else if (x > 1399 && x < 1600)
		cout << 3;
	else if (x > 1599 && x < 1800)
		cout << 2;
	else cout << 1;

}

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

typedef long long ll;

const int maxn=503;

ll n,m,dp[maxn][maxn];

int f(int i){
	static int rt=2*n-1;
	while(rt>=0&&i*i+rt*rt>4*n*n)
		--rt;
	return rt+1;
}
int g(int i){
	static int rt=2*n-1;
	while(rt>=0&&i*i+rt*rt>=n*n)
		--rt;
	return rt+1;
}

int main(){
	vector<pair<ll,ll> > a;
	scanf("%lld%lld",&n,&m);
//	printf("%lld ^^\n",m);
	for(ll i=0;i<2*n;++i){
		if(i<n)a.push_back(make_pair(g(i),f(i)));
		else a.push_back(make_pair(f(i),0));
	}
	ll c1,c2,ans=0;
	sort(a.begin(),a.end());
//	for(ll i=0;i<a.size();++i)
//		printf("(%lld %lld)\n",a[i].first,a[i].second);
	for(ll k=0;k<=n;++k){
//		printf("%d : \n",k);
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		c1=c2=0;
		for(ll i=0;i<a.size();++i){
			for(ll j=0;j<=k;++j){
				if(a[i].second==0){
					dp[i+1][j]=(dp[i+1][j]+dp[i][j]*(a[i].first-c1-j)%m)%m;
//					printf("%lld %lld %d %d %d^\n",dp[i][j],a[i].first-c1-j,a[i].first,c1,j);
				}else{
					if(j<k)
						dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j]*(a[i].first-c1-j)%m)%m;
					dp[i+1][j]=(dp[i+1][j]+dp[i][j]*(a[i].second-n-k-(c2-j))%m)%m; 
				}
//				printf("%lld ",dp[i][j]);
			}
			if(a[i].second==0)++c1;
			else ++c2;
//			puts("");
		}
//		return 0;
		if(k%2)ans=(ans-dp[2*n][k]+m)%m;
		else ans=(ans+dp[2*n][k])%m;
//		printf("%lld !\n",ans);
//		puts("");
	}
	printf("%lld\n",ans);
	return 0;
}



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

int main(){
    int s,w;
    cin>>s>>w;

    if(s<=w){
        cout<<"unsafe";
    }else{
        cout<<"safe";
    }

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI  3.14159265358979323846

ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a,m)%m;
        if(n%2==0)
            return (((res%m)*(res%m))%m);
        else
            return (((((res%m)*a)%m)*res)%m);
    }
}
int main()
{
    ll N;
    cin>>N;
    ll i,j;
    ll pref[10][10];
    memset(pref,0,sizeof(pref));
    ll ans=0;
    for(i=1;i<=N;i++)
    {
        ll f=i;
        vector<ll> g;
        while(f>0)
        {
            g.push_back(f%10);
            f/=10;
        }
        reverse(g.begin(),g.end());
        ll t=g.size();
        if(g[t-1]!=0)
        {
            ans+=2*pref[g[t-1]][g[0]];
            if(g[0]==g[t-1])
            {
                ans++;
            }
            pref[g[0]][g[t-1]]++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
import sys
def main():
    k = int(input())
    
    if k == 7 or k == 1:
        print(1)
        sys.exit()
    
    r = 7%k
    g = {r}
    ans = 1
    while True:
        ans+=1
        r = (10*r+7)%k
        if r==0:
            print(ans)
            break
        if r in g:
            print(-1)
            break
        else:
            g.add(r)
main()

Measured memory_bytes: 77916
c, d = map(int, input().split())
ans = 0

if(c % 3 == 0) :
    ans = 1
elif(d % 3 == 0) :
    ans = 1
elif((c + d) % 3 == 0) :
    ans = 1

if (ans == 1) :
    print ('Possible')
else :
    print ('Impossible')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int main (){
    int n;cin>>n;
    ll A[n+1],B[n+1];
    for(int i=1;i<=n;i++)cin>>A[i]>>B[i];
    ll res=0,cnt=0;
    for(int i=n;i>=1;i--){
        A[i]+=cnt;
        ll closest_mul = A[i]/B[i] + ((A[i]%B[i])>0);
        closest_mul*=B[i];
        //cout<<"closest multiple of "<<B[i]<<" is "<<closest_mul<<" where A["<<i<<"] is  = "<<A[i]<<endl;
        ll need = closest_mul - A[i];
        res+=need;
        cnt+=need;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1792
use proconio::{input, fastout};
use num::integer::gcd;

#[fastout]
fn main() {
    input! {
        n: i32,
    }
    let mut ans = 0;
    for i in 1..=n {
        for j in 1..=n {
            for k in 1..=n {
                ans += gcd(gcd(i, j), k);
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2188
using System;
using System.Collections.Generic;
using System.Linq;
using static Scanner;

class Program
{
    static void Main() => new Program().Solve();

    public void Solve()
    {
        var a = ReadInt();
        var b = ReadInt();
        Console.WriteLine(b % 2 == 0 && 0 <= a * 2 - b / 2 && a * 2 - b / 2 <= a ? "Yes" : "No");
    }
}

static class Scanner
{
    static Queue<string> que = new Queue<string>();

    public static string Read()
    {
        if (!que.Any())
        {
            foreach (var s in Console.ReadLine().Split()) que.Enqueue(s);
        }
        return que.Dequeue();
    }
    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());
    public static decimal ReadDecimal() => decimal.Parse(Read());

    public static IEnumerable<string> Read(long n)
    {
        for (long i = 0; i < n; i++) yield return Read();
    }
    public static IEnumerable<int> ReadInt(long n) => Read(n).Select(int.Parse);
    public static IEnumerable<long> ReadLong(long n) => Read(n).Select(long.Parse);
    public static IEnumerable<double> ReadDouble(long n) => Read(n).Select(double.Parse);
    public static IEnumerable<decimal> ReadDecimal(long n) => Read(n).Select(decimal.Parse);
}

Measured memory_bytes: 28320
#include <iostream>
#include <iomanip>
#include <complex>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;
typedef complex<double> com;

double tri(com a, com b) //triangle size
{
	return(conj(a)*b).imag() / 2;
}
struct cou {
	bool operator()(com a, com b) {
		return tri(a, b)<0;
	}
}; //Counterclockwise

priority_queue<com, vector<com>, cou> n; //node
double x, y, xo, yo;
double S = 0;
char s;
com a;

int main()
{
	cout.setf(ios::fixed);
	cin >> xo >> s >> yo;
	while (cin >> x >> s >> y)
	{
		n.push(com(x - xo, y - yo));
	}
	while (!n.empty())
	{
		a = n.top();
		n.pop();
		if (n.empty()) break;
		S += tri(a, n.top());
	}
	cout << setprecision(8) << S << endl;
	return 0;
}


Measured memory_bytes: 3188
local n = io.read("*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
table.sort(a)
local asum = {a[1]}
for i = 2, n do
  asum[i] = asum[i - 1] + a[i]
end
local ret = 1
for i = n - 1, 1, -1 do
  if asum[i] * 2 < a[i + 1] then
    break
  else
    ret = ret + 1
  end
end
print(ret)


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

using namespace std;

using ll = long long;
using ld = long double;

using pll = pair<ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using gr = vector<vll>;
using wgr = vector<vpll>;

#define pb push_back
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define REP(i, n) FOR(i, 0, n)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
struct d_ {
    template<typename T> d_ & operator ,(const T & x) { cerr << ' ' <<  x; return *this;}
    template<typename T> d_ & operator ,(const vector<T> & x) { for(auto x: x) cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define EPS (1e-10)
#define INF (1LL<<61)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) begin(x),end(x)
#define IN(n) ll n;cin >> n;
#define x first
#define y second

int main(void) {
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    ll maxst=0,maxst2=0,minen=INF,minen2=INF;
    vpll v(n);
    map<ll,ll> encnt;
    priority_queue<ll, vll, greater<ll>> prio;
    ll ret = 0;
    F(n) {
        ll a, b; cin >> a >> b;
        v[i] = {a,b};
        if(a > maxst2) {
            if(a > maxst) {
                maxst2 = maxst;
                maxst = a;
            } else maxst2 = a;
        }
        if(b < minen2) {
            if(b < minen) {
                minen2 = minen;
                minen = b;
            } else minen2 = b;
        }
        maxst=max(maxst,a);
        minen=min(minen,b);
        encnt[b]++;
        prio.push(b);
        ret = max(b-a+1,ret);
    }
    F(n) {
        ll curminen = minen;
        ll curmaxst = maxst;
        if(v[i].x == maxst) curmaxst = maxst2;
        if(v[i].y == minen) curminen = minen2;
        ret = max(ret,
                v[i].y-v[i].x+1
                +
                curminen-curmaxst+1);
    }
    sort(all(v));
    ll minr = v[n-1].y;
    encnt[v[n-1].y]--;
    for(ll i = n-2; i>=0; --i) {
        while(encnt[prio.top()]==0) prio.pop();
        minen=prio.top();
//         dbg(minen-v[i].x+1,
//                 minr-maxst+1
//            );
//         if(v[i].x <= minen) 
            ret = max(ret,
                max(minen-v[i].x+1,0ll)
                +
                max(minr-maxst+1,0ll)
                );
        minr = min(v[i].y, minr);
        encnt[v[i].y]--;
    }
    cout << ret << endl;
    return 0;
}


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

int main()
{
	string a, b;
	cin >> a >> b;
	int n = a.size(), m = b.size(), ans = 0x7fffffff;
	for (int i = 0; i <= n - m; ++i)
	{
		int s = 0;
		for (int j = 0; j < m; ++j)
			if (a[j + i] != b[j])
				++s;
		ans = ans < s ? ans : s;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3596
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, H, W;

signed main() {
  cin >> N >> H >> W;

  int cont = 0;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;

    if (a >= H && b >= W) cont++;
  }

  cout << cont << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,n) for(int i=0 ; i < (int) (n) ; ++i )

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

    int n,k;
    cin >> n >> k;
    int ary[n];
    rep(i,n) cin >> ary[i];

    map<int, int> mp;
    rep(i,n)
    {
        auto itr = mp.find(ary[i]);
        if (itr==mp.end())
        {
            mp[ary[i]] = 1;
        }
        else
        {
            mp[ary[i]]++;
        }
    }
    vector<int> vec;
    for (auto itr = mp.begin();itr!=mp.end();++itr)
    {
        vec.push_back(itr->second);
    }
    sort(vec.begin(), vec.end());

    int sz = vec.size();
    int ans = 0;
    if (sz<=k)
    {
        cout << 0 << endl;
    }
    else
    {
        rep(i,sz-k)
        {
            ans += vec[i];
        }
        cout << ans << endl;
    }
    
    

}




Measured memory_bytes: 11512
use std::io::BufRead;
use std::collections::HashSet;

fn main() {
    let mut set = HashSet::new();
    let stdin = std::io::stdin();
    for line in stdin.lock().lines().skip(1) {
        set.insert(String::from(line.unwrap().trim()));
    }

    for s in ["S", "H", "C", "D"].iter() {
        for n in 1..14 {
            let s = format!("{} {}", s, n);
            if !set.contains(&s) {
                println!("{}", s);
            }
        }
    }
}



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

// 3. bit（bitset高速化をする）

const int MAX_ROW = 510; // to be set appropriately
const int MAX_COL = 510; // to be set appropriately
struct BitMatrix {
    int H, W; // H * W 行列
    bitset<MAX_COL> val[MAX_ROW]; // MAX_ROW *　MAX_COL 行列
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) { return val[i]; }
};
// rankを求める
int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < (int)A.W; col++) {
        if (is_extended && col == (int)A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < (int)A.H; row++) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        if (rank != pivot) swap(A[pivot], A[rank]);
        for (int row = 0; row < (int)A.H; row++) {
            if (row != rank && A[row][col] != 0)  A[row] ^= A[rank];
        }
        rank++;
    }
    return rank;
}
// 連立一次方程式を解く（解が一つだけ存在するor存在しない）（resに参照渡しする）
int linear_equation(BitMatrix A, vector<int> b, vector<int> &res) {
    int m = (int)A.H, n = (int)A.W;
    BitMatrix M(m, n+1);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = GaussJordan(M, true);

    // check if it has no solution
    for (int row = rank; row < m; ++row) if (M[row][n] != 0) return -1;

    // answer
    res.assign(n, 0);
    for (int i = 0; i < rank; ++i) res[i] = M[i][n];
    return rank;
}

int main(){
    int n, m; cin >> n >> m;
    BitMatrix A(m, n);
    vector<int> b(m);
    for (int i = 0; i < m; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int s; cin >> s; s--;
            A[i][s] = 1;
        }
    }
    for (int i = 0; i < m; i++) cin >> b[i];

    vector<int> res;
    int rank = linear_equation(A, b, res);
    if (rank == -1) cout << 0 << endl;
    else cout << (1<<(n-rank)) << endl;
}

Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

ll gcd(ll a,ll b)
{
	if(a < b)swap(a,b);
	if(b == 0)return a;
	else return gcd(b,a%b);
}

int main()
{
	ll x,y;cin >> x >> y;
	ll ans = 0;
	ll now = x;
	
	while(now <= y)
	{
		ans++;now*=2;
	}
	
	cout << ans << endl;
		
	
	return 0;
}

Measured memory_bytes: 256
/*input
5 2 4
*/
#include <bits/stdc++.h>
using namespace std;
int n,memo[105][105];
int solve(int x, int y){
	if(memo[x][y]!=-1) return memo[x][y];
	if(x==1 && x+1==y) return 0;
	if(x-1==y && x==n) return 0;
	int ans = 0;
	if(x>1 && x-1!=y) ans|=!solve(y,x-1);
	else if(x<n && x+1!=y) ans|=!solve(y,x+1);
	return memo[x][y]=ans;
}
int main(){
	int x,y;
	cin>>n>>x>>y;
	memset(memo,-1,sizeof(memo));
	if(abs(x-y)%2) cout<<"Borys";
	else cout<<"Alice";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int k,a,b,i,max,j,flag=0;
	scanf("%d",&k);
	scanf("%d %d",&a,&b);
	for (i=a;i<=b;i++)
	  if (i%k==0)
	    flag=1;
	if (flag==1){printf("OK");
	}else printf("NG");
}

Measured memory_bytes: 1720
//先頭の文字以外は必要ない。先頭の文字の個数をcnt[i]などで持ち、残り数が多いほうから使っていく。(未証明)

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int n, k;
string p[10000];
int cnt[26];

int main() {
	int i, j;
	
	cin >> n >> k;
	for (i = 0; i < n; i++) {
		cin >> p[i];
		cnt[p[i][0] - 'A']++;
	}
	
	for (i = 0; ; i++) {
		sort(cnt, cnt + 26, greater<int>());
		if (cnt[k - 1] <= 0) break;
		for (j = 0; j < k; j++) cnt[j]--;
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 896
import java.util.*

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)
    val k = sc.nextInt()
    val s = sc.nextInt()

    var result = 0
    for (x in 0..k) {
        for (y in 0..k) {
            if (x+y <= s && s <= x+y+k) result++
        }
    }
    print(result)
}


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

int main(){
    int k;
    string s;
    cin >> k >> s;
    if((int)(s.length()) <= k){
        cout << s << endl;
    }else{
        s.erase(k,s.size());
        s +="...";
        cout << s << endl;
    }


    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

int main() {
 int N;
 cin>>N;
 vector<int>A(N);
 map<int,int>K;
 for(int i=0;i<N;i++){
   cin>>A[i];
   K[A[i]]++;
 }
 for(int i=0;i<N;i++){
   if(K[A[i]]>1){cout<<"NO"<<endl;return 0;}
 }
 cout<<"YES"<<endl;
return 0;}

Measured memory_bytes: 10368
C1=list(map(int,input().split()))
C2=list(map(int,input().split()))
C3=list(map(int,input().split()))

a=[0,0,0]
b=[0,0,0]
for i in range(100):
    a[0] = i
    b[0] = C1[0] - a[0]
    b[1] = C1[1] - a[0]
    b[2] = C1[2] - a[0]
    a[1] = C2[0] - b[0]
    a[2] = C3[0] - b[0]

    if a[1]+b[1]==C2[1] and a[1]+b[2]==C2[2] and a[2]+b[1]==C3[1] and a[2]+b[2]==C3[2]:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

        Scanner scan = new Scanner(System.in);
		while(true){
            int x = scan.nextInt();
            int y = scan.nextInt();
			if ((x==0) && (y==0)){
				break;
			}
			else {
				if (x < y) System.out.println(x + " " + y);
				else System.out.println(y + " " + x);
			}
		}
		
	}

}

Measured memory_bytes: 36060
import java.util.*;
import java.awt.*;
import java.math.BigInteger;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        String s1=sc.next();
        String s2=sc.next();
        BigInteger a1=new BigInteger(s1);
        BigInteger a2=new BigInteger(s2);
        if(a1.compareTo(a2)>0){
            out.println("GREATER");
        }else if(a1.compareTo(a2)==0){
            out.println("EQUAL");
        }else{
            out.println("LESS");
        }
    }
}

Measured memory_bytes: 22740
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c,i,count=0;
    scanf("%d %d %d",&a,&b,&c);
     for(i=a;i<b+1;i++){
         if(c<i)break;
         if(c%i == 0)count++;
     }
     printf("%d\n",count);
     
    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> score(N);
    for (int i = 0; i < N; ++i) {
       cin >> score.at(i);
    }
    for (int i = 0; i < N; ++i) {
       sort(score.begin(),score.end());
       reverse(score.begin(),score.end());
    }
    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < N; ++i) {
        if(i%2 == 0) Alice += score.at(i);
        if(i%2 == 1) Bob += score.at(i);
    }
    cout << Alice - Bob;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=200005;
char s[maxn],temp[maxn];
int have[30];

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	while(cin>>s){
		memset(have,0,sizeof(have));
		ll n=strlen(s);
		for(ll i=0;i<n;i++){
			have[s[i]-'a']++;
		}
		ll ans=(n*(n-1))/2+1;
		for(int i=0;i<26;i++){
			ans-=(ll)have[i]*(have[i]-1)/2;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int mindigit(long int val){
  return val%10;
}
int maxdigit(long int val){
  //int ans=0;
  while(val>9){
    val/=10;
  }
  return val;
}

int main(){
  long int N;
  cin>>N;
  
  int c[10][10]={0};
  
  long long int ans=0;
  for(int a=1;a<N+1;a++){
    c[maxdigit(a)][mindigit(a)]++;
  }
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      ans+=c[i][j]*c[j][i];
    }
  }
  //cout<<maxdigit(1000)<<endl;
  cout <<ans<<endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int N,M,R;
int dist[210][210];
vi r;

signed main(void) {
    cin>>N>>M>>R;
    REP(i, 1, N) {
        REP(j, 1, N) {
            dist[i][j]=INF;
            if (i==j) dist[i][j]=0;
        }
    }
    rep(i, R) {
        int tmp; cin>>tmp;
        r.pb(tmp);
    }
    sort(all(r));
    rep(i, M) {
        int A,B,C; cin>>A>>B>>C;
        dist[A][B]=C;
        dist[B][A]=C;
    }
    REP(k,1,N) {
        REP(i,1,N) {
            REP(j,1,N) {
                if (dist[i][j]>dist[i][k]+dist[k][j]) {
                    dist[i][j]=dist[i][k]+dist[k][j];
                }
            }
        }
    }
    
    int min_cost=INF;
    do {
        int cost=0;
        rep(i, r.size()-1) {
            cost+=dist[r[i]][r[i+1]];
        }
        min_cost=min(cost,min_cost);
    } while(next_permutation(all(r)));
    
    cout<<min_cost<<endl;
    return 0;
}

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

string tar = "AKIHABARA";
string s;

int main(){
	cin >> s;
	bool yes = 1;
	int idx = 0;
	for(int i=0;i<s.size();i++){
		if(s[i] == tar[idx]){
			idx++;
		} else if(tar[idx] == 'A' && idx+1<tar.size() && s[i] == tar[idx+1]){
			idx+=2;
		} else {
			yes = 0;
		}
	}
	if(yes && idx >= tar.size()-1) printf("YES\n");
	else printf("NO\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

typedef long long int ll;

int main() {
	optimizar_io
	string s, t;

	cin >> s >> t;
	int n = s.size();
	int m = t.size();
	int ans = 1e9;
	for (int i = 0; i + m <= n; i++) {
		int diff = 0;
		for (int j = 0; j < m; j++) {
			if (s[i + j] != t[j])
				diff++;
		}
		ans = min(ans, diff);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3656
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0



s=int("".join(list(input().split())))
for i in range(s):
    if i**2==s:
        print("Yes")
        break
else:
    print("No")


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

#define size_t int

using namespace std;
typedef unsigned long ul;
typedef unsigned long long ull;

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

  int n;
  std::cin >> n;

  ul sums;
  for (size_t i = 1; i <= n; i++) {
    /* code */
    sums += i;
  }

  std::cout << sums << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    ll N;
    cin >> N;

    vll count(N + 1, 0);
    for (ll x = 1; x * x <= N; x++)
    {
        for (ll y = x; y * y <= N; y++)
        {
            for (ll z = y; z * z <= N; z++)
            {
                ll tmp = x * x + y * y + z * z + x * y + y * z + z * x;
                if (tmp >= 1 && tmp <= N)
                {
                    if (x == y && y == z)
                    {
                        count[tmp]++;
                    }
                    else if (x != y && y != z && z != x)
                    {
                        count[tmp] += 6;
                    }
                    else
                    {
                        count[tmp] += 3;
                    }
                }
            }
        }
    }

    reple(i, 1, N)
    {
        cout << count[i] << endl;
    }

    return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

ll f(int n, int m, vector<vector<char>> &G, vector<vector<ll> > &dp) {
	if(n == 0 && m == 0) return 1ll;
	if(n < 0 || m < 0 || G[n][m] == '#') return 0;
	if(dp[n][m] != -1) return dp[n][m];
	dp[n][m] = (f(n - 1, m, G, dp) + f(n, m - 1, G, dp)) % MOD;
	return dp[n][m];
}

void solve() {
	int m, n;
	cin >> n >> m;
	vector<vector<char> > G(n, vector<char>(m));
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j< m; ++j) {
			cin >> G[i][j];
		}
	}
	vector<vector<ll> > dp(n, vector<ll>(m, -1));
	cout << f(n - 1, m - 1, G, dp);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	solve();
	
	return 0;
}


Measured memory_bytes: 12072
#include<stdio.h>
int main()
{
	int A,B,C;
	scanf("%d%d%d",&A,&B,&C);
	if(A==5&&B==5&&C==7||A==5&&B==7&&C==5||A==7&&B==5&&C==5)
	    printf("YES");
    else
	    printf("NO");
    return 0;
	
 } 


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

using namespace std;

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

  vector<int> sums_W;
  sums_W.push_back(0);
  for (int i = 0; i < N; ++i) {
    if (S[i] == 'W') {
      sums_W.push_back(sums_W[i] + 1);
    }
    else {
      sums_W.push_back(sums_W[i]);
    }
  }

  int ans = N;
  for (int i = 0; i < N; ++i) {
    int tmp = 0;
    // i より西側の人のうち, 'W' の人数を求める
    tmp += sums_W[i] - sums_W[0];

    // i より東側の人のうち, 'E' の人数を求める
    tmp += (N-i-1) - (sums_W[N]-sums_W[i+1]);

    ans = min(ans, tmp);
  }

  cout << ans << endl;
}


Measured memory_bytes: 2804
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i = 0; i<n; i++) cin>>a[i]>>b[i];
	sort(a,a+n);
	sort(b,b+n);
	if(n&1) cout<<b[(n-1)/2]-a[(n-1)/2]+1<<endl;
	else cout<<b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1<<endl;
	return 0;
}

Measured memory_bytes: 5196
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#define SIZE 500005

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

ll sum[SIZE];
ll A[SIZE];
ll pos[SIZE];
ll dp[SIZE];

int main()
{
	int n;
	scanf("%d %lld",&n,&pos[0]);
	for(int i=0;i<n;i++) scanf("%lld",&A[i]);
	for(int i=0;i<n;i++)
	{
		pos[i+1]=min(pos[i],llabs(A[i]-pos[i]));
	}
	dp[n]=0;
	for(int i=n-1;i>=0;i--)
	{
		//[0,dp[i+1]] の間に収まる[0,dp[i]]のmin
		dp[i]=dp[i+1];
		if(A[i]/2LL<=dp[i]) dp[i]+=A[i];
	}
	//for(int i=0;i<n;i++) printf("%lld ",dp[i]);puts("");
	//for(int i=0;i<n;i++) printf("%lld ",pos[i]);puts("");
	int Q;
	scanf("%d",&Q);
	for(int i=0;i<Q;i++)
	{
		int t;
		scanf("%d",&t);t--;
		if(pos[t]<=dp[t+1]) puts("NO");
		else puts("YES");
	}
	return 0;
}


Measured memory_bytes: 14080
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
ll dp[100010][3]; // dp[i][j]: i日目までで、i日目でj番目を選んだ時のマキシマムザ幸福
int main() {
    int N;
    cin >> N;
    int abc[N][3];
    rep(i, N) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    // ll dp[100010][3]; // dp[i][j]: i日目までで、i日目でj番目を選んだ時のマキシマムザ幸福
    // rep(i, 100010){
    //     rep(j, 3) dp[i][j] = 0;
    // }
    rep(i, N){
        rep(j, 3) {
            rep(k, 3){
                if (j==k) continue;
                chmax(dp[i+1][k], dp[i][j] + abc[i][k]);
            }
        }
    }
    ll ans = 0;
    rep(i, 3) chmax(ans, dp[N][i]);
    cout << ans << endl;

    return 0;
}

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

int w, h;

int dfs(int y, int x, vector<string> &v){
  int my[] = {0, 0, 1, -1};
  int mx[] = {1, -1, 0, 0};
  int ret = 1;
  REP(i, 4){
    int ny = y + my[i], nx = x + mx[i];
    if(ny >= 0 && nx >= 0 && ny < h && nx < w && v[ny][nx] == '.'){
      v[ny][nx] = '#';
      ret += dfs(ny, nx, v);
    }
  }
  return ret;
}

int main(){
  while(cin >>w >>h && w){
    vector<string> v(h);
    REP(i, h) cin >>v[i];
    REP(i, h) REP(j, w) if(v[i][j] == '@') cout <<dfs(i, j, v) <<endl;
  }
  return 0;
}

Measured memory_bytes: 1252
#include <stdio.h>

int isSame(const int *A,const int *B)
{
	int p1, p2, t1, t2, f1, f2, e, h;

	h = 0;
	for (p1 = 0; p1 < 6; p1++)
	{
		if (A[0] == B[p1] && A[5] == B[5 - p1])
		{
			h = 1;
			break;
		}
	}
	if (!h) return 0;

	h = 0;
	for (p2 = 0; p2 < 6; p2++)
	{
		if (p2 == p1 || p2 == 5 - p1) continue;
		if (A[1] == B[p2] && A[4] == B[5 - p2])
		{
			h = 1;
			break;
		}
	}
	if (!h) return 0;

	t1 = p1 / 3;
	t2 = t1 > 0 ? 3 - (t1 + p1 % 3) : p1 % 3;
	f1 = p2 / 3;
	f2 = f1 > 0 ? 3 - (f1 + p2 % 3) : p2 % 3;

	e = t1 ^ f1;
	e = f2 - (t2 + 1) % 3 != 0 ? !e * 3 : e * 3;
	e += e > 0 ? (t2 + f2) - 1 : 3 - (t2 + f2);
		
	if (A[2] != B[e] || A[3] != B[5 - e]) return 0;

	return 1;	
}

int main()
{
	int A[6];
	int B[6];
	int i;

	for (i = 0; i < 6; i++) scanf("%d", &A[i]);
	for (i = 0; i < 6; i++) scanf("%d", &B[i]);

	if (isSame(A, B)) printf("Yes\n");
	else printf("No\n");

	return 0;

}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
 #define Endl endl 
#define pb push_back
// #define  mp make_pair  
#define mod_ 1000000007
#define INF 1000000000000000000
#define overflow_ (pow(2,32)-1)
#define ll long long int
#define ld long double
#define pll pair<ll,ll>


ll fact[200005];

long long int fact_(long long int n)
{
    long long int ans=1;
    fact[0]=fact[1]=1;
    for(int i=2;i<=n;i++)
    {
        ans=(ans*i)%mod_;
        fact[i]=ans%mod_;
    }
    return ans;
}
long long int mod_inv(long long int a,long long int b)
{
    long long int ans=1;
    while(b)
    {
        if(b%2==1)
        ans=(ans*a)%mod_;
 
        a=(a*a)%mod_;
        b=b>>1;
    }
    return ans;
}
long long int ncr(long long int n,long long int r)
{
    if(n<r)
    return 0;
    if(r==0)
    return n;
    if(r==1)
    return n;
    if(n==r)
    return 1;
 
    return ((((fact[n]%mod_)*mod_inv(fact[r]%mod_,mod_-2))%mod_)*mod_inv(fact[n-r]%mod_,mod_-2))%mod_;
}
signed main()
{

   // fact_(100000);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll dp[n+5]={0};
    for(int i=2;i<=n;i++)
    {
        dp[i]+=2;
        for(int j=2*i;j<=n;j+=i)
        {
            dp[j]++;
        }
    
    }
    dp[1]=1;
    ll ans=0;
    for(int c=1;c<n;c++)
    {
        ll res=n-c;
     //   cout<<c<<" "<<dp[c]<<endl;
        ans+=dp[res];


    }
    cout<<ans<<Endl;
}




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

int main()
{
    int w,h,x,y;
    std::cin >> w >> h >> x >> y;
    double s = ((double)w * (double)h) / 2.0;
    int m = (2*x == w && 2*y == h) ? 1 : 0;

    std::cout << s << " " << m << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>

using namespace std;

int main(){
    int n,a,b;
    long count=0;
    vector<int> A;
    vector<int> B;
    cin >> n;
    for (int i=0;i<n+1;i++){
        cin >> a;
        A.push_back(a);
    }
    for (int i=0;i<n;i++){
        cin >> b;
        B.push_back(b);
    }

    for (int i=0;i<n;i++){
        for (int j=i;j<i+2;j++){
            //cout << "-----------" << endl;
            //cout << "A"<< j << ":" <<A[j] << endl;
            //cout << "B"<< i << ":" <<B[i] << endl;
            //cout << "count:" << count << endl;
            //cout << "-----------" << endl;
            if (A[j]<B[i]){
                count += A[j];
                B[i]=B[i]-A[j];
                A[j]=0;
                
            }
            else{
                count += B[i];
                A[j]=A[j]-B[i];
                break;
                
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>
#include <string.h>

int dp[ 1001 ];

int main( void ) {
	int i, j;
	int cs, maxW, n, v[ 1000 ], w[ 1000 ], max;

	cs = 0;
	while( scanf( "%d %d", &maxW, &n ), maxW ) {
		for ( i = 0; i < n; i++ )
			scanf( "%d,%d", v + i, w + i );

		memset( dp, -1, sizeof dp );
		dp[ 0 ] = 0;

		for ( i = 0; i < n; i++ )
			for ( j = maxW - w[ i ]; j >= 0; j-- )
				if ( dp[ j ] != -1 )
					dp[ j + w[ i ] ] = dp[ j + w[ i ] ] > dp[ j ] + v[ i ] ? dp[ j + w[ i ] ] : dp[ j ] + v[ i ];

		max = 0;
		for ( i = 0; i <= maxW; i++ )
			max = max > dp[ i ] ? max : dp[ i ];

		for ( i = 0; dp[ i ] != max; i++ ) ;

		printf( "Case %d:\n%d\n%d\n", ++cs, max, i );
	}

	return 0;
}

Measured memory_bytes: 612
# -*- coding: utf-8 -*-
s = input()

a_num = 0
bc_num = 0
ans = 0
i = 0
while i < len(s):
    if s[i] == 'A':
        a_num += 1
        i += 1
    elif s[i:i+2] == 'BC':
        ans += a_num
        i += 2
    else:
        a_num = 0
        b_num = 0
        i += 1

print(ans)


Measured memory_bytes: 3500
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); ++i)

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    UnionFind (int n) {
        par.resize(n, -1);
        rank.resize(n, 1);
    }
    int root (int n) {
        if (par[n] == -1) return n;
        return par[n] = root(par[n]);
    }
    void unite (int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] < rank[b]) {
            par[a] = b;
        } else {
            par[b] = a;
            if (rank[a] == rank[b]) {
                rank[a]++;
            }
        }
    }
};


int main() {
    int n, k, l;
    cin >> n >> k >> l;
    UnionFind road(n), rail(n);
    rep(i, k) {
        int p, q; cin >> p >> q;
        p--; q--;
        road.unite(p, q);
    }
    rep(i, l) {
        int r, s; cin >> r >> s;
        r--; s--;
        rail.unite(r, s);
    }
    map<pair<int, int>, int> nums;
    vector<pair<int, int>> pairs(n);
    rep(i, n) {
        int ro, ra;
        ro = road.root(i);
        ra = rail.root(i);
        pairs[i] = make_pair(ro, ra);
        nums[pairs[i]]++;
    }
    rep(i, n) {
        cout << nums[pairs[i]] << endl;
    }
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
      ll r,c,i,j;
      cin>>r>>c;
      string s;
      vector<char>v[r+2];
      ll x[r+1][c+1];
      for(i=0;i<r;i++){
            cin>>s;
            for(j=0;j<c;j++){
                  v[i].push_back(s[j]);
            }
      }
     // x[0][0]=1;
      for(i=0;i<r;i++){
            for(j=0;j<c;j++){
                  if(i==0 && j==0){x[i][j]=1;}
                  else if(i==0 && v[i][j]=='.'){x[i][j]=x[i][j-1];}
                  else if(i==0){x[i][j]=0;}
                  else if(j==0 && v[i][j]=='.'){x[i][j]=x[i-1][j];}
                  else if(j==0){x[i][j]=0;}
                  else if(v[i][j]=='.'){
                        x[i][j]=x[i][j-1]+x[i-1][j];
                        x[i][j]=x[i][j]%1000000007;
                  }
                  else{
                        x[i][j]=0;
                  }
                  //cout<<x[i][j]<<" ";
            }
           // cout<<"\n";
      }
      cout<<x[r-1][c-1]<<"\n";
}

Measured memory_bytes: 9088
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Scanner;

public class Main{
	static Scanner sc;

	static int[] wordNum;

	public static void main(String[] args) throws Exception {
		//InputStream in = new FileInputStream("src/input.txt");
		InputStream in = System.in;
		//PrintStream out = new PrintStream("src/output.txt");

		//System.setOut(out);

		sc = new Scanner(in);

		wordNum = new int['z'+1];
		int H = sc.nextInt();
		int W = sc.nextInt();

		for(int i = 0; i < H; i++){
			String temp = sc.next();
			for(int j = 0; j < W; j++){
				wordNum[temp.charAt(j)] += 1;
			}
		}

		int wordCount = 0;
		int odd = 0;
		int two = 0;
		int four = 0;
		for(int i = 'a'; i <= 'z'; i++){
			if(wordNum[i] != 0){
				wordCount++;
				//System.out.println(wordNum[i]);

				four += (int)(wordNum[i] / 4);
				two += (int)(wordNum[i] / 2) - (int)(wordNum[i] / 4)*2;
				if(wordNum[i] % 2 == 1){
					odd++;
				}
			}
		}

		int fourNum = (int)(H/2) * (int)(W/2);
		int twoNum  = (int)((H*W - (fourNum*4)) / 2);
		int oddNum  = (H*W)%2;
		//System.out.println(fourNum +"\t"+ twoNum +"\t"+  oddNum + "\t" + four);

		boolean yes = true;
		if(odd >= 2){
			yes = false;
		}else{
			if(four >= fourNum && odd == oddNum){
				yes = true;
			}else{
				yes = false;
			}
		}



/*
		if(odd >= 2){
			yes = false;
		}else if(odd == 1 && H*W%2 == 1 || odd == 0 && H*W%2 == 0){
			yes = true;
		}
*/
		/*
		int[] countDict = new int[wordCount];
		int count = 0;
		for(int i = 'a'; i < 'z'; i++){
			if(wordNum[i] != 0){
				countDict[count] = wordNum[i];
				count++;
			}
		}
		*/
		if(yes){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}


	}
}

Measured memory_bytes: 23252
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
using namespace std;
#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;

ll a[10000];
int main() {
	ll n, l,sum=0,m=1000;
	cin >> n >> l;
	for (int i = 0; i < n; i++) {
		a[i] = i + l;
		sum += a[i];
		if (abs(m) > abs(a[i]))m = a[i];
	}
	cout << sum-m << endl;
	return 0;
}




Measured memory_bytes: 256
def main():
  n = int(input())
  plist = list(map(int, input().split()))
  ans = 0
  for i in range(1, n-1):
    if plist[i-1] < plist[i] < plist[i+1] or plist[i-1] > plist[i] > plist[i+1]:
      ans += 1
  print(ans)


if __name__ == '__main__':
  main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
const int N=1e5;
int solve(int x){
  if(x==1)return 3*N;
  if(x==2)return 2*N;
  if(x==3)return N;
  return 0;
}
int main(){
  int a,b;
  cin>>a>>b;
  int ans=0;
  if(a==1&&b==1)ans=4*N;
  ans+=solve(a)+solve(b);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意
int main(){
  int k,n; string s; cin>>k>>s;
  n=s.length();
  
  if(n<=k)cout<<s<<endl;
else {rep(i,k)cout<<s[i];cout<<"...";}

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef int64_t ll;

void solve() {
    ll n;
    cin >> n;
    unordered_set<string> s;
    for(ll i = 0; i < n; i++) {
        string temp;
        cin >> temp;
        s.emplace(temp);
    }
    cout << s.size();
}    

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

Measured memory_bytes: 17716
#include <iostream>

using namespace std;

void printRectangle(int height, int width) {
    for (int row = 0; row < height; ++row) {
        string line;
        for (int column = 0; column < width; ++column) {
            line += "#";
        }

        cout << line << endl;
    }

    cout << endl;
}

int main() {
    while (true) {
        int height, width;
        cin >> height >> width;

        if (height == 0 && width == 0) break;

        printRectangle(height, width);
    }

    return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
inline int add(int x, int y, int mod) {
   if (x >= mod) x %= mod;
   if (y >= mod) y %= mod;
   x  += y;
   return (x >= mod ? x - mod : x);
} 
inline int mul(int x, int y, int mod) {
  if (x >= mod) x %= mod;
  if (y >= mod) y %= mod;
  return (x*y) % mod;
}
inline int sub(int x, int y, int mod) {
  x -= y;
  if (x + mod <= 0) {
    x %= mod;
  }
  return (x < 0 ? x+mod : x);
}


int PowerMod(int x, int n, int mod) {
  int res = 1;
  for (;n > 0;) {
    if (n & 1) {
      res 	= mul(res, x, mod);
    }
    x = mul(x, x, mod);
    n /= 2;
  }
  return res;
}

int modInverse(int a, int p) {
   
    return PowerMod(a, p-2, p);
}
int modBinomial(int n, int k, int p) {
    int numerator = 1; 
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    int denominator = 1; 
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    return ( numerator* modInverse(denominator,p) ) % p;
}
signed main(){
	IOS;
	int T=1;
// 	cin >> T;
	while(T--){
	    int n ,a,b;
	    cin >> n >>a >>b;
	    int tot = PowerMod(2,n,MOD);
	    tot = sub(tot,1,MOD);
	    int x1 = modBinomial(n,a,MOD);
	    int y1= modBinomial(n,b,MOD);
	    tot = sub(tot,x1,MOD);
	    tot = sub(tot,y1,MOD);
        cout << max(0ll,tot)  << endl;
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int n,h;
cin>>n>>h;
vector<int>a,b;
int sum_b = 0;
for(int i =0;i<n;i++)
{
    int x,y;
    cin>>x>>y;sum_b +=y;
    a.push_back(x);b.push_back(y);
}
sort(a.begin(),a.end());
int a_max = a[n-1];
sort(b.rbegin(),b.rend());
int cnt = 0;
int f = 0;
for(int i =0;i<n;i++)
{
   if(b[i]>=a_max)
   {
        h = h-b[i];
    //cout<<h<<endl;
    cnt++;
    if(h<=0)
    {
        f = 1;
        break;
    }
    else
    {
        f = 0;
    }
   }
   else
   {
       f = 0;
   }
}
if(f == 0)
{
    cnt+= ceil((1.0*(h))/a_max);
}
cout<<cnt;
return 0;
}


Measured memory_bytes: 1276
#include <cstdio>

using namespace std;
const int maxn = 100000 + 233;
int n,k,a[maxn],pos,l,r;
int main(){
	scanf("%d%d",&n,&k);
	if((n - 1) % (k - 1) == 0)printf("%d",(n - 1)/(k - 1));
	else printf("%d",(n - 1) / (k - 1) + 1);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,s,t) for(int i=s ; i<t ; i++)
typedef long long ll;
typedef pair<ll,ll> P;
const int max_n = 1e5;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  int n,m,k;  cin >> n >> m >> k;
  UnionFind fr(n);
  vector<set<int> > d(n);
  rep(i,0,m){
    int x,y;  cin >> x >> y;
    --x;  --y;
    fr.merge(x,y);
    d[x].insert(y);
    d[y].insert(x);
  }
  rep(i,0,k){
    int x,y;  cin >> x >> y;
    --x;  --y;
    if(!fr.issame(x,y)) continue;
    d[x].insert(y);
    d[y].insert(x);
  }
  rep(i,0,n){
    int ans = fr.size(i) - 1 - d[i].size();
    cout << ans << " ";
  }
  cout << endl;
  return 0;

}


Measured memory_bytes: 24704