akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main() {
  int n;
  string s[6];
  char c = '*';

  cin >> n;

  REP(i, n) {
    double h;
    cin >> h;
    if(h < 165) s[0] += c;
    else if(165.0 <= h && h < 170.0) s[1] += c;
    else if(170.0 <= h && h < 175.0) s[2] += c;
    else if(175.0 <= h && h < 180.0) s[3] += c;
    else if(180.0 <= h && h < 185.0) s[4] += c;
    else s[5] += c;
  }

  REP(i, 6) {
    cout << i+1 << ':' << s[i] << endl;
  }
}

Measured memory_bytes: 1236
def solve():

    s = input()
    t = input()

    dict_st = {}
    dict_ts = {}

    for x, y in zip(s, t):
        if x not in dict_st:
            dict_st[x] = y
        else:
            if dict_st[x] != y:
                print("No")
                break

        if y not in dict_ts:
            dict_ts[y] = x
        else:
            if dict_ts[y] != x:
                print("No")
                break
    else:
        print("Yes")


if __name__ == "__main__":
    solve()


Measured memory_bytes: 41840
#include<stdio.h>
#include<string.h>

int main(void)
{
  char str[20];
  int n,i;
  scanf("%s",str);
  n=strlen(str);
  i=n-1;
  while(i>=0){
    printf("%c",str[i--]);
  }
  printf("\n");
  return 0;
}

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

char s[100][100],c[2];
int main(){
	int w,h;scanf("%d%d%s",&w,&h,c);
	rep(i,h)rep(j,w){
		if((i==0||i==h-1)&&(j==0||j==w-1))s[i][j]='+';
		else if(i==0||i==h-1)s[i][j]='-';
		else if(j==0||j==w-1)s[i][j]='|';
		else s[i][j]='.';
	}
	s[h/2][w/2]=c[0];
	rep(i,h)cout<<s[i]<<endl;
}

Measured memory_bytes: 3204
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  const string color = "RGBY";
  int H, W, d;
  cin >> H >> W >> d;
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      int py = ((y - x) + 1000 * d) / d % 2;
      int px = ((y + x) + 1000 * d) / d % 2;
      cout << color[py * 2 + px];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define repf(i, n) for(int i=1; i<(int)(n+1); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int k, x;
    cin >> k >> x;
    if(500*k >= x) Yes();
    else No();
}

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

typedef long long ll;
#define rep(i, n) for(ll i=0; i<n; i++)
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define sz(v) ll(v.size)


void solve(ll N, vector<ll> V, vector<ll> C){
    vector<ll> ret;
    rep(i, N) {
        ret.push_back(V[i] - C[i]);
    }
    sort(ret.begin(), ret.end());
    ll res = 0;
    rep(i, N) {
        if (ret[i] > 0) {
            res += ret[i];
        }
    }
    cout << res << endl;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> V(N);
    rep(i, N) {
        cin >> V[i];
    }
    vector<ll> C(N);
    rep(i, N) {
        cin >> C[i];
    }
    solve(N, V, C);
    return 0;
}


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

int main(void){
    int n,x,t,p;
    cin>>n>>x>>t;
    p=n/x;
    if(n%x==0)cout<<p*t<<endl;
    else cout<<(p+1)*t<<endl;
}

Measured memory_bytes: 3616
### constant

DELTA = 1e-10

### main

d, n, b = gets.split.map(&:to_i)
#p [d, n, b]

phs = Array.new(n){gets.split.map(&:to_f)}
#p phs

min_v2 = Float::INFINITY

for b0 in (0..b)
  l = d.to_f / (b0 + 1)
  max_vx2 = max_vy2 = l / 2
  max_v2 = l
  ok = true
  
  phs.each do |pi, hi|
    xi = pi - (pi / l).floor * l
    if xi.abs < DELTA || (l - xi).abs < DELTA
      ok = false
      break
    end

    yi = -(xi * xi - l * xi) / (2 * max_vx2)
    if yi < hi
      vx2 = -(xi * xi - l * xi) / (2 * hi)
      vy2 = l * l / (4 * vx2)
      v2 = vx2 + vy2
      if max_v2 < v2
        max_v2 = v2
        max_vx2 = vx2
        max_vy2 = vy2
      end
    end
  end

  min_v2 = max_v2 if ok && min_v2 > max_v2
end

puts Math.sqrt(min_v2)

Measured memory_bytes: 6152
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=1LL<<60;


int main(){
    ll n;
    cin>>n;
    map<ll,ll> mp;
    for(ll i=0;i<n;i++){
        ll a;
        cin>>a;
        mp[a]++;
    }

    if(mp.size()!=3 && mp.size()!=2 && mp.size()!=1){
        cout<<"No"<<endl;
        return 0;
    }

    if(mp.size()==3){
        vector<ll> b(3),c(3);
        ll p=0;
        for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
            b[p]=(itr->second);
            c[p]=(itr->first);
            p++;
        }
        for(ll i=1;i<3;i++){
            if(b[i]!=b[i-1]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        if(c[1]!=(c[0]^c[2]) || c[2]!=(c[1]^c[0]) || c[0]!=(c[1]^c[2]) ){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(mp.size()==2){
        vector<ll> b(2),c(2);
        ll p=0;
        for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
            b[p]=(itr->second);
            c[p]=(itr->first);
            p++;
        }
        if(!(c[0]==0 && b[0]*2==b[1]) && !(c[1]==0 && b[1]*2==b[0])){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(mp.size()==1){
        vector<ll> b(1),c(1);
        ll p=0;
        for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
            b[p]=(itr->second);
            c[p]=(itr->first);
            p++;
        }
        if(b[0]!=n || c[0]!=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    
    cout<<"Yes"<<endl;
}
 
   

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	vector<string> a(H);
	vector<string> n;
	rep(i, H) cin >> a[i];
	rep(i, H) {
		rep(j, W) {
			if (a[i][j] == '#') {
				n.pb(a[i]);
				break;
			}
		}
	}

	char ans[100][100];
	int w = 0;
	rep(i, W) {
		bool flag = false;
		rep(j, n.size()) {
			if (flag) ans[j][w] = n[j][i];
			if (n[j][i] == '#' && !flag) {
				flag = true;
				j = 0;
				ans[j][w] = n[j][i];
			}
		}
		w++;
		if (!flag)w--;
	}
	ll i = 0;
	ll j = 0;
	for (i; i < H; ++i) {
		j = 0;
		bool flag = false;
		if (ans[i][j] != '#' && ans[i][j] != '.') break;
		for (j; j < W; ++j) {
			if (ans[i][j] == '#' || ans[i][j] == '.') cout << ans[i][j];
			else {
				flag = true;
				cout << endl;
				break;
			}
		}
		if(!flag) cout << endl;
	}

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  int a[N];
  ll sum=0;
  for(int i=0;i<N;i++){
    cin >> a[i];
    sum+=a[i];
  }
  ll ans=10000000000;
  ll sum2=0;
  for(int i=0;i<N-1;i++){
    sum2+=a[i];
    ans=min(ans,abs(sum-2*sum2));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main
{
  private static ArrayList<Integer> primeNumberList = new ArrayList<>();

  public static void main(String[] args) throws NumberFormatException, IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    ArrayList<Integer> inputList = new ArrayList<>(50);

    while (input.ready())
    {
      int inputNum = Integer.valueOf(input.readLine());
      if (inputNum == 0)
      {
        break;
      }
      inputList.add(inputNum);
    }

    int max = 0;
    for (Integer each : inputList)
    {
      if (max < each)
        max = each;
    }

    setPrimeNumberList(max);

    for (int num : inputList)
    {
      System.out.println(sumOfPrimeNumbers(num));
    }
  }

  private static int sumOfPrimeNumbers(int count)
  {
    int ans = 0;
    for (int i = 0; i < count; i++)
    {
      ans += primeNumberList.get(i);
    }
    return ans;
  }

  private static void setPrimeNumberList(int listSize)
  {
    int num = 3;

    primeNumberList.add(2);
    while (primeNumberList.size() < listSize)
    {
      if (isPrimeNumber(num))
      {
        primeNumberList.add(num);
      }
      num++;
    }
  }

  private static boolean isPrimeNumber(int number)
  {
    if (number % 2 == 0)
    {
      return false;
    }

    final int limit = (int) Math.sqrt(number);
    for (int each : primeNumberList)
    {
      if (each > limit)
      {
        break;
      }
      if (number % each == 0)
        return false;
    }
    return true;
  }
}

Measured memory_bytes: 28276
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var input = t.ReadInputOneLine();
            long sum = 0;

            for (var i = 1; i <= input; i++)
            {
                if (i % 3 != 0)
                {
                    if (i % 5 != 0)
                    {
                        if (i % 15 != 0)
                        {

                            sum += i;
                        }
                    }
                }
            }
            Console.WriteLine(sum);
        }

        public int ReadInputOneLine()
        {
            return int.Parse(Console.ReadLine());
        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ParseIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }


        public List<double> ParseDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ParseLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 17604
//g++ -std=c++14 test.cpp -o test.out
//入出力：http://kaitei.net/cpp/iostream/
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

int N;
long K;
int a[100000];
int b[100000];
long table[100000+1];
int ans;

void solve(){
	memset(table,0,sizeof(table));
	for(int i=0;i<N;i++){
		table[a[i]]+=b[i];
	}
	for(int i=1;i<=100000;i++){
		K-=table[i];
		if(K<=0){
			ans = i;
			break;
		}
	}
}

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

	solve();

	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	int dataSet = in.nextInt();
	for (int i = 0; i < dataSet; i++) {
	 double[] x = new double[2];
	 double[] y = new double[2];
	 double[] r = new double[2];
	 for (int j = 0; j < r.length; j++) {
		x[j] = in.nextDouble();
		y[j] = in.nextDouble();
		r[j] = in.nextDouble();
	 }
	 double l = Math.hypot(x[0] - x[1], y[0] - y[1]);
	 if (r[0] + r[1] < l) {
		System.out.println(0);
	 } else {
		double c = (r[0] - r[1]);
		if (l < c) {
		 System.out.println(2);
		} else if (l < -c) {
		 System.out.println(-2);
		} else {
		 System.out.println(1);
		}
	 }
	}
 }
}

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

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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
   int n, q;
   cin >> n;
   vector<int>a(n), cnt(100001);
   ll sum = 0;
   rep(i, 0, n){
       int a;
       cin >> a;
       cnt[a]++;
       sum += a;
   }
   cin >> q;
   rep(i, 0, q){
       int b, c;
       cin >> b >> c;
       sum += cnt[b]*(c-b);
       cout << sum << endl;
       cnt[c]+=cnt[b];
       cnt[b]=0;
   }
}

Measured memory_bytes: 4048
import collections
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

H,W = IL()
h,w = IL()

print(H*W-(h*W+w*H-h*w))

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

template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
using namespace std;
int calc(const string &s){
	int sum=0;
	for(int i=0;i<11;i++){
		sum+=(s[10-i]-'0')*(i%6+2);
	}
	sum=11-sum%11;
	if(sum>=10)sum=0;
	return sum;
}
int main(){
	string S;
	cin>>S;
	for(int i=0;i<12;i++){
		if(S[i]=='?'){
			if(i==11)printf("%d\n",calc(S.substr(0,11)));
			else{
				int r=-1;
				for(int j=0;j<=9;j++){
					S[i]=j+'0';
					if(calc(S.substr(0,11))==S[11]-'0'){
						if(r>=0){r=-2;break;}
						r=j;
					}
				}
				if(r==-1)puts("NONE");
				else if(r==-2)puts("MULTIPLE");
				else printf("%d\n",r);
			}
		}
	}
}

Measured memory_bytes: 1180
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        String n = s.nextLine();
        String s1 = String.valueOf(n.charAt(0));
        int i1=0;
        int i2=0;
        String s2="";
        for(int i=0;i<n.length();i++){
            if(String.valueOf(n.charAt(i)).equals(s1)){
                i1++;
            }else{
                if (s2.equals("") || String.valueOf(n.charAt(i)).equals(s2)) {
                    s2=String.valueOf(n.charAt(i));
                    i2++;
                }
            }
        }
        System.out.println(i1==2&&i2==2?"Yes":"No");
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    C *= 2;
    int ans = 0;
    if (A + B > C) {
        int a = min(X, Y);
        ans += C * a;
        X -= a;
        Y -= a;
    }
    if (A > C) {
        ans += C * X;
        X = 0;
    }
    if (B > C) {
        ans += C * Y;
        Y = 0;
    }
    ans += A * X;
    ans += B * Y;
    cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (h,w,d)= readLine()!!.split(" ").map { it.toInt() }
    val a= (1..h).map { readLine()!!.split(" ").map { it.toInt() }}
    val q= readLine()!!.toInt()
    val lr =(1..q).map { readLine()!!.split(" ").map { it.toInt() } }

    val p=Array(d){ IntArray(1+h*w/d) }
    for(i in 0..h-1){
        for(j in 0..w-1){
            val m = a[i][j]
            p[m%d][m/d]=i*w+j
        }
    }

    val mp = Array(d){  IntArray(1+h*w/d)}
    for(i in 0..d-1){
        for(j in 1..mp[i].lastIndex){
            val dx = Math.abs( p[i][j-1]%w - p[i][j]%w )
            val dy = Math.abs( p[i][j-1]/w - p[i][j]/w )
            mp[i][j] = mp[i][j-1] + (dx+dy) //jの累積和
        }
    }

    lr.fold(StringBuilder()) { sb,it->
        val l=it[0]
        val r=it[1]
        sb.append( mp[r%d][r/d]-mp[l%d][l/d] ).append("\n")
    }.let { print(it) }


}

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

#define pb push_back
#define F first
#define S second
#define mp make_pair

const int N = 1e6 + 10, Mod = 1e9 + 7;


vector< long long > V;
vector< pair< long long, long long > > Q;

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m; cin >> n >> m;
    for(int i = 1; i <= n; i++){
        long long x; cin >> x;
        V.pb(x);
    }
    for(int i = 1; i <= m; i++){
        long long x, y; cin >> x >> y;
        Q.pb(mp(y, x));
    }
    sort(Q.rbegin(), Q.rend());
    for(auto i : Q){
        while(V.size() <= 2 * n && i.S){
            V.pb(i.F);
            i.S--;
        }
    }
    sort(V.rbegin(), V.rend());
    long long sum = 0;
    for(int i = 0; i < n; i++ )
        sum += V[i];
    return cout << sum, 0;
}


Measured memory_bytes: 3952
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
ceil = math.ceil
s = input()
t = input()
ls = len(s)
lt = len(t)
ans = 10**9
for i in range(0,ls-lt+1):
    #print(i,i+lt-1)
    tmp=0
    for j in range(lt):
        if t[j]!=s[i+j]:
            tmp+=1
    ans =min(ans,tmp)
print(ans)


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

int main()
{
    int a, b;

    cin >> a >> b;

    if (a < b)
    {
        cout << "a < b" << endl;
    }
    else if (a > b)
    {
        cout << "a > b" << endl;
    }
    else
    {
        cout << "a == b" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3080
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    bool f[50][50]={false};
    vector<int> day[30];
    for(int i=0; i<n; i++) f[i][i] = true;
    for(int i=0,a; i<n; i++){
      cin >>a;
      for(int j=0,b; j<a; j++){
	cin >>b;
	day[b-1].push_back(i);
      }
    }
    for(int i=0; i<30; i++){
      for(int j=0; j<day[i].size(); j++)
	for(int k=0; k<day[i].size(); k++)
	  for(int l=0; l<n; l++)
	    f[day[i][j]][l] = f[day[i][k]][l] = f[day[i][j]][l]|f[day[i][k]][l];
      for(int j=0; j<n; j++){
	bool flag = true;
	for(int k=0; k<n; k++) flag&=f[j][k];
	if(flag){cout <<i+1<<endl;goto jump;}
      }
    }
    cout <<"-1"<<endl;
  jump:;
  }
  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) {if (x < y) x = y;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    int cur = 0;
    for (int i = 0; i < 200001; i++) {
        k--;
        cur = a[cur];
        if (!k) {
            cout << cur + 1 << "\n";
            return 0;
        }
    }
    vector<int> b = {cur};
    int v = a[cur];
    while (v != cur) {
        b.pb(v);
        v = a[v];
    }
    int sz = b.size();
    k %= sz;
    cout << b[k] + 1 << "\n";
}
/*

*/  

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

int main(){
 int n;
  cin>>n;
  int temp1,temp2;
  int flag=1;
  int cnt=0;
  for(int i=0;i<n;i++){
    cin>>temp1>>temp2;
    if(flag==1 && temp1==temp2){
      cnt++;
    }
    else if (temp1==temp2){
      flag=1;
      cnt=1;
    }
    else{
      cnt=0;
      flag=0;
    }
    if(cnt==3){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
    int s;
    cin>>s;
    int a[4];
    a[0]=s%10;
    a[1]=s/10%10;
    a[2]=s/100%10;
    a[3]=s/1000;
    for(int i=0;i<=3;i++){
    	for(int j=0;j<=3;j++){
    		if(a[i]==a[j]&&(i-j==1||j-i==1)){
    			cout<<"Bad"<<endl;
				return 0; 
    		}
    	}
    }
    cout<<"Good";
	return 0; 
}



Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

std::string S;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> S;
	S[S.size() - 8] = '\0';
	out << S.c_str() << endl;

	return 0;
}
#endif


Measured memory_bytes: 888
# -*- coding: utf-8 -*-
from functools import reduce

def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    z = y
    while x%y != 0:
        z = x%y
        x = y
        y = z
    else:
        return z
            

def gcd_list(numbers):
    return reduce(gcd, numbers)


N = int(input())

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

print(gcd_list(A))

Measured memory_bytes: 14596
#include <iostream>

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;

  int count = 0;
  for (int i = 0; i < n; ++i) {
    int d1, d2;
    std::cin >> d1 >> d2;
    if (d1 == d2) {
      ++count;
    } else {
      count = 0;
    }
    if (count == 3) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }

  std::cout << "No" << std::endl;

  return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

int sa(int a){
	cout << a << endl;
}

int main(){
	cin.tie(0);					//cinとcoutの結び付きを解除
	ios::sync_with_stdio(false);//stdioとの同期を解除
	
	int n,m,a,b,t;
	
	cin >> n >> m;
	a = (n-m) * 100;
	a += m * 1900;
	b = pow(2, m);
	a = a * b;
	
	cout << a;
	
	return 0;
	
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        n: usize,
        m: usize,
        mut x: [isize; m],
    }

    if n >= m {
        println!("0");
        return;
    }

    x.sort();

    let mut y = Vec::new();
    for i in 0..m-1{
        y.push(x[i+1]-x[i]);
    }

    y.sort();

    let sum:isize = y[0..m-n].iter().sum();
    println!("{}", sum);

}

Measured memory_bytes: 6396
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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


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

    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];
    vector<ll> s(N + 1, 0);
    rep(i, 0, N) s[i + 1] = s[i] + A[i];
    map<ll, ll> m;
    rep(i, 1, N + 1) m[s[i]]++;
    ll rsl = 0ll;
    rsl += m[0];
    for(auto it = m.begin(); it != m.end(); it++) {
        if(it->second <= 1) continue;
        else rsl += it->second * (it->second - 1) / 2;
    }

    cout << rsl << endl;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

void nope() {
    cout << "No\n";
    exit(0);
}

void yep() {
    cout << "Yes\n";
    exit(0);
}

int32_t main() {

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];

    map<int, int> f;
    for(int i = 0; i < n; ++i) f[a[i]]++;

    if(f.size() == 1 && f.begin()->first == 0) yep();
    
    if(n%3) nope();
    
    vector<int> nums;
    for(auto p : f) {
        int cnt = p.second;
        while(cnt >= n/3) {
            nums.push_back(p.first);
            cnt -= n/3;
        }
    }

    if(nums.size() != 3) nope();

    int xo = 0;
    for(int num : nums)
        xo ^= num;

    if(xo != 0) nope();
    
    yep();
    
    return 0;
}


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

int main()
{
	string str;
	int a;
	cin >> a >> str;

	if (a >= 3200)
	{
		cout << str;
	}
	else
	{
		cout << "red";
	}


	return 0;
}

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

int dp[4000][5000];
int a[4000], b[4000], n, t, s, maxn;
int main() {
	cin >> n >> t >> s;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= t; j++){
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			if ((j + b[i] <= s || j >= s) && j + b[i] <= t) { dp[i + 1][j + b[i]] = max(dp[i + 1][j + b[i]], dp[i][j] + a[i]); }
		}
	}
	for (int i = 0; i <= t; i++) {
		maxn = max(maxn, dp[n][i]);
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 60140
# -*- coding: utf-8 -*-

def main(N,K):
    ans = 0
    for i in range(1,N+1):
        tmp = 1/N
        score = i
        count = 0
        while(K>score):
            score *= 2
            count += 1
        tmp /= (2**count)
        ans += tmp
    print(ans)

if __name__ == '__main__':
    N, K = map(int, input().split())
    main(N,K)

Measured memory_bytes: 3064
#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>;

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

  n %= 10;

  string ans = "bon";

  vector<int> h = {2,4,5,7,9};
  vector<int> p = {0,1,6,8};

  for(int i : h){
    if(n==i){
      ans = "hon";
      break;
    }
  }
  for(int i : p){
    if(n==i){
      ans = "pon";
      break;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3612
def ABC069D():
    H, W = map(int, input().split())
    N = int(input())
    a = list(map(int, input().split()))
    ans = []
    for i in range(N):
        for j in range(a[i]):
            ans.append(i + 1)
    printlist = [[0 for i in range(W)] for j in range(H)]
    k = 0
    for i in range(H):
        for j in range(W):
            printlist[i][j] = ans[k]
            k += 1
        if i % 2 != 0:
            printlist[i] = printlist[i][::-1]

    for i in range(H):
        for j in range(W):
            print(printlist[i][j], end = "")
            if j != W:
                print(" ", end = "")
        print()
    print()

ABC069D()

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

int main(){
  int N, K; cin >> N >> K;
  if(N==1){
    cout << 0 << endl;
    return 0;
  }
  vector<char> B(N);
  for(int i=0;i<N;i++){
    cin >> B[i];
  }
  int ans=0;
  for(int i=0;i<N-1;i++){
    if(B[i]==B[i+1]){
      ans++;
    }
  }
  cout << min(N-1,ans+K*2) << endl;
}
    

Measured memory_bytes: 384
import math

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

ans = 1
a = y
for i in range(10**9) :
  if a < x or a == 1:
    break
  x_t = x
  ans_t = 1
  for j in range(10**9) :
    x_t = x_t*2
    if x_t > y :
      break
    ans_t += 1
  ans = max(ans,ans_t)
  a = math.floor(a**0.5)

print(ans)

Measured memory_bytes: 3060
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1;
		cin >> n;
		if (n < 0) return 0;
		vector<int> a(n);
		for (int i = 0; i < n; ++i) {
			cin >> a[i];
		}
		int ans = 0, nx = 1;
		for (int i = 0; i < n; ++i) {
			if (a[i] == nx) {
				++nx;
			} else {
				++ans;
			}
		}
		cout << (ans < n ? ans : -1) << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <math.h>
using namespace std;

int main(void){
 int N,sum = 0;
 cin >> N;
 int A[N];
 int B[N];
 int C[N-1];
 for(int i = 0;i<N;i++){
     cin >> A[i];
 }
 for(int i = 0;i<N;i++){
     cin >> B[i];
     sum = sum + B[i];
 }
 for(int i = 0;i<N-1;i++){
     cin >> C[i];
 }
 for(int i = 0;i<N-1;i++){
     if(A[i]==A[i+1]-1){
         sum = sum + C[A[i]-1];
     }
 }
 cout << sum << endl;

 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define rep(i, s, n) for(int i = s; i < n; i++) 
#define ll long long 

ll pate[51];
ll all[51];


ll func(int n, ll x) {
    //cout << n << " " << x <<  endl;
    if(n == 0) {
        if(x <= 0) return 0;
        else return 1;
        //cout << 1 << endl;
    }

    if(x <= 1+all[n-1]) {
        return func(n-1, x-1);
        //cout << func(n-1, x-1) << endl;
        //func(n-1, x-1);
    }
    else { //if(x <= 1+2*all[n-1]+1) {
        //cout << 2*pate[n-1]+1 << endl;
        return pate[n-1]+1+func(n-1, x-all[n-1]-2);    
    }
    /*
    else if(x <= all[n-1]+1+1) {
        return pate[n-1]+1;
        //cout << pate[n-1]+1 << endl;
    }
    else if(x <= 1+2*all[n-1]+1) {
        //cout << 2*pate[n-1]+1 << endl;
        return pate[n-1]+1+func(n-1, x-all[n-1]-2);    
    }
    else {
        return 2*pate[n-1]+1;
    }
    */

}

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

    all[0] = 1;
    pate[0] = 1;
    rep(i, 1, n+1) {
        all[i] = 2*all[i-1]+3;// + pow(2, i+1);
        pate[i] = 2*pate[i-1]+1;// + pow(2, i);
        //cout << pate[i] << endl;
    }

    int num = n;
    ll ans = func(n, x);
    cout << ans << endl;
    
    return 0;

}

Measured memory_bytes: 256
/*
 *  Created on: 8 / 5 / 2020
 *  Author:     Eslam Waheed
 */
#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
//#include <bits/Int128.h>
using namespace std;

//#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO
#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)

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

//const ll mod = 1e9 + 7;
//__int128
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    //stp(0)
    Eslam__Waheed
        ll a, b, c, k; cin >> a >> b >> c >> k;
    ll ans = 0;
    if (a >= k)
    {
        cout << k;
        return 0;
    }
    if ((a + b) >= k)
    {
        cout << a;
        return 0;
    }
    k -= (a + b);
    cout << a - k;
}

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

int main(){
    int n;
    cin >> n;
    int a[10001] = {};
    for(int i = 1; i <= 150; i++){
        for(int j = 1; j <= 150; j++){
            for(int k = 1; k <= 150; k++){
                if(i*i+j*j+k*k+i*j+j*k+k*i <= 10000){
                    int n = i*i+j*j+k*k+i*j+j*k+k*i;
                    a[n]++;
                }
            }
        }
    }
    for(int i = 1; i <= n; i++){
        cout << a[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		String ans = "";
		if("Sunny".equals(S)) {
			ans = "Cloudy";
		}else if("Cloudy".equals(S)) {
			ans = "Rainy";
		}else {
			ans = "Sunny";
		}
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 21460
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long base = sc.nextInt();
        for (int i = 1; i < n; i++) {
            base = getLCM(base, sc.nextInt());
        }
        System.out.println(base);
     }
     
    static long getLCM(long x, long y) {
        return x / getGCD(x, y) * y;
    }
    
    static long getGCD(long x, long y) {
        if (x % y == 0) {
            return y;
        } else {
            return getGCD(y, x % y);
        }
    }
}


Measured memory_bytes: 26416
import sys
import os
from itertools import combinations

def file_input():
    f = open('ABC128/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # int(input())
    N,M=map(int, input().split()) #N:switch M:light
    s=[[] for i in range(M)]
    k=[]
    for i in range(M):
        tmp=list(map(int, input().split()))
        k.append(tmp[0])
        s[i]=tmp[1:]
    p=list(map(int, input().split()))

    out=0
    for i in range(N+1):
        for li in combinations(range(N),i):
            # print(li)
            on=0
            for m in range(M):
                tmp=0
                for j in range(k[m]):
                    # print("m:"+str(m)+" k:"+str(j))
                    for c in li:
                        if s[m][j]==c+1:
                            tmp+=1
                if tmp%2==p[m]:
                    on+=1
            if on==M:
                # print(li)
                out+=1

    print(out)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6+7;
int a[maxn];
int main()
{
  int N;
  scanf("%d",&N);
  for (int i=0;i<N;i++)
  {
    scanf("%d",a+i);
  }
  int _max = max(a[0],a[1]);
  int _2max = min(a[0],a[1]);
  int count_max = 0;
  for (int i=2;i<N;i++)
  {
    if (a[i]>_max) _max = a[i];
    else{
      if (a[i]>_2max && a[i]<_max) _2max=a[i];
    }
  }
  for (int i=0;i<N;i++)
  {
      if (a[i]==_max) count_max++;
  }
  for (int i=0;i<N;i++)
  {
    if (a[i]==_max){
      if (count_max==1) printf("%d\n",_2max);
      else printf("%d\n",_max);
    }
    else printf("%d\n",_max);
  }
  return 0;
}


Measured memory_bytes: 2432
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
int ans;
void gcd(ll x,ll y){
	if(x<y) swap(x,y);
	if(y==0) return;
	ans++;
	gcd(y,x%y);
}


void mainmain(){
	ll x,y;
	while(cin>>x>>y,x){
		ans=0;
		gcd(x,y);
		cout<<__gcd(x,y)<<" "<<ans<<endl;
	}
}


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

Measured memory_bytes: 3152
//created by Whiplash99
import java.io.*;
import java.util.*;

public class Main
{
    private static int countFactors(long N)
    {
        int ans=1;
        for (long i = 2; i * i <= N; i++)
        {
            int count=0;
            while (N%i==0)
            {
                N /=i;
                count++;
            }
            ans*=(count+1);
        }
        return N>1?ans*2:ans;
    }
    private static int check(long N, long fact)
    {
        while (N%fact==0) N/=fact;
        return N%fact==1?1:0;
    }
    private static int solve(long N)
    {
        int ans=0;

        for(long i=2;i*i<=N;i++)
        {
            if(N%i==0)
            {
                ans += check(N, i);
                if(i*i!=N) ans+=check(N,N/i);
            }
        }
        return ans+1;
    }
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        long N=Long.parseLong(br.readLine().trim());
        int ans=solve(N)+countFactors(N-1)-1;

        System.out.println(ans);
    }
}

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


int main (void) {
  int N, K;  std::cin >> N >> K;
  std::string S; std::cin >> S;
  std::vector<int> S_;
  for(int i=0; i<N; i++) {
    if ( i == 0 ) {
      S_.push_back(0);
      continue;
    }
    if (S.substr(i-1, 2) == "10" || S.substr(i-1, 2) == "01") S_.push_back(i);
  }

  int count = (S[0] == '0') ? 1 : 0;
  int right = 0;
  int max = 0;
  for(int l : S_ ){
    if ( l != 0 && S.substr(l-1, 2) == "01" ) count--;
    for(int r=right >= l ? right : l ; r<N; r++){
      if ( r != l && S.substr(r-1,2) == "10" ) count++;
      if ( count > K ) {
        right = r-1; count--;
        break;
      }
      max = std::max(max, r+1-l);
    }
  }
  std::cout << max << std::endl;
  return 0;
}

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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll=long long;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9+7;

    int a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    v-=w;
    a=abs(a-b);
    if(v*t<a)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}

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

int main() {

  long long int s[2] = {0};

  for ( long long int x = 0; x < 2; x++ ) {
    for ( long long int i = 0; i < 4; i++ ) {
      long long int in;
      cin >> in;
      s[x] += in;
    }
  }

  if ( s[0] > s[1] ) {
    cout << s[0] << endl;
  }else {
    cout << s[1] << endl;
  }

  return 0;

}

Measured memory_bytes: 1160
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	ll a, b, c; cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)cout << 0 << endl;
	else
	{
		ll res = min({ a*b,b*c,c*a });
		cout << res << endl;
	}
}

Measured memory_bytes: 256