akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    S = input()
    N = len(S)
    for i in range(N - 2):
        if S[i] == S[i + 1]:
            print(i + 1, i + 2)
            return

        if S[i] == S[i + 2]:
            print(i + 1, i + 3)
            return

    if S[N - 2] == S[N - 1]:
        print(N - 1, N)
        return

    print(-1, -1)


if __name__ == "__main__":
    main()


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

template <typename T> T gcd(T a, T b) {
	if (b == 0) return abs(a);
	T r; while ((r = a % b) != 0) a = b, b = r;
	return abs(b);
}

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

    int a, b; cin >> a >> b;

    cout << gcd(a, b) << endl;
}



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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while (C > 0 && A > 0 ) {
    C -= B;
    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    }
    else
      A -= D;
    if (A <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}


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

int ctoi(char c){
    int num;
    num = c-'0';
    return num;
}

int main(){
    string S;
    cin >> S;
    int front, back;
    front = ctoi(S[0])*10+ctoi(S[1]);
    back = ctoi(S[2])*10+ctoi(S[3]);
    if(1<= front && front<=12){
        if(1<= back && back<=12){
            cout << "AMBIGUOUS" <<endl;
        }else{
            cout << "MMYY" <<endl;
        }
    }else{
        if(1<= back && back<=12){
            cout << "YYMM" <<endl;
        }else{
            cout << "NA" <<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

int main(){


    ll n,k;
    cin>>n>>k;
    ll sum=0;
    ll sum2=0;
    for (int i = 1; i <=n ; ++i) {
        if(k%2==0){
            if(i%k==0){sum++;}
            else if(i%k==k/2){
                sum2++;
            }
        }else{
            if(i%k==0)sum++;
        }

    }

    cout<<sum*sum*sum+sum2*sum2*sum2<<endl;





}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

ll f(ll x)
{
    ll r = 0;
    while (x) {
        r += (x % 10);
        x /= 10;
    }

    return r;
}

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

    if (N % f(N) == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;

#define fbo find_by_order
#define ook order_of_key
#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count());

// /mnt/c/Users/vince/Desktop/POST-IOI/Codeforces/Regular/670

int n, k;
int A[200003];
int pref[200003];

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	// printf("%lld\n", rng());

	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; i++)
		scanf("%d", &A[i]);

	for(int cnt = 1; cnt <= k; cnt++)
	{
		memset(pref, 0, sizeof pref);
		for(int i = 1; i <= n; i++)
		{
			pref[max(1,i-A[i])]++;
			pref[min(n, i+A[i])+1]--;
		}
		bool bol = 1;
		for(int i = 1; i <= n; i++)
		{
			pref[i] += pref[i-1];
			A[i] = pref[i];
			if(A[i] != n)
				bol = 0;
		}
		if(bol)
		{
			// printf("%d\n", cnt);
			break;
		}
		// for(int i = 1; i <= n; i++)
			// printf("%d%c", A[i], (i == n)? '\n' : ' ');
	}
	for(int i = 1; i <= n; i++)
		printf("%d%c", A[i], (i == n)? '\n' : ' ');
}




Measured memory_bytes: 5376
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    int ans=(n/x+(n%x>0))*t;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

typedef pair<int, int> pii;

ll DP[105][105];
ll p[105];

ll f(ll r, ll c)
{
	ll mi = INF;
	REP(i, c - r)
	{
		mi = min(mi, DP[r][r + i] + DP[r + i + 1][c] + p[r - 1] * p[r + i] * p[c]);
	}
	return mi;
}

int main()
{
	cin >> n;
	REP(i, n+1)
	{
		DP[i][i] = 0;
	}
	cin >> p[0] >> p[1];
	REP(i, n - 1)
	{
		cin >> k >> p[i+2];
	}
	REP(i, n - 1)
	{
		DP[i + 1][i + 2] = p[i] * p[i + 1] * p[i + 2];
	}
	REP(i, n - 2)
	{
		//REP(j, 3 + i, n + 1)
		for(int j=3+i;j<=n;j++)
		{
			DP[j - 2 - i][j] = f(j - 2 - i,j);
		}
	}
	
	cout << DP[1][n] << endl;

	return 0;
}

Measured memory_bytes: 3176
import java.util.*;
public class Main{
public static void main(String[]args){
  Scanner sc=new Scanner(System.in);
  int ans=0;
  int n=sc.nextInt();int m=sc.nextInt();int a=sc.nextInt();int b=sc.nextInt();
  for(int i=0;i<=n;i++){
  for(int j=0;j<=m;j++){
  for(int k=0;k<=a;k++){
  if(i*500+j*100+k*50==b)ans++;
  }
  }
  }
  System.out.println(ans);
}

}

Measured memory_bytes: 23764
fun main(arr: Array<String>) {
    val (n,d) = readLine()!!.split(" ").map { it.toInt() }
    val points = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }
    val ans = (0 until points.lastIndex).map { idx-> (idx+1 until n).count { isGoodDist(points[idx], points[it]) } }.sum()
    println(ans)
}

fun isGoodDist(p1:List<Int>, p2:List<Int>):Boolean {
    val total = p1.indices.map { (p1[it] - p2[it])*(p1[it] - p2[it]) }.sum()
    for(i in (1..total)) {
        if(i*i>total) {
            break
        }
        if(i*i==total) {
            return true
        }
    }
    return false
}

Measured memory_bytes: 36676
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int ns = s.length();
	int nt = t.length();
	int dp[ns+1][nt+1];
	for(int i=0;i<=ns;i++)
	{
		for(int j=0;j<=nt;j++)
		{
			if(i==0 || j==0)
			dp[i][j]=0;
			else if(s[i-1]==t[j-1])
			{
				dp[i][j] = dp[i-1][j-1] +1;
			}
			else
			{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	//cout<<dp[ns][nt]<<endl;
	int i=ns;
	int j=nt;
	int index = dp[ns][nt];
	char lcs[index+1];
	lcs[index] = '\0';
	while(i>0 && j>0)
	{
		//cout<<"1";
		if(s[i-1]==t[j-1])
		{
			lcs[index-1] = s[i-1];
			i--,j--,index--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
		{
			i--;
		}
		else
		j--;
		//cout<<lcs[index];
		//cout<<i<<" "<<j<<endl;
		//cout<<index<<" "<<lcs[index+1]<<endl;
	}
	for(int i=0;i<dp[ns][nt];i++)
	{
		cout<<lcs[i];
	}
}

Measured memory_bytes: 35456
import math
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    X = int(input())

    lcm = X * 360 // math.gcd(X, 360)
    ans = lcm // X
    print(ans)


if __name__ == "__main__":
    main()


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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	string s;
	ll ans = 0;
	cin>>s;
	forn(i,s.len()/2){
		if(s[i]!=s[s.len()-i-1])ans++;
	}
	cout<<ans<<"\n";
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""



Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<algorithm>


using namespace std;

int main()
{
	long long X;
	long long SUM = 0, time = 0;

	cin >> X;

	if (X == 1) {
		time = 1;
	}
	else {
		for (int i = 1; i < X + 1; ++i) {
			SUM = SUM + i;
			if (SUM >= X) {
				time = i;
				break;
			}
		}
	}
	cout << time << endl;

	return 0;

}

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

void solve()
{
    int n;
    cin >> n;
    int x = n * 800;
    int y = n / 15 * 200;
    cout << x - y << endl;
}

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

Measured memory_bytes: 3572
#include <stdio.h>
#define ll long long int

int main() {
    int n;
    scanf("%d", &n);
    ll sum = 0, a, flag = 0;
    while (n--) {
        scanf("%lld", &a);
        sum += a;
        (sum > 1000000000000000000) ? flag = 1 : sum;
    }
    flag ? printf("-1") : printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 1732
import sys
import math

N, H = map(int, input().split())
katana_list = [tuple(map(int, input().split())) for _ in range(N)]
katana_list.sort(reverse=True)
cut_max = katana_list[0][0]

katana_list = [tuple([katana[0], katana[1]]) for katana in katana_list \
               if katana[1] >= cut_max]
katana_list.sort(key=lambda x: x[1], reverse=True)

cnt = 0
for katana in katana_list:
    H -= katana[1]
    cnt += 1
    if H <= 0:
        print(cnt)
        sys.exit()

katana_list.sort(reverse=True)
cnt += math.ceil(H / katana_list[0][0])
print(cnt)


Measured memory_bytes: 24344
#include<stdio.h>
#include<math.h>
int mun[10000];
int k=0;

int main (){
   int i=3,j;
   int n=0,a,b;for(i=3;i<1e5;i+=2){
 	for(j=2;j<=sqrt(i);j++){
 		if(i%j==0){
 			i+=2;j=2;
		 }else for(int l=2;l<=sqrt((i+1)/2);l++) if((i+1)%(l*2)==0){
		 		i+=2;j=2;break;
		 }
	 }
mun[k]=i;k++;
 }
   scanf("%d",&n);
   while(n--){
   scanf("%d %d",&a,&b);
   int sum=0;
   for(int i=0;i<1e4;i++){if(mun[i]>b)break;
   	if(mun[i]>=a&&mun[i]<=b) {sum++;
	   }
   }
printf("%d\n",sum);
} }

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<iostream>
#include <math.h>//pow(x,y)=x^y 99999とかの場合+1するif文
#include <algorithm>//sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(init,i,n) for (int i=init; i <(n);i++)
#define ll long long
#define rev(s) reverse(s.begin(),s.end())
#define sor(v) sort(v.begin(),v.end())
//コード自動整形 Shift + Alt + F @vscode
using namespace std;


/////main/////
int main() {
ll N,D;
cin>>N>>D;
vector<ll> X(N);
vector<ll> Y(N);
rep(0,i,N){
    cin >> X.at(i)>>Y.at(i);
}
ll cnt = 0;

rep(0,i,N){
    if(D*D>=(X.at(i)*X.at(i)+Y.at(i)*Y.at(i))){
        cnt++;
    }
}
cout<<cnt<<endl;
return 0;
}
/////main/////

/////function/////

Measured memory_bytes: 6368
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

#define ll long long
#define in(params) cin >> (params);
#define p(params) cout << (params) << endl;
#define mod 1000000007LL

using namespace std;

int main()
{
    string S;
    string ok = "ACGT";
    cin >> S;

    int m = 0;
    int c = 0;
    for (ll i = 0; i < S.length(); i++)
    {
        if(ok.find(S[i]) == string::npos) {
            c = 0;
        } else {
            c++;
        }
        m = max(m, c);
    }

p(m);
    return 0;
}

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

int main() {
   long long int a,b,k;
    cin>>a>>b>>k;
    if(k>a){
        long long int c=(k-a);
        long long int d=b-c;
        if(d<0) cout<<0<<" "<<0;
        else cout<<0<<" "<<d;
    }
    else{
        cout<<(a-k)<<" "<<b;
    }
    return 0;
    
}

Measured memory_bytes: 256
n = int(input())
M = [[float("inf") for i in range(n)] for i in range(n)]
for i in range(n):
 L = list(map(int, input().split()))
 for j,v in enumerate(L):
  if v != -1:
   M[i][j] = v

def prim():
 color = [0] * n
 d = [float("inf")] * n
 p = [-1] * n
 d[0] = 0

 while True:
  minv = float("inf")
  u = -1
  for i in range(n):
   if minv > d[i] and color[i] != 2:
    u = i
    minv = d[i]
  if u == -1: break
  color[u] = 2
  for v in range(n):
   if color[v] != 2 and M[u][v] != float("inf"):
    if d[v] > M[u][v]:
     d[v] = M[u][v]
     p[v] = u
     color[v] = 1
 sum = 0
 for i in range(n):
  if p[i] != -1:
   sum += M[i][p[i]]
 return str(sum)

print(prim())

Measured memory_bytes: 8128
#include <iostream>
#include <algorithm>
using namespace std;
int h, w;
char b[1005][1005], f[2][2] = { 0 };
char t[] = { 'J','O','I' };

bool solve(char c1[2][2], char c2[2][2]) {
	bool flag = true;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			if (c1[i][j] != c2[i][j]) flag = false;
		}
	}
	return flag;
}

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> b[i][j];
		}
	}
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			cin >> f[i][j];
		}
	}
	int res = 0;
	for (int i = 0; i < h - 1; i++) {
		for (int j = 0; j < w - 1; j++) {
			if (b[i][j] == f[0][0]) {
				bool foo = true;
				if (b[i][j + 1] != f[0][1]) foo = false;
				if (b[i + 1][j] != f[1][0]) foo = false;
				if (b[i + 1][j + 1] != f[1][1]) foo = false;
				if (foo) res++;
			}
		}
	}
	int ma = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int nc[3] = { 0 };//nc:全数
			int nt = 0;//今のchar番号
			for (int k = 0; k < 3; k++) {
				if (b[i][j] == t[k]) nt = k;
			}
			char cut[2][2];
			for (int k = 0; k < 3; k++) {
				if (i + 1 < h&&j + 1 < w) {
					cut[0][0] = t[(nt+k)%3];
					cut[0][1] = b[i][j + 1];
					cut[1][0] = b[i + 1][j];
					cut[1][1] = b[i + 1][j + 1];
					if (solve(cut, f)) nc[k]++;
				}
				if (j-1>=0&&i + 1 < h) {
					cut[0][0] = b[i][j - 1];
					cut[0][1] = t[(nt + k) % 3];
					cut[1][0] = b[i + 1][j - 1];
					cut[1][1] = b[i + 1][j];
					if (solve(cut, f)) nc[k]++;
				}
				if (j + 1 < w&&i-1>=0) {
					cut[0][0] = b[i - 1][j];
					cut[0][1] = b[i - 1][j + 1];
					cut[1][0] = t[(nt + k) % 3];
					cut[1][1] = b[i][j + 1];
					if (solve(cut, f)) nc[k]++;
				}
				if (i - 1 >= 0 && j - 1 >= 0) {
					cut[0][0] = b[i - 1][j - 1];
					cut[0][1] = b[i - 1][j];
					cut[1][0] = b[i][j - 1];
					cut[1][1] = t[(nt + k) % 3];
					if (solve(f, cut)) nc[k]++;
				}
			}
			ma = max(ma, max(nc[1], nc[2]) - nc[0]);
			//if (max(nc[1], nc[2]) - nc[0] == 1) cout << i << " " << j << endl;
		}
	}
	cout << res + ma << endl;
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
typedef vector<long long> vlint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<vector<long long>> vlint2;



int main() {
    int n, k; cin >> n >> k;
    char s;
    int cnt[n+2*k]; int index = 1;
    cnt[0] = 0;
    cin >> s;
    bool isOne = (s == '1');
    bool startOne = (s == '1');
    cnt[1] = 1;
    rep(i, n-1){
        cin >> s;
        if (
            (s == '1' && isOne) || (s == '0' && !isOne)
            ){
            cnt[index] ++;
        }
        else{
            isOne = isOne^true;
            index ++;
            cnt[index] = 1;
        }
    }
    index++;
    rep(i, 2 * k){
        cnt[index+i] = 0;
    }
    // accumulation
    rep(i, index + 2 * k-1){
        cnt[i+1] += cnt[i];
    }
    int ans = 0;
    int ans_y;
    For(i, 1, index){
        if (
            (startOne && i % 2 == 0) || (!startOne && i % 2 == 1)
        ){
            ans_y = cnt[i+2*k-1] - cnt[i-1];
        }
        else{
            ans_y = cnt[i+2*k] - cnt[i-1];
        }
        ans = max(ans, ans_y);
    }
    cout << ans << endl;
    


}



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

int main()
{
    ll N;
    cin >> N;
    vector<ll> P(N);
    rep(i, N) cin >> P[i];

    ll ans = 1, mi = P[0];
    rep(i, N - 1)
    {
        if (P[i + 1] < mi)
        {
            ans++;
            mi = P[i + 1];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
N = int(input())
l = []
c=0
for i in range(N):
    l.append(sorted(input()))
l.sort()

base =0
next = 1
ren = 1
while True:
    if l[base] == l[next]:
        ren += 1
        next += 1
    else:
        c += ren * (ren - 1) // 2
        base = next
        next += 1
        ren = 1
    if next == N:
        c += ren * (ren-1) // 2
        break
print(c)


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

int arr[20];

int main()
{

    int x;
    for(int i=0;i<3;i++)
    {
        cin>>x;
        arr[x]++;
    }
    if(arr[5]==2 and arr[7]==1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main() {
    int price; cin >> price;
    if (price == 0) return 0;
    while (1) {
        int mon[4];
        int sum = 0;
        cin >> mon[0];
        sum += mon[0] * 10;
        cin >> mon[1];
        sum += mon[1] * 50;
        cin >> mon[2];
        sum += mon[2] * 100;
        cin >> mon[3];
        sum += mon[3] * 500;
        int oturi = sum - price;
        int c500 = oturi / 500;
        int c100 = oturi % 500 / 100;
        int c50 = oturi % 100 / 50;
        int c10 = oturi % 50 / 10;
        if (mon[0] - c10 > 0) cout << "10 " << mon[0] - c10 << endl;
        if (mon[1] - c50 > 0) cout << "50 " << mon[1] - c50 << endl;
        if (mon[2] - c100 > 0) cout << "100 " << mon[2] - c100 << endl;
        if (mon[3] - c500 > 0) cout << "500 " << mon[3] - c500 << endl;
        cin >> price;
        if (price == 0) return 0;
        else cout << endl;
    }
}


Measured memory_bytes: 3004
import sys
input = sys.stdin.readline
from itertools import zip_longest

def grouper(n, iterable, fillvalue=None):
    "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
    args = [iter(iterable)] * n
    return zip_longest(fillvalue=fillvalue, *args)



def get_divisors(x):
    divisors = []
    for i in range(1, int(x**0.5)+1):
        if x % i == 0:
            divisors.append(i)
            if i != x // i:
                divisors.append(x//i)

    return divisors

def m_exist(n, m):
    #if (n%5)**4 != m%5:
    #    return -1
    a_max = int(abs(m)**(1/2))
    for a in range(a_max):
        calc = 5 * (a**4 - 2*n*a**3 + 2*(n**2)*a**2 - (n**3)*a  )+ n**4
        if calc == m:
            return a
    return -1

x = int(input())




D_Lis = get_divisors(x)
if len(D_Lis) %2 == 1:
    D_Lis.append(D_Lis[-1])
for n, m in grouper(2, D_Lis):
    a = m_exist(n,m)
    if a == -1:
        pass
    else:
        print(a, a-n)
        break
    a = m_exist(m, n)
    if a == -1:
        pass
    else:
        print(a, a-n)
        break


Measured memory_bytes: 9520
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, m, k;
    cin >> n >> m >> k;
    V<ll> a(n), b(m);
    read(a);
    read(b);
    for (int i = 1; i < n; i++) a[i] += a[i - 1];
    for (int i = 1; i < m; i++) b[i] += b[i - 1];
    int res = lwb(b, k + 1LL);
    for (int i = 0; i < n; i++) {
        if (a[i] > k) continue;
        chmax(res, i + 1 + lwb(b, k - a[i] + 1LL));
    }
    cout << res << newl;
}

Measured memory_bytes: 6332
#include <bits/stdc++.h>
using namespace std;
#define N 1111111
#define int long long
bool vis[1111111];
int pri[111111],tot;
int a[11111],b[11111],f[555][555];
map<int,bool>mp;
int LCM(int a,int b){return a/__gcd(a,b)*b;}
int LCM(int a,int b,int c,int d){
	return LCM(LCM(LCM(a,b),c),d);
}
signed main(){
	for (int i=2;tot<=1111 && i<N;i++){
		if (!vis[i]) pri[++tot]=i;
		for (int j=1;j<=tot && pri[j]*i<N;j++){
			vis[i*pri[j]]=1; 
			if (i%pri[j]==0) break;
		}	
	}
	int n; scanf("%lld",&n);
	for (int i=1;i<=n;i++){
		a[i]=pri[i];
		b[i]=pri[i+n];
	}
	for (int i=0;i<=n+1;i++) f[i][0]=f[0][i]=f[n+1][i]=f[i][n+1]=1;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if ((i+j)%2==0)
				f[i][j]=a[(i-j)/2+(n+1)/2]*b[(i+j)/2];
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if ((i+j)&1){
				f[i][j]=LCM(f[i-1][j],f[i][j-1],f[i+1][j],f[i][j+1])+1;
				while (mp.count(f[i][j])) f[i][j]=(f[i][j]-1)*2+1;
				mp[f[i][j]]=1;
			}
				
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++) printf("%lld ",f[i][j]);
		puts("");
	}
	return 0;
}


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

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

using namespace std;

int n, c[(int)1e5 + 7], a[(int)1e5 + 7], w;
long long d[(int)2e5 + 7], mx;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> w;
    for(int i = 1; i <= n; i++)
        cin >> a[i] >> c[i];
    for(int i = 1; i <= w; i++){
        d[i] = -1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = w; j >= 0; j--){
            if(d[j] >= 0){
                d[j + a[i]] = max(d[j + a[i]], d[j] + (long long)c[i]);
            }
        }
    }
    for(int i = w; i >= 0; i--){
        mx = max(mx, d[i]);
    }
    cout << mx;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int n,m;
    bool ans=true;
    cin >>n>>m;
    vector<vector<int>>path(n);
    int a,b;
    rep(i,m){
        cin>>a>>b;
        a--;
        b--;
        path[a].pb(b);
        path[b].pb(a);

    }
    vector<int>rote(n,-1);
    vector<int>dis(n,INF);
    dis[0]=0;
    queue<int>q;
    q.push(0);
    int at;
    while(!q.empty()){
        at=q.front();
        q.pop();
        repi(itr,path[at]){
            if(chmin(dis[*itr],dis[at]+1)){
                rote[*itr]=at;
                q.push(*itr);
            }

        }
    }
    repi(itr,rote){
        if(itr!=rote.begin()){
            if(*itr==-1){
                ans=false;
            }
        }
       // clog<<(*itr)<<" ";
    }
   // clog<<endl;
    cout<<solve(ans)<<endl;
    if(ans){
        repi(itr,rote){
            if(itr!=rote.begin()){
                cout<<((*itr) +1)<<endl;
            }
        }
    }

    //cout<<ans<<endl;
}

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

#define INIT_CAP 10
#define NUM_NODE 20000
#define INF 1000000000

#define min(a, b) (((a) < (b)) ? (a) : (b))

typedef struct {
	int to, w;
} Edge;

typedef struct {
	Edge *elem;
	int cap, size;
} VecEdge;

typedef struct {
	int num;
	int d;
} PairNumDis;

typedef struct {
	int d;
	int idx;
} Node;

VecEdge adj[NUM_NODE];
PairNumDis heap[NUM_NODE];
int hsize;
Node node[NUM_NODE];

void init(int n) {
	while (n--)
		adj[n] = (VecEdge){malloc(sizeof(Edge) * INIT_CAP), INIT_CAP, 0};
}

void add(int from, int to, int w) {
	if (adj[from].size == adj[from].cap) {
		adj[from].cap <<= 1;
		adj[from].elem = realloc(adj[from].elem, sizeof(Edge) * adj[from].cap);
	}
	adj[from].elem[adj[from].size++] = (Edge){to, w};
}

void freeAll(int n) {
	while (n--)
		free(adj[n].elem);
}

int calcNextIdx(int i) {
	return i * 2 + 1 + (i * 2 + 2 < hsize && heap[i * 2 + 1].d > heap[i * 2 + 2].d);
}

PairNumDis delete(void) {
	int i;
	int nextIdx;
	const PairNumDis root = heap[0], last = heap[--hsize];

	for (i = 0; i * 2 + 1 < hsize && last.d > heap[nextIdx = calcNextIdx(i)].d; i = nextIdx) {
		heap[i] = heap[nextIdx];
		node[heap[i].num].idx = i;
	}
	heap[i] = last;
	node[last.num].idx = i;

	return root;
}

void decreaseKey(int num, int d) {
	int i;

	for (i = node[num].idx; i > 0 && d < heap[i - 1 >> 1].d; i = i - 1 >> 1) {
		heap[i] = heap[i - 1 >> 1];
		node[heap[i].num].idx = i;
	}
	heap[i] = (PairNumDis){num, d};
	node[num].idx = i;
}

void dijkstra(int n, int s) {
	int i;

	for (i = 0; i < n; i++) {
		heap[i] = (PairNumDis){i, INF};
		node[i] = (Node){INF, i};
	}
	hsize = n;

	node[s].d = 0;
	decreaseKey(s, 0);
	while (hsize > 0) {
		PairNumDis fromPair = delete();
		for (i = 0; i < adj[fromPair.num].size; i++) {
			Edge e = adj[fromPair.num].elem[i];
			if (fromPair.d + e.w < node[e.to].d) {
				node[e.to].d = fromPair.d + e.w;
				decreaseKey(e.to, node[e.to].d);
			}
		}
	}
}

char field[60][30];

int main(void) {
	int i, j, k, l, m;
	int w, h;
	int min;

	while (scanf("%d %d", &w, &h), w) {
		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				scanf(" %c", field[i] + j);

		init(h * w * 2);
		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				for (k = 0; k < 2; k++)
					for (l = i - 2; l <= i + 2; l++)
						if (l >= 0 && l < h)
							for (m = (k ? j - 3 : j + 1); m <= (k ? j - 1: j + 3); m++)
								if (m >= 0 &&  m < w)
									if (abs(i - l) + abs(j - m) <= 3)
										if (field[l][m] == 'S' || field[l][m] == 'T')
											add(i * w + j + k * h * w, l * w + m + (k ^ 1) * h * w, 0);
										else if (field[l][m] != 'X')
											add(i * w + j + k * h * w, l * w + m + (k ^ 1) * h * w, field[l][m] - '0');

		min = INF;
		for (i = 0; i < w; i++)
			if (field[h - 1][i] == 'S')
				for (j = 0; j < 2; j++) {
					dijkstra(h * w * 2, (h - 1) * w + i + j * h * w);
					for (k = 0; k < w; k++)
						if (field[0][k] == 'T') {
							min = min(min, node[k].d);
							min = min(min, node[k + h * w].d);
						}
				}

		printf("%d\n", min == INF ? -1 : min);

		freeAll(h * w * 2);
	}

	return 0;
}

Measured memory_bytes: 1060
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int N; cin>>N;
	map<P,int> cnt;
	REP(i,N){
		int lt = i%10;
		int digit = (int)log10(i);
		int s = i/pow(10,digit);
		cnt[make_pair(s, lt)]++;
	}
	int ans = 0;
	for(auto x: cnt){
		ans += x.second * cnt[make_pair(x.first.second, x.first.first)];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define T second.first
#define C second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,pair<int,int>> piii;

const int N= 1e2+5, L = 14, OO = 0x3f3f3f3f;
const ll M=10 ;
const double ESP = 1e-8;

int n, w;
pii A[N];
ll dp[N][100005];
ll solve(int idx, int tot_val){
    if(idx == n){
        if(tot_val == 0)return 0;
        return OO;
    }

    ll& ret = dp[idx][tot_val];
    if(~ret)
        return ret;

    return ret = min(solve(idx+1, tot_val), (tot_val-A[idx].S>=0)? solve(idx+1, tot_val - A[idx].S) + A[idx].F : OO);


}

int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    cin>>n>>w;
    for(int i=0; i<n; i++)cin>>A[i].F>>A[i].S;
    memset(dp, -1, sizeof dp);
    int ans;
    for(int i=1; i<=100000; i++){
        if(solve(0,i) <= w)
            ans = i;
    }
    cout<<ans;
}


Measured memory_bytes: 82304
def exist?(n, a)
  return true if a.all? { |num| num == n - 1 }
  color_count = a.max
  uniq_color_count = 0

  a.each do |num|
    return false if num < color_count - 1
    uniq_color_count += 1 if num == color_count - 1
  end

  multi_color_count = color_count - uniq_color_count
  return true if multi_color_count.positive? && 2 * multi_color_count + uniq_color_count <= n
  false
end

n = gets.to_i
a = gets.split.map(&:to_i)
puts exist?(n, a) ? 'Yes' : 'No'

Measured memory_bytes: 8068
lr = [0 for i in range(8)]
while True:
    try:
        a,b = map(float,input().split())
    except:
        break
    if a >= 1.1:
        lr[0] += 1
    elif a >= 0.6:
        lr[2] += 1
    elif a >= 0.2:
        lr[4] += 1
    else:
        lr[6] += 1
    if b >= 1.1:
        lr[1] += 1
    elif b >= 0.6:
        lr[3] += 1
    elif b >= 0.2:
        lr[5] += 1
    else:
        lr[7] += 1
print(lr[0],lr[1])
print(lr[2],lr[3])
print(lr[4],lr[5])
print(lr[6],lr[7])
    


Measured memory_bytes: 5576
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <unordered_set>

using namespace std;
#define INF 99999
#define _GLIBCXX_DEBUG
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define fi first
#define se second
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
using namespace std;


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

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int n, x, ans;
	while(1){
		ans = 0;

		scanf("%d %d", &n, &x);
		if(n == 0 && x == 0) break;

		if(n < 3 || x < 6){
			ans = 0;
		}else if(x > n + (n - 1) + (n - 2)){
			ans = 0;
		}else{
			for(int i = 1;i <= n - 2;i++){
			for(int j = i + 1;j <= n - 1;j++){
				if(i == j) continue;
				for(int k =  j + 1;k <= n;k++){
					if(j == k || i == k) continue;
					if((i + j + k) == x) ans++;
				}
			}
		}
	}
	printf("%d\n", ans);
}
return 0;
}


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


#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int N = 2e5 + 10;


using namespace std;

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    IOS;


    string s;
    string t;
    cin >> s >> t;

    ll cnt = 0;

    for (int i = s.length() - 1; i >= 0; i--)
    {
        if (s[i] == t[i])
        {
            continue;
        }

        else
        {
            cnt++;
        }
    }

    cout << cnt << endl;

}


Measured memory_bytes: 3884
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
	int N;
	char s[11];
	int k;
	cin >> N;
	cin >> s >> k;
	
	for(int i=0;i<N;i++){
		if(s[i] != s[k-1]) s[i]='*';
	}
	
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

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

signed main(){
	string s;
	cin>>s;
	int cnt=0;// W
	int sum=0;

	rep(i,s.size()){
		if(s[i]=='W'){
			sum+=i-cnt;
			cnt++;
		}
	}
	cout<<sum<<endl;


	return 0;
}


Measured memory_bytes: 3728
import sys
from itertools import accumulate

def main():
    input = sys.stdin.readline
    N = int(input())
    U = [0] + list(accumulate(map(int, input().split())))
    D = [0] + list(accumulate(map(int, input().split())))

    ans = 0
    for i in range(1, N+1):
        cur = U[i] + D[N] - D[i-1]
        ans = max(ans, cur)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>

int cnt[51] = {};

int main() {
  int N, M, a, b;

  scanf("%d %d", &N, &M);

  for (int i = 0; i < M; i++) {
    scanf("%d %d", &a, &b);
    cnt[a] += 1;
    cnt[b] += 1;
  }

  for (int i = 1; i <= N; i++) {
    printf("%d\n", cnt[i]);
  }
}


Measured memory_bytes: 128
import sys
 
def solve(N, T, A, ls_H):
    temperature = []
    difference = []
    near = []
    ti = 10**5//1
    for x in ls_H :
        air = T - x * 0.006
        temperature.append(air)
    #print(temperature)
    
    for y in temperature :
        til = A - y
        difference.append(til)
    #print(difference)
    
    for z in difference :
        near.append(abs(z))
    #print(near)
    
    for i in near :
        if ti > i :
            ti = i
    #print(ti)
    return near.index(ti) + 1


def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    A = int(ws[1])
    ws = sys.stdin.readline().strip().split()
    ls_H = list(map(int, ws))
    return (N, T, A, ls_H)
 
def main():
    print(solve(*readQuestion()))
 # Uncomment before submission
main()

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	ll n; cin >> n;
	int l;
	ll tmp = 26;
	for(l=1; ; l++){
		if(tmp >= n) break;
		n -= tmp;
		tmp *= 26;
	}
	n--;
	vector<char> ans(l);
	for(int i=l-1; i>=0; i--){
		ans[i] = (n % 26) + 'a';
		n /= 26;
	}
	rep(i,l) cout << ans[i];
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

int main() {
  int s, w;
  cin >> s >> w;
  cout << ((s <= w) ? "unsafe" : "safe") << endl;
  return 0;
}

Measured memory_bytes: 3632
S = input()

k = 0
s = 0
for i in range(len(S)):
  if i % 2 == 0:
    if S[i] == "0":
      k += 1
    else:
      s += 1
  else:
    if S[i] == "1":
      k += 1
    else:
      s += 1

print(min(k, s))

Measured memory_bytes: 3188
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    ll a,b; cin>>a>>b;
    cout<<max(max(a+b, a-b), a*b);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<cctype> 
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
 
  int H,W;
  cin >> H >> W;
  char C[H][W];
  int i,j,k;
      
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      cin >> C[i][j];
    }
  }
  for(i=0;i<H;i++){
    for(k=0;k<2;k++){   
      for(j=0;j<W;j++){
	cout << C[i][j];
      }
      cout << '\n';
    }

  }
      
  
  return 0;
}


Measured memory_bytes: 256
n = input()

origin = [n[0],n[1],n[2],n[3]]
dic = {}

count = 0
num = n[0]
flg = False
for o in origin:
  if o == num:
    count += 1
    if count > 2:
      flg = True
  else:
    num = o
    count = 1

if flg:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<pair<int, int>> v[n + 1];
    for (int i = 1; i <= n; ++ i) {
        int a;
        cin >> a;
        while (a --) {
            int p, h;
            cin >> p >> h;
            v[i].emplace_back(p, h);
        }
    }
    int ans = 0;
    for (int a = 0; a < (1 << n); ++ a) {
        vector<int> st;
        for (int b = a, x = 0; b ; b >>= 1, ++ x) {
            if (b & 1) {
                st.emplace_back(x + 1);
            }
        }
        vector<int> foo(n + 1, 0);
        for (auto& x : st) foo[x] = 1;
        for (auto& x : st) {
            for (auto& y : v[x]) {
                if (foo[y.F] != y.S) goto here;
            }
        }
        ans = max(ans, (int)st.size());
        here:;
    }
    cout << ans;
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b;
    scanf( "%d %d",&a,&b );
    if( a < b )printf( "a < b" );
    else if( a > b ) printf( "a > b" );
    else printf( "a == b" );
    printf( "\n" );
    return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <set>

using namespace std;

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

    set<int> p;
    for (int i = 0; i < n; i++) {
        int pi;
        cin >> pi;
        p.insert(pi);
    }

    int res = 0;
    for (int i = 0; ; i++) {
        if (p.find(x - i) == p.end()) {
            res = x - i;
            break;
        } else if (p.find(x + i) == p.end()) {
            res = x + i;
            break;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 3612
//Awwawa! Dis cold yis ratten buy tEMMIE!
#include <bits/stdc++.h>
#define ll long long
#define maxn 200005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
char s[maxn];
int main() {
	scanf("%s", s);
	int l = strlen(s);
	int le = 0, ig = 0;
	ll ans = 0;
	for (int j = 0; j < l; j++) {
		if (s[j] == '0') {
			if (le % 2) le++;
			else ig++;
		}
		else {
			if (le % 2 == 0) {
				ans += (l - j);
				ans += (ig / 2);
			}
			else {
				ans += ((ig + 1) / 2);
			}
			le++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  string s;
  cin >> s;
  ll k=s.size();
  bool ok=false;
  rep(i,k-1){
    if(s[i]=='A'&&s[i+1]=='C'){
      ok = true;
    }
  }
  if(ok){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

int n, k;
string ans;
int main(){
    ios_base::sync_with_stdio(0);
    scanf("%d", &k);
    reads(ans);
    if(ans.size()>k) ans = ans.substr(0,k) + "...";
    printf("%s", ans.data());
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

int N;
string S;

signed main() {
  cin >> N >> S;

  static int dp[200001][2];
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < 2; j++) {
      dp[i][j] = 1e9;
    }
  }

  for (int i = 0; i < N; i++) {
    dp[i+1][0] = dp[i][0] + (S[i] == '#');
    dp[i+1][1] = min(dp[i][0], dp[i][1] + (S[i] == '.'));
  }

  int ans = min(dp[N][0], dp[N][1]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3716