akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,i,flg,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++)	{
		flg=0;
		if(i%3==0)	flg=1;
		x=i;
		while(x>0)	{
			if(x%10==3)	flg=1;
			x/=10;
		}
		if(flg==1)	printf(" %d",i);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2704
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define pll pair<long long,long long>
using namespace std;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a;
    long double b;
	cin>>a>>b;
	int c=b;
	int k=a*c+a*(b-c);
	cout<<k;
	return 0;
}

Measured memory_bytes: 3732
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h1 = sc.nextInt(), m1 = sc.nextInt(), h2 = sc.nextInt(), m2 = sc.nextInt(), k = sc.nextInt();
        System.out.println((h2 - h1) * 60 + (m2 - m1) - k);
    }
}

Measured memory_bytes: 26972
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef pair<ll, ll> pll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define PI 3.14159265358979323846264338327950288419716939937510
#define mp make_pair
#define vvl vector<vector<ll>>
#define vll vector<ll>
#define vpll vector<pll>
ll inf = 1e18;
ll p = 1e9 + 7;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll pwr(ll x, ll y)
{
    ll res = 1;
    x = x ;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) ;
        y = y >> 1;
        x = (x * x) ;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, j, y, x,  z, w, g, key,  k, n, m, a, b, t, c, d;
    ll t2, t3, t4, t1, t5, t6;
    ll s;
    cin >> n;
    vll len, len2;
    for (i = 0; i < n; i++)
    {
        cin >> x >> y;
        len.pb(x + y);
        len2.pb(x - y);
    }
    sort(len.begin(), len.end());
    sort(len2.begin(), len2.end());
    ll a2 = len2[n - 1] - len2[0];
    a2 = abs(a2);

    ll ans = len[n - 1] - len[0];
    ans = abs(ans);
    cout << std::max(a2, ans);
    return 0;
}

Measured memory_bytes: 6668
#include<bits/stdc++.h>
using namespace std;
int cf(int a)
{
	int ans=2;
	for(int i=1;i<a;i++)
	{
		ans*=2;
	}
	return ans;
}
int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a>b && a>c)
		cout<<cf(k)*a+b+c<<'\n';
	else if(b>a && b>c)
		cout<<cf(k)*b+a+c<<'\n';
	else
		cout<<cf(k)*c+a+b<<'\n';
	return 0;
} 

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int N;
    cin >> N;
    vector<ll> H(N);
    rep(i,N) cin >> H[i];
    ll tmp = 0;
    ll ans = 0;
    rep(i,N-1)
    {
        if(H[i] >= H[i+1])
        {
            tmp++;
        }
        else
        {
            ans = max(ans, tmp);
            tmp = 0;
        }
    }
    //cout << ans << " " << tmp << endl;
    cout << max(ans, tmp) << endl;
}


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

#define gc getchar
#define t int t; cin>>t; while(t--)
#define rep(i,j,k) for(i=j; i<k; i++)
#define rrep(i,j,k) for(i=j; i>=k; i--)
#define repm(i,j,n,m) for(i=0; i<n; i++) for(j=0; j<m; j++)
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); it++)
#define ZERO(a) memset(a,0,sizeof(a))
#define lowbit(x) (x&(-x))
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end()
#define fin scan_int()
#define fout(x) fast_out(x)
#define pd(x) printf("%d ",x)
#define newl printf("\n")
#define xx first
#define yy second
#define INOUT take_input_and_output_from_file();
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define strtoint(s,n) if (!(istringstream(s) >> n) ) n = 0;
#define mod 1000000007
typedef long long ll;
typedef vector<int > vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<string,int > psi; 
typedef pair<int ,int > pii;

string inttostr(int str){stringstream stream;stream << str;return stream.str();}
ll modexpo(ll a,ll b,ll n){ll d=1;while(b){if(b&1)d=(d*a)%n;b>>=1;a=(a*a)%n;}return d;}
ll expo(ll a,ll b){ll d=1;while(b){if(b&1)d=d*a;b>>=1;a=a*a;}return d;}
inline ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b) {return (a*b)/gcd(a,b);}
ll inv(ll a,ll m){return modexpo(a,m-2,m);}
void parr(int a[],int n){int i;rep(i,0,n)cout<<a[i]<<" ";cout<<endl;}

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

inline int scan_int() {
    int NR=0,sign=1;
    char c=gc();
    while( c < 48 || c > 57 ) {
        if(c=='-') sign=0;
        c=gc();
    }
    while(c>47 && c< 58) {
        NR = (NR << 3) + (NR << 1) + (c - 48);
        c=gc();
    }
    return (sign?NR:(-NR));
}

////////////////////////////////////////////////////////////////////////////////////////////



int main(){
    //INOUT;
    
    int n=fin;

    int cnt=0, i;
    rep(i,1,n+1) {
        int j, c=0;
        for(j=1; j*j<=i; j++) {
            if(i%j==0 && i&1) {
                if(j*j == i) c++;
                else c+=2;
            }
            if(c>9) break;
        }
        if(c==8) cnt++;
    }

    //cout<<cnt<<endl;
  printf("%d", cnt);


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

ll ans[2048] = {1};

int main(){
	int n; scanf("%d", &n);
	FOR(i, 1, n+1){
		FOR(j, 0, i-3 +1) ans[i] += ans[j];
		ans[i] %= 1'000'000'007;
	}
	printf("%lld\n", ans[n]);
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,a;
    cin>>n;
    deque<ll> deq;
    rep(i,n){
        cin>>a;
        if(i%2) deq.push_front(a);
        else deq.push_back(a);
    }
    if(n%2) reverse(all(deq));
    for(auto x:deq) cout<<x<<' ';
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3840
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

enum Loc{
	Left,
	Right,
	Top,
	Bottom,
};

int N;
int* boss,*height;

//??????????????????index?????????????????????????????§??????????????¢??°
int get_boss(int id){
	if(boss[id] == id)return id; //???????????£??¨??????????????????????????????
	else{
		return boss[id] = get_boss(boss[id]); //??£??¨??§????????????????????????????±??????????????????£??¨??????????????????????????§???
	}
}

int isSame(int x,int y){
	return get_boss(x) == get_boss(y);
}

void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	//??¢???????????°??????????????????????????????
	if(boss_x == boss_y)return;

	//?????????????????????????????????
	if(height[x] > height[y]){

		boss[boss_y] = boss_x;

	}else if(height[x] < height[y]){

		boss[boss_x] = boss_y;

	}else{ //height[x] == height[y]

		boss[boss_y] = boss_x;
		height[x]++;
	}
}

int main(){

	int Q,command,x,y;

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

	boss = new int[N];
	height = new int[N];

	for(int i = 0; i < N; i++){
		boss[i] = i;
		height[i] = 1;
	}

	for(int i = 0; i < Q; i++){
		scanf("%d %d %d",&command,&x,&y);

		if(command == 0){ //unite??????
			unite(x,y);
		}else{
			if(isSame(x,y)){
				printf("1\n");
			}else{
				printf("0\n");
			}
		}
	}

	return 0;
}

Measured memory_bytes: 2756
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

signed main(){
    int n;
    cin >> n;
    rep(t, 0, n){
        int d[6][6] = {0};
        rep(i, 1, 6) rep(j, 1 ,6) cin >> d[i][j];
        rep(i, 1, 6) rep(j, 1, 6) d[i][j] += d[i][j - 1];
        rep(i, 1, 6) rep(j, 1, 6) d[j][i] += d[j - 1][i];
        int MAX = 0;
        rep(i, 1, 6) rep(j, i, 6) rep(k, 1, 6) rep(l, k, 6){
            int sum = (j - i + 1)*(l - k + 1);
            int tmp = d[j][l] - d[j][k - 1] - d[i - 1][l] + d[i - 1][k - 1];
            if(sum == tmp) MAX = max(MAX, tmp);
        }
        cout << MAX << endl;
    }
}

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

int main(){
  int N;
  cin >>N;
  
  int c=0;
  vector<int> a(N);
  
  for(int i=0;i<N;i++){
  cin >>a.at(i);
  }
  
  bool fin=false;
  
  while(1){
  for(int i=0;i<N;i++){
  if(a.at(i)%2==1){
    fin=true;

    break;}
    else if(a.at(i)%2==0){
    a.at(i)=a.at(i)/2;
    }

    
  }
    if(fin){break;}
    else {c++;}
    
  }


cout << c<<endl;


}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	ll ma = -1;
	ll ind = -1;
	ll sum = 0;
	vector<ll> L(N);
	REP(i, N){
		cin >> L[i];
		if(ma<L[i]){
			ma = max(ma, L[i]);
			ind = i;
		}
	}
	REP(i, N){
		if(i==ind) continue;
		sum += L[i];
	}
	//dump(sum)
	//dump(ma)
	cout << (ma<sum?"Yes":"No") << endl;
    return 0;
}

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

int main()
{
	string s;

	cin >> s;

	if (s[2] == s[3])
		if (s[4] == s[5])
			printf("Yes");
		else
			printf("No");
	if (s[2] != s[3])
		printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

typedef long long ll;

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < 3; i++) {
    if (s[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,sum,count;
  while(1){
  count = 0;
  cin >> n;
  if(n==0) break;
  for(int i=0; i<n; i++){
    sum = 0;
    for(int j=i+1; j<n; j++){
        sum += j;
        if(sum==n) count++;
        if(sum>n) break;
    }
  }
  cout << count << endl;
  }
  return 0;
}


Measured memory_bytes: 3020
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,a,b;cin>>n>>a>>b;
  if((b-a)%2)cout<<"Borys"<<endl;
  else cout<<"Alice"<<endl;
  return 0;
}


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

int main(){
    int N,T,A,min,number;
    cin >> N >> T >> A;
    int H[N]={};
    min = 1000000;

    for(int i = 0;i<N;i++){
        cin >> H[i];       
        //min = min(min,abs(T-H[i]));
        if(min>abs(A*1000-(T*1000 - H[i]*6 )) ){
            number = i+1;
            min = abs(A*1000 -(T*1000 - H[i]*6 ));
        }       
    }
cout << number <<endl;

}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);
vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}
int main()
{
	IOS;
    cout.precision(30);
    int n; cin >> n; string s; cin >> s;
    ll ans=0;
    for (int i=0;i<n;i++)
    {
        string s1=s.substr(i,n);
        vector<int> pref=z_function(s1);
        int l=n-i;
        for (int j=0;j<l;j++)
        {
            if (pref[j]<=j)
            {
                ans=max(ans,(ll)pref[j]);
            }
        }
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int A = in.nextInt();
            String op = in.next();
            int B = in.nextInt();
            System.out.println(op.equals("+") ? A + B : (A - B));
        }
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const int A = 1000005;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> c(A);
  rep(i,n) {
    cin >> a[i];
    c[a[i]]++;
  }
 
  bool pairwise = true;
  for (int i = 2; i < A; i++) {
    int cnt = 0;
    for (int j = i; j < A; j += i) {
      cnt += c[j];
    }
    if (cnt > 1) pairwise = false;
  }
 
  if (pairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
 
  int g = 0;
  rep(i,n) g = gcd(g,a[i]);
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }
 
  cout << "not coprime" << endl;
  return 0;
}

Measured memory_bytes: 11088
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d,a=0;cin>>n>>d;
  vector<vector<int>>x(n,vector<int>(d));
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++)cin>>x.at(i).at(j);
  }
  for(int k=0;k<n-1;k++){
    for (int l=k+1;l<n;l++){
      int p=0;
      for(int e=0;e<d;e++){
        p+=(x.at(k).at(e)-x.at(l).at(e))*(x.at(k).at(e)-x.at(l).at(e));
      }
      int q=sqrt(p);
      double r=sqrt(p);
      if(q==r)a++;
    }
  }
  cout<<a<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;


const int mod=1000000007;
//const int mod=998244353;





int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d;
//    cin>>n;
    string s;
    cin>>s;
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])
        cout<<"Bad\n";
    else
        cout<<"Good\n";
    
    
    
    
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        solve();
    }

    void solve() {
        int sqrtN = (int)Math.sqrt(n);
        System.out.println(sqrtN * sqrtN);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;
    int A[1000001];
    A[0]=0;
    for(int i=1;i<=N;i++){
        cin>>A[i];
    }
    int cut=K-1;
    if((N-1)%cut==0){
        cout<<(N-1)/cut<<endl;
    }else{
        cout<<(N-1)/cut+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 2560
while True : 
    A = list(map(int,input().split()))
    if A[0] == 0 : break
    cnt = 0 
    S = 0 
    for i in A : 
        S += min(i, 10) 
        if i == 1 : cnt += 1
    while cnt > 0 and S + 10 <= 21 : 
        cnt -= 1
        S += 10
    if S > 21 :
        S = 0
    print(S)
 


Measured memory_bytes: 5592
from collections import Counter

n = int(input())
st = []
for _ in range(n):
    st.append(input())
s = Counter(st)
s = s.most_common()

max = s[0][1]
max_s = []

for i in range(len(s)):
    if int(s[i][1]) == int(max):
        max_s.append(s[i][0])
max_s.sort()

for i in range(len(max_s)):
    print(max_s[i])

Measured memory_bytes: 49524
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int K = sc.nextInt();
   double ans =0.0;
     for(int i =1;i<=N;i++){
       if(i>=K){
         ans +=  1/(double)N;
       }
       if(i<K){
         double j=1.0;
         int num = i;
         while(num<K){
           j /=2;
           num = 2*num;
         }
   	  ans += (1/(double)N)*j;
       }
     }
     System.out.println(ans);
 }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int qmin(int a, int b){
	return (a < b) ? a : b;
}

int n, m;
char s[111][111];
int dist[111][111];

int main(){
	scanf("%d%d", &n, &m);
	rep(i, n) scanf("%s", s[i]);
	memset(dist, 0x3f, sizeof(dist));
	dist[0][0] = (s[0][0] == '#');
	rep(i, n){
		rep(j, m){
			if(i) dist[i][j] = qmin(dist[i][j], dist[i-1][j] + (s[i-1][j] == '.' && s[i][j] == '#'));
			if(j) dist[i][j] = qmin(dist[i][j], dist[i][j-1] + (s[i][j-1] == '.' && s[i][j] == '#'));
		}
	}
	cout << dist[n-1][m-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
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 LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,1,-1,1,-1,-1,0};
int dy[]={0,1,1,-1,-1,1,0,-1};


int main(){
    LL a,b,k;cin >> a >> b >> k;
    if(k <= a) a-=k;
    else{
        k -= a;
        a = 0;
        b -= k;
    }
    cout << a << " " << max(b,0LL) << endl; 
    return 0;
}


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

int main() {
  int N;
  ll D;
  cin >> N >> D;
  int ans = 0;
  rep(i, N) {
    ll X, Y;
    cin >> X >> Y;
    ll dist = X * X + Y * Y;
    if (dist <= D * D) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
const int INF = 1e9 + 7;
int a[maxn], b[maxn], c[maxn];
int dp[3][maxn];
int n;
int main() {
	while (cin >> n) {
		for (int i = 1; i <= n; i++)
			scanf("%d%d%d", &a[i], &b[i], &c[i]);
		memset(dp, 0, sizeof(dp));
		dp[0][1] = a[1], dp[1][1] = b[1], dp[2][1] = c[1];
		for (int i = 2; i <= n; i++) {
			dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a[i];
			dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + b[i];
			dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + c[i];
		}
		printf("%d\n", max(dp[0][n], max(dp[1][n], dp[2][n])));
	}
}

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

vector<vector<int>> T(200000), G = T;
vector<int> Count(200000, 0), Count_aftercontest = Count;

void solve(int a) {
	for (int i : T[a]) {
		Count[i] += Count[a];
		solve(i);
	}
	return;
}

void tree_aftercontest(int a) {
	Count_aftercontest[a] = 1;
	for (int i : G[a]) {
		if (Count_aftercontest[i])
			continue;
		T[a].push_back(i);
		tree_aftercontest(i);
	}
	return;
}

int main() {
	int N, Q, a, b, p, x;
	cin >> N >> Q;
	for (int i = 0;i < N - 1;i++) {
		cin >> a >> b;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	tree_aftercontest(0);
	for (int i = 0;i < Q;i++) {
		cin >> p >> x;
		p--;
		Count[p] += x;
	}
	solve(0);
	for (int i = 0;i < N;i++) {
		cout << Count[i] << " ";
	}
}

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

ll MOD = 1000000007;

vector<vector<ll>> Matrix_Multiplication(const vector<vector<ll>> &m1, const vector<vector<ll>> &m2)
{
  vector<vector<ll>> ret(m1.size(), vector<ll>(m2[0].size(), 0));
  rep(i, m1.size())
    rep(j, m2[0].size())
      rep(k, m1[0].size())
        ret[i][j] = (ret[i][j] + (m1[i][k] * m2[k][j]) % MOD) % MOD;
  return ret;
}

vector<vector<ll>> create_identity_matrix(int x)
{
  vector<vector<ll>> ret(x, vector<ll>(x, 0));
  rep(i, x)
    ret[i][i] = 1;
  return ret;
}

vector<vector<ll>> Matrix_Power(vector<vector<ll>> m, ll k)
{
  auto ret = create_identity_matrix(m.size());
  while (k > 0)
  {
    if (k % 2 == 1)
      ret = Matrix_Multiplication(ret, m);
    m = Matrix_Multiplication(m, m);
    k >>= 1;
  }
  return ret;
}

int main()
{
  int n;
  ll k;
  cin >> n >> k;
  vector<vector<ll>> a(n, vector<ll>(n));
  rep(i, n)
    rep(j, n)
      cin >> a[i][j];
  auto ret = Matrix_Power(a, k);
  ll ans = 0;
  rep(i, n)
    rep(j, n)
      ans = (ans + ret[i][j]) % MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
fun main(arg: Array<String>) {
    val N = nextInt()
    val A = Array<Long>(N) { nextLong() }
    var sum = 0L
    var ans = 0L
    for (n in 0 until N) {
        if (A[n] == 0L) {
            ans += sum / 2; sum = 0
        } else sum += A[n]
    }
    ans += sum / 2
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()


Measured memory_bytes: 41004
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<int> H(N);
	for (int i = 0; i < N; i++) cin >> H[i];

	int m = NIL, L = NIL;
	bool f = 1;

	for (int i = 0; i < N - 1; i++) {
		int a, b;
		a = H[i]; b = H[i + 1];
		if (a > b) {
			if (a - b > 1) {
				f = 0;
				break;
			}
			else {
				if ((L != NIL) && (L > b)) {
					f = 0;
					break;
				}
				else {
					L = b;
				}
			}
		}
	}

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

Measured memory_bytes: 3784
#include <stdio.h>
 
int main(void){
    char Str[1200];
    char *p;
    int l;
    int i;
    gets(Str);
    for(p = Str; *p!='\0'; p++){
        if('a' <= *p && *p <= 'z')*p+='A'-'a';
        else if('A' <= *p && *p <= 'Z')*p+='a'-'A';
    }
    printf("%s\n",Str);
 
    return 0;
}

Measured memory_bytes: 524
#include <algorithm>
#include <cassert>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

#define all(x) begin(x), end(x)

using namespace std;

template <typename T> T gcd(T a, T b) {
  if (a % b == 0) {
    return b;
  } else {
    return gcd(b, a % b);
  }
}

template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }

const int MAX_N = 100;
const int MAX_W = 10000;

int n, W;
int w[MAX_N], v[MAX_N];
int dp[MAX_N + 1][MAX_W + 1];

void solve() {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= W; ++j) {
        if (j >= w[i]) {
            dp[i+1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
        } else {
            dp[i+1][j] = dp[i][j];
        }
    }
  }
  printf("%d\n", dp[n][W]);
}

int main(void) {
  int i;
  cin >> n >> W;

  for (i = 0; i < n; i++) {
    cin >> v[i] >> w[i];
  }

  solve();

  return 0;
}


Measured memory_bytes: 7036
from math import sqrt, ceil, factorial
from collections import Counter

m = 10**9+7
def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    f = 2
    while n > 1:
        if n % f == 0:
            factor.append(f)
            n /= f
        else:
            f += 1
    return factor

def comb(n, r):
    a = 1
    for i in range(n-r+1, n+1):
        a *= i
    return a//factorial(r)

N, M = map(int, input().split())
p = prime_factorization(M)
c = Counter(p)
ans = 1
for v in c.values():
    ans *= (comb(v + N - 1, v) % m)
print(ans%m)

Measured memory_bytes: 38512
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

s = gets.chomp
t = gets.chomp

# 7文字 -> 1文字 
sa = s.length - t.length


def levenshtein_distance(s, t)
  di = 0
  s.length.times do |i|
    di += 1 if s[i] != t[i]
  end
  di
end

# puts sa
min = INF
0.upto(sa) do |i|
  bu = s.slice(i,t.length)
  # puts bu
  bu = levenshtein_distance(bu, t)
  # puts bu

  min = bu if min > bu
end

puts min




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

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL<<60;

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) {
    cin >> s[i];
  }
  vector<vector<ll> > dp(h, vector<ll>(w,INF));
  if (s[0][0] == '#') dp[0][0] = 1;
  else dp[0][0] = 0;
  rep(i,h) rep(j,w) {
    //白から黒に移動するときだけコスト+1
    rep(k,2) {
      int y = i + dy[k];
      int x = j + dx[k];
      if (y >= h || x >= w) continue;
      if (s[i][j] == '.' && s[y][x] == '#') dp[y][x] = min(dp[y][x], dp[i][j] + 1);
      else dp[y][x] = min(dp[y][x], dp[i][j]);
    }
  }
  cout << dp[h-1][w-1] << endl;
  return 0;
}

Measured memory_bytes: 384
//string _(){
//    int n;
//    cin >> n;
//    vvi arr(n,vi(3));
//    cin >> arr;
//    arr.insert(arr.begin(),{0,0,0});
//    ++n;
//    rep(i,0,n-2){
//        int d = abs(arr[i][1]-arr[i+1][1])+abs(arr[i][2]-arr[i+1][2]);
//        int t = arr[i+1][0]-arr[i][0];
//        if(d > t || d%2 != t%2)
//            return "No";
//    }
//    return "Yes";
//
//}
//
//
#include <iomanip>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
string _(){
    int n;
    cin >> n;
    vvi arr(n,vi(3));
    cin >> arr;
    arr.insert(arr.begin(),{0,0,0});
    ++n;
    rep(i,0,n-2){
        int d = abs(arr[i][1]-arr[i+1][1])+abs(arr[i][2]-arr[i+1][2]);
        int t = arr[i+1][0]-arr[i][0];
        if(d > t || d%2 != t%2)
            return "No";
    }
    return "Yes";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


Measured memory_bytes: 9600
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] daikeihen = new int[3];
        daikeihen[0] = sc.nextInt();
        daikeihen[1] = sc.nextInt();
        daikeihen[2] = sc.nextInt();
        System.out.println((daikeihen[0] + daikeihen[1]) * daikeihen[2] / 2);
    }
}


Measured memory_bytes: 21204
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list> 
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<fstream>
#include<set>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ld long double
#define pb push_back
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define B begin()
#define E end()
#define S size()
#define m9 1000000007
using namespace std;


 
/*
string fs(string str1, string str2)
{    if (str1.length() > str2.length())
        swap(str1, str2);
      string str = "";
    int n1 = str1.length(), n2 = str2.length();
    int diff = n2 - n1;
      int carry = 0;
      for (int i=n1-1; i>=0; i--)
    {
 
        int sum = ((str1[i]-'0') +
                   (str2[i+diff]-'0') +
                   carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }
      for (int i=n2-n1-1; i>=0; i--)
    {
        int sum = ((str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }
      if (carry)
        str.push_back(carry+'0');
      reverse(str.begin(), str.end());
 
    return str;
}*/
 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
/*
ll gcdextended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; 
    int gcd = gcdextended(b%a, a, &x1, &y1); 
   
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}
 
 
///RELATIVE COPRIME
ll modinverse(ll a, ll m) 
{ 
    ll x, y; 
   ll g = gcdextended(a, m, &x, &y); 
    if (g != 1) 
return -1;
    else
    { 
        ll res = (x%m + m) % m; 
        return res;  
    } 
} 
  */
ll powmod(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = powmod(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 
///M IS PRIME
ll modif(ll x,ll m){
return(powmod(x,m-2,m));
 
}
 
bool fa(vll &x,vll &y){return x[0]<y[0];}
bool fa1(vll &x,vll &y){return x[1]<y[1];}
bool f1(pll &x,pll &y){return x.second<y.second;}
bool f2(pll &x,pll &y){return x.first>y.first;}
bool f3(ll &x,ll &y){
    return x>y; 
    }

#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define pin(a) for(auto x:a)cout<<x<<" ";cout<<endl
#define fck(a) cout<<a;exit(0)
#define vvll vector<vector<ll> >
#define A(b) b.begin(),b.end()


//include<bits/stdc++.h>


int main()
{ fastio;
//freopen("input.txt", "r", stdin); 
//freopen("output.txt", "w", stdout);


string s;cin>>s;
ll n=s.S;
string c;cin>>c;

ll ans=0;
forl(i,0,n){
if(s[i]!=c[i])ans++;
}
cout<<ans;






return 0;
}


Measured memory_bytes: 3828
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(x) begin(x), end(x)
using namespace std;

template <typename T>
vector<T> longest_increasing_subsequence(vector<T> const & xs) {
    vector<T> l; // l[i] is the last element of the increasing subsequence whose length is i+1
    l.push_back(xs.front());
    for (auto && x : xs) {
        auto it = lower_bound(l.begin(), l.end(), x);
        if (it == l.end()) {
            l.push_back(x);
        } else {
            *it = x;
        }
    }
    return l;
}

int main() {
    // input
    int lx, ly, rx, ry, n; scanf("%d%d%d%d%d", &lx, &ly, &rx, &ry, &n);
    int h = abs(ry - ly);
    int w = abs(rx - lx);
    vector<pair<int, int> > f;
    repeat (i, n) {
        int x, y; scanf("%d%d", &x, &y);
        x = lx <= rx ? x - lx : lx - x;
        y = ly <= ry ? y - ly : ly - y;
        if (0 <= x and x <= w and 0 <= y and y <= h) {
            f.emplace_back(x, y);
        }
    }
    // solve
    vector<int> lis;
    if (not f.empty()) {
        vector<int> g;
        sort(whole(f));
        for (auto it : f) g.push_back(it.second);
        lis = longest_increasing_subsequence(g);
    }
    double result = 100.0 * (h + w) - (20 - 5 * M_PI) * lis.size();
    if (lis.size() == min(w, h) + 1) {
        result += 5 * M_PI;
    }
    // output
    printf("%.15lf\n", result);
    return 0;
}


Measured memory_bytes: 4848
//#pragma GCC         optimize("O3")
#include            <bits/stdc++.h>
#include            <ext/pb_ds/assoc_container.hpp>
#include            <ext/pb_ds/tree_policy.hpp>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define mp          make_pair
#define mem(x,i)    memset(x,i,sizeof(x))
#define ff          first
#define ss          second
#define popcount(x) __builtin_popcount(x)
#define all(x)      x.begin(),x.end()
#define Case(t)     for(int ks=1;ks<=t;ks++)
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define D(x)        cerr<< __LINE__ <<": "<< #x << " = "<<(x) <<'\n';
#define endl        '\n'

using namespace std;
using namespace __gnu_pbds;

using ll  = long long;
using ld  = long double;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;

const int INF    = 0x3f3f3f3f;
const ll LL_INF  = 0x3f3f3f3f3f3f3f3f;
const double PI  = acos(-1);
const double eps = 1e-4;
const int mod    = 998244353;
const int mx     = 100005;
template <typename T>  using orderedSet =
    tree<T, null_type, less_equal<T>,
    rb_tree_tag, tree_order_statistics_node_update>;//find_by_order,order_of_key*/

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

//ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(; b; b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
/*----------------------BitMask-----------------------------------------*/
//inline int setBit(int N,int pos){return N=N | (1<<pos);}
//inline int resetBit(int N,int pos){return N= N & ~(1<<pos);}
//inline bool checkBit(int N,int pos){return (bool) (N& (1<<pos));}

int main()
{
    int n;
    cin>>n;
    n--;
    int b[n];
    for(int i=0;i<n;i++) cin>>b[i];
    int ans=b[0]+b[n-1];
    for(int i=0;i<n-1;i++) ans+=min(b[i],b[i+1]);
    cout<<ans;
}


Measured memory_bytes: 3616
takahasi_HP, takahasi_ATK, aoki_HP, aoki_ATK = map(int, input().split())

while True:
    aoki_HP -= takahasi_ATK
    if aoki_HP  <= 0:
        print("Yes")
        break
    takahasi_HP -= aoki_ATK
    if takahasi_HP <= 0:
        print("No")
        break

Measured memory_bytes: 9168
#include<cstdio>
#include<algorithm>
using namespace std;

long long gcd(long long x,long long y)
{
	if(!y) return x;
	return gcd(y,x%y);
}

int main()
{
	long long a,b,c,d;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	long long e=c*d/gcd(c,d);a--;
	long long ans=(b-a+1)-((b-(b%c))-(a-(a%c)))/c-1-((b-(b%d))-(a-(a%d)))/d-1+((b-(b%e))-(a-(a%e)))/e+1;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    if (S.length() < 26) {
      for (char c = 'a';;c++) {
        if (S.indexOf(c) == -1) {
          System.out.println(S + c);
          break;
        }
      }
    } else {
      int place[] = new int[26];
      for (int i=0; i<26; i++) {
        place[S.charAt(i) - 'a'] = i;
      }
      boolean okay = false;
      for (int i=24; i>=0; i--) {
        char s = S.charAt(i);
        for (char c = s; c < 'z';) {
          c++;
          if (place[c - 'a'] > i) {
            System.out.println(S.substring(0, i) + c);
            i = -1;
            okay = true;
            break;
          }
        }
      }
      if (!okay) {
        System.out.println(-1);
      }
    }
  }
}

Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <limits>
#include <utility>
#include <bitset>
#include <sstream>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define INF 1e9

int main()
{

	string s;
	cin >> s;
	int size = s.size();

	int ans = INF;
	int tmp = -INF;
	int cnt = 0;
	for (char c = 'a'; c <= 'z'; c++)
	{
		cnt = 0;
		tmp = -INF;

		for (int i = 0; i < size; i++)
		{
			if (s[i] == c)
			{
				tmp = max(tmp, cnt);
				cnt = 0;
			}
			else {
				cnt++;
			}
		}
		tmp = max(tmp, cnt);
		ans = min(ans, tmp);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import Control.Monad (unless)

factTrailZeros :: Int -> Int
factTrailZeros n = sum . takeWhile (/= 0) . map (n `div`) $ iterate (*p) p
    where p = 5

main = do
    n <- readLn
    unless (n == 0) $ do
        print $ factTrailZeros n
        main

Measured memory_bytes: 3816
#include "bits/stdc++.h"
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ll = long long int;

const int mod = 1e9+7;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	int n; cin >> n;
	map<int, int> m;
	vector<int> a(n), b(n);
	for (auto &i : a) {
		cin >> i;
		++m[i];
	}
	for (auto &i : b) {
		cin >> i;
		++m[i];
	}
	reverse(begin(b), end(b));
	set<int> bad;
	set<int> vals;
	int intersect = -1;
	int l = 0, r = -1;
	for (int i = 0; i < n; ++i) {
		if (a[i] != b[i]) continue;
		bad.insert(i);
		l = l == -1 ? i : l;
		r = i;
		intersect = a[i];
	}
	assert(r-l+1 >= (int)bad.size());
	set<int> active;
	for (int i = 0; i < n; ++i) {
		if (a[i] == intersect || b[i] == intersect) continue;
		active.insert(i);
	}
	for (auto i : bad) {
		if (active.empty()) return cout << "No\n", 0;
		auto u = *active.begin();
		swap(b[i], b[u]);
		active.erase(u);
	}
	cout << "Yes\n";
	for (auto x : b)
		cout << x << ' ';
	cout << '\n';
}

// Suppose a[i] = b[i] and a[j] = b[j], i < j
// i < j -> a[i] <= a[j], b[i] >= b[j]
// a[i] + x = b[i] - y for some x, y >= 0
// x + y = 0
// x = y = 0

// Suppose intersection is with x
// c1x in a, c2x in b, c3x common
// c1x + c2x <= n
// n - c1x - c2x + c3x free spots
// Claim: c3x <= n - c1x - c2x + c3x
// 0 <= n-c1x-c2x
// True
// Why WA?????

Measured memory_bytes: 23404
#include<stdio.h>

main(){
  int x,y,d=0;

  scanf("%d%d",&x,&y);
  while(1){
    d = x % y;
    if(d == 0){
      printf("%d\n",y);
      break;
    }
    x = y % d;
    if(x == 0){
      printf("%d\n",d);
      break;
    }
    y = d % x;
    if(y == 0){
      printf("%d\n",x);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
 
  if (N%500<=A) {
    cout << "Yes" << endl;
  }
   else if(N%500>=A) {
      cout << "No" << endl;
    }
  }
 

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A(N);
  vector<int>B(N);
  vector<int>C(N-1);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>B.at(i);
    sum=sum+B.at(i);
  }
  for(int i=0;i<N-1;i++){
    cin>>C.at(i);
  }
  for(int i=0;i<N-1;i++){
    if(A.at(i+1)==A.at(i)+1){
      sum=sum+C.at(A.at(i)-1);
    }
  }
  cout<<sum<<endl;
}
      

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

int main(){
  int a, b;
  std::cin >> a >> b;
  int d, r;
  double f;
  d = a / b;
  r = a % b;
  f = ((double) a) / b;
  std::cout<<std::fixed<<std::setprecision(10) << d << " " << r << " " << f << std::endl;
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    std::string s;
    std::cin >> s;

    rep(i, s.size()) {
        if (s[i] == ',') s[i] = ' ';
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
# ABC149c


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    # map(int,input().split())
    x = int(input())

    def prime_factorize(n):
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a

    for i in range(x, x * x):
        if len(prime_factorize(i)) < 2:
            print(i)
            exit(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << " ";
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<ll> tmp(n+1);
    ll sum = 0, cnt = 0;
    while(sum < n * n && cnt < k) {
        sum = 0;
        ll l, r;
        rep(i,0,n){
            l = max(0LL, i - a[i]);
            r = min(n-1, i + a[i]);
            r++;
            tmp[l]++;tmp[r]--;
        }
        rep(i,0,n){
            tmp[i+1] += tmp[i];
            a[i] = tmp[i];
            sum += a[i];
        }
        fill(all(tmp), 0);
        cnt++;

    }

    debug(cnt);
    print(a);
}

Measured memory_bytes: 6388