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

using ll = long long;

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.at(i).at(j);
        }
    }

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

    using P = pair<int, int>;   

    int max_dist = 0;

    for (int sy = 0; sy < h; sy++) {
        for (int sx = 0; sx < w; sx++) {
            for (int gy = 0; gy < h; gy++) {
                for (int gx = 0; gx < w; gx++) {
                    if (s.at(sy).at(sx) == '#' || s.at(gy).at(gx) == '#') continue;
                    
                    vector<vector<int>> d(h, vector<int>(w, 1000));
                    queue<P> que;

                    que.push(P(sy, sx));

                    d.at(sy).at(sx) = 0;

                    while (!que.empty()) {
                        P pos = que.front(); que.pop();
                        if (pos.first == gy && pos.second == gx) break;

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

                            if (0 <= ny && ny < h && 0 <= nx && nx < w && 
                                s.at(ny).at(nx) != '#' && 
                                d.at(ny).at(nx) == 1000) {
                                que.push(P(ny, nx));
                                d.at(ny).at(nx) = d.at(pos.first).at(pos.second) + 1;
                            }
                        }
                    }

                    if (d.at(gy).at(gx) == 1000) continue;

                    max_dist = max(max_dist, d.at(gy).at(gx));
                    //printf("%d %d %d %d %d\n", sy, sx, gy, gx, d[gy][gx]);
                }
            }
        }
    }
    cout << max_dist << endl;
}

Measured memory_bytes: 256
//file_name:ABC64_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);


    ll ans = 0;

    ans = a[n-1]-a[0];

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



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

#define mo 998244353
#define MAXN 3005 
#define int long long

int n,m,S;
int s[MAXN],a[MAXN],c[MAXN],d[MAXN];

void rd()
{
	cin >> n >> S;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
}

signed main()
{
	rd();
//	c[0] = s[0] = 1;
	int ans = 0;
	for(int i = 1; i <= n; i ++) {
		c[0] ++;
		for(int j = S; j >= 0; j --)
			if(j+a[i] <= S) {
				c[j+a[i]] += c[j];
				if(c[j+a[i]] >= mo) c[j+a[i]] -= mo;
			}
		for(int j = 0; j <= S; j ++) {
			s[j] += c[j]; 
			if(s[j] >= mo) s[j] -= mo;
		}
		for(int j = 0; j <= S; j ++)
			d[j] += s[j];/*
		cout<<i<<"----\n";
		for(int j = 0; j <= S; j ++)
			cout<<c[j]<<" ";
		cout<<"\n";
		for(int j = 0; j <= S; j ++)
			cout<<s[j]<<" ";
		cout<<"\n\n";*/
	/*	cout<<"\n";
		for(int j = 0; j <= S; j ++)
			cout<<d[j]<<" ";
		cout<<"\n\n";*/
		
		
		ans += c[S];
		if(ans >= mo) ans -= mo;
	}
//	ans += c[S];
	cout<<ans%mo<<"\n";
	return 0;
}
/*
3 4
2 2 4
4 5
2 2 3 3 
*/

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int arr[100005];
int main()
{
	int n;
	scanf("%d",&n);
	long long sum=0,cnt=0;
	for (int i=0;i<n;i++)
	scanf("%d",&arr[i]),sum+=arr[i];
	long long tmp=1LL*n*(n+1)/2;
	if (sum%tmp)
	{
		printf("NO");
		return 0;
	}
	sum/=tmp;
	for (int i=0;i<n;i++)
	{
		long long cur=arr[i]-(arr[(i+1)%n]-sum);
		if (cur<0 || cur%n)
		{
			printf("NO");
			return 0;
		}
		cnt+=cur/n;
	}
	printf((cnt==sum)? "YES":"NO");
}

Measured memory_bytes: 640
//
//  main.cpp
//  D
//
//  Created by Charles on 2017/12/24.
//  Copyright © 2017年 Charles. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
const int maxn=1e5+5;
char s[maxn];
int main(int argc, const char * argv[]) {
    while(~scanf("%s",s)){
        int len=(int)strlen(s);
        int ans=(len+1)/2;
        while(ans<len && s[ans]==s[ans-1] && s[len-ans]==s[len-ans-1]) ans++;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int k; cin >> k;
    int num = 0;
    rep(i, (int)1e8) {
        num = num*10 + 7;
        num = num%k;
        // debug(num);
        if (num==0) {
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

int main(){
  int n, d;  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d, 0));
  rep(i,n)rep(j,d)  cin >> x[i][j];
  int ans = 0;
  rep(k,n){
    rep(i,k){
    double a = 0;
      rep(j,d){
          a+=(x[k][j]-x[i][j])*(x[k][j]-x[i][j]);
      }
    int b = sqrt(a);
    if(a == b*b) ans++;
    }
  }
  cout << ans << endl;
  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;

int main() {
	int n;
	cin>>n;
	
	vector<pair<int,int>> v(n);
	rep(i,n){
		int a;
		cin>>a;
		v[i]=make_pair(a,i+1);
		
	}
	
	sort(v.begin(),v.end());
	
	rep(i,n){
		cout<<v[i].second<<" ";
	}
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;

vector<int> Z_algorithm(vector<ll> S) {
	int c = 0, n = S.size();
	vector<int> Z(n, 0);
	for (int i = 1; i < n; i++) {
		int l = i - c;
		if (i + Z[l] < c + Z[c]) {
			Z[i] = Z[l];
		}
		else {
			int j = max(0, c + Z[c] - i);
			while (i + j < n && S[j] == S[i + j])j++;
			Z[i] = j;
			c = i;
		}
	}

	Z[0] = n;
	return Z;
}

int N;
ll a[200000 + 100], b[200000 + 100];

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

	vector<ll> xor_a(N), xor_b(N);
	for (int i = 0; i < N - 1; i++) {
		xor_a[i] = a[i] ^ a[i + 1];
	}
	xor_a[N - 1] = a[N - 1] ^ a[0];
	for (int i = 0; i < N - 1; i++) {
		xor_b[i] = b[i] ^ b[i + 1];
	}
	xor_b[N - 1] = b[N - 1] ^ b[0];
	
	vector<ll> tmp_for_zalgo;//xor_b + xor_a + xor_a
	//上の3つを連結したものにZ_algoを適用して、共通接頭辞の長さがN(bの長さ)を超えてるのならば、bと一致するといえる。
	for (int i = 0; i < N; i++)tmp_for_zalgo.push_back(xor_b[i]);
	for (int i = 0; i < N; i++)tmp_for_zalgo.push_back(xor_a[i]);
	for (int i = 0; i < N; i++)tmp_for_zalgo.push_back(xor_a[i]);

	auto res_for_zalgo = Z_algorithm(tmp_for_zalgo);

	vector<pair<int, ll>> ans;
	for (int i = N; i < 2 * N; i++) {
		if (res_for_zalgo[i] >= N) {
			ans.push_back(make_pair(i - N, a[i - N] ^ b[0]));
		}
	}
	sort(ans.begin(), ans.end());
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].first << " " << ans[i].second;
		cout << endl;
	}
	return 0;
}

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

using namespace std;
typedef unsigned int ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

ll s[2001],t[2001],dp[2001][2001]={0};

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,m;cin>>n>>m;
    REP(i,n){cin>>s[i];}
    REP(i,m){cin>>t[i];}
    REP(i,n+1){dp[i][0]=1;}
    REP(i,m+1){dp[0][i]=1;}
    REP(i,n){
        REP(j,m){
            if(s[i]==t[j]){
                dp[i+1][j+1]=(dp[i+1][j]+dp[i][j+1])%MOD;
            }else{
                dp[i+1][j+1]=(dp[i+1][j]+dp[i][j+1]-dp[i][j]+MOD)%MOD;
            }
        }
    }
    cout<<dp[n][m]<<"\n";
}

Measured memory_bytes: 19200
#include <bits/stdc++.h>
#include <string.h>
#define ll long long
using namespace std;
struct value
{
	ll x;
	ll y;
};
bool compare(value a, value b)
{
	//for descending order replace with a.roll >b.roll
	if (a.y < b.y)
		return 1;
	else
		return 0;
}
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
bool isPerfectSquare(long double x) 
{    
  long double sr = sqrt(x);  
  return ((sr - floor(sr)) == 0); 
} 
void pk()
{
	string s;
	cin>>s;
	if(s=="SUN")
	  {cout<<7; return;}
	if(s=="MON")
	  {cout<<6; return;}
	if(s=="TUE")
	  {cout<<5; return;}
	if(s=="WED")
	  {cout<<4; return;}
	if(s=="THU")
	  {cout<<3; return;}
	if(s=="FRI")
	  {cout<<2; return;}
	if(s=="SAT")
	  {cout<<1; return;}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	{
		pk();
	}
	
}

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

int main() {
  long long n;
  cin >> n;
  
  map<string,long long> ms;
  string t;
  for(int i=0;i<n;i++){
    cin >> t;
    sort(t.begin(),t.end());
    ms[t]++;
  }
  long long ans = 0;
  for (auto x : ms){
    if(x.second > 1){
      ans+= ((x.second * (x.second - 1)) / 2);
    }
  }
  cout << ans;  
}

Measured memory_bytes: 11136
import itertools
H,W,K=map(int,input().split())

sl=[]
for i in range(H):
    s=input()
    sl.append(s)

sh=list(range(H))
sw=list(range(W))

cnt=0

for i in range(H+1):
    for sqh in itertools.combinations(sh,i):
        for j in range(W+1):
            for sqw in itertools.combinations(sw,j):
                bcnt=0
                #print(sqh,sqw)
                for k in range(H):
                    for l in range(W):
                        if k not in sqh and l not in sqw:
                            if sl[k][l]=="#":
                                bcnt+=1
                
                if bcnt==K:
                    cnt+=1

print(cnt)

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

#define N 200123
#define mod 1000000007

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    if(fopen("input.in", "r")){
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int a, b;
    cin >> a >> b;
    cout << max(0, a-b*2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int n; cin >> n;
    vector<double> dp(n+1,0);
    dp[0] = 1;
    rep(i,n) {
        double p; cin >> p;
        vector<double> dp_tmp(n+1,0);
        rep(j,n+1) {
            dp_tmp[j] += dp[j]*(1-p);
            if (j-1 >= 0) dp_tmp[j] += dp[j-1]*p;
        }
        swap(dp,dp_tmp);
    }
    double ans = 0;
    for (int i = (n+1)/2; i <= n; i++) {
        ans += dp[i];
    }
    printf("%.10f\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

const ll A=0, G=1, C=2;

int main(void) {
  ll N;
  cin >> N;
  ll i, j, k, l, m;
  ll dp[105][4][4][4]={};
  
  for(j=0; j<4; j++) {
    for(k=0; k<4; k++) {
      for(l=0; l<4; l++) {
        if(j==A&&k==G&&l==C) continue;
        if(j==G&&k==A&&l==C) continue;
        if(j==A&&k==C&&l==G) continue;
        dp[3][j][k][l]=1;
      }
    }
  }
  
  for(i=3; i<N; i++) {
    for(j=0; j<4; j++) {
      for(k=0; k<4; k++) {
        for(l=0; l<4; l++) {
          for(m=0; m<4; m++) {
            if(k==A&&l==G&&m==C) continue;
            if(k==G&&l==A&&m==C) continue;
            if(k==A&&l==C&&m==G) continue;
            
            if(j==A&&l==G&&m==C) continue;
            if(j==A&&k==G&&m==C) continue;
            
            moC(dp[i+1][k][l][m], +, dp[i][j][k][l]);
            
          }
        }
      }
    }
  }
  
  ll ans=0;
  for(j=0; j<4; j++) {
    for(k=0; k<4; k++) {
      for(l=0; l<4; l++) {
        moC(ans, +, dp[N][j][k][l]);
      }
    }
  }
  
  pt(ans);
}
  
  


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a, b, c, d,e,f,g;
	cin >> a >> b >> c >> d;
	e = a * b;
	f = a - c;
	g = b * c;
	if (a*b == c * d) {
		cout << 0 << endl;
	}
	
	else {
		cout << e - (g + f*d) << endl;
	}
}

Measured memory_bytes: 3608
Array = [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]

K = gets.chomp.to_i

puts Array[K-1]

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

using namespace std;

int main(){
	int SrcNum, FeatureNum, Plus;
  	cin >> SrcNum >> FeatureNum >> Plus;
  
	vector<int> aMulti(FeatureNum);
  	for(int i = 0; i < FeatureNum; ++ i)
      cin >> aMulti[i];
  
  	int nCorrect = 0;
  	while(SrcNum-- > 0){
    	int nResult = 0;
      	for(int i = 0; i < FeatureNum; ++ i){
          	int nFeature;
          	cin >> nFeature;
          	nResult += nFeature * aMulti[i];
        }
      
      	if(nResult > -Plus) ++ nCorrect;
    }
  
  	cout << nCorrect << endl;
  
	return 0; 
}

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

int floor(ll x, ll y) {
  return x / y;
}

int main() {
  ll A, B, N;cin >> A >> B >> N;
  if (B == 1) cout << 0 << endl;
  else {
    if (N < B) {
      ll C = floor(A * N, B) - A * floor(N, B);
      cout << C << endl;
    }
    else {
      ll D = floor(A * (B - 1), B) - A * floor((B - 1), B);
      cout << D << endl;
    }
  }
}

Measured memory_bytes: 3488
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, H, N, A[1001], B[1001];
	scanf("%d %d", &H, &N);
	for (i = 1; i <= N; i++) scanf("%d %d", &(A[i]), &(B[i]));
	
	int h, j, cost[10001] = {};
	for (h = 1; h <= H; h++) {
		cost[h] = cost[h-1] + B[1];
		for (i = 1; i <= N; i++) {
			j = (h >= A[i])? h - A[i]: 0;
			if (cost[j] + B[i] < cost[h]) cost[h] = cost[j] + B[i];
		}
	}
	
	printf("%d\n", cost[H]);
	fflush(stdout);
	return 0;
}

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

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


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
using namespace std;
typedef long long ll;

int main() {
	int D;
	ll G;
	cin >> D >> G;
	int p[D];
	int c[D];
	for (int i = 0; i < D; i++) {
		cin >> p[i] >> c[i];
	}
	
	int min = INT_MAX;
	for (int i = 0; i < (1 << D); i++) {
		ll sum = 0;
		int ans = 0;
		for (int j = 0; j < D; j++) {
			if ((1 << j) & i) {
				sum += 100 * (j+1) * p[j] + c[j];
				ans += p[j];
			}
		}
		//cout << ans<<" "<<sum<<endl;
		ll left = G - sum;
		if (left>0) {
			for (int j = D - 1; j >= 0; j--) {
				if (!((1 << j) & i)) {

					if ((int)(left / (100 * (j+1))) + 1 <= p[j]) {
						int Ans = (int)(left / (100 * (j+1))) ;
						if (left % (100 * (j + 1)) != 0)Ans++;
						ans += Ans;
						sum += Ans * (100 * (j+1));
					}
					break;
				}
			}
		}
		//cout << ans<<" "<<sum << endl;
		if (ans < min&&sum>=G) {
			min = ans;
		}
	}
	cout << min;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(a,b) (0<=(a)&&(a)<b)
using namespace std;

int main(){
	int t,N;
	int dx[6]={1,1,0,-1,-1,0};
	int dy[6]={0,1,1,0,-1,-1};
	while(cin>>t>>N && (t!=0||N!=0)){
		int visited[121][121]={0};
		int tx,ty,ans=1;
		queue<pair<int,int>> q;
		REP(i,0,N){
			cin>>tx>>ty;
			visited[ty+60][tx+60]=-1;
		}
		int sx,sy;
		cin>>sx>>sy;
		q.push({sx+60,sy+60});
		visited[sy+60][sx+60]=1;
		while(!q.empty()){
			int nowx=q.front().first,nowy=q.front().second;
			q.pop();
			REP(k,0,6){
				int nextx=nowx+dx[k],nexty=nowy+dy[k];
				if(visited[nexty][nextx]!=0) continue;
				visited[nexty][nextx]=visited[nowy][nowx]+1;
				ans++;
				if(visited[nexty][nextx]<=t)	q.push({nextx,nexty});
			}
		}

		p(ans);
	}
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
  int n; cin>>n;
  vector<string> v;
  bool flag = true;
  for(int i = 0; i< n; i++){
    string s; cin>>s;
    v.push_back(s);
    if(i>0){
      if(v[i-1][v[i-1].size()-1] != v[i][0]){
        flag = false;
      }
      for(int j = 0; j<v.size();j++){
        if(v[i] == v[j]&&i != j) flag = false;
      }
    }
  }
  cout<<(flag ? "Yes":"No")<<endl;

  return 0;
}


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

int main()
{
	int a[3];
	int k;
	for(int i=0;i<3;i++)
		cin>>a[i];
	cin>>k;
	sort(a,a+3);
	while(k--) {
		a[2]*=2;
	}
	int ans=0;
	for(int i=0;i<3;i++)
		ans+=a[i];
	cout<<ans<<endl;	
	return 0;
 } 

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;
const int inf = 1001001001;



int main(void) {
  int a,p;
  cin >> a >> p;
  cout << (a*3+p)/2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1000000007;
ll fact[1200200];
ll invfact[1200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


int main(){
    make_fact(1100000);
    make_invfact(1100000);
    ll x, y;
    cin >> x >> y;
    if((x + y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }

    ll n = x + y;
    x -= n / 3;
    y -= n / 3;
    if(x < 0 || y < 0){
        cout << 0 << endl;
    }
    else{
        cout << comb(x+y, x) << endl;
    }


    return 0;
}




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

typedef vector<int> vi;

const int MOD = (int)(1e+9) + 7;
int H, W;
vector<string> M;
vector<vi> dp;

void input_init(void) {
	cin >> H >> W;
	M.resize(H);
	for (int j = 0; j < H; ++j)
		cin >> M[j];
	dp.resize(H, vi(W, 0));
}

void solve(void) {
	dp[0][0] = 1;
	for (int j = 0; j < H; ++j) {
		for (int i = 0; i < W; ++i) {
			if (i != 0) {
				if (M[j][i] != '#')
					dp[j][i] += dp[j][i - 1];
					dp[j][i] %= MOD;
			}
			if (j != 0) {
				if (M[j][i] != '#')
					dp[j][i] += dp[j - 1][i];
					dp[j][i] %= MOD;
			}
		}
	}
}

int main(void) {
	input_init();
	solve();
	int ans = dp[H - 1][W - 1];
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 5248
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int N=scan.nextInt();
        int K=scan.nextInt();
        int i;
        int express=1;
        int next1,next2;
        for(i=0;i<N;i++){
            next1=express*2;
            next2=express+K;
            if(next1<next2){
                express=next1;
            }
            else{
                express=next2;
            }
        }
        System.out.println(express);
    }
}

Measured memory_bytes: 23764
/**
*    author:  yuya1234
*    created: 13.07.2020 09:28:05
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int count_bits(int n)
{
    n=(n&0x55555555)+(n>>1&0x55555555);
    n=(n&0x33333333)+(n>>2&0x33333333);
    n=(n&0x0f0f0f0f)+(n>>4&0x0f0f0f0f);
    n=(n&0x00ff00ff)+(n>>8&0x00ff00ff);
    n=(n&0x0000ffff)+(n>>16&0x0000ffff);
    return n;
}


ll modpow(ll a,ll n, ll mod) {
  if(mod <= 0) return 0;
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int solve(int n) {
  if (n == 0) return 0;
  return solve(n % count_bits(n)) + 1;
}


int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  //std::cout << std::fixed << std::setprecision(15);

  ll n;
  cin>>n;

  string x;
  cin>>x;

  ll p=0;
  REP(i,n)
  {
    if(x[i]=='1')p++;
  }

  ll a1=0,a2=0;
  REP(i,n){
    if(x[i]=='1'){
      if(p==1){
        a1=0;
      }else{
        a1=(a1+modpow(2,n-i-1,p-1))%(p-1);
      }
      a2=(a2+modpow(2,n-i-1,p+1))%(p+1);
    }
  }


  REP(i,n){
    if(x[i]=='1'){
      if(p==1){
        cout<<0<<endl;
      }else{
        cout<<1+solve((a1-modpow(2,n-i-1,p-1)+p-1) % (p-1))<<endl;
      }
    }else{
      cout<<1+solve((a2+modpow(2,n-i-1,p+1)) % (p+1))<<endl;
    }
  }
 
  return 0;
}

Measured memory_bytes: 3772
#include <iostream>

int main() {
  long long a, b, c;
  std::cin >> a >> b >> c;
  long long d = c - a - b;
  if (d > 0 && 4*a*b < d*d) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}

Measured memory_bytes: 256
A,B = map(int,input().split())
tmp=0
cnt=0

while tmp<2:
  if A > B:
    cnt+=A
    A-=1
    tmp+=1
  elif A < B:
    cnt+=B
    B-=1
    tmp+=1
  else:
    cnt+=A
    A-=1
    tmp+=1
print(cnt)
  


Measured memory_bytes: 2940
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	for (auto i : s) {
		if (i == '1') {
			N++;
		}
	}
	cout << N << endl;
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.trim()
  var S = input.split("");
  var combo = 0;
  var ans = 0;
  for(var i=0;i<S.length;i++){
    if(S[i]=="A"||S[i]=="G"||S[i]=="C"||S[i]=="T"){
      combo++;
      if(ans<combo){
        ans=combo;
      }
    }else{
      combo = 0;
    }
  }
  console.log(ans)
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

namespace Abc086B
{
    class Program
    {
        static void Main(string[] args) {
            var a_b = Console.ReadLine().Split();
            var number = int.Parse(a_b[0] + a_b[1]);
            var approximateRoot = (int)(Math.Round(Math.Sqrt(number)));
            Console.WriteLine(approximateRoot*approximateRoot==number?"Yes":"No");
        }
    }
}


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

#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))
#define PB push_back
#define mkp make_pair
#define F first
#define S second
#define INF 0x3f3f3f3f
#define EPS 1e-8

typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int H,W;
	cin>>W>>H;
	vector<string> v(H);
	rep(i,H) cin>>v[i];
	vector<vint> vv1(H,vint(W,INF));
	vector<vint> vv2(H,vint(W,INF));
	pii s;
	queue<pii> q1,q2;
	long double p = 0;
	rep(i,H){
		rep(j,W){
			if(v[i][j] == 'g'){
				q1.push(pii(i,j));
			}
			else if(v[i][j] == 's'){
				s=pii(i,j);				
				v[i][j] = '.';
				p+=1.0;
			}
			else if(v[i][j] == '*'){
				q2.push(pii(i,j));
			}
			else if(v[i][j] == '.'){
				p+=1.0;
			}
		}
	}
	p=1/p;
	int cnt = 0;
	int dd[]={0,1,0,-1,0};
	while(q1.size()){
		int qs = q1.size();
		rep(i,qs){
			pii top = q1.front();
			q1.pop();
			if(vv1[top.F][top.S]!=INF) continue;
			vv1[top.F][top.S] = cnt;
			rep(j,4){
				pii nex = top;
				nex.F += dd[j];
				nex.S += dd[j+1];
				if(v[nex.F][nex.S] == '#') continue;
				if(v[nex.F][nex.S] == '*') continue;
				q1.push(nex);
			}
		}
		cnt++;
	}
	cnt = 0;
	while(q2.size()){
		int qs = q2.size();
		rep(i,qs){
			pii top = q2.front();
			q2.pop();
			if(vv2[top.F][top.S]!=INF) continue;
			vv2[top.F][top.S] = cnt;
			rep(j,4){
				pii nex = top;
				nex.F += dd[j];
				nex.S += dd[j+1];
				if(v[nex.F][nex.S] == '#') continue;
				if(v[nex.F][nex.S] == '*') continue;
				q2.push(nex);
			}
		}
		cnt++;
	}
	int maxn = 0;
	rep(i,H) rep(j,W){
		if(vv1[i][j] != INF) maxn=max(maxn,vv1[i][j]);
	}
	map<pair<int,int>,int> ma;
	double bb = 0;
	rep(i,H){
		rep(j,W){
			if(v[i][j] != '.') continue;
			int x = vv1[i][j];
			int y = vv2[i][j];
			int t = min(x,y);
			bb += t*p;
			x-=t;
			y-=t;
			pii z = pii(x,y);
			if(ma.count(z)==0) ma[z] = 0;
			ma[z]+=1;
		}
	}
	long double ans = 1e100;
	rep(o,maxn+1){
		long double a = 0;
		long double b = bb;
		for(auto x:ma){
			if(x.F.F-x.F.S <= o){
				b += p*x.F.F*x.S;
			}
			else{
				b += p*x.F.S*x.S;
				a += p*x.S;
			}
		}
		long double e = b/(1-a);
		long double tmp;
		if(vv1[s.F][s.S]-vv2[s.F][s.S] <= o) tmp = vv1[s.F][s.S];
		else tmp = vv2[s.F][s.S] + e;
		ans = min(ans,tmp);
	}
	cout<<fixed<<setprecision(20);
	cout<<ans<<endl;
}

Measured memory_bytes: 12916
#include<bits/stdc++.h>
#define int long long
const int mo=1e9+7;
int ksm(int a,int b){
	int ans=1;
	while (b){
		if (b&1) ans=ans*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return ans;
} 

int n,m,f[5010][5010];
char s[10010];
signed main(){
	scanf("%lld\n",&n);
	scanf("%s",&s);
	m=strlen(s);
	f[0][0]=1;
	for (int i=1;i<=n;++i){
		f[i][0]=(f[i-1][0]+f[i-1][1])%mo;
		for (int j=1;j<=n;++j){
			(f[i][j]+=f[i-1][j-1]*2)%=mo;
			(f[i][j]+=f[i-1][j+1])%=mo;
		} 
	}
		
	printf("%lld\n",f[n][m]*ksm(ksm(2,m),mo-2)%mo);
}

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


int main() {
  int a,b;
  cin>>a>>b;
  if(0<a && a<10 && 0<b && b<10){cout<<a*b<<endl;}
  else{cout<<-1<<endl;}
}

Measured memory_bytes: 256
main :: IO ()
main = do
  let
    f :: Int -> Int -> Int
    f k m = (2 * k) `min` (m - 1)
  [n, k] <- map read . words <$> getLine :: IO [Int]
  let
    step :: Char -> [Bool] -> [Bool]
    step 'L' rest = False : rest
    step 'R' rest = True : rest
    step _ _ = []
  ds <- foldr step [] <$> getContents :: IO [Bool]
  let
    (m, s) = foldl step (1, 0) . (zipWith (==) <$> id <*> tail) $ ds :: (Int, Int)
      where
        step :: (Int, Int) -> Bool -> (Int, Int)
        step (m, s) b | b         = m `seq` s `seq` (m, s + 1)
                      | otherwise = m `seq` s `seq` (m + 1, s)
  print $ s + f k m


Measured memory_bytes: 4972
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut v:Vec<usize> = (0..n).map(|_| read()).collect();
    let mut mx = v[0];
    let mut ans = "Yes";
    for i in 1..n {
        if v[i] <= v[i-1] {
            v[i-1] -= 1;
        }
        mx = max(mx, v[i-1]);
        if v[i] < mx {
            ans = "No";
            break;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2764
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
string s;
cin>>s;
bool flag=true;
for(int i=0;i<s.size();i++){
    if(i%2==0){
        if(s.at(i)!='h'){
            flag=false;
        }
    }
     if(i%2==1){
        if(s.at(i)!='i'){
            flag=false;
        }
    }
}
if(flag&&s.size()%2==0){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	for(int i=0;i<s.size()-1;i++)
	{
		if(s[i]==s[i+1])
		{
			cout << i+1 << " " << i+2;
			return 0;
		}
	}
	for(int i=0;i<s.size()-2;i++)
	{
		if(s[i]==s[i+2])
		{
			cout << i+1 << " " << i+3;
			return 0;
		}
	}
	cout << "-1 -1";
	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace RemainingBalls
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputBalls = Console.ReadLine().Split(' ');
            var ballsCount = Console.ReadLine().Split(' ');
            var chosenBall = Console.ReadLine();

            string leftBall = inputBalls[0];
            string rightBall = inputBalls[1];

            int leftBallCount = int.Parse(ballsCount[0]);
            int rightBallCount = int.Parse(ballsCount[1]);

            if(chosenBall == leftBall)
            {
                leftBallCount--;
            }

            else if(chosenBall == rightBall)
            {
                rightBallCount--;
            }

            Console.WriteLine(leftBallCount + " " + rightBallCount);
        }
    }
}

Measured memory_bytes: 11092
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int A, B, C;

    private void Scan()
    {
        var line = Console.ReadLine().Split(' ');
        A = int.Parse(line[0]);
        B = int.Parse(line[1]);
        C = int.Parse(line[2]);
    }

    public void Solve()
    {
        Scan();
        for (int i = 1; i <= 100; i++)
        {
            int j = A * i;
            if(j%B == C)
            {
                Console.WriteLine("YES");
                return;
            }
        }
        Console.WriteLine("NO");
    }
}


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

#define pb push_back
#define fi first
#define se second


using namespace std;


long long power(long long x, unsigned long long y, long long p)  
{  
    long long res = 1;     
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  


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

	long long remain = 7%k;

	long long counter = 1;

	while(remain)
	{
		remain = remain + 7 * power(10, counter, k);
		remain = remain % k;

		counter++;

		if(counter > 1000000)
		{
			cout<<-1<<endl;
			return 0;
		}
	}

	cout<<counter<<endl;

	return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int K, A, B;
    cin >> K >> A >> B;
    for (size_t i = A; i <= B; i++)
    {
        if (i % K == 0)
        {
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",(long long)x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)1e6+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll fmod(ll x){if (x<mod) return x;return x%mod;}
ll mul(ll a, ll b, ll c){
	ll ret=0;while(b){if (b%2) ret=(ret+a)%c;a=(a*2)%c;b>>=1;}
    return ret;
}
int modpow(ll a, ll b){
    ll ret=1;while(b){if (b%2) ret=(ret*a)%mod;a=(a*a)%mod;b>>=1;}
    return (int)ret;
}
inline int inv(int x){ return modpow(x, mod-2);}
int isprime[N];
void calc_prime(){
	isprime[1]=1;for(ll i=2;i<N;i++) if (!isprime[i]) for(ll j=i*i;j<N;j+=i) isprime[j]=1;
}
int a[N], b[N];
int main(){
    int n;cin >>n;
    string s;
    cin>>s;
    int cnt = 1;
    for(auto c: s){ 
        if (c=='R') {
            a[cnt] =0;
            b[cnt] = a[cnt];
        }
        else{
            a[cnt]=1;
            b[cnt]=1;
        }
        cnt++;
    }
    sort(a+1, a+n+1);
    int ans = 0;
    fr(i, 1, cnt){
        if (a[i]!=b[i]) ans++;
    }
    pr(ans/2);n_l;
    return 0;
}



Measured memory_bytes: 5328
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// nがあり、nの数だけの整数の入力
			long n = sc.nextLong();
			Set<Long> an = new HashSet<>();
			for (long i = 0; i < n; i++) {
				an.add(sc.nextLong());
			}
			System.out.println(an.size() == n ? "YES" : "NO");
		}
	}

	/**
	 * 最小公倍数
	 */
	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}

	/**
	 * 最大公約数
	 */
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}

Measured memory_bytes: 104052
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <tuple>
#include <functional>
#include <set>

using namespace std;

int main()
{
	int n;
	int k;
	cin >> n >> k;
	long long f[20][20];
	for (int i = 0; i < 20; ++i) {
		for (int j = 0; j < 20; ++j) {
			f[i][j] = 1LL << 60;
		}
	}
	f[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int a = 0; a < n; ++a) {
			for (int b = 0; b <= n; ++b) {
				if (a + b != i)
					continue;
				f[a + 1][b] = min(f[a + 1][b], f[a][b] * 2);
				f[a][b + 1] = min(f[a][b + 1], f[a][b] + k);
			}
		}
	}

	long long ans = 1LL << 60;
	for (int i = 0; i <= n; ++i) {
		ans = min(f[i][n - i], ans);
	}
	cout << ans << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int a,b;
  cin>>a>>b;
  cout<<!!(a%b)<<endl;


}

Measured memory_bytes: 256
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#include<bits/stdc++.h>

using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(b/a>c)
        cout<<c<<endl;
    else
        cout<<b/a<<endl;
}


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

int main(){
  int N,Y;
  int yen10000 = -1;
  int yen5000 = -1;
  int yen1000 = -1;
  cin >> N >> Y;

  for(int i=0;i<=N;i++){
    for(int j=0;j + i<=N;j++){
      int k = N - i - j;
      int sum = 10000*i + 5000*j + 1000*k;
      if(sum==Y){
        yen10000 = i;
        yen5000 = j;
        yen1000 = k;
      }
    }
  }
  cout << yen10000 << " " << yen5000 << " " << yen1000 << endl;
}


Measured memory_bytes: 256