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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::vector<int64_t> a(3);
  std::cin >> a;
  std::sort(a.begin(), a.end());
  if (a[0] + a[1] == a[2]) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(float,input().split()))
dp = [[0 for i in range(n+1)] for j in range(n+1)]
dp[0][0] = 1
for i in range(1,n+1):
  for j in range(n+1):
    if j == 0:
      dp[i][j] = dp[i-1][j]*(1-a[i-1])
    else:
      dp[i][j] = dp[i-1][j-1]*a[i-1]+dp[i-1][j]*(1-a[i-1])
print(sum(dp[-1][n//2+1:]))

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

typedef long long ll;

const ll mod=1e9+7;
const int maxn=2e5+5;

int main(){
	int n;
	scanf("%d",&n);
	int ans=1;
	for(int i=1;i<=3;i++){
		ans*=n;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int count=0;
	if(n<105)
	{cout<<0<<endl;return 0;}
	for(int i=105;i<=n;i+=2)
	{
		int num=0;
		for(int j=1;j<sqrt(i);j++)
			if(j%2==1&&i%j==0)
			{
				num++;
				if(i/j%2==1)
				num++;
			}
		if(num==8)
			count++;
	}
	cout<<count<<endl;
	return 0;
}

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

int main( int argc, char *argv[] )
{
int r;
int g;
int b;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> r;
	cin >> g;
	cin >> b;
	if( ( g * 10 + b ) % 4 == 0 )
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

ll calcNumOfCombination(ll n, ll r){
  mint num(1);
  for(ll i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num.x;
}

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

  ll n, a, b;
  cin >> n >> a >> b;

  mint ans(2l);
  ans = ans.pow(n);
  ans -= 1;


  ans -= calcNumOfCombination(n, a);
  ans -= calcNumOfCombination(n, b);

  cout << ans.x << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

class Myclass
{
	long a, b;

public:
	void Get_Num();
	void Compare();
};

void Myclass::Get_Num()
{
	cin >> a;
	cin >> b;

	Compare();
}

void Myclass::Compare()
{
	if( ( -1000 <= a && a <= 1000 ) && ( -1000  <= b && b <= 1000 ) )
	{
		if( a < b )
		{
			cout << "a < b" << endl;
		}else
		if( a > b )
		{
			cout << "a > b" << endl;
		}else
		if( a == b )
		{
			cout << "a == b" << endl;
		}
	}
}

int main()
{
	Myclass mc;
	
	mc.Get_Num();

	return 0;
}

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
  //input
  int a;
  cin >> a;
  int b;
  cin >> b;
  int t;
  cin >> t;

  int num = t / a;


  //solve
  int ans = num * b;
  

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " = " << x << ", ";
#define ll long long
#define pb push_back
using namespace std;
#define FAST_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
const int MOD = 2 * (1e9 + 7);
long double dp[3003][3003] = {};
int main()
{
    FAST_IO
    int n;
    cin >> n;
    vector<long double> a(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> a[i];

    dp[0][0] = 1;
    // dp[0][1] = 1;
    // dp[0][2] = 1;
    // dp[0][3] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            dp[i][j] = dp[i - 1][j] * (1.00000 - a[i]);
            if (j > 0)
            dp[i][j] += dp[i - 1][j - 1] * a[i];
        }
    }
    // for (int i = 0; i <= n; i++)
    // {
    //     for (int j = 0; j <= n; j++)
    //     {
    //         // if (j > n - j)
    //         cout << fixed << setprecision(5) << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    long double ans = 0;
    for (int i = 0; i <= n; i++)
    {
        if (i > n - i)
        {
            ans += dp[n][i];
        }
    }
    cout << fixed << setprecision(15) << ans << '\n';
}

Measured memory_bytes: 139264
#include <iostream>

using namespace std;

int64_t way[100001];
bool broken[100001] = {false};

int64_t add(int64_t a, int64_t b){
	int64_t tmp = a+b;
	return (a+b)%1000000007;
}

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

	for(int i = 0; i < m; ++i){
		int tmp;
		cin >> tmp;
		broken[tmp] = true;
	}

	way[0] = 1;
	if(broken[1]){
		way[1] = 0;
	}else{
		way[1] = 1;
	}

	if(n == 1){
		cout << way[1] << endl;
	}else{
		for(int i = 2; i <= n; ++i){
			if(broken[i]){
				way[i] = 0;
			}else{
				way[i] = add(way[i-1], way[i-2]);
//				way[i] = way[i-1] + way[i-2];
//				way[i] %= 1000000007;		
			}
		}
		cout << way[n] << endl;
	}

	return 0;

}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
double  N,D;
  cin >> N >> D;
  int result = 0;
  long long A,B;
  for(int a = 0;a < N;a++){
    cin >> A >> B;
   if(D * D >= A * A + B * B) result++;
    
    
  }
  cout << result << endl;
}

Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int A[200001];
int cnt[2020];

int main() {
	cin.tie(0);
	cout.tie(0);

	ios::sync_with_stdio(false);


	string S;
	cin >> S;
	int n = S.length();
	int ten = 1;
	for (int i = 1; i <=n; i++) {
		int cur = S[n - i] - '0';
		A[i] = (A[i - 1] + cur * ten)%2019;
		ten = (ten * 10) % 2019;

	}
	FOR(i, 0, n + 1) {
		cnt[A[i]]++;
	}

	int ans = 0;

	FOR(i, 0, 2019) {
		ans+=((cnt[i] * (cnt[i] - 1)) / 2);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

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

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

bool is_operand(char c) {
  if(c == '+' || c == '*' || c == '^') return true;
  else return false;
}

int to_number(char num, int a, int b, int c, int d){
  if(num == 'a') return a;
  else if(num == 'b') return b;
  else if(num == 'c') return c;
  else if(num == 'd') return d;
}

int calc(int x, int y, char ope) {
  if(ope == '+') return x | y;
  else if(ope == '*') return x & y;
  else if(ope == '^') return x ^ y;
}

int simulate(string S, int _a, int _b, int _c, int _d) {
  stack<int> stk;
  
  for(int i = 0; i < S.size(); i++) {
    char c = S[i];
    if('a' <= c && c <= 'd') stk.push(to_number(c, _a, _b, _c, _d));
    else if(is_operand(c)) {
      int x = stk.top(); stk.pop();
      int y = stk.top(); stk.pop();
      stk.push(calc(x, y, c));
    }
  }
  return stk.top();
}

void solve(string S, string P) {
  int hash_number = simulate(S, P[0] - '0', P[1] - '0', P[2] - '0', P[3] - '0');

  int hash_count = 0;
  for(int a = 0; a < 10; a++) {
    for(int b = 0; b < 10; b++) {
      for(int c = 0; c < 10; c++) {
	for(int d = 0; d < 10; d++) {
	  if(hash_number == simulate(S, a, b, c, d)) hash_count++;
	}
      }
    }
  }
  cout << hash_number << " " << hash_count << endl;
}

int main(){
  string S, P;
  while(cin >> S, S != ".") {
    cin >> P;
    reverse(all(S));
    solve(S, P);
  }
  return 0;
}



Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<vector>
#include<cmath>
#define maxn 5007 
#define ll long long  
using namespace std;
ll a,b; 
inline ll read()
{
	ll x = 0;
	ll flag = 1;
	char ch;
	ch = getchar();
	while(!isdigit(ch)) 
	{
		if(ch == '-') flag = -1;
	ch = getchar();
	} 
	while(isdigit(ch))
	{
		x = (x<<1) + (x<<3) + ch - 48;
		ch = getchar();
	}
	return x * flag;
}


int main()
{
	a = read();
	b = read();
	if(a == 1 || b == 1) 
	{
		printf("1\n");
		return 0;
	 } 
	ll sum = a * b;
	ll ans = sum / 2;
	if(sum % 2 == 1) ans++;
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9 + 7;

int dp[100010][13];

signed main(){
    string s;
    cin >> s;
    dp[0][0] = 1;
    for(int i = 0; i < s.size(); i++){
        for(int j = 0; j < 13; j++){
            if(s[i] == '?'){
                for(int k = 0; k < 10; k++){
                    (dp[i + 1][(j * 10 + k) % 13] += dp[i][j]) %= mod;
                }
            }else{
                (dp[i + 1][(j * 10 + (s[i] - '0')) % 13] += dp[i][j]) %= mod;
            }
        }
    }
    cout << dp[s.size()][5] << endl;
}

Measured memory_bytes: 10624
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int h=sc.nextInt();
            int w=sc.nextInt();
            if(h==0&&w==0) break;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(i%2==j%2) System.out.printf("#");
                    else System.out.printf(".");
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 61580
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
	ll k, a, b;
	cin >> k >> a >> b;
	if (b - a < 2) {
		cout << 1 + k;
	}
	else {
		cout << max(0LL, (k - (a - 1)) / 2) * (b - a) + a + ((k - (a - 1)) % 2 ? 1 : 0);
	}
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

int n, k;
int d[9];

bool judge(int x){
	while(x > 0){
		int p = x % 10;
		rep(i, k){
			if(d[i] == p){
				return false;
			}
		}
		x /= 10;
	}
	return true;
}

int main(){
	cin >> n >> k;
	rep(i, k){
		cin >> d[i];
	}

	while(!judge(n)){
		++n;
	}
	cout << n << endl;
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    if (s[1] == 'B') {
        cout << s[0] << 'R' << s[2] << endl;
    }
    if (s[1] == 'R') {
        cout << s[0] << 'B' << s[2] << endl;
    }
    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   string s;
   cin>>s;
   bool f=true;
   rep(i,s.size()){
      for(int j=0;j<i;j++){
         if(s[i]==s[j]) f=false;
      }
   }
   f==true? cout<<"yes":cout<<"no";

return 0;
}

Measured memory_bytes: 256
/*input
39
RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB
*/
#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define MAX 100005
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define ff first
#define ss second
#define T int t;cin>>t;while(t--)
using namespace std;

bool check(char c,int x){
    if((x == 0 && c=='R') || (x==1 && c=='G') || (x==2 && c=='B'))
        return true;
    return false;
}
signed main(){
    int n;
    cin >> n;
    char s[n+2];
    cin >> s;
    int f[n+1][3] = {};
    for(int i=n-1;i>=0;i--){
        f[i][0] = f[i+1][0]+(s[i]=='R');
        f[i][1] = f[i+1][1]+(s[i]=='G');
        f[i][2] = f[i+1][2]+(s[i]=='B');
    }
    int ans = 0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(s[i] == s[j])continue;
            int x = 0;
            if(s[i]=='R'){
                if(s[j]=='G') x = 2;
                else x = 1;
            }
            else if(s[i]=='G'){
                if(s[j]=='R') x = 2;
                else x = 0;
            }
            else{
                if(s[j]=='R') x = 1;
                else x = 0;
            }
            ans += f[j+1][x];
            if(j+j-i<n && check(s[j+j-i],x))
                ans--;
        }
    }
    cout << ans << '\n';
}


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

int gcd(int x,int y){
    if(y==0)return x;
    x=x%y;
    gcd(y,x);
}
int kota(string x,int c){
    int a=0;
    rep(i,x.length()){
    a+=x[i];
    c++;
    }
    c--;
    if(a<10) return c;
    string d=to_string(a);
    kota(d,0);
}
main()
{
    string s;
    cin>>s;
    if(s=="SUN") cout<<7<<endl;
    if(s=="MON") cout<<6<<endl;
    if(s=="TUE") cout<<5<<endl;
    if(s=="WED") cout<<4<<endl;
    if(s=="THU") cout<<3<<endl;
    if(s=="FRI") cout<<2<<endl;
    if(s=="SAT") cout<<1<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,M=MAP()
broken=[False]*(N+1)
for i in range(M):
    a=INT()
    broken[a]=True

dp=[0]*(N+7)
dp[0]=1
for i in range(N):
    if not broken[i+1]:
        dp[i+1]+=dp[i]
        dp[i+1]%=MOD
    if i!=N-1 and not broken[i+2]:
        dp[i+2]+=dp[i]
        dp[i+2]%=MOD
print(dp[N])


Measured memory_bytes: 7796
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int n,k,out;
vvi G;
int dfs(int a){
	int t=0;
	rep(i,G[a].size()){
		int w=dfs(G[a][i]);
		if(w==k&&a)out++,w=0;
		t=max(t,w);
	}
	return t+1;
}
int main(){
	cin>>n>>k;
	G=vvi(n);
	rep(i,n){
		int a;
		cin>>a;
		a--;
		if(i)G[a].pb(i);
		else if(a)out++;
	}
	dfs(0);
	cout<<out<<endl;
}








Measured memory_bytes: 10368
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


K = int(input())

# 解法1
# 数列 s は、s[1] = 7, s[i+1] = s[i] * 10 + 7 の漸化式で与えられる
# 特性方程式 α = α * 10 + 7 を考えると、α = -7/9 より、
# s[i+1] + 7/9 = 10 * (s[i] + 7/9) となる
# つまり、s[i] + 7/9 = 10^(i-1) * (7 + 7/9)
# <=> s[i] = 10^(i-1) * 70/9 - 7/9
# <=> s[i] = 7/9 * (10^i - 1)
# よって、7/9 * (10^i - 1) % K == 0 となるような最小の正の整数 i を求めれば良いことになる
# K と 10 が互いに素でない場合は答えが存在しないことに注意

# 解法2
# s[i] = s[i-1] * 10 + 7 より、s[i] % K = (s[i-1] * 10 + 7) % K (ただし、s[0] = 0)
# <=> s[i] % K = s[i-1] * 10 % K + 7 % K
# K と 10 が互いに素でない場合は答えが存在しないことに注意

if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    i = 1
    s_i = 0
    while True:
        s_i = (s_i * 10 + 7) % K
        if s_i == 0:
            print(i)
            break
        i += 1


Measured memory_bytes: 75008
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll m;
  cin >> m;
  
  vector<ll> d(m), c(m);
  ll sum = 0, k = 0;
  for (int i = 0; i < m; i++){
    cin >> d[i] >> c[i];
    sum += d[i] * c[i];
    k += c[i];
  }

  cout << k - 1 + (sum - 1) / 9 << endl;

  return 0;
}


Measured memory_bytes: 3328
def main():
    N = int(input())

    x = int(N / 1.08)

    if int(x * 1.08) == N:
        print(x)
    elif int((x+1)*1.08) == N:
        print(x+1)
    else:
        print(':(')
    
if __name__ == "__main__":
    main()


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

using namespace std;
int ed[100005],n,m;
int a,b;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        scanf("%d%d",&a,&b);
        ed[a]++;
        ed[b]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(ed[i]%2==1)
        {
            printf("NO\n");
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <map>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define INF 1e10
typedef long long ll;
typedef long double ld;
int main(){
    string s; cin>>s;
    int size=SIZE(s);
    ll sum=0;
    REP(bit,1<<(size-1)){
        string num;
        FOR(i, 0, size){
            num+=s.substr(i,1);
            if(bit & 1<<i){
                sum+=stoll(num);
                num="";
            }
        }
        sum+=stoll(num);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける


ll n,m,k;

int main(){
  ll ans=0;
  cin>>n>>m>>k;
  vi a(n),b(m);
  REP(i,n) cin>>a[i];
  REP(i,m) cin>>b[i];

  ll myk=0;
  ll aw=-1,bw=-1;
  for(ll i=0;i<n;i++){
    if (myk+a[i]<=k){
      myk+=a[i];
      ans++;
      aw=i;
    }else{
      break;
    }
  }


  for(ll i=0;i<m;i++){
    if (myk+b[i]<=k){
      myk+=b[i];
      ans++;
      bw=i;
    }else{
      break;
    }
  }

  if ((aw==n-1)&(bw==m-1)){
    cout<<ans<<endl;
    return 0;
  }

  if (aw==-1){
    cout<<ans<<endl;
    return 0;
  }


  bw++;
  ll tmpans=ans;
  for(ll i=aw;i>=0;i--){
    myk-=a[i];
    tmpans--;
    for(;bw<m;bw++){
        if (myk+b[bw]<=k){
          myk+=b[bw];
          tmpans++;
        }else{
          break;
        }
    }
    ans=max(ans,tmpans);
  }



  



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

/*
5 4 2
1000000000 1000000000 1000000000 1000000000 1000000000
1 1 1 1

*/

Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

class Dice {
public:
  int face[6];
  Dice() {}
  void roll(int i, int j, int k, int l) {
    int tmp = face[i];
    face[i] = face[j];
    face[j] = face[k];
    face[k] = face[l];
    face[l] = tmp;
  }
  void roll_y() {roll(0,2,5,3);}
  void roll_x() {roll(0,1,5,4);}



  void move(char c) {
    if (c == 'E') for (int i = 0; i < 3; i++) {
      roll_y();
    }
    if (c == 'W') roll_y();
    if (c == 'N') roll_x();
    if (c == 'S') for (int i = 0; i < 3; i++) {
      roll_x();
    }
  }
};

int main() {
  Dice di;

  for (int i = 0; i < 6; i++) {
    cin >> di.face[i];
  }

  string s;
  cin >> s;

  for (int i = 0; i < s.size(); i++) {
    di.move(s.at(i));
  }
  cout << di.face[0] << endl;

  return 0;
}



Measured memory_bytes: 3220
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static int h, w;
	static char[][] t, a, b;
	static int[][] p;

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

	static void rec1(int cy, int cx) {
		a[cy][cx] = 'B';
		for (int i=0; i<4; i++) {
			int ny = cy + dy[i];
			int nx = cx + dx[i];
			if (ny < 0 || nx < 0 || h <= ny || w <= nx) continue;
			if (a[ny][nx] == '.') {
				rec1(ny, nx);
			}
		}
	}

	static void rec2(int cy, int cx) {
		b[cy][cx] = 'W';
		for (int i=0; i<4; i++) {
			int ny = cy + dy[i];
			int nx = cx + dx[i];
			if (ny < 0 || nx < 0 || h <= ny || w <= nx) continue;
			if (b[ny][nx] == '.') {
				rec2(ny, nx);
			}
		}
	}

	static boolean solve() {
		w = in.nextInt();
		h = in.nextInt();
		if (w + h == 0) return false;

		t = new char[h][w];
		a = new char[h][w];
		b = new char[h][w];

		for (int i=0; i<h; i++) {
			t[i] = in.next().toCharArray();
			for (int j=0; j<w; j++) {
				a[i][j] = b[i][j] = t[i][j];
			}
		}

		for (int i=0; i<h; i++) {
			for (int j=0; j<w; j++) {
				if (t[i][j] == 'B') {
					rec1(i, j);
				} else if (t[i][j] == 'W') {
					rec2(i, j);
				}
			}
		}

		int cntB = 0, cntW = 0;

		for (int i=0; i<h; i++) {
			for (int j=0; j<w; j++) {
				if (t[i][j] != '.') continue;
				if (a[i][j] == 'B' && b[i][j] == '.') {
					cntB++;
				} else if (a[i][j] == '.' && b[i][j] == 'W') {
					cntW++;
				}
			}
		}

		out.println(cntB+" "+cntW);

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

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

int main(){
  int a,b;
  int x=0;
  cin >> a >> b;

  if (a >= b){
    x += a;
    a -= 1;
  }else{
    x += b;
    b -= 1;
  }

  if (a >= b){
    x += a;
    a -= 1;
  }else{
    x += b;
    b -= 1;
  }

  cout << x;
  
}


Measured memory_bytes: 256
import math
a,b,h,m = map(int,input().split())
th_h = 2*math.pi*(h/12 + m/720)
th_m = 2*math.pi*m/60
l_2 = a**2 + b**2 - 2*a*b*(math.cos(th_h-th_m))
l = math.sqrt(l_2)
print(l)

Measured memory_bytes: 9496
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint N;
  cin>>N;
  lint A[N];
  REP(i,N)cin>>A[i];
  map<lint,lint> m1,m2;
  REP(i,N)m1[A[i]+i]++;
  REP(i,N)m2[-A[i]+i]++;
  lint ans=0;
  for(auto e: m1){
    // cerr<<e.first<<" "<<e.second<<endl;
    ans+=e.second*m2[e.first];
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main(void) {
	int N;
	cin >> N;

	vector<int> A(N), diff(N);

	long long int sum = 0, tri = 0, op = 0, slip = 0;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
		tri += i + 1;
	}

	if (sum % tri == 0) op = sum / tri;
	else {
		cout << "NO" << endl;
		system("pause");
		return 0;
	}
	
	for (int i = 0; i < N - 1; i++) diff[i] = A[i + 1] - A[i];
	diff[N - 1] = A[0] - A[N - 1];

	for (int i = 0; i < N; i++) {
		diff[i] -= op;
		if (diff[i] > 0) {
			cout << "NO" << endl;
			system("pause");
			return 0;
		}
		if (diff[i] < 0) {
			diff[i] = -diff[i];
			if (diff[i] % N != 0) {
				cout << "NO" << endl;
				system("pause");
				return 0;
			}
			slip += diff[i] / N;
		}
	}

	if (slip <= op) cout << "YES" << endl;
	else cout << "NO" << endl;



	system("pause");

	return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
int main (){
    int t_h,t_s,a_h,a_s;cin>>t_h>>t_s>>a_h>>a_s;
    // first takashi attacks
    while(true){

        a_h-=t_s;
        if(a_h<=0){
            cout<<"Yes";
            return 0;
        }

        t_h-=a_s;
        if(t_h<=0){
            cout<<"No";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int (i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int (i) = (int)(initial); (i) < (int)(n); ++(i))
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int (i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int (i) = (int)(initial); (i) > (int)(n); (i)--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
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; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
	vector< pair<ll, ll> > p;
	for(ll i = 2; i*i <= n; i++) {
		if ((n % i) != 0) continue;
		p.push_back(make_pair(i, 0));
		while((n % i) == 0) {
			n /= i;
			p[i].second += 1;
		}
		p.push_back(make_pair(n, 0));
	}

	if (n != 1) p.push_back(make_pair(n, 1));
	return p;
}
string alphabet() { return "abcdefghijklmnopqrstuvwxyz"; }

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

	ll result = 0;
	repeat(i, N) {
		int n = i+1;
		if ((n%3) == 0 || (n%5) == 0) continue;

		result += n;
	}

	cout << result << endl;
	return 0;
}

Measured memory_bytes: 3624
a , b, c, d=list(input())
sign = '+-'
for i in range(2):
    for j in range(2):
        for k in range(2):
            if eval(a+sign[i]+b+sign[j]+c+sign[k]+d) == 7:
                print(str(a+sign[i]+b+sign[j]+c+sign[k]+d)+'=7')
                exit()

Measured memory_bytes: 3060
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
#define clr0(a) memset(a,0,sizeof(a))
#define clr1(a) memset(a,-1,sizeof(a))
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
int main()
{
    long long n,ar[100005],i,mov,ans;
    while(cin>>n)
    {
        for(i=0; i<n; i++)
        {
            cin>>ar[i];
        }
        mov=0,ans=0;
        for(i=0; i<n-1; i++)
        {
            if(ar[i]>=ar[i+1])
            {
                mov++;
            }
            else
                mov=0;
            if(mov>ans)
            {
                ans=mov;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;
#define rep(i,n) for(unsigned int i = 0;i <  n;i++)

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a - 1)*(b - 1);
	return(0);
}


Measured memory_bytes: 256
N,K = map(int,input().split())
H = list(map(int,input().split()))

inf = float("inf")
dp = [inf]*N

for i in range(N):
  if i == 0:
    dp[i] = 0
  elif i ==1:
    dp[i] = abs(H[i]-H[i-1])
  else:
    for j in range(K):
      if dp[i]>=dp[i-j-1]+abs(H[i]-H[i-j-1]):
        dp[i] = dp[i-j-1]+abs(H[i]-H[i-j-1])
print(dp[-1])

Measured memory_bytes: 55264
N, M = map(int, input().split())
drinks = [list(map(int, input().split())) for _ in range(N)]

drinks.sort()

ans = 0
for i in range(N):
    if M < drinks[i][1]:
        ans += M * drinks[i][0]
        break
    else:
        ans += drinks[i][1] * drinks[i][0]
        M -= drinks[i][1]
print(ans)

Measured memory_bytes: 27480
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    int bre = 0;
    cin >> N;
    vector<int64_t> A(N);

    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    auto itr1 = A.begin();
    auto itr2 = itr1;
    itr2++;
    while(itr1 != A.end()){
        if(itr2 == A.end()){
            bre++;
            break;
        }

        if(*itr1 < *itr2){
            while(*itr1 <= *itr2 && itr2 != A.end()){
                itr1++;
                itr2++;
            }
            itr1++;
            itr2++;
            bre++;
        }

        else if(*itr1 > *itr2){
            while(*itr1 >= *itr2 && itr2 != A.end()){
                itr1++;
                itr2++;
            }
            itr1++;
            itr2++;
            bre++;
        }

        else if(*itr1 == *itr2){
            itr1++;
            itr2++;
        }
    }
    cout << bre << endl;
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
int tot=0,nxt[100001],to[100001],head[100001],degree[100001],f[100001];
void addedge(int u,int v)
{
    tot++;
    nxt[tot]=head[u];
    to[tot]=v;
    head[u]=tot;
}
int dfs(int ind)
{
    int i,v;
    if(head[ind]==0)
        f[ind]=0;
    if(f[ind]>=0)
        return f[ind];
    for(i=head[ind];i;i=nxt[i])
    {
        v=to[i];
        f[ind]=max(f[ind],dfs(v)+1);
    }
    return f[ind];
}
int main()
{
    memset(f,0xff,sizeof(f));
    int u,v,n,m,i,ans;
    scanf("%d %d",&n,&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d %d",&u,&v);
        addedge(u,v);
        degree[v]++;
    }
    for(i=1;i<=n;i++)
    {
        dfs(i);
    }
    ans=0;
    for(i=1;i<=n;i++)
        ans=max(ans,f[i]);
    printf("%d",ans);
    return 0;
    }

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int d = scan.nextInt();
		double[][] point = new double[n][d];
		double[][] y = new double[n][d];

		for(int i = 0; i < n; i++) {
			for(int j = 0; j < d; j++) {
				point[i][j] = scan.nextDouble();
			}
		}

		int count = 0;
		for(int i = 0; i < n - 1; i++) {
			for(int j = i + 1; j < n; j++) {
				double dist = 0;
				for(int k = 0; k < d; k++) {
					dist += Math.pow((point[i][k] - point[j][k]), 2);
				}
				dist = Math.sqrt(dist);
				if(dist == Math.floor(dist)) {
					count++;
				}
			}
		}
		System.out.println(count);
 	}
}

Measured memory_bytes: 24532
/*
        FFFFFFFFFFFFFFFFFFFFFF
        F::::::::::::::::::::F
        F::::::::::::::::::::F
        FF::::::FFFFFFFFF::::F
          F:::::F       FFFFFF
          F:::::F
          F::::::FFFFFFFFFF
          F:::::::::::::::F
          F:::::::::::::::F
          F::::::FFFFFFFFFF
          F:::::F
          F:::::F
        FF:::::::FF
        F::::::::FF
        F::::::::FF
        FFFFFFFFFFF
*/
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define int long long
#define mod 1000000007
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define nl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<nl
#define cout2(a,b) cout<<a<<" "<<b<<nl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<nl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<nl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<nl
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define ms(v,n) memset((v),n,sizeof(v));
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define ad(a,b)  (a%mod+b%mod+mod)%mod
#define inf 1e18
#define cases ll T;cin>>T;while(T--)
#define BLOCK 500
//const double PI = 3.141592653589793238460;
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
 
using namespace std;

int main()
{
    
    fast

    string s;
    cin>>s;
    ll n=s.size();
    ll a=0,b=0;
    f(i,n)
    {
        if(s[i]=='A')
        a++;
        else
        b++;
    }

    if(a==2 ||b==2)
    cout<<"Yes";
    else
    cout<<"No";
    
    
    





    

    return 0;
    
}

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

int main(){
  cin >> s;
  bool flg = true;
  for(int i=1;i<s.size();i++) {if (s[i]!='9') flg=false;}
  int ans = (s[0]-'1') + 9 * (s.size()-1) + (flg);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque> 
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype> 
using namespace std;

int main(){
    string A, B;
    cin >> A >> B;
    int C=(int)A.size() - (int)B.size();
    if (C>0) {
        cout << "GREATER" << endl;
        return 0;
    }
    else if (C<0) {
        cout << "LESS" << endl;
        return 0;
    }
    else if (C==0) {
        for(int i=0; i<A.size(); i++) {
            if (A.at(i)>B.at(i)) {
                cout << "GREATER" << endl;
                return 0;
            }
            else if (A.at(i)<B.at(i)) {
                cout << "LESS" << endl;
                return 0;
            } 
        }
    }
    cout << "EQUAL" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,t=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(i==105||i==135||i==165||i==189||i==195) t++;
	}
	cout<<t;
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <utility>
#include <deque>
#include <array>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, int &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

using I = deque<int>::iterator;

int guess(I i[2], int g) {
	if (i[0] == i[1])
		return 0;
	int t {*i[0] < 0 ? g : *i[0]};
	i[0]++;
	return t;
}

int main() {
	for (;;) {
		array<deque<int>,3> a;
		for (auto &i: a)
			for (;;) {
				int c {gcu()};
				if (c == EOF)
					return 0;
				else if (isdigit(c))
					i.push_front(c - '0');
				else if (c == 'X')
					i.push_front(-1);
				else
					break;
			}
		int s {[&] {
			for (auto &i: a) {
				if (i.size() == 1)
					continue;
				if (i.back() < 0)
					return 1;
			}
			return 0;}()};
		deque<int>::iterator it[3][2];
		auto q {[&] {
			for (auto i: it)
				if (i[0] != i[1])
					return true;
			return false;
		}};
		[&] {
			for (int i: range(3))
				it[i][1] = end(a[i]);
			for (int i: range(s, 10)) {
				for (int j: range(3))
					it[j][0] = begin(a[j]);
				int c {};
				if ([&] {
					while (q()) {
						int t = c + guess(it[0], i) + guess(it[1], i);
						if (t % 10 != guess(it[2], i))
							return false;
						c = t / 10;
					}
					return true;
					}()) {
					outl(i);
					return;
				}
			}
			outl("NA");
		}();
	}
}


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

int main(){
	
    int n,d;
    cin >> n >> d;
    vector<vector<float>> A(n, vector<float>(d));
    bool ok = false;

    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> A[i][j];
        }
    }

    float count = 0;
    float tmp = 0;
    //double unchi = 1;
    int ans=0;


    for(int i = 0; i < n-1; i++){
        for (int j = i+1; j < n; j++){
            for(int k = 0; k < d; k++){
                count+=(A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
            }
        tmp=sqrt(count);
        if(fmod(tmp,1)==0){
            ans++;
        }
        count = 0;
        }
    }

    cout << ans <<endl;
    
}
		




Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	string s;
	cin>>a>>b;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[a]!='-'){
			cout<<"No"<<endl;
			return 0;
		}
	
	
		if(i!=a)
		{
			if(s[i]<'0'||s[i]>'9')
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0; 
	

} 

Measured memory_bytes: 256
n = int(input())
p_list = list(map(int,input().split()))
p_list = sorted(p_list)
if p_list[int((n/2)-1)] == p_list[int(n/2)]:
    print(0)
else:
    print(p_list[int(n/2)] - p_list[int((n/2)-1)])


Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	ll A=0,B=0;
	FOR(i,2*N) A+=K+i;
	FOR(i,N) B+=K+2*N+i;
	if(B<A) return _P("-1\n");
	vector<vector<int>> R;
	set<int> V;
	if(N%2==0) {
		if(K>N/2) return _P("0\n");
		int TK=N/2;
		R.push_back({TK,3*TK,5*TK});
		for(i=1;i<=N/2;i++) R.push_back({TK+i,2*N+i-1,TK+i+2*N+i-1});
		for(i=1;i<=N/2-1;i++) R.push_back({N+i,3*N/2+i,5*N/2+2*i});
		FORR(r,R) {
			FORR(a,r) {
				a-=TK-K;
				V.insert(a);
			}
			assert(r[0]+r[1]<=r[2]);
		}
	}
	else {
		if(K>N/2+1) return _P("0\n");
		int TK=N/2+1;
		for(i=1;i<=N/2+1;i++) R.push_back({TK+i-1,2*N+i-1,TK+i+2*N+i-2});
		for(i=1;i<=N/2;i++) R.push_back({N+i,3*N/2+i,5*N/2+2*i});
		FORR(r,R) {
			FORR(a,r) {
				a-=TK-K;
				V.insert(a);
			}
			assert(r[0]+r[1]<=r[2]);
		}
	}
	assert(V.size()==3*N);
	assert(*V.begin()==K);
	assert(*V.rbegin()==K+3*N-1);
	
	
	FORR(v,R) {
		cout<<v[0]<<" "<<v[1]<<" "<<v[2]<<endl;
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 21936
import java.util.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer;

public class Main {
	static class IO 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public IO() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
        int [] readarray(int sz){
            int [] ret = new int[sz];
            for(int i = 0; i<sz; i++)ret[i] = nextInt();
            return ret;
        }
    } 
    public static void main(String[] args){
        IO fs = new IO();
        int n = fs.nextInt();
        long [] a  = new long[n];
        for(int i = 0; i<n; i++)a[i] = fs.nextLong();
        Arrays.sort(a);
        //PriorityQueue<Integer> pq = new PriorityQueue<Integer> (new Comparator<Integer> () {public int compare(Integer a, Integer b) {return b - a;}});
        long ans = a[n-1];
        int j = n-2;
        for(int i = n-2; i>=0;i-=2){
            if(i-1>=0){
                //i-=1;
                ans+=a[j];
            }
            if(i-2>=0){
                //i-=1;
                ans+=a[j];
            }
            j-=1;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 56728
import datetime

s=input()

s_date = datetime.datetime.strptime(s, '%Y/%m/%d')

last_date = '2019/05/01'

t_date = datetime.datetime.strptime(last_date, '%Y/%m/%d')

if s_date < t_date:
    print('Heisei')

else:
    print('TBD')

Measured memory_bytes: 10324