akhauriyash/Code-Regression huggingface dataset:
main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  case (n,m) of
    (1,1) -> print 0
    (0,mm) -> print mm
    (1,mm) -> print mm
    (nn,mm) -> print $ nn*(nn-1) `div` 2 + mm*(mm-1) `div` 2


Measured memory_bytes: 508
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
void solve()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a<b || d<b)
    {
        cout<<"No"<<endl;
        return ;
    }
    if(c>=b-1)
    {
        cout<<"Yes"<<endl;return ;
    }
    int g=__gcd(b,d);
    int k=(b-(a%b)+g-1)/g;k--;
    int ses=(a%b)+k*g;
    if(ses>c)
    {
        cout<<"No"<<endl;return ;
    }
    cout<<"Yes"<<endl;
}
 main()

{
    fast
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;

}





































Measured memory_bytes: 3580
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int mi =0;
    int ans = 0;
    rep(i,n){
        int m;
        cin >> m;
        ans += m;
        mi = max(mi,m); 
    }
    ans-=mi/2;
    cout << ans;
    return 0;
}

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

/*
全てのindexについて, そのindexから始めた場合第二手はどこに行くか, を有向グラフで表すと
1->2->4->1->2->4->1->...のように周期性が見つかる. その周期で1からk回操作したときの最大値を
それぞれの周期で求めて, そのmaxを取れば良い.
何回操作したときが最大かは, 一周期の合計がプラスなら(重ね得る周期数*一周期の合計)+一周期内で
累積和が最大になる地点, マイナスなら一周期内で累積和が最大になる地点, で求まる.
*/

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> p(n);
  vector<int> c(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> c[i];
  rep(i, n) p[i]--;  // 入力が1-indexなので0-index化
  ll ans = -1e18;
 
  // 全てのindexについて, そのindexから始めた場合の周期を調べる
  rep(si, n) {
    vector<int> s;  // 一周期の数列を入れる
  	ll total = 0;  // 一周期の合計
    int x = si;
    while (1) {
      x = p[x];  // 次のindex
      s.push_back(c[x]);
      total += c[x];
      if (x == si) break;  // 一周したのでbreak
    }
    
    int l = s.size();
    ll t = 0;  // 一周期の現時点までの累積和
    rep(i, l) {
      t += s[i];
      if (i + 1 > k) break;  // kが一周期分よりも少なかったらそこまでしか進めない
      ll now = t;  // 一周期の現時点までの累積和 (total>0なら+(一周期の合計*周期数))
      
      // 一周期の合計がマイナスなら周期を重ねるごとに最終値は減っていくので, 
      // 第一周期の中で累積和が最大になる地点が答え.
      // プラスなら周期を重ねるほど最終値は増えていくので,
      // 重ねられるだけ周期を重ねた合計 + 最終周期の中で累積和が最大になる地点が答え.
      if (total > 0) {
        ll e = (k - (i + 1)) / l;  // k-i回で何周期重ねられるか
        now += total * e;  // 一周期の合計 * 周期数
      }
      ans = max(ans, now);
    }
  }
  cout << ans << endl;
}

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

int main(){
  int N;
  string s;
  cin >> N >> s;
  int count = 0;
 
  for(int i=0; i<=999; i++){
    int a[3] = { i/100, (i/10)%10, i % 10};
    int tmp = 0;
    for(int k=0; k<N; k++){
      if(a[tmp] == (s[k] - '0')) tmp++;
      if(tmp == 3) break;
    }
    if(tmp == 3) count++;
  }
  cout << count << endl;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

string s;
bool dp[110][10];
string key="keyence",ans;

void input(){
	cin>>s;
	return;
}

void solve(){
	for(int i=0;i<s.size();i++){
		for(int j=i;j<s.size();j++){
			string now="";
			for(int k=0;k<i;k++)now+=s[k];
			for(int k=j;k<s.size();k++)now+=s[k];
			if(now==key){
				cout<<"YES"<<endl;
				return;
			}
		}
	}
	cout<<"NO"<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}

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


int main() {
  int num;
  int tmp;
  int cnt = 0;
  vector<int> vec(9,0);
  
  cin >> num;
  
  for(int i = 0; i < num; i++){
    cin >> tmp;
    if(tmp <=399) vec.at(0) = 1;
    if(tmp >= 400 && tmp <= 799) vec.at(1) = 1;
    if(tmp >= 800 && tmp <= 1199) vec.at(2) = 1;
    if(tmp >= 1200 && tmp <= 1599) vec.at(3) = 1;
    if(tmp >= 1600 && tmp <= 1999) vec.at(4) = 1;
    if(tmp >= 2000 && tmp <= 2399) vec.at(5) = 1;
    if(tmp >= 2400 && tmp <= 2799) vec.at(6) = 1;
    if(tmp >= 2800 && tmp <= 3199) vec.at(7) = 1;
    if(tmp >= 3200) vec.at(8) += 1;
  }
  
  for(int i = 0; i < 8; i++){
    if(vec.at(i) == 1) cnt++;
  }
  
  // Min
  if(cnt == 0 && vec.at(8) >= 1){
    cout << 1 << " ";
  }else{
    cout << cnt << " ";
  }
  
  // Max
  if(vec.at(8) >= 1){
    cnt = vec.at(8) + cnt;
  }
  
  cout << cnt;
}


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

using namespace std;

int main(){
  ios::sync_with_stdio(false); cin.tie(NULL);
  int n, m; cin >> n >> m;
  vector<vector<int> > adj(n + 1);
  for(int i = 0; i < m; i++){
    int u, v; cin >> u >> v;
    adj[u].push_back(v);
  }
  vector<int> dp(n + 1, -1);
  function<int(int)> dfs = [&](int u){
    if(dp[u] != -1) return dp[u];
    int ret = 0;
    for(auto v: adj[u]){
      ret = max(ret, 1 + dfs(v));
    }
    return dp[u] = ret;
  };
  int ans = 0;
  for(int i = 1; i <= n; i++) ans = max(ans, dfs(i));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8832
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

//constexpr int inf = 2147483647;
//constexpr int64_t inf64 = 9223372036854775807;
//constexpr int mod = 1e9+7;

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

  int x, y;
  cin >> x >> y;

  if (y % 2 != 0) cout << "No" << endl;
  else {
    if (x*2 <= y && y <= x*4) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>

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

using namespace std;
using ll = long long int;
using ull = unsigned long long;

constexpr ull mod = 1e9+7;
constexpr int N = 13;
ull dp[100010][N];

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	double x;
	cin >> x;
	double check = x;
	check /= 1.08;
	int b = check;
	if (b > 1) {
		if ((int)(b * 1.08) == x) {
			cout << b << endl;
			return 0;
		}
		if ((int)((b - 1) * 1.08) == x) {
			cout << (b - 1) << endl;
			return 0;
		}
		if ((int)((b + 1) * 1.08) == x ) {
			cout << (b + 1) << endl;
			return 0;
		}
	}
	if ((int)(b * 1.08) == x) {
		cout << b << endl;
		return 0;
	}
	if ((int)((b + 1) * 1.08) == x) {
		cout << (b + 1) << endl;
		return 0;
	}
	cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;


int main(int argc, char *argv[]) {
	long long int n, m, v, p;
	cin >> n >> m >> v >> p;
	vector<long long int> va;
	for (int i = 0; i < n; i++) {
		long long int t;
		cin >> t;
		va.push_back(t);
	}
	sort(va.begin(), va.end());
	reverse(va.begin(), va.end());
	vector<long long int> vva;
	long long int c = 0;
	for (int i = 0; i < n; i++) {
		c += va[i];
		vva.push_back(c);
	}
	long long int b = p - 1, e = n - 1;
	while (b < e) {
		long long int mm = (b + e) / 2 + 1;
		// cout << b << " " << e << " " << mm << endl;
		// p - 1 -> mm
		long long int vv = v - 1 - (n - (mm - (p - 1) + 1));
		vv *= m;
		if (vv <= 0) {
			if (va[mm] + m >= va[p - 1]) {
				b = mm;
			}
			else {
				e = mm - 1;
			}
			continue;
		}
		
		// cout << vv << endl; 
		// cout << (va[mm] + m) * (mm - p + 1) - (vva[mm - 1] - (p == 1 ? 0 : vva[p - 2])) << endl;
		if (va[mm] + m >= va[p - 1] && vv <= (va[mm] + m) * (mm - p + 1) - (vva[mm - 1] - (p == 1 ? 0 : vva[p - 2]))) {
			b = mm;
		}
		else {
			e = mm - 1;
		}
	}
	cout << b + 1 << endl;
}









Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 100100
const ll inf = (ll)1e10;
const ll MOD = (ll)1e9+7;
ll dp[22][1 << 22];
bool chk ( int pos, int mask ) {
	return mask & (1 << pos);
}
int on ( int pos, int mask ) {
	return mask | (1<<pos);
}
int n, done;
int adj[21][21];
ll solve(int pos , int mask){
    
    if (pos == n){
			if (mask == done - 1) return 1;
			return 0;
    }
    if(dp[pos][mask] != -1) return dp[pos][mask];
    ll ret = 0;
    for(int i = 0 ; i < n; i++){
			if ( adj[pos][i] && !chk(i,mask) ) ret = (ret + solve ( pos+1, on(i,mask) ) ) %MOD;
    }
    return dp[pos][mask] = ret;
}
int main()
{
	#ifdef __APPLE__
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < n; j++ ) {
			cin >> adj[i][j];
		}
	}
	done = (1<<n);
	memset(dp,-1,sizeof(dp));
	cout << solve(0,0) << endl;
	return 0;
}


Measured memory_bytes: 721152
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n,m;
  string s;
  cin >> n >> m;
  cout << !(n%m==0) << endl;
  return 0;
}


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


int main (){
    string s,t;
    cin >> s >> t;
    if ((s[0] == t[2]) && (s[1] == t[1]) && (s[2] == t[0])) cout << "YES" <<endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
s = gets.chomp.split
a,b,c = s[0].to_i,s[1],s[2].to_i

while b != '?' do
    case b
    when '+' then
        puts a+c
    when '-' then
        puts a-c
    when '*' then
        puts a*c
    when '/' then
        puts a/c
    end
    s = gets.chomp.split
    a,b,c = s[0].to_i,s[1],s[2].to_i
end

Measured memory_bytes: 8700
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, k, sum =0;
    scanf("%d %d",&n, &k);
    vector<int>arr(n);
    vector<int>v;
    for(int i = 0; i < n; i++){
        scanf("%d",&arr[i]);
        v.push_back(arr[i]);
    }
     sort(v.begin(),v.end());
    for(int i = 0; i < k; i++){
        sum = sum + v[i];
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL n, a, b;
  cin >> n >> a >>b;
  LL ball = a + b;
  cout << a*(n/ball) + min(a, n-ball*(n/ball));

  return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i,n){
        cin >> a[i];
    }
        rep(i,n){
        cin >> b[i];
    }
        rep(i,n-1){
        cin >> c[i];
    }

    int res = 0;
    int pre = -10;
    rep(i,n){
        res += b[a[i]-1];
        if(pre+1 == a[i]) res += c[a[i]-2];
        pre = a[i];
    }
    cout <<res;
}

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

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> s(H, vector<char>(W));
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			cin >> s[i][j];
		}
	}

	for(int i = 1; i < H - 1; i++) {
		for(int j = 1; j < W - 1; j++) {
			if(s[i][j+1] == '.' &&
			   s[i][j-1] == '.' &&
			   s[i+1][j] == '.' &&
			   s[i-1][j] == '.' &&
			   s[i][j] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


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

string fixedNum( string a )
{
    if( a.size() == 1 )
        return a;
    for( int i = 0; i < a.size(); i++ )
        if( '1'<= a[i] && a[i] <= '9' )
            return a.substr( i, a.size() );
    return "0";
}

string calcAddition( string a, string b )
{
    a = fixedNum(a); b = fixedNum(b);
    int as = a.size(), bs = b.size(), d = as > bs ? as - bs : bs - as;
    string s = "0", t = "0";
    for( int i = 0; i < d; i++ )
        as > bs ? t += "0" : s += "0";
    s += a; t += b;

    for( int i = s.size() - 1; i >= 1; i-- )
    {
        s[i] += t[i] - '0';
        if( s[i] > '9' )
        {
            s[i] -= 10;
            s[i-1]++;
        }
    }

    return s[0] == '0' ? s.substr( 1, s.size() ) : s;
}

string calcMultiplication( string a, string b )
{
    a = fixedNum(a); b = fixedNum(b);
    int as = a.size(), bs = b.size(), d = as > bs ? as - bs : bs - as;
    string s = "0", t = "0", x = "", sum = "", zero = "", digit = "";
    for( int i = 0; i < d; i++ )
        as > bs ? t += "0" : s += "0";
    s += a; t += b;

    for( int i = 0; i < s.size(); i++ )
        zero += "0";
    
    x = zero;
    sum = zero;

    for( int i = s.size() - 1; i >= 1; i-- )
    {
        for( int j = s.size() - 1; j >= 1; j-- )
            x[j] = ( t[i] - '0' ) * ( s[j] - '0' );
        for( int j = s.size() - 1; j >= 1; j-- )
        {
            int f = x[j] / 10;
            x[j-1] += f;
            x[j] = x[j] - 10 * f + '0';
        }
        x += digit;
        sum = calcAddition( x, sum );
        digit += "0";
        x = zero;
    }
    return sum;
}

int main()
{
    string a, b;

    cin >> a >> b;

    int as = a.size(), bs = b.size();
    string s = a.substr( 1, as ), t = b.substr( 1, bs );

    if( a[0] == '-' && b[0] == '-' )
        cout << calcMultiplication( s, t ) << endl;
    else if( a[0] >= '0' && b[0] >= '0' )
        cout << calcMultiplication( a, b ) << endl;
    else
    {
        if( a == "0" || b == "0" )
            cout << "0" << endl;
        else if( a[0] == '-' )
            cout << '-' << calcMultiplication( s, b ) << endl;
        else
            cout << '-' << calcMultiplication( a, t ) << endl;
    }
    return 0;
}




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

int main() {
    string s; cin >> s;
    bool ans = false;
    rep(i, s.size()) {
        if (s.at(i) == '7') ans = true;
    }

    cout << (ans ? "Yes" : "No") << endl;
}

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

int main(){
	long long minn=20000000000,maxn=-20000000000,n;
	for(int i=0;i<3;i++){
		cin>>n;
		minn=min(minn,n);
		maxn=max(maxn,n);
	}
	cout<<minn<<" "<<maxn<<endl;
	return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pint;
typedef pair<double,int> pdi;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(ll i = n;i > 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define INF (2147483647)
#define mod (1000000007)

string S;
ll L;

ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M) % M;
}



ll solve(int l){
  ll tmp;
  char s;
  bool flag;
  flag = true;
  for(ll i = l; i < L; i++){
    s = S[i];
    if(s=='1'){
      return (2*solve(i+1) + RepeatSquaring(3,L-1-i,mod)) % mod;
    }
  }
  return 1;

}


int main(void) {
  cin >> S;
  L = S.size();
  ll ans;
  ans = solve(0);
  cout << ans;

}


Measured memory_bytes: 2048
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

vll X;
vll Y;
vll Z;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

class UnionFind {
public:
    vector<ll> parent; // parent[i]:iの親の番号　(例) parent[3] = 2 : 3の親が2
    UnionFind(ll N){ //最初は全てが根であるとして初期化
        for(ll node_i = 0; node_i < N; node_i++){
            ll parent_i = node_i;
            parent.push_back(parent_i);
        }
    }
    ll getRoot(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (parent[x] == x) return x;
        return parent[x] = getRoot(parent[x]);
    }
    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = getRoot(x); //xの根をrx
        ll ry = getRoot(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        parent[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
    bool isSameRoot(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = getRoot(x);
        ll ry = getRoot(y);
        return rx == ry;
    }
};

int main(){

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

    cin >> N;
    cin >> M;
    X.resize(M);
    Y.resize(M);
    Z.resize(M);

    rep(mi,M){
        cin >> X[mi];
        cin >> Y[mi];
        cin >> Z[mi];
    }
    rep(mi,M){
        X[mi]--;
        Y[mi]--;
    }
    
    UnionFind uf(N);

    rep(mi,M){
        uf.unite(X[mi],Y[mi]);
    }

    map<ll,ll> count_map;
    rep(ni,N){
        ll root_no = uf.getRoot(ni);
        count_map[root_no]++;
    }

    ll ans = 0;
    for(auto x : count_map) {
        ans++;
    }
    cout << ans << endl;
    

}

Measured memory_bytes: 12404
#include <iostream>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	
	int ans = t.size();
	
	for (int start = 0; start <= s.size() - t.size(); ++start) {
		int diff = 0;
		for (int i = 0; i < t.size(); ++i) {
			if (t[i] != s[start + i]) diff++;
		}
		ans = min(ans, diff);
	}
	
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		sa = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int[] c = new int[h * w];
		int k = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < a[i]; j++) {
				c[k] = i + 1;
				k++;
			}
		}

		for (int i = 0; i < h; i++) {
			StringBuilder sb = new StringBuilder();
			for (int j = 0; j < w; j++) {
				k = w * i;
				if (i % 2 == 0) {
					k += j;
				} else {
					k += w - 1 - j;
				}
				sb.append(c[k]).append(' ');
			}
			sb.deleteCharAt(sb.length() - 1);
			System.out.println(sb.toString());
		}
	}
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define all(a) (a).begin(),(a).end()
#define X first
#define Y second
#define inf 2e9+5
using namespace std;
const int N=1e5+5;
int wt[105],val[105];
int dp[N];
void solve()
{
  int n,w,ans=0; cin>>n>>w;
  for(int i=0;i<n;i++)cin>>wt[i]>>val[i];
  for(int i=0;i<n;i++)
  {
      for(int j=w-wt[i];j>=0;j--)
        {
            dp[wt[i]+j]=max(dp[wt[i]+j],dp[j]+val[i]);
            ans=max(ans,dp[wt[i]+j]);
       }
  }
  cout<<ans;
  return;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t; t=1;
    while(t--)solve();
    return 0;
}


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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int x,a,b;

int main()
{


    cin>>x>>a>>b;
    if(abs(x-a)>abs(x-b))
        cout<<"B";
    else
        cout<<"A";
}




Measured memory_bytes: 256
import math

n = input()
n = int(n)

points = []

for i in range(int(n)):
  p = input().split(" ")
  points.append((int(p[0]),int(p[1])))
  
sum = 0
for i in range(n):
  for j in range(n):
    dx = points[i][0] - points[j][0]
    dy = points[i][1] - points[j][1]
    sum += math.sqrt(dx*dx+dy*dy)
   
print(sum/( n ))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)




int main(){
    int n,q; cin>>n>>q;
    vector<vector<int>> p(n);
    rep(i,n-1){
        int a,b; cin>>a>>b;
        a--; b--;
        p[a].push_back(b);
        p[b].push_back(a);
    }
    vector<ll> padd(n,0);
    rep(i,q){
        int a,b; cin>>a>>b;
        padd[a-1]+=b;
    }
    deque<int> che;
    che.push_back(0);
    vector<ll> ans(n,-1);
    ans[0]=0;
    while(!che.empty()){
        int now=che[0];
        che.pop_front();
        ans[now]+=padd[now];
        for(auto &v: p[now]){
            if(ans[v]!=-1) continue;
            ans[v]=ans[now];
            che.push_back(v);
        }
    }
    rep(i,n){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 18856
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 

void lcs( char *X, char *Y, int m, int n ){ 
   int L[m+1][n+1];
   for (int i=0; i<=m; i++){ 
     for (int j=0; j<=n; j++){ 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   }
   int index = L[m][n]; 
   char lcs[index+1]; 
   lcs[index] = '\0';
   int i = m, j = n; 
   while (i > 0 && j > 0){
      if (X[i-1] == Y[j-1]){ 
          lcs[index-1] = X[i-1];
          i--; j--; index--;
      }
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   }
   cout <<lcs; 
} 
int main(){ 
  char X[100000]; 
  char Y[100000]; 
  cin>>X>>Y;
  int m = strlen(X); 
  int n = strlen(Y); 
  lcs(X, Y, m, n); 
  return 0; 
} 

Measured memory_bytes: 35456
#include<bits/stdc++.h>
#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define int long long
#define F first
#define S second
#define pb push_back
#define p2(n) (1<<(n))
#define lg2(n) __lg(n)
using namespace std;
using pii = pair<long long,long long>;
using ld = long double;
mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

int n,ans;
int a[110];

void solve(){
    cin >> n;
    rep(i,0,n)
        cin >> a[i];
    sort(a,a+n);
    rep(i,0,n)
        rep(j,i+1,n)
            if(a[i]!=a[j])
                rep(k,j+1,n)
                    if(a[k]!=a[i]&&a[k]!=a[j]&&a[k]<a[i]+a[j])
                        ans++;
    cout << ans << '\n';
}

signed main(){
    Rushia_mywife
    solve();
}

Measured memory_bytes: 3660
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = input()

N = [int(i) for i in N]

def dfs(l):
    if len(l) == 3:
        # 計算する
        result = N[0]
        for idx, op in enumerate(l):
            if op:
                result += N[idx+1]
            else:
                result -= N[idx+1]
        if result == 7:
            s = str(N[0])
            for n in range(len(l)):
                if l[n]:
                    s += "+"
                else:
                    s += "-"
                s += str(N[n+1])
            s += "=7"
            print(s)
            exit()
        return
    dfs(l + [0])
    dfs(l + [1])
dfs([])




Measured memory_bytes: 65772
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}


int main(void) {
	int n, k;
	cin >> n >> k;
	
	int count = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (k <= a) {
			count++;
		}
	}

	COUT(count);

	return 0;
}


Measured memory_bytes: 256
n, k = list(map(int, input().split()))

l = []
for i in range(n):
    score = i+1
    count = 0
    while(1):
        if score >= k:
            break
        score = score*2
        count += 1
    l.append((1/n)*pow((1/2),count))

print(sum(l))

Measured memory_bytes: 6296
#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 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const int NM = 101001;//ここを問題の制約を見ながらいじる．配列の確保に使う．
//int p[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．

// Main program
void solve() {
    ll H, W, N;
    cin >> H;
    cin >> W;
    cin >> N;

    ll sum = 0;

    if (H > W) {
        sum = ceil((double)N / (double)H);
    }
    else {
        sum = ceil((double)N / (double)W);
    }
    cout << sum;

    return;

}

int main() {
    solve();
    return 0;
}







Measured memory_bytes: 256
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
N = INT()
A = LIST()

ans = []
for i in range(N):
    tmp = [i+1] * A[i]
    ans += tmp

ans = np.array(ans).reshape(H, W).tolist()
for i in range(H):
    if i % 2 == 1:
        ans[i] = ans[i][::-1]

for a in ans:
    print(' '.join([str(i) for i in a]))


Measured memory_bytes: 27540
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

K = INT()

ans = 0
for i in range(1, K+1):
	for j in range(1, K+1):
		a = gcd(i, j)
		for k in range(1, K+1):
			ans += gcd(a, k)
print(ans)


Measured memory_bytes: 74864
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a==2||b==2){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
  

  
}

Measured memory_bytes: 20948
N=gets.chomp.to_i
array=gets.chomp.split(' ').map{|n|n.to_i}

hash = {}
bool = true

array.each do |item|
  if hash.has_key?(item) then
    bool = false
    break
  else
    hash[item] = true
  end
end

if bool then
  puts "YES"
else
  puts "NO"
end

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

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++){
    cin >> s.at(i);
  }
  sort (s.begin() , s.end());
  int count = 1;
  for (int i = 0; i < n - 1; i++){
    if (s.at(i) != s.at(i + 1)){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 9512
#include<stdio.h>
int n;
int p[20];
int abs(int x) {
	return ((x > 0) - (x < 0)) * x;
}
int min(int a, int b) {
	if (a <= b) return a;
	else return b;
}
int solve(int i, int sa, int sb) {
	int ssa, ssb;
	if (i >= n) return abs(sa - sb);
	ssa = solve(i + 1, sa + p[i], sb);
	ssb = solve(i + 1, sa, sb + p[i]);
	return min(ssa, ssb);
}
int main() {
	int i;
	while (1) {
		scanf("%d", &n);
		if (!n) break;
		for (i = 0; i < n; i ++) scanf("%d", &p[i]);
		printf("%d\n", solve(0, 0, 0));
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;cin>>n;
    vint h(n), a(n);
    rep(i, n){
        cin>>h[i];
    }
    int c = 0;int mi = 2000000000;
    for(int i = n-1;i>=0;i--){
        if(h[i] >= mi){
            c++;
            a[i] = c;
            chmax(mi, h[i]);
        }else{
            c = 0;
            a[i] = 0;
            mi = h[i];
        }
    }
    int ans = 0;
    rep(i, n){
        debug("%d %d \n",i , a[i]);
        chmax(ans, a[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
//参考http://d.hatena.ne.jp/kyuridenamida/20101019/1287421535 
using namespace std;
#define cost first.first
#define pos first.second
#define visit second
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

typedef pair<pair<int,string>,int> Node;

map<string,vector<pair<string,int> > > nodeinfo;
map<string,int> cakeshop;
int dijkstra(){
  int ret = 100000000;

  priority_queue<Node,vector<Node>,greater<Node> > Q;

  Q.push(make_pair(make_pair(0,"H"),0));
  map<string,int> memo[1<<10];
  while(Q.size()){
    Node q = Q.top();
    Q.pop();
    if(memo[q.visit].find(q.pos) !=memo[q.visit].end()){
      if(memo[q.visit][q.pos] <=q.cost) continue;
    }
    memo[q.visit][q.pos] = q.cost;

    if(q.pos =="D"){
      ret =min(q.cost,ret);
    }
    for(int i = 0;i <nodeinfo[q.pos].size();i++){
      Node next;
      next.visit = q.visit;
      next.cost = q.cost+nodeinfo[q.pos][i].second;
      next.pos = nodeinfo[q.pos][i].first;

      if(next.pos[0] =='C' &&(q.visit&(1<<(next.pos[1]-'1'))) )
	continue;
      if(next.pos[0] =='C'){
	next.visit |=(1<<(next.pos[1]-'1'));
	next.cost -=cakeshop[next.pos];
      }
      Q.push(next);
    }
  }
  return ret;
}
int main()
{
  int m,n,k,d;
  while(cin >>m>>n>>k>>d,m){
    nodeinfo.clear();
    cakeshop.clear();
    for(int i = 0;i < m;i++){
      int c;
      cin >>c;
      stringstream ss;
      ss <<'C'<<i+1;
      cakeshop[ss.str()] = c;
    }
    for(int i = 0;i < d;i++){
      string a,b;
      int c;
      cin >>a>>b>>c;
      nodeinfo[a].push_back(make_pair(b,c*k));
      nodeinfo[b].push_back(make_pair(a, c*k));
    }
    cout <<dijkstra()<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 2544
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Traveling AtCoDeer Problem
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int INF = 1 << 30;

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int mina = INF, maxa = 0;
  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    if (mina > ai) mina = ai;
    if (maxa < ai) maxa = ai;
  }

  printf("%d\n", maxa - mina);
  return 0;
}


Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    n,m=map(int,input().split())
    sc=[list(map(int,input().split())) for _ in range(m)]
    ans=-1
    for i in range(10**3):
        if (len(str(i))==n):
            flag=1
            for s,c in sc:
                if str(i)[s-1] != str(c):
                    flag=0
            if flag==1:
                ans =i
                break

    print(ans)



main()


Measured memory_bytes: 3060
k = gets.to_i
digit = 1
count = 0
tl = []
loop do
  tl[digit] = [] if tl[digit].nil?

  (0..9).each do |ti|
    if digit == 1
      tl[digit] << ti
      count += 1 unless ti.zero?
      break if count == k
    else
      min_idx = tl[digit-1].bsearch_index { |tld| tld / (10 ** (digit - 2)) >= ti - 1 }
      max_idx = tl[digit-1].bsearch_index { |tld| tld / (10 ** (digit - 2)) > ti + 1 } || tl[digit-1].size
      tl[digit-1][min_idx..(max_idx-1)].each do |tn|
        tl[digit] << ti * 10 ** (digit-1) + tn
        count += 1 unless ti.zero?
        break if count == k
      end
      break if count == k
    end
  end

  break if count == k
  digit += 1
end
puts tl[digit].last

Measured memory_bytes: 2808
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int R = sc.nextInt();
    int G = sc.nextInt();
    int B = sc.nextInt();
    int N = sc.nextInt();

    int ans = solve(R, G, B, N);

    System.out.println(ans);
  }
  
  private static int solve(int R, int G, int B, int n) {
    int count = 0;
    for (int i = n/R; i >=0; i--) {
      int minusR = n - i*R;
      for (int j = minusR/G; j >= 0; j--) {
        int minusRG = minusR - j*G;
        if (minusRG % B == 0) {
          count++;
        }
      }
    }
    return count;
  }
}  


Measured memory_bytes: 23124
#include <complex.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <stdio.h>

using namespace std;

typedef complex<double> xy_t;

double dot_product(xy_t a, xy_t b) {
  return (conj(a)*b).real();
}

double cross_product(xy_t a, xy_t b) {
  return (conj(a)*b).imag();
}

int main() {
  xy_t P[110];
  int N = 0;
  double x, y;
  
  while(scanf("%lf,%lf", &x, &y)!= EOF) {
    xy_t entry(x,y);
    P[N++] = entry;
  }

  //center all coordinates based on first element
  for (int i = 1; i < N; i++) {
    P[i] -= P[0];
  }
  
  //calculate sum
  double sum = 0.0;
  for (int i = 1; i+1 < N ; i++) {
    xy_t  a = P[i] , b = P[i + 1];
    sum += cross_product(a, b) / 2.0;
  }

  printf("%.6f\n", abs(sum));
  
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int K, A, B; cin >> K >> A >> B;
  for (int k = A; k <= B; ++k) {
    if (k % K == 0) {
      cout << "OK" << CRLF;
      return;
    }
  }
  cout << "NG" << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int q; cin >> q;
	while(q--){
		ll a,b; cin >> a >> b;
		if(a>b)swap(a,b);
		if(a==b){
			printf("%lld\n",2*(a-1));
		}else{
			double pp=sqrt(a*b);
			ll p=pp;
			ll ans=0;
			if(p*p==a*b){
				p--;
			}
			else if(p*(p+1)>=a*b){
				ans--;
			}
			ans+=p*2-1;
			printf("%lld\n",ans );
		}
	}
}


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

int main() {
    string s;
    cin>>s;
    int ans=700;
    rep(i,3) {
        if (s[i]=='o') ans+=100;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

#define MOD 1000000007

int N;
int x[100000];
int y[100000];
set<int> tree[100000];
ll dpW[100000];
ll dpB[100000];

ll dfs(int v, int prev, bool prevColor)
{
    if (dpB[v] != -1) {
        if (prevColor) return ((dpW[v] + dpB[v]) % MOD);
        else return (dpW[v] % MOD);
    }
    else {
        ll countW = 1, countB = 1;
        for (auto itr = tree[v].begin(); itr != tree[v].end(); ++itr) {
            if ((*itr) != prev) {
                countW = (countW * dfs((*itr), v, true)) % MOD;
                countB = (countB * dfs((*itr), v, false)) % MOD;
            }
        }
        dpW[v] = countW;
        dpB[v] = countB;
        if (prevColor) return ((dpW[v] + dpB[v]) % MOD);
        else return (dpW[v] % MOD);
    }
}


int main(int argc, char **argv)
{
    cin >> N;
    REP(i, N - 1) cin >> x[i] >> y[i];

    REP(i, N - 1) {
        tree[x[i] - 1].insert(y[i] - 1);
        tree[y[i] - 1].insert(x[i] - 1);
    }
    REP(i, N) dpW[i] = -1;
    REP(i, N) dpB[i] = -1;

    cout << dfs(0, -1, true) << endl;

    return 0;
}


Measured memory_bytes: 23552