akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=10010000;
const ll mod=1000000007;

int main(){
  ll now=7;
  ll ans=1;
  ll k;
  cin>>k;
  now%=k;
  
  while(now!=0&&ans<INF){
    now=now*10+7;
    now%=k;
    ans++;
  }
  
  if(ans==INF) cout<<-1<<endl;
  else cout<<ans<<endl;
  
  
}





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

int main() {
  int n , m;
  cin >> n >> m;
  vector<int> roads(m * 2);
  for (int i = 0; i < m * 2; i++) {
    cin >> roads.at(i);
  }
  for (int i = 0; i < n; i++) {
    int count = 0;
    for (int j = 0; j < roads.size(); j++) {
    	if ((i + 1) == roads.at(j)) {
          count++;
        }
  	}
    cout << count << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int	main(void)
{
  	int	a;
  	int b;
  	int	c;
  
  	int num;
  
  	num = scanf("%d %d %d", &a, &b, &c);
  	if (num != 3)
      	return (0);
  
  	if (a + b + c >= 22)
      	printf("bust");
  	else
      	printf("win");
  
  	return (0);
}

Measured memory_bytes: 128
//C�w�b�_
#include <string.h>
#include <stdlib.h>

//C++���C�u����
#include <cstdio>
#include <string>
#include <iostream>
#include <cstdlib>
#include <tuple>
#include <typeinfo>
#include <algorithm>
#include <vector>
#include <iomanip>

using namespace std;

int main(void)
{
	int n1,n2,n3,n4;
	bool flag;

	cin>>n1>>n2>>n3>>n4;

	if(n1==1||n1==4||n1==7||n1==9){
		flag=true;

		if(n2==1||n2==4||n2==7||n2==9){
			if(n2==n1) flag=false;
		}else{
			flag=false;
		}

		if(n3==1||n3==4||n3==7||n3==9){
			if(n3==n2||n3==n1) flag=false;
		}else{
			flag=false;
		}

		if(n4==1||n4==4||n4==7||n4==9){
			if(n4==n3||n4==n2||n4==n1) flag=false;
		}else{
			flag=false;
		}
	}
	else{
		flag=false;
	}

	if(flag) cout<<"YES";
	else cout<<"NO";



	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
map<string,int> m;
int main(void){
  char s[] = "aa";
  char r[11] = "";
  for(int i = 1;; i++){
    if(strlen(r) && r[strlen(r)-1] =='a'){
      printf("?aba\n"); fflush(stdout);
    }else{
      printf("?%s\n",s); fflush(stdout);
    }
    m[(string)s] = 1;
    scanf("%s",r);
    if(m.find(string(r)) != m.end() || 'a' != r[0]){
      printf("!OUT");
      break;
    }
    m[(string)r] = 1;
    s[0] = r[strlen(r)-1];
  }
}

Measured memory_bytes: 1256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        while(s.contains("B")){
            s = s.replaceAll("^B|[01]B", "");
        }
        System.out.print(s);
    }
}

Measured memory_bytes: 22740
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int n;
int memo[100005];
int arr[100005];
int main(){
    scanf("%d",&n);
    memset(memo,127,sizeof(memo));
    memo[0]=0;
    for (int x=0;x<n;x++){
        scanf("%d",&arr[x]);
    }
    for (int x=0;x<n;x++){
        memo[x+1]=min(memo[x+1],memo[x]+abs(arr[x]-arr[x+1]));
        memo[x+2]=min(memo[x+2],memo[x]+abs(arr[x]-arr[x+2]));
    }
    printf("%d\n",memo[n-1]);
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
	int i,j,h,w;
	char s[8];
	scanf("%d%d",&h,&w);
	for(i = 1;i <= h;i++){
		for(j = 1;j <= w;j++){
			scanf("%s",s);
			if(s[0] == 's' && s[1] == 'n' && s[2] == 'u' && s[3] == 'k' && s[4] == 'e'){printf("%c%d\n",j+64,i);}
		}
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] H = new int[N];
        for (int i = 0; i < N; i++) {
            H[i] = Integer.parseInt(sc.next());
        }

        int first = H[0];
        int[] extH = Arrays.copyOfRange(H, 1, N);

        int viewCnt = 1;
        int max = first;
        for (int i : extH) {
            max = Math.max(i, max);
            if (i >= max) {
                viewCnt++;
            }
        }

        System.out.println(viewCnt);
    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;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 FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
string s, t;
int ssize, tsize;
int irekaeP;
/**********************************************/

int search(){
    FORR(i, ssize - 1, tsize - 1){
        int cnt = 0;
        FORR(j, tsize - 1, 0){
            if(s[i - cnt] != t[j] && s[i - cnt] != '?'){
                break;
            } 
            if(j == 0){
                return i-tsize+1;
            }
            cnt++;
        }
    }
    return -1;
}

int main(){
    cin >> s >> t;
    ssize = s.size();
    tsize = t.size();
    
    irekaeP = search();
    if(irekaeP != -1){
        s.replace(irekaeP, tsize, t);
        REP(i, ssize){
            if(s[i] == '?') s[i] = 'a';
        }
        cout << s << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }
}


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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using ch = char;
using vll = V<ll>;
using vvll = V<V<ll>>;
using vvvll = V<V<V<ll>>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vvpll = V<vpll>;
using vtpll = V<tpll>;
using vst = V<str>;
using vch = V<ch>;
using vvch = V<vch>;
using qll = queue<ll>;
using vqll = V<qll>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin() 
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a) //
/*vvll v(n,vll(m)) n行m列  continue
A.erase(A.begin()+i); 配列Aのi番目を消せる
std::binary_search(v.bgn,v.en,a); 二分探索
abs(a,b)   pow(a,n)  to_string  stoll
auto Iter=lower_bound(v.bgn,v.en,a); v[i]>=aとなる初のv[i]
v.insert(lower_bound(v.bgn,v.en,a),b); bを入れられる
lower upper  co(*Iter) co(Iter-v.bgn) v[i]>=aとなる初のi
vvll v(100001,vll(0)); v[a].pb(b); v[b].pb(a);
priority_queue<ll> pque; pque.push(ai); pque.top(); pque.pop();
priority_queue<ll,vll,greater<ll>> pque; 昇順
vqll q(3);  q[0].push(0); q[0].push(2); q[0].push(1);
q[0].front()→0 q[0].back()→1 q[0].pop(); q[0].front()→2
que.pop() que.sz while(!que.empty())
ll a=1,b=2,c=4,xo; xo=a^b^c; if(a^b^c==0)co(xo)→7 if(xo==0)co(xo)→なし
*/

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
#define comuse Comuse()
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll pow_mod(ll a,ll n,ll mod){
  ll res=1;
  for(;n>0;n/=2){
    if(n%2==1)res=(res*a)%mod;
    a=(a*a)%mod;
  }
  return res;
}
ll digit_sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0)break;
  }
  return m;
}
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}

int main(){
  ll a,b;
  cin>>a>>b;
  ll c=0;
  if(b==1){
    co(0);
  }
  else{
  for(ll i=1;;i++){
    if(b<=c+a){
      co(i);
      break;
    }
    else{
      c+=a-1;
      //co(c);
    }
  }
  }
}


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

int main(){
  int a,b;
  cin >> a >> b;
  
  int x,y,z;
  x = a+b;
  y = a-b;
  z = a*b;
  
  int answer = max(x, max(y,z));
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    long long A, B, C;
    cin >> A >> B >> C;
    int K;
    cin >> K;

    int cnt = 0;

    while (B <= A) {
        B <<= 1;
        ++cnt;
    }

    while (C <= B) {
        C <<= 1;
        ++cnt;
    }

    if (cnt <= K) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }


    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
using namespace std;
int main()
{
	int n;
	while (cin >> n, n)
	{
		int x = 10, y = 10;
		int m[21][21] = {};
		for (int i = 0;i < n;i++)
		{
			int a, b;cin >> a >> b;m[a][b] = 1;
		}
		int c;cin >> c;
		int cnt = 0;
		for (int i = 0;i < c;i++)
		{
			char s;int l;cin >> s >> l;
			int d = s == 'N' ? 0 : s == 'E' ? 1 : s == 'S' ? 2 : 3;
			for (int j = 0;j < l;j++)
			{
				x += dx[d], y += dy[d];
				cnt += m[x][y];
				m[x][y] = 0;
			}
		}
		cout << (cnt == n ? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 3056
N = int(input())
A = [0] + list(map(int, input().split()))

B = [0] * (N + 1)

for i in reversed(range(1, N + 1)):
    tmp = 0
    for j in range(i, N + 1, i):
        tmp += B[j]

    if tmp % 2 != A[i]:
        B[i] = 1

for i in range(1, N + 1):
    tmp = 0
    for j in range(i, N + 1, i):
        tmp += B[j]
    if A[i] != tmp % 2:
        print(-1)
        exit()

print(sum(B))
ans = []
for i, b in enumerate(B):
    if b == 1:
        ans.append(i)
if len(ans) > 0:
    print(*ans, sep=' ')


Measured memory_bytes: 69352
/*****Enigma_27*****/
#include<bits/stdc++.h>
#define ll          long long
#define all(a)      (a).begin(),(a).end()
#define pb          push_back
#define INF         10000000000000000
using namespace std;
ll i,j,k,n,x,mid,sum1=0,sum2=0,ans,l[300005],r[300005];
vector<ll> v(300005);
int main()
{
    cin>>n;
	for(i=0;i<3*n;i++){
		cin>>v[i];
	}
	priority_queue<int> pq; //max_heap for first half
	priority_queue<int,vector<int>,greater<int> > pq2; //min_heap for second half
	ll csum=0;
	for(i=0;i<3*n;i++){
		pq2.push(v[i]);
		csum+=v[i];
		if(pq2.size()>n){
			csum-=pq2.top();pq2.pop();
		}
		if(pq2.size()==n)l[i]=csum;else l[i]=-INF; //maximum  possible sumof n numbers till ith index so, 
	}											//if i<n or pq2.size<n set it to -inf cause it is not favourable
	csum=0;
	for(int i=3*n-1;i>=0;i--){
		pq.push(v[i]);
		csum+=v[i];
		if(pq.size()>n){
			csum-=pq.top();pq.pop();
		}
		if(pq.size()==n) r[i]=csum;else r[i]=INF;//minimum  possible sumof n numbers till ith index from back so, 
	}											//if i<2*n or pq2.size<n set it to inf cause it is not favourable
	ll ans=-INF;
	for(i=0;i<3*n-1;i++){
		ans=max(ans,l[i]-r[i+1]); //checking at where the partition would be for maximum ans
								// u can also loop from n to 2*n because l[i]is -inf before n and r[i]is inf after 2*n
	}
	cout<<ans<<endl;
 
    return 0;
}

Measured memory_bytes: 8184
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=1e4+7;
typedef long long ll;
int dp[maxn<<2];
int at[maxn],co[maxn];
int n,h;
int main(){
    memset(dp,inf,sizeof(dp));
    dp[0] = 0;
    cin>>h>>n;
    for(int i=1;i<=n;i++)
    	cin>> at[i] >> co[i];
    for(int i=1;i<=n;i++){
    	for(int j=1;j<at[i];j++)
            dp[j] = min(dp[j],co[i]);
        for(int j = at[i];j<=h;j++)
        	dp[j] = min(dp[j],dp[j-at[i]]+co[i]);
	}
	printf("%d\n",dp[h]);
    return 0;
}

Measured memory_bytes: 384
n , k = map(int,input().split())
a = list(map(int,input().split()))
for j in range(k):
    b = [0 for i in range(n)]
    for i in range(n):
        b[max(0,i-a[i])] += 1
        if i+a[i]+1 < n:
            b[i+a[i]+1] -= 1
    for i in range(n-1):
        b[i+1] += b[i]
    if a == b:
        print(*b)
        exit()
    a = b[:]
print(*b)

Measured memory_bytes: 219588
#include <iostream>
#include <vector>
#include <queue>
#define mod (int)1e9 + 7
#define f(k, l) for (int i = k; i < l; i++)
using namespace std;
typedef long long int ll;
int main(void)
{
	int n;
	cin >> n;
	vector<ll> t(n + 2, 0), a(n + 2, 0), h(n + 2, (int)1e9);
	f(1, n + 1)
	{
		cin >> t[i];
	}
	f(1, n + 1)
	{
		cin >> a[i];
	}
	f(0, n)
	{
		if (t[i] != t[i + 1])
		{
			if(t[i]>a[i]){
				cout<<0<<endl;
				return 0;
			}
			h[i + 1] = 1;
		}
	}
	f(0, n)
	{
		int c = n - i;
		if (a[c + 1] != a[c])
		{
			if(a[c]>t[c]){
				cout<<0<<endl;
				return 0;
			}
			if (h[c] == 1 && t[c] != a[c])
			{
				cout << 0 << endl;
				return 0;
			}
			else
			{
				h[c] = 1;
			}
		}
		//else if(h[c]!=1){
		//h[c]=min(t[c],a[c]);
		//	}
	}
	ll ans = 1;
	f(1, n + 1)
	{
		//	cout<<h[i]<<endl;
		h[i] = min(h[i], min(a[i], t[i]));
		ans *= h[i];
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
W, H, N = list(map(int, input().split()))
x0 = 0
x1 = W
y0 = 0
y1 = H

for i in range(N):
	x, y, a = list(map(int, input().split()))
	if a == 1:
		if x0 <= x:
			x0 = x
	elif a == 2:
		if x <= x1:
			x1 = x
	elif a == 3:
		if y0 <= y:
			y0 = y
	else:
		if y <= y1:
			y1 = y

if x1 - x0 <= 0 or y1 - y0 <= 0:
	print(0)
else:
	print((x1 - x0) * (y1 - y0))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

class Combination{
    long long int maxn;
    long long int mod;
    std::vector<long long int> factorial;
    std::vector<long long int> inverse;

    public:

    Combination(long long int n,long long int m):maxn(n),mod(m){
        factorial.push_back(1);
        inverse.push_back(1);

        for(long long int i = 1; i <= n; i++){
            factorial.push_back((factorial.back()*i)%mod);
            inverse.push_back([&](long long int x,long long int n) -> long long int{
                long long int ret = 1;
                while(n > 0){
                    if(n&1)ret = (ret*x)%mod;
                    x = (x*x)%mod;
                    n >>= 1;
                }
                return ret;
            }(factorial.back(),mod-2));
        }
    }

    long long int comb(long long int n,long long int r){
        return (((factorial[n]*inverse[n-r])%mod)*inverse[r])%mod;
    }
};

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

    LL n;
    cin >> n;
    vector<LL> a(n+1);
    vector<LL> count(n+1,0);
    LL same;

    for(int i = 0; i < n+1; i++){
        cin >> a[i];
        count[a[i]]++;
        if(count[a[i]] > 1){
            same = a[i];
        }
    }

    LL l,r;
    for(int i = 0; i < n+1; i++){
        if(a[i] == same){
            l = i;
            break;
        }
    }
    for(int i = l+1; i < n+1; i++){
        if(a[i] == same){
            r = i;
            break;
        }
    }

    Combination cmb(n+2,MOD);

    for(LL k = 1; k <= n+1; k++){
        LL ans = cmb.comb(n+1,k);
        if(l+n-r >= k-1){
            ans -= cmb.comb(l+n-r,k-1);
            if(ans < 0){
                ans += MOD;
            }
            ans %= MOD;
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4588
import java.util.* ;
class Main {
  public static void main(String[] args) {
    
    Scanner scan = new Scanner(System.in);
	int A = scan.nextInt();
    char op = scan.next().charAt(0);
    int B = scan.nextInt();
    if(op == '+'){
      System.out.println(A+B);
    }else{
      System.out.println(A-B);
    }

  }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(void){
    string S;
    cin >> S;
    if(S == "AAA" || S == "BBB") printf("No");
    else printf("Yes");
    
}




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

using namespace std;

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

typedef pair<long long, long long> ii;

vector<pair<long long, ii>> ans;

long long sum = 0, n;

priority_queue<int> pq;

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    while(n--){
        int h, p;
        cin >> h >> p;
        ans.pb({h + p, {h, p}});
    }
    sort(ans.begin(), ans.end());
    for(int i = 0; i < ans.size(); i++){
        pq.push(ans[i].se.se);
        sum += ans[i].se.se;
        if(sum > ans[i].fi){
            while(sum > ans[i].fi && !pq.empty()){
                sum -= pq.top();
                pq.pop();
            }
        }
    }
    cout << pq.size() << "\n";
}



Measured memory_bytes: 512
from statistics import median_low

# input
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
    A[i] = A[i] - (i + 1)

b = median_low(A)
ans = 0

for i in range(N):
    ans += abs(A[i] - b)

print(ans)



Measured memory_bytes: 27236
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n;
long long a[200100],res;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);reverse(a+1,a+n+1);
	for(int i=2;i<=n;i++) res+=a[(i+1)/2];
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
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 X;
    cin >> X;
    if (400 <= X and X <= 599)
        cout << 8;
    else if (600 <= X and X <= 799)
        cout << 7;
    else if (800 <= X and X <= 999)
        cout << 6;
    else if (1000 <= X and X <= 1199)
        cout << 5;
    else if (1200 <= X and X <= 1399)
        cout << 4;
    else if (1400 <= X and X <= 1599)
        cout << 3;
    else if (1600 <= X and X <= 1799)
        cout << 2;
    else if (1800 <= X and X <= 1999)
        cout << 1;
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int x, y, z, i, sum = 0, count = 0;
    scanf("%d %d %d",&x, &y, &z);
    for(i = 1; ;i++)
	{
		sum = sum + y + z;
		if(sum + z <= x)
			count ++;
	    else
	    	break;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 256
// In the name of God
#include <bits/stdc++.h>

using namespace std;
#define Size(x) ((int)(x).size())
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int INF = 1e9 + 10;

int main()
{
	ios_base :: sync_with_stdio(false) ,cin.tie(0) , cout.tie(0);
	ll a;cin>>a;
	ll t = a/11;
	a %= 11;
	if(a == 0) cout << (t<<1) << '\n';
	else if(a > 6) cout << ((t+1)<<1) << '\n';
	else cout << (t<<1)+1 << endl;
	return 0;
}


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

public class ABC
{
    //          long[] sp = Console.ReadLine().Split().Select(long .Parse).ToArray();
    //          int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray();
    //          int N =  int.Parse(Console.ReadLine());
    //CompLib.Collections.PriorityQueue<?>
    public static void Main()
    {
        int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int a = sp[0], b = sp[1];
        int output = 0;
        if (2 * b >= a)
        {

        }
        else
        {
            output = a-2 * b;
        }
        Console.WriteLine(output);

    }

}

Measured memory_bytes: 13396
N = int(input())
D = {}
for n in range(N):
    w = input()
    if w not in D:
        D[w] = 1
    else:
        D[w] += 1
m = max(D.values())
l = []
for (key, value) in D.items():
    if value == m:
        l.append(key)
for s in sorted(l):
	print(s)

Measured memory_bytes: 93656
#include <stdio.h>
int main(){
  int a,b,i,ans1=0,ans2=0;
  scanf("%d %d",&a,&b);
  for(i=0;i<b;i++){
    ans1=ans1*10+a;
  }
  for(i=0;i<a;i++){
    ans2=ans2*10+b;
  }
  if(ans1>ans2) printf("%d",ans1);
  else printf("%d",ans2);
  
  return 0;
}

Measured memory_bytes: 128
# abc169_b.py
# https://atcoder.jp/contests/abc169/tasks/abc169_b

# B - Multiplication 2 /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# N個の整数 A1,...,ANが与えられます。
# A1×...×ANを求めてください。
# ただし、結果が 1018を超える場合は、代わりに -1 を出力してください。

# 制約
#     2≤N≤10^5
#     0≤Ai≤10^18
#     入力は全て整数である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# A1 ... AN

# 出力
# 値 A1×...×ANを整数として出力せよ。ただし、この値が 10^18を超える場合は、代わりに -1 を出力せよ。

# 入力例 1
# 2
# 1000000000 1000000000

# 出力例 1
# 1000000000000000000
# 1000000000×1000000000=1000000000000000000です。

# 入力例 2
# 3
# 101 9901 999999000001

# 出力例 2
# -1

# 101×9901×999999000001=1000000000000000001ですが、これは 10^18を超えるので、代わりに -1 を出力します。

# 入力例 3
# 31
# 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0

# 出力例 3
# 0


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = 1
    if min(values) == 0:
        result = 0
    else:
        for value in values:
            result *= value
            if result > 10**18:
                result = -1
                break

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2', '1000000000 1000000000']
        lines_export = [1000000000000000000]
    if pattern == 2:
        lines_input = ['3', '101 9901 999999000001']
        lines_export = [-1]
    if pattern == 3:
        lines_input = ['31', '4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0']
        lines_export = [0]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 23460
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 1000
    ll = rr = A[0]
    status = "down"
    for a in A[1:]:
        if status == "down":
            if ll < a:
                status = "up"
                rr = a
            else:
                ll = a
        else:
            if rr <= a:
                rr = a
            else:
                status = "down"
                q, r = divmod(ans, ll)
                ans = rr * q + r
                ll = a

    if status == "up":
        q, r = divmod(ans, ll)
        ans = rr * q + r

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9200
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

a, b, k = map(int, readline().split())

if a > k:
    a -= k
    k = 0
else:
    k -= a
    a = 0
if k != 0:
    if b > k:
        b -= k
        k = 0
    else:
        b = 0
        k = 0


print(a, b)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	for(ll i=0;i<n;++i){
		ll t;
		cin>>t;
		if(t>=k)
			ans++;
	}
	cout<<ans<<endl;
}

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

#define ll                  long long int
#define llu                 long long unsigned
#define ld                  long double
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);
#define endl                "\n"
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define mp                  make_pair
#define ms(a,b)             memset((a),(b),sizeof(a))
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(min(a,b),min(c,d))
#define max4(a,b,c,d)       max(max(a,b),max(c,d))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
#define NUM                 1000000
#define PI		            2*acos(0.0)
#define maximum             (-1*INF)
#define READ(f) 	        freopen("f", "r", stdin)
#define WRITE(f) 	        freopen("f", "w", stdout)
const int INF = 1e5 + 10 ;

int main()
{
    string n;
    cin>>n;
    ll len = n.size();
    bool flag = false;
    for(ll i=0; i<len; i++)
    {
        if(n[i] == '7')
            flag = true;
    }
    if(flag)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

int main(){
  long long N,D;
  cin >> N >> D;
  long long X,Y;
  long long counter=0;
  for(int i=0;i<N;i++){
    cin >> X >> Y;
    if(X*X+Y*Y <= D*D){
      counter ++;
    }
    else{
    }
  }
  cout << counter << endl;

}

Measured memory_bytes: 3620
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
num_list = [int(num) for num in lines.pop(0).split(" ")]
k, = [int(num) for num in lines.pop(0).split(" ")]

m = max(num_list)
ans = sum(num_list) - m + (m * (2 ** k))
print(ans)


Measured memory_bytes: 9012
s = list(input())
t = list(input())
n = len(s)
k = len(t)
ans = float("Inf")
for i in range(n-k+1):
    p = 0
    for j in range(k):
        if s[i+j] != t[j]:
            p += 1
            
    ans = min(ans, p)
    
print(ans)

Measured memory_bytes: 65140
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n,k; cin>>n>>k;
	int z=n/k;
	int s=n/k;
	if(k%2==0 && k/2<=n%k) s++;
	if(k%2){
		cout<<z*z*z<<"\n";
	}
	else{
		cout<<z*z*z+s*s*s<<"\n";
	}
	return 0;
}

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

int main() {
  unsigned long long h, w;
  scanf("%llu", &h);
  scanf("%llu", &w);

  unsigned long long ans;

  if (h % 2 == 0) {
    ans = h / 2 * w;
  } else {
    ans = (h / 2) * w + ((w + 1) / 2);
  }

  if (h == 1 || w == 1) {
    ans = 1;
  }

  printf("%llu\n", ans);
}

Measured memory_bytes: 256
k = int(input())
if k % 2 == 0 or k % 5  == 0:
    print(-1)
    exit()

cnt=1
mod=7
while True:
    if mod % k  == 0:
        print(cnt)
        exit()
    cnt+=1
    mod*=10
    mod+=7
    mod%=k

Measured memory_bytes: 63216
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2

 int d[101],f[101],M[101][101],tt,color[101];
 int n;

 void visit(int u){
       int v;
       color[u]=GRAY;
       d[u]=++tt;
       for(v=0;v<n;v++){
             if(M[u][v]==0)continue;
             if(color[v]==WHITE)visit(v);
             }
       color[u]=BLACK;
       f[u]=++tt;
       }

 void dfs(){
       int u;
       tt=0;
       for(u=0;u<n;u++){color[u]=WHITE;}
       for(u=0;u<n;u++){
                if(color[u]==WHITE)visit(u);
                }
       for(u=0;u<n;u++){
                printf("%d %d %d\n",u+1,d[u],f[u]);
                }
       }


 int main(){
           int i,j,k,v,u;
          scanf("%d",&n);
          for(i=0;i<n;i++){
                  for(j=0;j<n;j++){
                           M[i][j]=0;
                           }
                  }
          for(i=0;i<n;i++){
                  scanf("%d %d",&u,&k);
                  u--;
                  for(j=0;j<k;j++){
                            scanf("%d",&v);
                            v--;
                            M[u][v]=1;
                            }
                  }
          dfs();
          return 0;
          }








Measured memory_bytes: 2124
n,*a=map(int,open(0))
m=max(a)

if a.count(m)>1:
    for i in range(n):
        print(m)
else:
    s=sorted(set(a))[::-1][1]
    for i in a:
        if i==m:
            print(s)
        else:
            print(m)

Measured memory_bytes: 17164
#include <stdio.h>
int main()
{
    int n, a[100];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = n - 1; i >= 0; i--)
    {
        if (i > 0)
        {
            printf("%d ", a[i]);
        }
        else
        {
            printf("%d", a[i]);
        }
    }
    printf("\n");
}


Measured memory_bytes: 2108
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::vector<int> A;
	std::cin >> N;
	A.resize(N);
	for (auto& a : A)
		std::cin >> a;
	
	int diff = 0;
	std::sort(A.rbegin(), A.rend());
	for (int i = 0; i < A.size(); ++i) {
		if (i % 2 == 0) {
			diff += A[i];
		} else {
			diff -= A[i];
		}
	}
	std::cout << diff << "\n";
}


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

using namespace std;

int main(void) {
  int S, AA, BB;
  string tmp;
  bool isYYMM = false;
  bool isMMYY = false;
  
  cin >> tmp;
  
  S = stoi(tmp);
  AA = S / 100;
  BB = S % 100;
  
  // judge YYMM
  if((12>=BB) && (BB >= 1)) {
    isYYMM = true;
  }
  // judge MMYY
  if((12>=AA) && (AA >= 1)) {
    isMMYY = true;
  }
  
  if(isYYMM && isMMYY) {
    cout << "AMBIGUOUS" << endl;
  } else if(isYYMM && !isMMYY) {
    cout << "YYMM" << endl;
  } else if(!isYYMM && isMMYY) {
    cout << "MMYY" << endl;
  } else {
    cout << "NA" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int ans = 0;
  int tmp = 0;
  int N; cin>>N;
  vector<int> H(N);
  REP(i,N) cin>>H[i];
  for(int i = 1; i < N;	i++) {
    if(H[i] <= H[i-1]) {
      tmp++;
      chmax(ans, tmp);
    } else tmp = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)

int main(){
	int n;
	cin>>n;
	vector<int> dp(3);
	rep(i,0,2){
		cin>>dp[i];
	}
	rep(i,2,n){
		vector<int> new_dp(3,0);
		vector<int> p(3);
		rep(j,0,2){
			cin>>p[j];
		}
		rep(j,0,2){
			rep(k,0,2){
				if(j!=k){
					new_dp[j] = max(new_dp[j], dp[k]+p[j]); 
				}
			}
		}
		dp = new_dp;
	}
	cout<<max({dp[0],dp[1],dp[2]})<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 998244353;
ll inv[5000001];
int main(){
    int n;
    scanf("%d",&n);
    int k = n/2+1;
    ll bad = 0;
    ll multiplier = 1;
    ll ans = 1;
    ll x = 1;
    inv[1] = 1;
    for (int i = 2; i <= n-k+1; i++){
        inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;
    }
    for (int i = 0; i < n; i++) {
        ans *= 3;
        ans %= mod;
    }
    for (int i = n; i >= k; i--){
        bad += multiplier*x;
        bad %= mod;
        multiplier *= i;
        multiplier %= mod;
        multiplier *= inv[n-i+1];
        multiplier %= mod;
        x *= 2;
        x %= mod;
    }
    ans -= 2*bad;
    ans = ((ans%mod)+mod)%mod;
    printf("%lld",ans);
}


Measured memory_bytes: 39296
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string w;
    cin >> w;
    map<char, int> mp;
    rep(i, w.size()){
        mp[w[i]]++;
    }

    bool b = true;
    for(auto i = mp.begin(); i != mp.end(); i++){
        if(i->second % 2 == 1) b = false;
    }
    cout << (b ? "Yes" : "No") << endl;
}

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

int main(){
	char s[100000];
	int res1 = 0, res2 = 0;
	cin >> s;
	
	for(int i = 0; s[i] != '\0'; i++) {
		int n = ('0' + (i % 2)) ^ s[i];
		res1 += n;
		res2 += 1 - n;
	}
	
	cout << ((res1 < res2) ? res1 : res2) << endl;	
	return 0;
}

Measured memory_bytes: 384
import sys

n, k = map(int, input().split())
a = list(map(lambda x: int(x)-1, input().split()))

is_visited = [0] * n
visited = list()
i = 0
cnt = 0
while True:
    if cnt == k:
        print(i+1)
        sys.exit()
    if is_visited[i]:
        break
    is_visited[i] = 1
    visited.append(i)
    i = a[i]
    cnt += 1

si = visited.index(i)
loop = visited[si:]
n_loop = len(loop)
left_k = k - cnt
print(loop[left_k % n_loop] + 1)

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

using namespace std;

#define int long long

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

    string s;
    cin >> s;
    if(s[0] == s[1] && s.size() == 2) {
        cout << 1 << " " << 2 << endl;
        return 0;
    }
    else {
        for(int i = 0; i < s.size() - 2; ++i) {
            map<char, int> mp;
            for(int j = 0; j < 3; ++j) ++mp[s[i + j]];
            for(int j = 0; j < 3; ++j) {
                if(mp[s[i + j]] >= 2) {
                    cout << i + 1 << " " << i + 3 << endl;
                    return 0;
                }
            }
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
def main():
    n,k = map(int,input().split())
    bi = ''
    while n != 0:
        bi += str(n % abs(k))
        if k < 0:
            n = -(-n // k)
        else:
            n = n // k
    bilast = bi[::-1]
    print(len(bilast))

if __name__ == '__main__':
    main()
    

Measured memory_bytes: 38460
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int R = sc.nextInt();
		
		if(R < 1200){
	   		System.out.println("ABC");
		}else if(R < 2800){
	   		System.out.println("ARC");
		}else{
	   		System.out.println("AGC");
		}

		
   		sc.close();
        return ;

    }
    
}



Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>

int main(void){
    std::string s;
    std::cin >> s;
    std::vector<char> box;
    for(int i = 0; i < s.size(); i++){
        box.push_back(s[i]);
    }

    std::sort(box.begin(),box.end());
    box.erase(std::unique(box.begin(),box.end()), box.end());

    char abcde[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

    for(int i = 0; i < 26; i++){
        if(!(box[i] == abcde[i])){
            std::cout << abcde[i];
            return 0;
        }
    }

    std::cout << "None";
    return 0;
}




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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("lld", &x); return (x); }

int main()
{
	map<char, char> conversion;
	int n;
	int m;
	while( scanf("%d\n", &n) != EOF )
	{
		if( n == 0 )break;
		conversion.clear();
		loop(i, 0, n)
		{
			char src;
			char conv;
			scanf("%c %c\n", &src, &conv);
			conversion[src] = conv;
		}
		scanf("%d\n", &m);
		loop(i, 0, m)
		{
			char c[2];
			scanf("%s", c);
			if( conversion.count(c[0]) == 0 )
			{
				printf("%c", c[0]);
			}
			else
			{
				printf("%c", conversion[c[0]]);
			}
		}
		cout << endl;
	}
	return (0);
}

Measured memory_bytes: 1204
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int n = sc.nextInt();
    for (int i = 0; i < n; i++) {
      String com = sc.next();
      int a = sc.nextInt();
      int b = sc.nextInt();
      if (com.equals("print")) {
        print(str, a, b);
      } else if (com.equals("reverse")) {
        str = reverse(str, a, b);
      } else if (com.equals("replace")) {
        String p = sc.next();
        str = replace(str, a, b, p);
      }
    }
  }
  static void print(String str, int a, int b) {
    System.out.println(str.substring(a, b + 1));
  }
  static String reverse(String str, int a, int b) {
    String str1 = str.substring(0, a);
    String str2 = str.substring(a, b + 1);
    String str3 = str.substring(b + 1);
    StringBuilder sb = new StringBuilder(str2);
    str = str1 + sb.reverse().toString() + str3;
    return str;
  }
  static String replace(String str, int a, int b, String p) {
    StringBuilder sb = new StringBuilder(str);
    sb.replace(a, b + 1, p);
    str = sb.toString();
    return str;
  }
}


Measured memory_bytes: 29756
a,b,m=map(int,input().split())
cooler=list(map(int,input().split()))
microwave=list(map(int,input().split()))
min_price=min(cooler)+min(microwave)
for i in range(m):
    x,y,c=map(int,input().split())
    min_price=min(min_price,cooler[x-1]+microwave[y-1]-c)
print(min_price)

Measured memory_bytes: 18608
#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 each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<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;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  ll x;
  scanf("%lld",&x);
  int n = 50;
  vl a(n,49+x/n);
  x %= n;
  rep(i,x) {
    rep(j,n) a[j]--;
    a[i] += n+1;
  }
  cout<<n<<endl;
  cout<<a<<endl;
  return 0;
}






















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

l = []
r = []
for i in range(n):
  x = xs[i]
  if x < 0:
    l.append(x)
  else:
    r.append(x)
    
if l == []:
  print(r[k-1])
  exit()
elif r == []:
  print(-l[-k])
  exit()
  
if n == k:
  print(min(r[-1], -l[0])*2+max(r[-1], -l[0]))
  exit()
  
ts = []
for i in range(max(k-len(l), 0), min(len(r), k+1)):
  if i == 0:
    t = -l[-k]
  elif i == k:
    t = r[k-1]
  else:
    t = min(r[i-1], -l[-(k-i)])*2+max(r[i-1], -l[-(k-i)])
  ts.append(t)
#print(ts)
print(min(ts))

Measured memory_bytes: 14480
import numpy as np
import pdb

def main():
    N = int(raw_input())
    myarray = np.array(raw_input().split(' ')).astype(int)
    answer = process(myarray)
    print answer

def process(myarray):
    turn = 0
    possible = True
    while(possible):
        possible =  (np.sum(np.mod(myarray, 2)) == 0)
        if possible:
            turn += 1
            myarray = myarray / 2

    return turn

if __name__ == '__main__':
    main()


Measured memory_bytes: 10784
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int h, w, n; cin >> h >> w >> n;
  if (h > w) swap(h, w);
  int ans = 0, masu = 0;
  REP(i, h) {
    if (masu < n) {
      ++ans;
      masu += w;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256