akhauriyash/Code-Regression huggingface dataset:
// C - Christmas Eve
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = INF;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n >> k;
  vlli d(n), e(n - 1);
  rep(i, 0, n)
  {
    cin >> d[i];
  }
  SORT(d);
  // rep(i, 1, n)
  // {
  //   ans = d[i - 1] - d[i];
  //   e[i - 1] = ans;
  // }
  // // cout << e << endl;
  // b = MAX(e);
  // rep(i, 0, n - 1)
  // {
  //   if (e[i] == e[i + 1])
  //   {
  //     count = e[i] + e[i + 1];
  //   }
  // }
  // cout << count << endl;
  rep(i, 0, n - k + 1)
  {
    ans = d[i + k - 1] - d[i];
    count = min(count, ans);
  }
  cout << count << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1e9 + 7;

struct factorial
{
    vector<ll> fac, finv, inv;

    factorial(int n) : fac(2, 1), finv(2, 1), inv(2, 1)
    {
        int i;

        rep(i, 2, n)
        {
            fac.push_back(fac[i - 1] * i % MOD);
            inv.push_back(MOD - inv[MOD % i] * (MOD / i) % MOD);
            finv.push_back(finv[i - 1] * inv[i] % MOD);
        }
    }

    ll comb(int n, int k)
    {
        if (n < k)
        {
            return 0;
        }

        if (n < 0 || k < 0)
        {
            return 0;
        }

        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    ll perm(int n, int k)
    {
        if (n < k)
        {
            return 0;
        }

        if (n < 0 || k < 0)
        {
            return 0;
        }

        return fac[n] * finv[n - k] % MOD;
    }
};

int main(void)
{
    int N, K;
    ll a[100010];
    int i, j;
    ll ans = 0;

    cin >> N >> K;

    factorial f(N);

    rep(i, 0, N - 1)
    {
        cin >> a[i];
    }

    sort(a, a + N);

    rep(i, 0, N - 1)
    {
        ans += (a[i] * f.comb(i, K - 1)) % MOD;
        ans -= (a[i] * f.comb(N - i - 1, K - 1)) % MOD;
        ans %= MOD;
    }

    cout << ans % MOD << endl;
}

Measured memory_bytes: 3680
s = [list(input()) for _ in range(3)]
i = 0
while len(s[i])!=0:
    get_s = s[i].pop(0)
    if get_s=="a":
        i = 0
    elif get_s=="b":
        i = 1
    else:
        i = 2
player = ["A","B","C"]
print(player[i])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int a,b;

int main(){
	cin >> a >> b;
	if(a <= 8 && b <= 8)cout << "Yay!" << endl;
	else cout << ":(" << endl;
}

Measured memory_bytes: 256
import collections


def main():
    n = input()
    if n[0] == "9":
        if n[1:] == "9" * len(n[1:]):
            print(9 * len(n))
        else:
            print(9 * len(n) - 1)
    else:
        if n[1:] == "9" * len(n[1:]):
            print(int(n[0]) + 9 * len(n[1:]))
        else:
            print(int(n[0]) + 9 * len(n[1:]) - 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9364
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int m, d;
    cin >> m >> d;
    int c = 0;
    for(int i = 4; i <= m; i++){
        for(int j = 22; j <= d; j++){
            int p = j%10;
            int q = j/10;
            if(p >= 2 and q >= 2){
                if(p*q == i)
                    c++;
            }
        }
    }
    cout << c << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define PI pair<int,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)



int32_t main() { 
    boost;
    
	int x,y,z;
	cin>>x>>y>>z;
	swap(x,y);
	swap(x,z);
	cout<<x<<" "<<y<<" "<<z<<endl;
}           

Measured memory_bytes: 256
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

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

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)

int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                x = __gcd(i,j);
                x  =__gcd(x,k);
                y+= x;
            }
        }
    }
    cout<<y<<endl;
    return 0;
}



Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>

using namespace std;

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

	double ans = 0;
	double now = 0;
	long long pt = 0;
	for (int i = 1; i <= n; i++) {
		pt = i;
		now = 1.0;
		while (pt < k) {
			pt *= 2;
			now /= 2.0;
		}
		ans += now / n;
	}

	printf("%.10f\n", ans);

	return 0;
}


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

int main() {
  int a, b ,c ,k,d;
  int ans =0 ;
 
  cin >> a >> b >> c >> k;
  d = max ( a , max ( b,c));
  int e=d ;
  ans =  a + b +c -d;
  for ( int i=0 ; i< k ; i++){
    e*=2 ;
  }
       ans +=e;
       cout << ans << endl;
}

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

using namespace std;

int main()
{
	string str;
	cin >> str;

	int number_of_instruction;
	cin >> number_of_instruction;

	for (int i = 0; i < number_of_instruction; ++i)
	{
		string instruction;
		int param1, param2;
		string temp_str = "";
		string replace_str = "";
		cin >> instruction >> param1 >> param2;

		if (instruction == "print")
		{
			for (int i = param1; i <= param2 ; ++i)
			{
				temp_str += str[i];
			}
			cout << temp_str << endl;
		}

		if(instruction == "reverse")
		{
			for (int i = 0; i < param1; ++i)
			{
				temp_str += str[i];
			}
			for (int i = param2; i >= param1; --i)
			{
				temp_str += str[i];
			}
			for (int i = param2+1; i < str.size(); ++i)
			{
				temp_str += str[i];
			}
			str = temp_str;
		}

		if(instruction == "replace")
		{
			string replace_str;
			cin >> replace_str;
			str.replace(param1, param2 - param1 + 1, replace_str);
		}

	}
}

Measured memory_bytes: 1220
# coding: utf-8
# Your code here!

class Sch:
    def __init__(self, m, t):
        self.m = m
        self.t = t
        
    def __lt__(self,other):
        if self.t == other.t:
            return self.m < other.m
        else:
            return self.t < other.t
        

while True:
    N = int(input())
    if N == 0:
        break
    
    schedule = []
    for l in range(N):
        m,a,b = [int(i) for i in input().split()]
        schedule.append(Sch(m,a))
        schedule.append(Sch(-m,b))

    schedule.sort()
    
    M = 0
    ans = "OK"
    for i in range(len(schedule)):
        M = M + schedule[i].m
        if M > 150:
            ans = "NG"
            break
    
    print(ans)
    





Measured memory_bytes: 5624
#include<cstdio>
#include<iostream>
#include<cstring>

using namespace std;

const int maxn=200010;
long long int a[maxn];
long long int s[maxn],xo[maxn];

int main()
{
	long long int n;
	scanf("%lld",&n);
	long long int ans=0;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		s[i]=s[i-1]+a[i];
		xo[i]=xo[i-1]^a[i];
	}
	int l=1;
	for(int r=1;r<=n;r++){
		while(s[r]-s[l-1]!=(xo[r]^xo[l-1])&&l<=r)
			l++;
		ans+=r-l+1;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4992
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n;
	cin >> n;
	vector<int>arr(n);
	rep(i, n)cin >> arr[i];
	int cnt = 0;
	REP(i, n)if (i != arr[i-1])cnt++;
	if (cnt == 0 || cnt == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}

string s;

bool palin(int l, int r) {
    while(l < r) {
        if(s[l] != s[r]) {return false;}
        l ++;
        r --;
    }
    return true;
}

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> s;
    int n = s.size();
    if(palin(0, n - 1) && palin(0, (n / 2) - 1) && palin(n / 2 + 1, n - 1)) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}




Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    int n; cin>>n;
    vector<tuple<double, double, double>> points;
    for(int i=0; i<n; i++){
        double x, y; cin>>x>>y;
        double theta = atan2(y, x);
        points.emplace_back(theta, y, x);
        points.emplace_back(theta + 2 * pi, y, x);
    }

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

    double ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i; j<2*n && j<i+n; j++){
            double sumy = 0, sumx = 0;
            for(int k=i; k<=j; k++){
                double theta, y, x;
                tie(theta, y, x) = points[k];

                sumy += y;
                sumx += x;
            }

            double dist = sqrt(sumx * sumx + sumy * sumy);
            chmax(ans, dist);
        }
    }

    printf("%.12f\n", ans);
}

Measured memory_bytes: 512
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

void main(){
    int e, rest, ans;

    while (true) {
        e = readln.chomp.to!int;

        if (!e) break;

        ans = 1<<30;

        for(int z = 0; z^^3 <= e; ++z) {
            rest = e - z^^3;
            for(int y = 0; y^^2 <= rest; ++y) {
                int x = rest - y^^2;

                ans = min(ans, x + y + z);
            }
        }

        writeln(ans);
    }
}

Measured memory_bytes: 2760
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;

int main(){
    int n;
    string s;
    cin >> n >> s;
    
    int smin = 0;
    int cur = 0;
    int num = 0;
    rep(i, n){
        if(s[i] == '(') ++cur;
        else --cur, ++num;
        smin = min(smin, cur);
    }
    
    string ans = "";
    rep(i, -smin) ans += "(";
    ans += s;
    rep(i, n-2*num-smin) ans += ")";
    
    cout << ans << "\n";
}

Measured memory_bytes: 256
# D

from collections import deque
S = deque(input())
Q = int(input())

#q = []
#for _ in range(Q):
#  q += [input().split(" ")]

hc = 0

for i in range(Q):
  #qi = q[i]
  qi = input().split(" ")
  if len(qi)==1:
    #S = S[::-1]
    if hc==0:
      hc = 1
    else:
      hc = 0
  else:
    fi = int(qi[1])
    ci = qi[2]
    if hc ==0:
      if fi==1:
        S.appendleft(ci)
      else:
        S.append(ci)
    else:
      if fi==1:
        S.append(ci)
      else:
        S.appendleft(ci)

S = list(S)
if hc == 1:
  S = S[::-1]
print("".join(S))

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

int main() {
    int y,m,d;
    char s1,s2;
    cin >> y >> s1 >> m >> s2 >> d;
    if(y <= 2018) {
        cout << "Heisei" << endl;
    }
    else if(y == 2019 && m < 4) {
        cout << "Heisei" << endl;
    }
    else if(y == 2019 && m == 4 && d <= 30) {
        cout << "Heisei" << endl;
    }
    else cout << "TBD" << endl;
}

Measured memory_bytes: 256
import numpy as np
d=int(input())
c=list(map(int,input().split()))
TotalLoss=sum(c)
for i in range(26):
  c[i]=TotalLoss-c[i]
c=np.array(c)
s=[]
for i in range(d):
  si=list(map(int,input().split()))
  s.append(si)
s=np.array(s)
s-=c
ans=[]
for i in range(d):
  si=s[i]
  index=np.argmax(si)
  ans.append(index+1)
for i in range(d):
  print(ans[i])

Measured memory_bytes: 27388
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
	cin>>n;
	long long *a = new long long[n];
	for(int i=0;i<n;i++) cin>>a[i];
  
	long long amount=1000;
  
	for(int i=0;i<n;i++){
		int j=i+1;
		while(j<n && a[j]>=a[j-1]) j++;
		j--;
		long long diff=a[j]-a[i];
		if(diff<=0){
			i=j;
			continue;
		}
		long long no_buy =amount/a[i];
		long long remain =amount%a[i];
		long long profit =(a[j])*no_buy;
		amount=remain+profit;
		i=j;
	}
	cout<<max(amount,(long long)1000)<<endl;
}

Measured memory_bytes: 3636
def solve(w,h):
	if 0 <= w < W and 0 <= h < H and tile[h][w] == ".":
		tile[h][w] = 0
		solve(w+1,h); solve(w,h+1); solve(w-1,h); solve(w,h-1)
while 1:
	W,H = map(int,raw_input().split())
	if W == 0: break
	tile = [list(raw_input()) for i in range(H)]
	for h in range(H):
		try:
			sw = tile[h].index("@")
			sh = h
			tile[sh][sw] = "."
			break
		except:
			pass
	solve(sw,sh)
	print sum(tile[h].count(0) for h in range(H))

Measured memory_bytes: 4464
a_1 = list(map(int,input().split()))
a_2 = list(map(int,input().split()))
a_3 = list(map(int,input().split()))
a = [a_1,a_2,a_3]
n = int(input())
for i in range(n):
  h = int(input())
  for j in range(3):
    for k in range(3):
      if(a[j][k]==h):
        a[j][k]=0
ans = "No"
for i in range(3):
  if(a[i][0]==0)and(a[i][0]==a[i][1])and(a[i][1]==a[i][2]):
    ans = "Yes"
for i in range(3):
  if(a[0][i]==0)and(a[0][i]==a[1][i])and(a[1][i]==a[2][i]):
    ans= "Yes"
if((a[0][0]==0)and(a[1][1]==a[2][2])and(a[0][0]==a[1][1]))or((a[0][2]==0)and(a[1][1]==a[2][0])and(a[0][2]==a[1][1])):
  ans = "Yes"
  
print(ans)
    
    


Measured memory_bytes: 9292
try:
    N = int(input())
    if N>=1 and N<=100:
        a = input().split()
        counter=0
        for i in range(0,len(a)):
            if (i+1)%2 != 0 and int(a[i])%2!=0:
                counter+=1
        print(counter)
except Exception as e:
    print(e)

Measured memory_bytes: 9184
#include "bits/stdc++.h"

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? " " : "");
  outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? "\n" : "");
  outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
  return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
  return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

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

  var(int, a, b);
  outl((a - 1) * (b - 1));

  return 0;
}


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

vector<int> msnums;

void make();
void solve(int n);
bool check(int n);

int main(int argc, char const *argv[]){
    int msnum;
    make();
    while(1){
        cin>>msnum;
        if (msnum == 1) break;
        solve(msnum);
    }
    return 0;
}

void make(){
    const int max = 300000;
    for (int i = 2; i < max; i++){
        int var = i % 7;
        if (var == 1 || var == 6){
            msnums.push_back(i);
        }
    }
}

void solve(int n){
    vector<int> prime;
    for (const auto& it : msnums){
        if (n % it == 0){
            if(check(it)) prime.push_back(it);
        }
    }
    cout<<n<<":";
    for ( const auto& it : prime){
        cout<<" "<<it;
    }
    cout<<'\n';
}

bool check(int n){
    for (const auto& it : msnums){
        if (it==n) break;
        if (n % it == 0) return false;
    }
    return true;
}

Measured memory_bytes: 3312
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;

int N, M, nonzero[256];
vector< char > list;
vector< string > s;
int conv[256], leftConv[256], rightConv[256];


int check() {
    int left = 0, right = 0;
    for(int i = 0; i < N; i++) {
        string num;
        for(int j = 0; j < s[i].size(); j++) {
            num.push_back(conv[s[i][j]] + '0');
        }
        //cout << num << endl;
        if(num[0] == '0' && num.size() != 1) return 0;
        else if(i == N - 1) {
            right = atoi(num.c_str());
        }
        else {
            left += atoi(num.c_str());
        }
    }
    //cout << left << " " << right << endl;
    if(right == left) return 1;
    else return 0;
}

int sum = 0;
int rec(int idx, int used) {

    ///cout << sum << endl;
    if(idx == M) {
        return sum == 0;
    }

    int ret = 0;
    for(int i = 0; i <= 9; i++) {
        if(nonzero[list[idx]] && i == 0) continue;
        if(used >> i & 1) {
            sum += (rightConv[list[idx]] * i) - (leftConv[list[idx]] * i);
            ret += rec(idx + 1, used & ~(1 << i));
            sum -= (rightConv[list[idx]] * i) - (leftConv[list[idx]] * i);
        }
    }

    return ret;
}

int main() {

    while(cin >> N, N) {
        memset(nonzero, 0, sizeof(nonzero));
        memset(conv, 0, sizeof(conv));
        memset(leftConv, 0, sizeof(leftConv));
        memset(rightConv, 0, sizeof(rightConv));
        for(int i = 0; i < N; i++) {
            string str; cin >> str;
            if(str.size() != 1) {
                nonzero[str[0]] = 1;
            }
            for(int j = 0; j < str.size(); j++) {
                list.push_back(str[j]);
                if(i < N - 1) {
                    leftConv[str[j]] += pow(10, (str.size() - j - 1));
                } else {
                    rightConv[str[j]] += pow(10, (str.size() - j - 1));
                }
            }
            s.push_back(str);
        }

        sort(list.begin(), list.end());
        list.erase(unique(list.begin(), list.end()), list.end());
        M = list.size();

        cout << rec(0, (1 << 10) - 1) << endl;
        list.clear();
        s.clear();
    }
}

Measured memory_bytes: 3312
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.range;

void main() {
	auto N = readln.chomp.to!int;
	auto a = readln.split.to!(int[]);
	sort(a);
	writeln(a[$-1] - a[0]);
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  int sum = 0;
  int t[n];
  for(int i = 0; i < n; i++) {
    cin >> t[i];
    sum += t[i];
  }
  int m; cin >> m;
  int p[m], x[m];
  int ans;
  for(int i = 0; i < m; i++) {
    cin >> p[i] >> x[i];
  }
  for(int i = 0; i < m; i++) {
    ans = sum;
    ans += x[i] - t[p[i]-1];
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int n, m; cin >> n >> m;
    vector<pair<int, int>> ab;
    rep(i, n) {
        int a, b; cin >> a >> b;
        ab.emplace_back(a, b);
    }
    sort(ab.begin(), ab.end());
    
    int ans = 0;
    priority_queue<int> pq;
    int cur = 0;

    reprev(i, m) {
        while(cur<n && i+ab[cur].first<=m) { pq.push(ab[cur++].second); }
        if (pq.size()) { ans += pq.top(); pq.pop(); }
    }

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




Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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 gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    string S;
    cin >>S;
    if(S[4]==S[5] && S[2]==S[3]){
        cout << "Yes" << endl;

    }else{
        cout << "No" << endl;
    }
    

    return 0;
    

}

Measured memory_bytes: 3628
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
    int n,q;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    cin>>q;
    int tp1,a,b;
    while(q--){
        cin>>a>>b>>tp1;
        cout<<count(&v[a],&v[b],tp1)<<"\n";
    }

}
//list<int> lit;
//list<int>::iterator it;
//int main()
//{
//    lit.clear();
//    int t,tp,a;
//    it=lit.begin();
//    cin>>t;
//    while(t--){
//        cin>>tp;
//        switch(tp){
//        case 0:
//            cin>>a;
//            lit.insert(it,a);
//            break;
//    case 1:
//            cin>>a;
//            if(a<0){
//                while(a++){
//                    if(it!=lit.end())it++;
//                }
//            }
//            else if(a>0){
//                while(a--){
//                    if(it!=lit.begin())it--;
//                }
//            }
//        break;
//    case 2:
//        lit.erase(--it);
//        break;
//        }
//    }
//    lit.reverse();
//    for(it=lit.begin();it!=lit.end();it++){
//
//        cout<<*it<<"\n";
//    }
//}



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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

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

    char prev=S[0];
    lint cnt=0;
    for(int i=1;i<S.size();i++){
        if(S[i]!=prev) cnt++;
        prev=S[i];
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int w, n;
	int a[31];
	cin >> w >> n;
	for (int i = 1; i <= w; i++){
		a[i] = i;
	}
	int x, y;
	char t;
	for (int i = 0; i < n; i++){
		cin >> x >> t >> y;
		swap(a[x], a[y]);
	}
	for (int i = 1; i <= w; i++){
		cout << a[i] << endl;
	}
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

struct UnionFind {
    vector<int> parent;
    vector<int> rank;
    UnionFind() {}
    UnionFind(int size) { init(size); }
    void init(int size) {
        parent.assign(size, -1);
        rank.assign(size, 0);
    }
    int operator[](int x) { return find(x); }
    int find(int x) { return parent[x] < 0 ? x : (parent[x] = find(parent[x])); }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -parent[find(x)]; }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        rank[x] = max(rank[x], rank[y] + 1);
        parent[x] += parent[y];
        parent[y] = x;
        return true;
    }
    bool uniteByRank(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        else if (rank[x] < rank[y]) swap(x, y);
        else if (rank[x] == rank[y]) ++rank[x];
        parent[x] += parent[y];
        parent[y] = x;
        return true;
    }
    bool uniteBySize(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        else if (size(x) < size(y)) swap(x, y);
        rank[x] = max(rank[x], rank[y] + 1);
        parent[x] += parent[y];
        parent[y] = x;
        return true;
    }
};

int N, M;


int main() {
    cin >> N >> M;
    UnionFind uf(N);

    rep(i, M) {
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;

        uf.uniteByRank(x, y);
    }

    int ans = 0;
    set<int> s;
    rep(i, N) {
        int p = uf.find(i);
        if (s.find(p) == s.end()) {
            ans++;
            s.insert(p);
        }
    }
    write(ans);
}

Measured memory_bytes: 5760
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#define MOD 10000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define revrep(i,n) for(ll i=n;i>0;i--)

typedef long long ll;

ll fac[100001], inv[100001];

ll mygcd(ll a, ll b) { if (b == 0) return a; return mygcd(b, a % b); }

ll mylcm(ll a, ll b) { return a / mygcd(a, b) * b; }

ll mymax(ll a, ll b) { return (a > b) ? a : b; }

ll mymin(ll a, ll b) { return (a < b) ? a : b; }

int myasc(const void* a, const void* b) { return *(ll*)a - *(ll*)b; }

int mydsc(const void* a, const void* b) { return *(ll*)b - *(ll*)a; }

ll mypow(ll a, ll b) {
	ll x;
	if (b == 0) return 1;
	else if (b % 2 == 1) return a * mypow(a, b - 1) % MOD;
	x = mypow(a, b / 2);
	return x * x % MOD;
}

ll mycomb(ll a, ll b) {
	if (a < b || a < 0 || b < 0)return 0;
	return fac[a] * inv[a - b] * inv[b] % MOD;
}

int main() {
	ll n, k,a,flag;
	scanf("%lld%lld", &n, &k);
	
	printf("%lld", (n+k-3)/(k-1));

	return 0;
}

Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define rep(i,a,b) for (rg int i=a;i<=b;i++)
#define per(i,a,b) for (rg int i=b;i>=a;i--)
#define pb push_back
#define lowbit(x) (x&(-x))
#define mk make_pair
#define VI vector<int>
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define fi first
#define se second
#define il inline
#define ll long long
#define db double
#define ld long double
#define inf 0x3f3f3f3f3f
#define getc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<15,stdin),p1==p2)?EOF:*p1++)
char buf[1<<15],*p1 = buf,*p2 = buf;
inline ll read(){
    #define num ch-'0'
    char ch;bool flag=0;ll res;
    while(!isdigit(ch=getc()))
    (ch=='-')&&(flag=true);
    for(res=num;isdigit(ch=getc());res=res*10ll+num);
    (flag)&&(res=-res);
    #undef num
    return res;
}
inline void write(ll x){
	if (x < 0) x = ~x + 1ll, putchar('-');
	if (x > 9) write(x / 10ll);
	putchar(x % 10ll + '0');
}
#define mid ((l + r)>>1)
#define ls (x<<1)
#define rs ((x<<1)|1)
#undef mid
#undef ls
#undef rs
#define maxn 310
ll d[maxn][maxn];
ll a[maxn][maxn];
void solve()
{
	int n = read(),m = read();
	ll l = read();
	rep(i,1,n) rep(j,1,n) d[i][j] = (i == j) ? 0:inf;
	rep(i,1,m)
	{
		int x = read(),y = read();
		ll z = read();
		if(z <= l) d[x][y] = d[y][x] = min(d[x][y],z);
	}
	rep(k,1,n)
	{
		rep(i,1,n)
		{
			rep(j,1,n)
			{
				d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
			}
		}
	}
	rep(i,1,n)
	{
		rep(j,1,n)
		{
			a[i][j] = (d[i][j] <=l)?1:inf;
			if(i == j) a[i][j] = 0;
		}
	}
	rep(k,1,n)
	{
		rep(i,1,n)
		{
			rep(j,1,n)
			{
				a[i][j] = min(a[i][j],a[i][k] + a[k][j]);
			}
		}
	}
	int q = read();
	while(q--)
	{
		int s = read(),t = read();
		cout<<((a[s][t]>=inf)?-1:a[s][t]-1)<<endl;
	}
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("data.txt","r",stdin);
	#endif
//	int T = read();
//	while(T--)
	solve();
}

Measured memory_bytes: 5112
import sys


def main():
  input = sys.stdin.readline
  n = int(input())
  a_li = list(input().split())
  a_li = [int(s) for s in a_li]

  a_li.sort()
  for i in range(n-1):
    if a_li[i] == a_li[i+1]:
      print("NO")
      sys.exit()
  print("YES")
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 25244
#include<stdio.h>
int main(void)
{
    int a,b,c,n=-1,x=-1,q=-1;
    while(n+x!=0){
        while(n+x>0){
            for(a=1;a<=n-2;a++){
                for(b=a+1;b<=n-1;b++){
                    for(c=b+1;c<=n;c++){
                        if(a+b+c==x){
                            q++;
                        }
                    }
                }
            }
            n=0;
            x=0;
        }
        if(q>-1){
            printf("%d\n",q);
        }
        q=0;
        scanf("%d%d",&n,&x);
    }
    return 0;
}


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

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

    ll n, m;
    cin >> n >> m;

    ll c_cnt = m / 2;
    ll s_cnt = n;

    ll sa = c_cnt - s_cnt;

    if(sa <= 0) {
        cout << c_cnt << endl;
        return 0;
    }
    else {
        ll ans = s_cnt + (sa / 2);
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 3616
n = int(input())
a = list(map(int, input().split()))

sa = [0 for _ in range(n+1)]
for i in range(n):
    sa[i+1] = sa[i] + a[i]

sa.sort()
ans = 0
tmp = - 10 ** 10
cnt = 1
for i in range(n+1):
    if sa[i] == tmp:
        cnt += 1
    else:
        ans += cnt * (cnt - 1) // 2
        tmp = sa[i]
        cnt = 1

ans += cnt * (cnt - 1) // 2

print(ans)

Measured memory_bytes: 26136
#include <iostream>

using namespace std;
int touhi(int num) {
	int sum=0;
	for (int i = 1; i <= num; i++) {
		sum += i;
	}
	return sum;
}
int main() {
	int i, j;
	int a, b;
	int dif;

	cin >> a >> b;
	dif = b - a;

	i = 1;
	while (1) {
		if (touhi(i + 1) - touhi(i) == dif)break;
		i++;
	}

	cout << touhi(i) - a << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
typedef long long ll;
typedef pair<int, int> P;
const int INF=1e7;

bool graph[8];
bool pass[8][8];
int N,M;
int ans;
int dfs(int num,int cnt) {
	if (cnt == N-1)return 1;
		FOR(k, 0, 8) {
			if (pass[num][k] == true && graph[k] == false) {
				graph[k] = true; 
				
				ans += dfs(k, cnt+1);
				graph[k] = false;
			}
		}
		return 0;
}

int main(void)
{
	cin >> N >> M;
	FOR(i, 0, M) {
		int a, b;
		cin >> a >> b;
		graph[0] = true;
		pass[a - 1][b - 1] = pass[b - 1][a - 1] = true;
	}
	dfs(0,0);
	ct(ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double pi = Math.PI;
		double area = r * r * pi;
		double length = 2 * r * pi;
		System.out.printf("%f %f", area, length);
	}
}


Measured memory_bytes: 28156
#include<bits/stdc++.h>
using namespace std;
#define fr(i,n) for(int i=0;i<(n);++i)
#define foor(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,n) for(int i=(n);i--;)
#define roof(i,b,a) for(int i=(b);i>=(a);--i)
#define all(x) x.begin(),x.end()
#define Sort(x) sort(all(x))
#define PQ priority_queue
#define print(x) cout<<(x)<<"\n"
typedef long long ll;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int>pli;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<pii>vpii;
typedef vector<pll>vpll;
typedef vector<pli>vpli;
typedef map<int,int>mii;
typedef map<ll,ll>mll;
template<typename T>vector<T>&operator<<(vector<T>&v,const T t){v.push_back(t);return v;}
template<typename T>multiset<T>&operator<<(multiset<T>&m,const T t){m.insert(t);return m;}
template<typename T>set<T>&operator<<(set<T>&s,const T t){s.insert(t);return s;}
template<typename T,typename U>PQ<T,vector<T>,U>&operator<<(PQ<T,vector<T>,U>&q,const T t){q.push(t);return q;}
template<typename T,typename U>istream&operator>>(istream&s,pair<T,U>&p){return s>>p.first>>p.second;}
template<typename T>istream&operator>>(istream&s,vector<T>&v){fr(i,v.size()){s>>v[i];}return s;}
template<typename T,typename U>ostream&operator<<(ostream&s,const pair<T,U>p){return s<<p.first<<" "<<p.second;}
template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto a:v){s<<a<<endl;}return s;}
vpli dijkstra(const int N,const vpli E[],const int s,const ll inf){vpli d;fr(i,N)d<<pli{inf,i};d[s].first=0;PQ<pli,vpli,greater<pli>>pq;pq<<(d[s]=pli{0,s});while(pq.size()){pli a=pq.top();pq.pop();int v=a.second;if(d[v].first>=a.first){for(pli e:E[v]){if(d[v].first+e.first<d[e.second].first){d[e.second]=pli{d[v].first+e.first,v};pq<<pli{d[v].first+e.first,e.second};}}}}return d;}
ll gcd(ll a,ll b){return a?gcd(b%a,a):b;}

char S[601][601];
ll yoko[601][601],tate[601][601];
const ll M=1e9+7,B=123457;
main(){cin.tie(0);ios::sync_with_stdio(false);
	int N;
	scanf("%d\n",&N);
	fr(y,N){
		fr(x,N){
			S[y+N][x+N]=S[y+N][x]=S[y][x+N]=S[y][x]=getchar();
		}
		getchar();
	}
	fr(y,N*2){
		ll h=0;
		fr(x,N*2){
			h=yoko[y][x]=(h*B%M+S[y][x])%M;
		}
	}
	fr(x,N*2){
		ll h=0;
		fr(y,N*2){
			h=tate[y][x]=(h*B%M+S[y][x])%M;
		}
	}
	ll p=1;
	fr(i,N){p=p*B%M;}
	ll z=N;
	fr(y,N){
		fr(i,N){
			if(
				(yoko[y+i][N]-yoko[y+i][0]*p%M+M)%M
				!=
				(tate[y+N][i]-tate[y][i]*p%M+M)%M
			){
				--z;
				break;
			}
		}
	}
	print(z*N);
}


Measured memory_bytes: 6272
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

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

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

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

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

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

func main() {
	defer stdout.Flush()
	m := int64(2019)
	L := readInt64()
	R := readInt64()

	if m <= (R - L + 1) {
		println(0)
		return
	}

	var ans int64 = m
	for i := L; i <= R; i++ {
		for j := i + 1; j <= R; j++ {
			ans = min64(ans, (i*j)%m)
		}
	}
	println(ans)
}

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


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int cnt = 0;
    if(s[0]=='R' || s[1] == 'R' || s[2] == 'R') cnt = 1;
    if(s[0]=='R'&& s[1]=='R' || s[2]=='R'&& s[1]=='R') cnt = 2;
    if(s[0]=='R'&& s[1]=='R'&& s[2]=='R') cnt = 3;
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3648
n=int(input())
br=[]
re=[]
for i in range(n):
    s=input()
    br.append(s)

m=int(input())
for i in range(m):
    t=input()
    re.append(t)
count=[0]
for i in range(n):
    brcou=0
    for j in range(n):
        if br[i]==br[j]:
            brcou+=1
    for k in range(m):
        if br[i]==re[k]:
            brcou-=1
    count.append(brcou)
print(max(count))


Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
	char a[6]={'A','B','C','D','E','F'};
	char  b,c;int b1=0,c1=0;
	b=getchar();
	char d=getchar();
	c=getchar();
	for(int i=0;i<6;i++)
	{
		if(a[i]==b)
			b1=i+10;
		if(a[i]==c)
			c1=i+10;	
	}
	if(b1<c1)
	{
		printf("<\n");
	}
	if(b1>c1)
	{
		printf(">\n");
	}
		if(b1==c1)
	{
		printf("=\n");
	}
	
	return 0;
 } 

Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()

t = [0] * (n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] == 'AC' else 0)

for i in range(q):
    l, r = map(int, input().split())
    print(t[r-1]-t[l-1])

Measured memory_bytes: 7748
// ABC 160-B
// 2020.3.28 bal4u

#include <stdio.h>

typedef long long ll;

int main()
{
	int X;
	ll ans;

	scanf("%d", &X);
	ans = (ll)1000 * (X/500);
	X %= 500;
	ans += 5* (X/5);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    int a,n,i,min = 1000000,max = -1000000;
    long int sum = 0;
    scanf("%d",&n);
    for(i = 0;i < n; i++){
        scanf("%d",&a);
        sum+=a;
        if(min > a)
            min=a;
        if(max < a)
            max=a;
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;

int main() {
    int a,b;
    cin >> a >>b;
    int cnt = 0;
    for(int i =a;i<=b;++i){
        string s = to_string(i);
        if(s[4]==s[0]&&s[3]==s[1]){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
   int x, a, b;
   cin >> x >> a >> b;
   if(a >= b){
      cout << "delicious" << endl;
   }else{
      if(a + x >= b){
         cout << "safe" << endl;
      }else{
         cout << "dangerous" << endl;
      }
   }
}

Measured memory_bytes: 3652