akhauriyash/Code-Regression huggingface dataset:
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
typedef modint<MOD> m;
#pragma endregion

ll a[200000];
int main() {
  cin >> N >> K;
  rep(j, N){
    cin >> a[j];
  }
  ll i=0;
  ll sum = 0;
  for(;i<K;i++){
    sum += a[i];
  }
  max_value = max(max_value, sum);
  for(;i<N;i++){
    sum -= a[i-K];
    sum += a[i];
    max_value = max(max_value, sum);
  }
  cout << (max_value+K)/2;
  if((max_value+K)%2 == 1) cout << ".5";
}



Measured memory_bytes: 1792
use std::io::{stdin, Read};
use std::str::FromStr;
use std::cmp;
fn main() {
    let n :usize = read();
    let h = read_vec::<i64>(n);
    let mut dp = vec![1000000000i64;n+10];
    dp[0] = 0;
    for i in 0..n{
        if i+1<n{
        dp[i+1] = cmp::min(dp[i] + (h[i]-h[i+1]).abs(), dp[i+1]);
        }
        if i+2<n {
        dp[i+2] = cmp::min(dp[i] + (h[i]-h[i+2]).abs(), dp[i+2]);
        }
    }
    println!("{}",dp[n-1]);
}
#[allow(dead_code)]
fn read_vec<T: FromStr>(n: usize) -> Vec<T> {
    let mut v = vec![];
    for _ in 0..n {
        let a = read::<T>();
        v.push(a);
    }
    v
}
#[allow(dead_code)]
fn read_str() -> Vec<char> {
    let s: String = read();
    s.chars().collect::<Vec<char>>()
}
#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().unwrap_or_else(
        |_| panic!("Faild to parse {}", s),
    )
}


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

int main(){
    int N;  cin >> N;
    int A;
    int cnt = 0;
    for(int i=0; i<N; i++){
         cin >> A;
         if(A%2==1) cnt++;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



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

    int x;
    cin>>x;
    if(x<30){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

vector<vector<int>> a;
int now[1000];
int was[1000];

void init(int n){
    for(int i=0; i<n; i++){
        was[i] = 0;
    }
}

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

    for(int i=0; i<n; i++){
        vector<int> buf;
        for(int j=0; j<n-1; j++){
            int a_;
            cin >> a_;
            buf.push_back(a_); 
        }
        a.push_back(buf);
        now[i] = 0;
    }

    int cnt = 0;
    int day = 0;
    while(cnt < n*(n-1)/2){
        bool game = false;
        init(n);
        for(int i=0; i<n; i++){
            if(now[i] >= n-1){
                continue;
            }
            int vs = a[i][now[i]]-1;
            if(was[i] == 1){
                continue;
            }
            if(was[vs] == 1){
                continue;
            }
            if(i == a[vs][now[vs]]-1){
                now[i]++;
                now[vs]++;
                game = true;
                cnt++;
                was[i] = 1;
                was[vs] = 1;
            }
        }
        if(!game){
            cout << -1 << endl;
            return 0;
        }
        day++;
    }
    cout << day << endl;
    return 0;
}

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

int main(){
  int w,a,b;
  cin>>w>>a>>b;
  if(w>=abs(a-b)){ cout<<"0"; return 0; }
  else if(a<b) { cout<<b-a-w; return 0; }
  else cout<<a-b-w;


}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string s;
	cin>>s;
	int n = s.size();
	rep(i, n-1){
		if(s.substr(i, 2)=="AC"){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
num = input()
num = int(num)
numinput = input()
numlist = numinput.split(" ")
evenlist = list()
con = 0
maxcon = int(num) * 1000
point = 0
for i in numlist:
  con = con + int(i)
  if int(i) % 2 == 0:
      evenlist.append(i)
  else:
      continue
if num <= 100 and con <= maxcon:
  for i in evenlist:
    if int(i) % 3 == 0 or int(i) % 5 == 0:
      point = point + 1
    else:
      continue
else:
  print("")
if point == len(evenlist):
  print("APPROVED")
else:
  print("DENIED")


Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    vector<int> hoge = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<hoge.at(k-1)<<endl;
    
    return 0;
}

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

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

typedef long long ll;
using namespace std;

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

  int N;
  string S;
  cin >> N >> S;

  ll r = 0;
  ll g = 0;
  ll b = 0;
  REP(i, N) {
    if (S.at(i) == 'R') {
      ++r;
    } else if (S.at(i) == 'G') {
      ++g;
    } else {
      ++b;
    }
  }

  ll ans = r * g * b;

  REP(i, N) {
    REPI(j, i + 1, N) {
      int k = j + (j - i);
      if (k >= N)
        break;

      if (S.at(i) != S.at(j) && S.at(i) != S.at(k) && S.at(j) != S.at(k)) {
        --ans;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	string S=in<string>();
	int min_sub = 1e9;
	for(int i=0,ei=S.size()-2;i<ei;i++){
		int value=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
		int sub = abs(753-value);
		min_sub = min(sub,min_sub);
	}

	cout << min_sub << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;

ll h,w;
ll a[505][505];

int main(){FIN
    cin>>h>>w;
    REP(i,h) REP(j,w) cin>>a[i][j];

    using T=tuple<ll,ll,ll,ll>;
    vector<T> move(0);
    REP(i,h){
        REP(j,w){
            if(a[i][j]%2!=0){
                if(j<w-1){
                    a[i][j]--; a[i][j+1]++;
                    move.push_back(make_tuple(i+1,j+1,i+1,j+2));
                }
                else if (j==w-1 && i<h-1){
                    a[i][j]--; a[i+1][j]++;
                    move.push_back(make_tuple(i+1,j+1,i+2,j+1));
                }

            }
        }
    }
    cout<<move.size()<<endl;
    for(auto p:move){
        cout<<get<0>(p)<<' '<<get<1>(p)<<' '<<get<2>(p)<<' '<<get<3>(p)<<endl;
    }
    return 0;
}

Measured memory_bytes: 8172
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;
ll mod=1e9+7;
const int MAXN = 1e5+3; //AREGLAAAAAAAAR!!!!
int a[MAXN],memo[MAXN];
ll fac[MAXN],invfac[MAXN];

ll sq(ll x){return x*x%mod;}
ll powfast(ll b, ll e){
	if(!e) return 1;
	return sq(powfast(b,e>>1)) * (e&1? b : 1) %mod;
}


int main(){
	int n;
	ri(n);
	int rep;
	ms(memo,-1);
	FOR(i,0,n+1){
		ri(a[i]);
		if(memo[a[i]]==-1){
			memo[a[i]]=i;
		}else rep=i-memo[a[i]];		
	}

	fac[0]=1;
	fac[1]=1;
	FOR(i,2,MAXN) fac[i]=(fac[i-1]*i)%mod;
	invfac[0]=1;
	
	FOR(i,1,MAXN) invfac[i]=powfast(fac[i],mod-2);
	FOR(k,1,n+2){
		ll ans=((fac[n+1]*invfac[n+1-k])%mod*invfac[k])%mod;
		if(n-rep>=k-1) ans-=((fac[n-rep]*invfac[n-rep-k+1])%mod*invfac[k-1])%mod;
		ans=(ans+mod)%mod;
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };

int n, z, w, a[2010];
int memo[2010][2];
#define INF INT_MAX/2

int f(int id, int turn, int x, int y) {
	if (id == n)return abs(x - y);
	if (memo[id][turn] != -1)return memo[id][turn];

	if (turn == 0) {
		int ma = -1;
		rep(i, id, n)ma = max(ma,f(i+1,1-turn,a[i],y));
		return memo[id][turn] = ma;
	}
	else {
		int mi = INF;
		rep(i, id, n)mi = min(mi, f(i + 1, 1 - turn,x,a[i]));
		return memo[id][turn] = mi;
	}
}

int main() {
	cin >> n >> z >> w;
	rep(i, 0, n)cin >> a[i];

	rep(i, 0, n)rep(t, 0, 2)memo[i][t] = -1;
	cout << f(0, 0, z, w) << endl;

	return 0;
}

Measured memory_bytes: 384
local function getgcd(x, y)
  while 0 < x do
    x, y = y % x, x
  end
  return y
end
local a, b = io.read("*n", "*n")
local c, d = io.read("*n", "*n")
a = math.abs(a - c)
b = math.abs(b - d)
local gcd = getgcd(a, b)
a, b = a // gcd, b // gcd
print(gcd * (a + b - 1))


Measured memory_bytes: 1016
#include <bits/stdc++.h>
using namespace std;
#define ACL
#ifdef ACL
#include <atcoder/all>
using namespace atcoder;
#endif
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
using LD = long double;
using VI = vector<int>;
using VVI = vector<vector<int> >;
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T> >;
template <typename T> using VVV = vector<vector<vector<T> > >;
void print() {cout << endl;}
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <typename T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <typename T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> void SORT (T &v) {sort(v.begin(), v.end());}
template <typename T> void SORTR (T &v) {sort(v.begin(), v.end(), greater<>());}
template <typename T> T GCD(T x,T y) {return __gcd(x,y);}
template <typename T> T LCM(T x,T y) {return x/__gcd(x,y)*y;}
template <typename T> int SZ(T v) {return v.size();}
template <typename T> T PCNT(T x) {return __builtin_popcountll(x);}
template <typename T> T BIT(T x) {return 1LL<<(x);}
int INF = 2000000000;
long double PI = acosl(-1);
int MOD = 1000000007;


int32_t main() {
    chrono::system_clock::time_point start_time, end_time;
    start_time = chrono::system_clock::now();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0, res = 0;
    
    int K;
    cin >> K;
    string S;
    REP(i,K) S += "ACL";
    cout << S << endl;

    
    



    end_time = chrono::system_clock::now();
    assert(chrono::duration_cast<chrono::milliseconds>(end_time-start_time).count() < 2500);
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abl/abl_a && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abl/abl_a && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abl/abl_a && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3688
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n,m,c;
    vector<int> a,b;
    int val;
    int ans = 0;

    cin >> n >> m >> c;
    
    for(int i = 0; i < m;i++){
        int num;
        cin >> num;
        b.push_back(num);
    }

    for(int i = 0; i < n; i++){
        val = 0;
        for(int j = 0; j < m; j++){
            int a;
            cin >> a;
            val += a*b[j];
        }
        if(val + c > 0)ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int dummy = 0;
	cin >> dummy;
	int min = 0;
	int minvalue = 0, minNo = 0;
	cin >> minNo >> minvalue;
	int tempvalue = 0, tempNo = 0;
	while (cin >> tempNo, cin >> tempvalue) {
		if (minvalue >= tempvalue) {
			minvalue = tempvalue;
			minNo = tempNo;
		}
	}
	cout << minNo + minvalue;
}

Measured memory_bytes: 768
function Main(input) {
	input = input.split("\n");
    tmp = input[0].split(" ");

    const L = parseInt(tmp[0]);
    const R = parseInt(tmp[1]);
    const d = parseInt(tmp[2]);

    var n = 0;

    for (let i=L; i<(R+1) ; i++) {

        if(i%d == 0) {

            n++;

        }
    }

    console.log( '%d', n);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29672
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

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;
}

vector<int> as;
vector<int> bs;

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

    as.resize(N + 1, 0);
    for (int i = 0; i < N; i++) {
        cin >> as[i + 1];
    }

    int m = 0;

    bs.resize(2 * (N + 1), 0);
    for (int i = N; i >= 1; i--) {
        int cnt = 0;
        for (int j = i * 2; j <= N; j += i) {
            if (bs[j] == 1) cnt++;
        }
        if ((as[i] == 0 && cnt % 2 == 0) || (as[i] == 1 && cnt % 2 == 1)) {
            bs[i] = 0;
        } else {
            m++;
            bs[i] = 1;
        }
    }

    cout << m << endl;
    for (int i = 1; i <= N; i++) {
        if (bs[i] == 1) {
            cout << i << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3200
import numpy as np

XY=np.array(input().split(" "),dtype=np.int32)

X=XY[0]
Y=XY[1]

b_count=0
t_count=0

flag=False
for x in range(X+1):
    b_count=x
    t_count=X-b_count

    legs=2*b_count+4*t_count

    if(legs==Y):
        flag=True
        break

if(flag):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27036
#include <stdio.h>
#include <string.h>
char t1[1510];
char t2[1510];
int main(){
	int n;
	int a=0,b=0;
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %s",&t1,&t2);
		if(strcmp(t1,t2)==0) a++,b++;
		if(strcmp(t1,t2)>0) a+=3;
		if(strcmp(t1,t2)<0) b+=3;
	}
	printf("%d %d\n",a,b);
	return 0;
}

  

 



Measured memory_bytes: 2044
from math import factorial
N = int(input())
s = {}
for i in range(N):
    w = sorted(list(input()))
    w = ''.join(w)
    if w in s :
      s[w]+=1
    else:
      s[w] = 1

count = 0
for k in s:
  if s[k] >= 2:
    count += factorial(s[k]) // (factorial(s[k] - 2) * factorial(2))
    
print(count)

Measured memory_bytes: 17932
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;

//B
int main() {
	int N;
	scanf("%d", &N);

	vector<vector<int>> graph(N, vector<int>(0));

	for (int i = 0; i < N; i++) {
		char s[210];
		scanf("%s", s);

		int connect = 0;

		for (int j = 0; j < N; j++) {
			if (s[j] == '1') {
				graph[i].push_back(j);
			}
		}
	}

	ll result = -1;

	for (int start = 0; start < N; start++) {
		int depth[210];
		for (int i = 0; i < N; i++) {
			depth[i] = -1;
		}
		depth[start] = 0;

		queue<int> search;
		search.push(start);
		int max_depth = 0;
		bool fail = false;

		//���D��T��
		while (search.empty() == false) {
			int node = search.front();
			search.pop();

			for (auto next : graph[node]) {
				if (depth[next] == -1) {
					depth[next] = depth[node] + 1;
					search.push(next);

					max_depth = std::max(max_depth, depth[next]);
				}
				else if (depth[next] == depth[node] - 1 || depth[next] == depth[node] + 1) {
					//ok
				}				
				else {
					fail = true;
					break;
				}
			}

			if (fail == true) {
				break;
			}
		}

		if (fail == false && max_depth + 1 > result) {
			result = max_depth + 1;
		}
	}

	printf("%lld\n", result);

}

//A
/*
int main() {
	char S[110];
	ll K;
	scanf("%s", S);
	scanf("%lld", &K);
	ll len = strlen(S);

	ll count[4];
	memset(count, 0, sizeof(count));

	char prev_char = ' ';
	for (ll i = 0; i < std::min(4LL, K); i++) {
		for (int j = 0; j < len; j++) {
			char c = S[j];

			if (c == prev_char) {
				count[i]++;
				prev_char = ' ';
			}
			else {
				prev_char = c;
			}
		}
	}

	ll result = 0;
	if (K <= 4) {
		for (auto val : count) {
			result += val;
		}
	}
	else {
		if (count[0] == count[1] && count[1] == count[2] && count[2] == count[3]) {
			result = count[0] * K;
		}
		else if (count[0] != count[1] && count[1] == count[2] && count[2] == count[3]) {
			result = count[0] + count[1] * (K - 1);
		}
		else if (count[0] != count[1] && count[0] == count[2] && count[1] == count[3]) {
			if (K % 2 == 0) {
				result = (count[0] + count[1]) * (K / 2);
			}
			else {
				result = (count[0] + count[1]) * (K / 2) + count[0];
			}
		}
		else {
			//(T-T
			result = count[0] * K;
		}

	}

	printf("%lld\n", result);

	return 0;
}
*/

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define len(s) s.length()
#define all(v) v.begin(),v.end()
const ll INF = INT_MAX;
const int N = 2e5 + 5;
const ll mod = 1000000007 ;
using namespace std;

int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;
	// cin >> tc;
	while (tc--) {

		ll n, m, l, r;
		ll i, j;
		ll  y;

		ll x;

		cin >> x >> y;

		for (i = 0; i <= 10 * x; i++) {
			for (j = 0; j <= 10 * x; j++) {
				if (2 * i + j * 4 == y and  i + j == x) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}

		cout << "No" << endl;


	}
}


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

#define ll long long
#define ar array

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll int n, sum=0;
	cin >> n;
	for(int i=1;i<=n;i++) {
		if(i%3!=0 && i%5!=0) {
			sum+=i;
		}
	}
	cout <<sum;
}


Measured memory_bytes: 3640
import math
N = int(input())
counter = N+N
upper = int(math.ceil(math.sqrt(N)))
for i in range(upper):
  List = []
  if N%(i+1)==0:
    List.append([i+1,int(N/(i+1))])
  for item in List:
    if item[0]+item[1]-2 < counter:
      counter = item[0]+item[1]-2
  
print(counter)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

int main()
{
    int n; cin >> n;
    vint t(n), a(n);
    rep(i, n) cin >> t[i]; 
    rep(i, n) cin >> a[i]; 

    vector<ll> ans(n);

    if(n==1) {
        if(a[0] != t[0]) pr(0);
        else pr(1);
        return 0;
    }
    if(a[0] > a[1] && t[0] != a[0]) {pr(0); return 0;}
    if(t[n-2] < t[n-1] && t[n-1] != a[n-1]) {pr(0); return 0;}

    if(n==2) {pr(1); return 0;}

    ans[0] = 1;
    ans[n-1] = 1;
    FOR(i, 1, n-1){
        if(t[i] < t[i-1] || a[i] < a[i+1]){pr(0); return 0;}
        if(t[i] > t[i-1] && a[i] > a[i+1]){
            if(a[i] != t[i]) {
                pr(0); 
                return 0;
                }
            ans[i] = 1;
        }else if(t[i] > t[i-1]){
            if(a[i] < t[i]) {pr(0); return 0;}
            ans[i] = 1;
        }else if(a[i] > a[i+1]){
            if(a[i] > t[i]) {pr(0); return 0;}
            ans[i] = 1;
        }else{
            ans[i] = (ll)min(a[i], t[i]);
        }
    }

    ll k = 1;
    rep(i, n){
        k *= ans[i];
        k %= MOD;
    }
    pr(k);
    return 0;}

Measured memory_bytes: 4808
m, n = map(int,input().split())
M = []
for i in range(m):
    a_ik = list(map(int, input().split()))
    M.append(a_ik)
N = []
for i in range(n):
    b_i1 = int(input())
    N.append(b_i1)

for i in range(m):
    sum = 0
    for k in range(n):
            c_ij = M[i][k]*N[k]
            sum = sum + c_ij
    print(sum)



Measured memory_bytes: 6008
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){

  int r;
  cin >> r;

  if (r < 1200){
    cout << "ABC" << endl;
  }
  else if ((1200 <= r) && (r < 2800)){
    cout << "ARC" << endl;
  }
  else {
    cout << "AGC" << endl;
  }

  return 0;
}


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

int main() {
 UL N; cin>>N;
 UL ans[60000]={};
 for(UL x=1; x<=100; x++) for(UL y=1; y<=100; y++) for(UL z=1; z<=100; z++){
  ans[x*x+y*y+z*z+x*y+y*z+z*x]++;
 }
 rep(i,N) printf("%u\n",ans[i+1]);
 return 0;
}



Measured memory_bytes: 3928
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
ll power(ll x,ll y)
{
	if(y==1)
	return x;
	ll ans=power(x,y/2);
	ans=((ans%mod)*(ans%mod))%mod;
	if(y&1)
	ans=((ans%mod)*(x%mod))%mod;
	return ans%mod;
}

int main()
{
	ll n;
	cin>>n;
	if(n==1)
	cout<<0<<endl;
	else if(n==2)
	cout<<2<<endl;
	else{
	
	ll ans=power(10,n);
	ans=((ans%mod)-(power(9,n)%mod)+mod)%mod;
	ans=((ans%mod)-(power(9,n)%mod)+mod)%mod;
	ans=((ans%mod)+(power(8,n)%mod))%mod;
	cout<<ans%mod<<endl;}
	return 0;
}


Measured memory_bytes: 3600
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
int T,X,Y;
int main() {
	cin>>N;

	int R=0;
	for(int i=0;i<N;i++){
		cin>>T>>X>>Y;
		if(T%2==1 && (X+Y)%2==1 && (X+Y)<=T){
			R++;
		}
		else if(T%2==0 && (X+Y)%2==0 && (X+Y)<=T){
			R++;
		}
		else {
			cout<<"No"<<endl;
			return 0;
		}
	}

	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, o io.Writer) {
	in := bufio.NewReader(_r)
	type pair struct{ x, y, d int }
	d := [][2]float64{'L': {-1, 0}, 'R': {1, 0}, 'D': {0, -1}, 'U': {0, 1}}
	f := func(l, r float64, f func(float64) float64) float64 {
		for i := 0; i < 100; i++ {
			m1 := l + (r-l)/3
			m2 := r - (r-l)/3
			v1, v2 := f(m1), f(m2)
			if v1 < v2 {
				r = m2
			} else {
				l = m1
			}
		}
		return f((l + r) / 2)
	}

	var n, x, y int
	var s []byte
	Fscan(in, &n)
	a := make([]pair, n)
	for i := range a {
		Fscan(in, &x, &y, &s)
		a[i] = pair{x, y, int(s[0])}
	}
	Fprintf(o, "%.10f", f(0, 1e8, func(t float64) float64 {
		xl, xr, yl, yr := 1e9, -1e9, 1e9, -1e9
		for _, p := range a {
			x, y := float64(p.x)+t*d[p.d][0], float64(p.y)+t*d[p.d][1]
			xl = Min(xl, x)
			xr = Max(xr, x)
			yl = Min(yl, y)
			yr = Max(yr, y)
		}
		return (xr - xl) * (yr - yl)
	}))
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;

bool check(string s){
    char c = s[0];
    for(int i=1;i<s.size();++i) if(c != s[i]) return false;
    return true;
}

int main(){
    string s;
    cin >> s;
    map<char,int> mp;

    int MAX = -1;
    string str = "qazxswedcvfrtgbnyhujmiklop";

    int ans = 1e9;
    for(auto c : str){
        int cnt = 0;
        string t = s;
        while(!check(t)){
            string u = "";
            for(int i=0;i<t.size()-1;++i){
                if(find(t.begin(),t.end(),c) == t.end()){
                    cnt = 1e9;
                    break;
                } 
                if(t[i] == c || t[i+1] == c ) u += c;
                else u += s[i];
            }
            t = u;
            ++cnt;
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

void addElement(pll el, vector<pair<pll, ll>> &L)
{
  for (auto &li : L)
  {
    if (li.first == el)
    {
      li.second++;
      return;
    }
  }
  L.push_back(make_pair(el, 1));
  return;
}

int main()
{
  int N, x, y;
  pll XY[50], PQ[50][50];
  vector<pair<pll, ll>> PQcnt;
  cin >> N;
  REP(i, N)
  {
    cin >> x >> y;
    REP(j, i)
    {
      ll p = x - XY[j].first, q = y - XY[j].second;
      pll pq = make_pair(p, q);
      PQ[i][j] = make_pair(p, q);
      PQ[j][i] = make_pair(-p, -q);
    }
    XY[i] = make_pair(x, y);
  }

  REP(i, N)
  {
    REP(j, N)
    {
      if (i == j)
        continue;
      addElement(PQ[i][j], PQcnt);
    }
  }

  pair<pll, ll> maxpll = make_pair(make_pair(0, 0), -INF);
  for (auto &pqcnt : PQcnt)
  {
    if (maxpll.second < pqcnt.second)
      maxpll = pqcnt;
  }

  ll cnt = N;
  REP(i, N)
  {
    REP(j, N)
    {
      if (i == j)
        continue;
      else if (PQ[i][j] == maxpll.first)
        cnt--;
    }
  }
  cout << cnt << '\n';

  return 0;
}


Measured memory_bytes: 384
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	int i,j,n,m,K;cin>>n>>m>>K;
	int gya[100]={0};
	int dark[16]={0};
	int road[100][100]={0};
	for(i=0;i<n;i++){gya[i]=-1;}
	for(i=0;i<m;i++){
		int d;cin>>d;d--;
		gya[d]=i;
		dark[i]=d;
	}
	static int dis[65536];
	for(int bi=0;bi<(1<<m);bi++){dis[bi]=99999;}
	dis[(1<<m)-1]=0;
	queue<int>que;que.push((1<<m)-1);
	for(i=0;i<n;i++){
		for(j=0;j<K;j++){
			cin>>road[i][j];road[i][j]--;
		}
	}
	while(que.size()){
		int pta=que.front();que.pop();
		int time=dis[pta];
		//cerr<<pta<<" "<<time<<endl;
		for(j=0;j<K;j++){
			int aaa=0;
			for(i=0;i<m;i++){
				if(!(pta&(1<<i))){continue;}
				int t=dark[i];
				if(gya[road[t][j]]<0){continue;}
				aaa|=(1<<gya[road[t][j]]);
			}
			if(mineq(dis[aaa],time+1)){que.push(aaa);}
		}
	}
	cout<<dis[0]<<endl;
	return 0;
}



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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  double d;
  cin >> d;
  if(d<1){
    cout << fixed << setprecision(10) << sqrt(2)*d << endl;
  }else{
    cout << fixed << setprecision(10) << max(sqrt(2)*d,floor(d)+1) << endl;
  }
  return 0;
}



Measured memory_bytes: 3272
/*************************************
 *プログラム名：A.c
 *
 *************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <unistd.h>
#include <sys/wait.h>
#include <signal.h>
#include <pthread.h>

//<<<<<>>>>>//

int main(void)
{
	int a, b, c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if (a + b == c) {
		puts("Yes");
	} else if (a + c == b) {
		puts("Yes");
	} else if (b + c == a) {
		puts("Yes");
	} else {
		puts("No");
	}
	
	return (0);

}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

void print_vec(vector<int> vec) {
  cout << "[";
  for (int i = 0; i < vec.size(); i++) {
    if (i) {
      cout << ", ";
    }
    cout << vec.at(i);
  }
  cout << "]...size: " << vec.size() << endl;
}

int main() {
  vector<string> v;

  while (1) {
    string cards;
    cin >> cards;

    if (cards == "-") {
      break;
    }

    int m;
    cin >> m;

    rep(i, m) {
      int h;
      cin >> h;

      string tmp = cards.substr(0, h);
      cards += tmp;
      cards.erase(0, h);
    }

    v.push_back(cards);
  }

  for (auto &&i : v) {
    printf("%s\n", i.c_str());
  }
}



Measured memory_bytes: 3184
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC095_cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine().Count(c => c == 'o');
            Console.WriteLine(700 + x * 100);
        }
    }
}


Measured memory_bytes: 11220
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;
import java.util.Comparator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if (a == b) {
			System.out.println(c);
		} else if (b == c) {
			System.out.println(a);
		} else if (a == c) {
			System.out.println(b);
		}
		
	}

	
	
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
string s, t;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> s >> t;

    int tlen = t.length();
    int cnt = 0;
    int mi = 10001;
    for(int i = 0; i <= s.length() - tlen; i++) {
        cnt = 0;
        string sub = s.substr(i, tlen);
        // cout << sub << endl;
        for(int j = 0; j < tlen; j++) {
            if(sub[j] != t[j]) {
                cnt++;
            }
        }
        mi = min(cnt, mi);
    }
    cout << mi << endl;
    return 0;
}


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

// balancing load


int main(){

	string s;cin>>s;
	if(s[0]=='A' and s[1]=='A' and s[2]=='A') cout<<"No";
	else if(s[0]=='B' and s[1]=='B' and s[2]=='B') cout<<"No";
	else cout<<"Yes";

	}

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

const int INF = 100000000;
typedef pair<int, int> P;

char maze[1010][1010];
int h, w;
vector<P> start;

int d[1010][1010];

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

void bfs(){
  queue<P> que;
  for(int i=0; i<h; ++i)
    for(int j=0; j<w; ++j) d[i][j] = INF;

  for(auto itr = start.begin(); itr != start.end(); ++itr){
    que.push(*itr);
    d[itr->second][itr->first] = 0;
  }

  while(que.size()){
    P p = que.front(); que.pop();

    for(int i=0; i<4; ++i){
      int nx = p.first + dx[i], ny = p.second + dy[i];

      if(0 <= nx && nx < w && 0 <= ny && ny < h && maze[ny][nx] != '#' && d[ny][nx] == INF){
        que.push(P(nx, ny));
        d[ny][nx] = d[p.second][p.first] + 1;
      }
    }
  }
  return;
}

int main(){
  cin >> h >> w;
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      cin >> maze[i][j];
      if(maze[i][j] == '#') start.push_back(P(j, i));
    }
  }
  bfs();
  int ans = 0;
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      ans = max(ans, d[i][j]);
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 21224
#include <iostream>
#include <vector>

using namespace std;

long long pow_mod(long long x, long long y, long long mod) {
    if (y == 0) {
        return 1;
    } else if (y % 2 == 0) {
        return pow_mod(x * x % mod, y / 2, mod);
    } else {
        return x * pow_mod(x, y - 1, mod) % mod;
    }
}

int main() {
    long long n, a, b;
    cin >> n >> a >> b;

    long long mod = 1000000007;
    vector<long long> inv(200001, 0);
    inv[1] = 1;
    for (int i = 2; i <= 200000; i++) {
        inv[i] = mod - (inv[mod % i] * (mod / i)) % mod;
    }

    long long res = pow_mod(2, n, mod);

    long long r1 = 1;
    for (long long i = 1; i <= a; i++) {
        r1 *= (n - i + 1);
        r1 %= mod;
        r1 *= inv[i];
        r1 %= mod;
    }
    res = (res - r1 + mod) % mod;

    long long r2 = 1;
    for (long long i = 1; i <= b; i++) {
        r2 *= (n - i + 1);
        r2 %= mod;
        r2 *= inv[i];
        r2 %= mod;
    }
    res = (res - r2 + mod) % mod;

    cout << res - 1 << endl;
}


Measured memory_bytes: 1792
A,B = map(int, input().split())
max_v = -10**9
tmp = A + B
max_v = tmp if max_v < tmp else max_v
tmp = A - B
max_v = tmp if max_v < tmp else max_v
tmp = A * B
max_v = tmp if max_v < tmp else max_v
print(max_v)
    

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

int main() {
  int L, R, d;
  cin >> L >> R >> d;
  int min;
  min = L/d;
  int max;
  max = R/d;
  if (L%d==0)
    cout << max-min+1 << endl;
  else
    cout << max-min << endl;
  return 0;
}

Measured memory_bytes: 3632
/*
g++ code.cpp
./a.out
*/

#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main() {
    int64_t n,m;
    cin >> n >> m;
    vector<int64_t> a(m);
    rep(i,m){
        cin >> a[i];
    
    }
    if(accumulate(a.begin(),a.end(),0L) > n){
        cout << -1 << endl;
    }else{
        cout << n - accumulate(a.begin(),a.end(),0L) << endl;
    }
}

Measured memory_bytes: 3676
#include<stdio.h>

int main(void){
  char str[3][128];
  int i,j,k,now[3]={0};
  for(i=0;i<3;i++) scanf("%s",str[i]);

  k=0;
  while(str[k][now[k]]!='\0'){
    j=(int)(str[k][now[k]]-'a');
    now[k]++;
    k=j;
  }
  printf("%c\n",'A'+k);
  return 0;
}


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

int main() {
    lli n;
    cin1(n);
    string s, t;
    cin >> s >> t;

    vector<int> ary;
    char cur, prev;
    prev = s[0];
    REPE(i, 1, n-1) {
        prev = s[i-1];
        cur = s[i];
        if (cur == prev) {
            ary.push_back(2);
            i++;
        }
        else {
            ary.push_back(1);
        }
    }
    if (s[n-1] != s[n-2]) {
        ary.push_back(1);
    }
    //ncout1(ary.size(), ary);
    lli mod = 1000000007;
    lli ans;
    if (ary[0] == 2)
        ans = 6;
    else
        ans = 3;
    REP(i, 0, ary.size()-1) {
        int cur = ary[i];
        int next = ary[i+1];
        if (cur == 1 && next == 1) {
            ans = ans * 2 % mod;
        }
        else if (cur == 1 && next == 2) {
            ans = ans * 2 % mod;
        }
        else if (cur == 2 && next == 1) {
        }
        else {
            ans = ans * 3 % mod;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < ll , ll >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 
const ll inf=1e18+1e17;
const ll mod =1e9+7;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=	(a*a)%mod;b>>=1;}return (res%mod);}
const int N = 2e5 + 5 ;


void solve(){
	char x;
	cin>>x;
	if ( x-'a'<0)
		cout<<"A\n";
	else
		cout<<"a\n";
	
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
	/*
	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif
// */
	ll t=1;
	//cin>>t;
	for ( ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
    	solve();
    }
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
int N, M, A, B, count = 0;
bool G[8][8];

int DFS(int V, int N, bool visited[8]) {
	bool ALL = true;
	int ret = 0;
	for (int i = 0; i < N; i++) {
		if (!visited[i]) ALL = false;
	}
	if (ALL) return 1;
	for (int i = 0; i < N; i++) {
		if (!G[V][i]) continue;
		if (visited[i]) continue;
		visited[i] = true;
		ret += DFS(i, N, visited);
		visited[i] = false;
	}
	return ret;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> A >> B;
		G[A - 1][B - 1] = true;
		G[B - 1][A - 1] = true;
	}
	bool visited[8];
	for (int i = 0; i < N; i++) {
		visited[i] = false;
	}
	visited[0] = true;
	cout << DFS(0, N, visited);
}

Measured memory_bytes: 256
#!/usr/bin/python3
import sys
input = lambda: sys.stdin.readline().strip()
k = int(input())
x = 0
for i in range(1, k + 1):
    x *= 10
    x += 7
    x %= k
    if x == 0:
        print(i)
        exit(0)
print(-1)


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

int main(void)
{
    int n, a, b;
    cin >> n >> a >> b;

    int sum = 0, alt = 0, ans = 0;
    for (int i = 1; i <= n; i++)
    {
        alt = i;
        do
        {
            sum += alt % 10;
            alt /= 10;
        } while(alt);
        if (a <= sum && sum <= b)
        {
            ans += i;
        }
        sum = 0;
    }

    cout << ans << endl;
}

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

int main(){
  long long n,a,b=1;
  cin>>n;

  for(int i=1; i<=sqrt(n); i++){
    if(n%i==0){
      a=i;
      b=n/i;
    }
  }

  int x=0,y=0;
  while(a!=0){
    a/=10;
    x++;
  }
  while(b!=0){
    b/=10;
    y++;
  }
  cout<<max(x,y)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define ll long long
#define coYes cout << "Yes" << endl
#define coYES cout << "YES" << endl
#define coyes cout << "yes" << endl
#define coNo cout << "No" << endl
#define coNO cout << "NO" << endl
#define cono cout << "no" << endl
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int b){ //最大公約数
    if(a%b == 0){
        return b;
    }else{
    return gcd(b, a%b);
    }
}

int main(){
    int n,m,count=0;
    cin >> n ;
    vector<string> s(n);
    rep0(i,n){
        cin >> s[i];
    }
    cin >> m;
    vector<string> t(m);
    rep0(i,m){
        cin >> t[i];
    }
    rep0(i,n){
        int c=0;
        rep0(j,n){
            if(s[i]==s[j]) c++;
        }
        rep0(j,m){
            if(s[i]==t[j]) c--;
        }
        count=max(c,count);
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

int main()
{
    double R0, W0, C, R;
    while (cin >> R0 >> W0 >> C >> R, (R0 > 0)) {        
        for (int X = 0; ; X++) {
            if ((R0 + X * R) / C - W0 >= 0) {
                cout << X << endl;
                break;
            }
        }
    }        
    return 0;
}

Measured memory_bytes: 3220
{-# LANGUAGE ScopedTypeVariables #-}

import           Data.Functor
import           Text.Printf

main :: IO ()
main = solve =<< fmap read . words <$> getLine

solve :: [Integer] -> IO ()
solve [a,b] = printf "%d %d %f\n" d r f
  where
    (d,r) = a `divMod` b
    f :: Double = (/) (fromInteger a) (fromInteger b)




Measured memory_bytes: 4060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 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; }

void _main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  double max = 0;
  int max_a = 0, max_b = 0;
  rep(i, 0, F/(A*100)+1) rep(j, 0, (F-A*i*100)/(B*100)+1) {
    if (0 == i && 0 == j) continue;
    int a = (A*i+B*j)*100;
    rep(c, 0, (F-a)/C+1) rep(d, 0, (F-a-c*C)/D+1) {
      int b = c*C + d*D;
      double r = (double)b/(a+b);
      if ((double)E/(100+E) >= r && max <= r) max = r, max_a = a+b, max_b = b;
    }
  }

  cout << max_a << " " << max_b << "\n";
}

Measured memory_bytes: 256