akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    ll n; cin >> n;
    ll a[100010];
    rep(i,0,n) cin >> a[i];

    ll ans = a[0] - 1, k = 2;
    a[0] = 1;
    rep(i,1,n) {
        // cout << "ans: " << ans << ", k: " << k << endl;
        if(a[i] > k) {
            ll t = ceil(a[i] / (double) k) - 1;
            ans += t;
            a[i] -= k * t;
            if(k == a[i]) --a[i];
        }
        else if(a[i] == k) k++;
    }

    // rep(i,0,n) printf("a[%d] = %lld\n", i, a[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
// Etavioxy
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define il inline
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch; int f=1;
	while(!isdigit(ch=getchar())) f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(x*10)+(ch^'0');
	return f*x;
}

enum{N=200023};

il void rev(int n,char*s){
	for(int x=1,y=n;x<y;x++,y--) swap(s[x],s[y]);
}

char s[N];
char s1[N],s2[N];
int tot1,tot2;

int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	int q=ci();
	bool r=0;
	rep(i,1,q){
		if( ci()==1 ){
			r^=1;
		}else{
			bool x=r^(ci()&1);
			char c[2];
			scanf("%s",c);
			if( x ) s1[++tot1] = c[0];
			else s2[++tot2] = c[0];
		}
	}
	if( r ){
		rev(tot2,s2);
		printf("%s",s2+1);
		rev(n,s);
		printf("%s",s+1);
		printf("%s",s1+1);
	}else{
		rev(tot1,s1);
		printf("%s",s1+1);
		printf("%s",s+1);
		printf("%s",s2+1);
	}
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << min(A,B) + min(C,D) << endl;
  return 0;
}


Measured memory_bytes: 256
// Problem : C - Tsundoku
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms

#include<bits/stdc++.h>
using namespace std ;

#define int     long long int
#define pii     pair<int, int>
#define vi      vector<int>
#define vii     vector<pair<int, int>>
#define pb      push_back
#define all(a)  (a).begin(),(a).end()
#define f       first
#define s       second
#define endl    '\n'
#define mod     1000000007    		

const int N = 2E5 + 5, M = 2E5 + 5;
int n, m, k ;
int a[N], b[M] ;


void solve()
{
	cin >> n >> m >> k ;
	for(int i = 1 ; i <= n ; i++)
	{
		cin >> a[i] ;
		a[i] += a[i - 1] ;
	}
	for(int i = 1 ; i <= m ; i++)
	{
		cin >> b[i] ;
		b[i] += b[i - 1] ;
	}
	int ans = 0 ;
	int ind = m ;
	for(int i = 0 ; i <= n ; i++)
	{
		if(a[i] > k)
			break ;
		while(a[i] + b[ind] > k)
			ind-- ;
		ans = max(ans, ind + i) ;
	}
	cout << ans << endl ;
}

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

    int t = 1 ;
    //cin >> t ;
    while(t--)
    {
        solve() ;
    }
    return 0 ;
}

Measured memory_bytes: 6764
string=str(input())
upper=string[0]+string[1]
lower=string[2]+string[3]
if 0 < int(upper) <13:
  upper_may_mm=1
else:
  upper_may_mm=0

if 0 < int(lower) <13:
  lower_may_mm=1
else:
  lower_may_mm=0


if (lower_may_mm ==1) & (upper_may_mm ==1):
  print("AMBIGUOUS")
elif (lower_may_mm ==0) & (upper_may_mm ==1):
  print("MMYY")
elif (lower_may_mm ==1) & (upper_may_mm ==0):
  print("YYMM")
else:
  print("NA")


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

//print vector
template <class T>
void printvec(vector<T> &v){
    for(int i = 0; i < v.size(); i ++){
        printf("%d ", v[i]);
    }
    cout << endl;
}
//take array input
template <class T>
void arrinput(T arr[], T size){
    for (int i = 0; i < size; i ++)
        scanf("%d", i + arr);
}
//take vector input
template <class T>
void vecinput(vector<T> & arr, T size){
    for (int i = 0; i < size; i ++){
        int x; scanf("%d", &x);
        arr.push_back(x);
    }
}

template <class T>
T min3(T a, T b, T c){
    return min(a,min(b,c));
}

#define in(a) scanf("%d,", &(a))
#define inn(a,b) scanf("%d%d", &(a), &(b))
#define in3(a,b,c) scanf("%d%d%d", &(a), &(b), &(c))
#define printi(i) printf("%d \n", (i));
#define printc(c) printf("%c \n", (c))
#define prints(s) printf("%s \n", (s))
#define vi vector<int>
#define vll vector<long long>
#define uset unordered_set<int>
#define mapii unordered_map<int, int>
#define seti set<int>
#define vvi vector<vi>
#define forn(n) for (int i = 0; i < (n); i ++)
#define FORN(n) for (int i = 1; i <= (n) ; i ++)
#define SORT(arr) sort((arr.begin()), (arr.end()))
#define MAX 1000005

typedef long long ll;

bool valid(string s, int k){
    for(int i = 1; i < k; i ++){
        if (abs(s[i] - s[i-1]) == 1){
            return false;
        }
    }
    return true;
}
int main(){   
    ios_base::sync_with_stdio(0);
	cin.tie(0);
    int N; in(N);
    cout << "ABC" << N << endl;
    return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int kazu = 1;
            int count = 0;
            bool ikkai = false;
            

            for(int i = 0; i < N; i++)
            {
                if (a[i] == kazu)
                {
                    kazu++;
                    count++;
                    ikkai = true;
                }
            }

            if(ikkai == false)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(N - count);

            }

        }
    }
    
}


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

typedef long long ll;

#define REP(i,n) for(ll i = 1; i <= (ll)(n); i++)
#define REPD(i,n) for(ll i = n; 0 < i; i--)
#define FOR(i,a,b) for(ll i = a; i <= (ll)(b); i++)
#define FORD(i,a,b) for(ll i = a; i >= (ll)(b); i--)

#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000 //10^12

int main() {
    ll N, a, count = 0;
    map<ll, ll> m{};

    cin >> N;
    
    REP(i, N) {
        cin >> a;
        count += m[i - a];
        m[a + i] += 1;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 26160
#include<cstdio>
#include<cmath>
#define neko 200010
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
using std::abs;
int n,m,a[neko],Mid;
int cmin(int x,int y){return x<y?x:y;}
bool check(int x)
{
	for(register int i=Mid,j=Mid;i&&j<=m;--i,++j)
	{
	//	printf("%d %d %d\n",x,i,j);
		if((a[i]<x)&&(a[i-1]<x))return 0;
		if((a[i]>=x)&&(a[i-1]>=x))return 1;
		if((a[j]<x)&&(a[j+1]<x))return 0;
		if((a[j]>=x)&&(a[j+1]>=x))return 1;
	}
	return a[1]>=x;
}
int main()
{
	scanf("%d",&n),Mid=(m=2*n-1)+1>>1;
	f(i,1,m)scanf("%d",&a[i]);
	int l=1,r=m,mid,ans;
	while(l<=r)
	{
		mid=(l+r)>>1;
		if(check(mid))l=mid+1,ans=mid;
		else r=mid-1;
	}return printf("%d\n",ans),0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
bool vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) return true; // 発見できた時
  else return false; // 発見できなかった時
}
struct edge {
  ll to, cost;
};

int main() {
  int H, W; cin >> H >> W;
  int M; cin >> M;
  vector<int> h(M), w(M);
  REP(i, M) {
    cin >> h[i] >> w[i];
    h[i]--; w[i]--;
  }
  vector<ll> x(H, 0), y(W, 0);
  REP(i, M) {
    x[h[i]]++; y[w[i]]++;
  }
  ll ans = 0;
  ll max_x = *max_element(all(x));
  ll max_y = *max_element(all(y));
  vector<ll> p, q;
  REP(i, H) if(x[i] == max_x) p.push_back(i);
  REP(i, W) if(y[i] == max_y) q.push_back(i);
  ans = max_x + max_y;
  bool flag = false; ll cnt = 0;
  REP(i, M) {
    if(binary_search(all(p), h[i]) && binary_search(all(q), w[i])) {
      cnt++;
    }
  }
  if(p.size() * q.size() == cnt) cout << ans - 1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 18564
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
const long long INF = 1e12;

int main() {
    cin >> n;
    vector<long long> a(n, 0);
    for(int i = 0; i < n; ++i) cin >> a.at(i);
    vector<long long> dp(n+1, INF);
    dp[0] = -1;

    int now = 0;
    for(int i = 0; i < n; ++i) {
        int check = a.at(i);
        if(dp.at(now) < check) {
            dp.at(now+1) = check;
            now++;
        }else {
            int chno = lower_bound(dp.begin(), dp.end(), check) - dp.begin();
            dp.at(chno) = check;
        }
    }
    cout << now << endl;
}


Measured memory_bytes: 4420
n, m = map(int, input().split())
N = [1]*n
P = [True] + [False]*(n-1)
for i in range(m):
    x, y = list(map(lambda tmp: tmp-1, map(int, input().split())))
    P[y] = True if P[x]==True else P[y]
    N[x] -= 1
    N[y] += 1
    P[x] = False if N[x]==0 else P[x]
print(sum(P))

Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int a;
    cin>>a;
    cout<<x[a];

    return 0;
}


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

int main()
{
    ll n,i,ok=0;
    string s;
    cin>>n>>s;
    if(n%2==1){
        cout<<"No"<<endl;
        return 0;
    }
    for(i=0;i<n/2;i++){
        if(s[i]!=s[i+(n/2)]){
            ok= 1;
        }
    }
    if(ok){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#include <bits/stdc++.h>
using namespace std;


int main() {
	int n;
    cin >> n;
    vector<int> a;
    
	rep(i, n){
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
    
	unordered_map<int,int> mp;
    long long ans = 0;
    
	rep(i, n){
        ans += mp[i+1-a[i]];
		mp[a[i]+i+1]++;

    }

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

Measured memory_bytes: 19184
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    int one = n % 10;
    if (one == 2 || one == 4 || one == 5 || one == 7 || one == 9) cout << "hon\n";
    else if (one == 0 || one == 1 | one == 6 || one == 8) cout << "pon\n";
    else if (one == 3) cout << "bon\n";
    return 0;
}



Measured memory_bytes: 3624
import static java.lang.System.out;
import java.io.File;
import java.util.Scanner;

public class Main {

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

    public void reverse() {
        try (Scanner scan = new Scanner(System.in)) {
            reverseStr(scan);
        } catch (Exception e) {
            System.exit(0);
        }
    }

    public void reverse(String inputDataPath) {
        try (Scanner scan = new Scanner(new File(inputDataPath))) {
            reverseStr(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void reverseStr(Scanner scan) {
        StringBuffer str = new StringBuffer(scan.nextLine());
        out.println(str.reverse());
    }
}

Measured memory_bytes: 26196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N; cin >> N;
  vector<ll> A(N); rep(i,N) cin >> A[i];
  ll allgcd=A[0];
  rep(i,N){
    allgcd = gcd(allgcd,A[i]);
  }
  if(allgcd!=1){
    cout << "not coprime" << endl;
    return 0;
  }
  vector<bool> B(1e6+1,false);
  rep(i,N){
    ll now = A[i];
    for(ll j=2;j*j<=A[i];j++){
      if(now%j==0){
        now/=j;
        if(B[j]){
          cout << "setwise coprime" << endl;
          return 0;
        }
        else B[j]=true;
        while(now%j==0) now/=j;
      }
    }
    if(now!=1){
      if(B[now]){
        cout << "setwise coprime" << endl;
        return 0;
      }
      else B[now]=true;
    }
  }
  cout << "pairwise coprime" << endl;
  return 0;
}


Measured memory_bytes: 11124
#include <cstdio>
#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<'='<<(n)<<endl

unordered_map<string,int> getstates(string board,int maxturn)
{
	unordered_map<string,int> m;
	queue<pair<string,int>> q;
	q.emplace(board,0);
	while(q.size()){
		string cb=q.front().first;
		int cc=q.front().second;
		q.pop();
		if(m.count(cb))
			continue;
		m.insert(make_pair(cb,cc));
		
		if(cc==maxturn)
			continue;
		for(int i=0;i<5;i++)
			for(int j=abs(i-2);j<5-abs(i-2);j++){
				if(cb[i*5+j]!='.')
					continue;
				for(int k=0;k<4;k++){
					int ni=i+"\xff\x1\0\0"[k],nj=j+"\0\0\xff\x1"[k];
					if(ni<0 || 5<=ni || nj<abs(ni-2) || 5-abs(ni-2)<=nj || cb[ni*5+nj]=='.')
						continue;
					swap(cb[i*5+j],cb[ni*5+nj]);
					q.emplace(cb,cc+1);
					swap(cb[i*5+j],cb[ni*5+nj]);
				}
			}
	}
	return m;
}

int main()
{
	string goal="##.###abc#defgh#ijk###.##";
	for(;;){
		string start(25,'#');
		for(int i=0;i<5;i++)
			for(int j=abs(i-2);j<5-abs(i-2);j++){
				int x; scanf("%d",&x);
				start[i*5+j]=x?x-1+'a':'.';
			}
		if(feof(stdin)) break;
		
		unordered_map<string,int> m1=getstates(start,10);
		unordered_map<string,int> m2=getstates(goal,10);
		
		int res=999;
		for(auto kv:m1)
			if(m2.count(kv.first))
				res=min(res,kv.second+m2[kv.first]);
		
		if(res==999)
			cout<<"NA"<<endl;
		else
			cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 5092
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N

cnt = 0
max_ = 0

if N == 1:
    print(0)
    exit()

for i in range(1, N):
    if H[i - 1] >= H[i]:
        cnt += 1
    else:
        if cnt > max_:
            max_ = cnt

        cnt = 0

if cnt > max_:
    max_ = cnt
    
print(max_)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll N, K;
ll R, S, P;
string T;

ll best(string s) {
    vvll dp(s.size(), vll(3, -1));
    dp[0][0] = s[0] == 's' ? R : 0;
    dp[0][1] = s[0] == 'r' ? P : 0;
    dp[0][2] = s[0] == 'p' ? S : 0;

    reprr(i, 1, s.size()) {
        dp[i][0] = (s[i] == 's' ? R : 0) + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = (s[i] == 'r' ? P : 0) + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = (s[i] == 'p' ? S : 0) + max(dp[i - 1][0], dp[i - 1][1]);
    }

    ll ans = max(dp[s.size()-1][0], max(dp[s.size()-1][1], dp[s.size()-1][2]));
    //cout << ans << endl;
    return ans;
}

int main()
{
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;
    vector<string> ss(K);

    rep(i, K) {
        string s = "";
        ll j = i;
        while (j < T.size()) {
            s.push_back(T[j]);
            j+= K;
        }
        //cout << "s: " << s << endl;
        ss[i] = s;
    }

    ll total = 0;
    for (auto s : ss) {
        total += best(s);
    }
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 6016
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	int n, a, b;
	cin>>n>>a>>b;
	vi v(n);
	rep(i, n) cin>>v[i];
	ll ans = 0LL;
	rep(i, n-1) {
		if((ll)b < (ll)(v[i+1]-v[i])*a) ans += b;
		else ans += (ll)(v[i+1]-v[i])*a;
	}
	cout<<ans<<endl;
}

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

int main()
{
  char  a[3];
  cin >> a;
  // cout << a << endl;
  int cnt = 0;
  for(int i = 0; i < 3; i++){
    char x = a[i];
    int y = (int)x;
    if(y == 49){
      cnt++;
    }
  }
  cout << cnt << endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;
using tdata=pair<datas,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i=0,N,M=1,cnt=0,bf=LLONG_MAX,x;
  cin>>N;
  rep(i,N){
    cin>>x;
    if(bf>=x){
      cnt++;
      M=max(M,cnt);
    }else{
      cnt=1;
    }
    bf=x;
  }
  cout<<M-1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int rf(int x,string s){
	int i=0;
	for(i=x;i<s.size();i++){
		if(s[i]=='L')break;
	}
	if((i-x)%2==0)return i;
	else return i-1;
}
int lf(int x,string s){
	int i=0;
	for(i=x;i>=0;i--){
		if(s[i]=='R')break;
	}
	if((x-i)%2==0)return i;
	else return i+1;
}
int main(){
	string s;
	cin>>s;
	vector<int>p(s.size(),-1);
	vector<int>map(s.size(),0);
	rep(i,s.size()){
		if(p[i]==-1){
			if(s[i]=='R') {
				if(i>=2){
					if(s[i-2]=='R'&&s[i-1]=='R') p[i]=p[i-2];
					else p[i]=rf(i,s);
				}else p[i]=rf(i,s);
			}else{
					if(i>=2){
						if(s[i-2]=='L'&&s[i-1]=='L') p[i]=p[i-2];
						else p[i]=lf(i,s);
				}else p[i]=lf(i,s);
			}
		}
	}
	rep(i,s.size()) map[p[i]]+=1;
	rep(i,s.size()){
		cout<<map[i];
		if(i!=s.size()-1)cout<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;

int main(){
  ll N; cin >> N;
  vector<ll> a(N);
  ll len = 0;
  rep(i,N){
     cin >> a.at(i);
     len += a.at(i);
  }

  ll ans = INFL,sum=0;
  rep(i,N){
    sum+=a.at(i);
    ans = min(ans,abs(len-2*sum));
  }

  cout << ans << endl;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_E
#define M_E 2.71828182845904523536
#endif

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x)
#endif

#define pln(x) cout << (x) << endl
#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> T& chmin(T &a, const U &b){return a = (a<=b?a:b);}
template <typename T, typename U> T& chmax(T &a, const U &b){return a = (a>=b?a:b);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N;
  while(cin >> N){
    vector<int> A(N); cin >> A;
    sort(ALL(A));
    int ans = A[0];
    REP(i,N) ans = gcd(ans, A[i]);
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 640
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int n=3;
struct mat{
	ll a[n][n];
};
ll mod;
mat operator*(mat a,mat b)
{
	mat c;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++)
		{
			c.a[i][j]=0;
			for(int k=0;k<n;k++) c.a[i][j]=(c.a[i][j]+a.a[i][k]%mod*(b.a[k][j])%mod)%mod;
		}
	return c;
}
mat qpow(mat x,ll y)
{
	mat res;for(int i=0;i<n;i++) for(int j=0;j<n;j++) res.a[i][j]=(i==j);
	while(y)
	{
		if(y&1) res=res*x;
		x=x*x;y=y/2;
	}
	return res;
}

ll A,B,L;ll C;
ll above(ll lim)
{
	ll l=0,r=L;ll res=0;
	while(l<=r)
	{
		ll mid=(l+r)/2;
		if(mid*B+A>=lim)
			r=mid-1,res=mid*B+A;
		else l=mid+1;
	}
	return res;
}
ll qpow(ll x,ll y)
{
	x%=mod;
	ll res=1;
	while(y)
	{
		if(y&1) res=res*x%mod;
		x=x*x%mod;y=y/2;
	}
	return res;
}

ll length(ll x)
{
	ll t=0;
	while(x) x/=10,t++;
	return t;
}
ll solution()
{
	ll l=1,r=10;ll k=10;mat res;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) res.a[i][j]=0;
	res.a[0][0]=A%mod,res.a[0][1]=0,res.a[0][2]=1;int flg=10000000;
	ll ek=0;
	while(1)
	{
		ll s=above(l),e=above(r)-B;if(!s) break;
		while(e+B<=C and length(e+B)==length(l)) e+=B;//cout<<l<<" "<<e<<"\n";
		if(e>C) e=C; ll tot=(e-s)/B+1;
		if(s<=e)
		{
			mat o;for(int i=0;i<n;i++) for(int j=0;j<n;j++) o.a[i][j]=0;
			o.a[0][0]=o.a[0][1]=o.a[2][2]=1;
			o.a[1][1]=k%mod;o.a[2][0]=B%mod;
			res=res*qpow(o,tot);ek+=tot;
		}
		flg--;if(!flg) break;
		if(l>4e17) break;
		l=l*10;
		
		if(r>2e17 or r*10>C) r=C,flg=1;
		else r=r*10;
		k=k*10%mod;
	}
	assert(ek==L+1);
	return res.a[0][1];
}



int main()
{
    cin>>L>>A>>B>>mod;L--;
    C=A+B*L;
    cout<<solution();
	return 0;    
}

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

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

	int num = n;
	int sum = 0;

	for (int i = 0; i < 10; i++) {
		sum += num % 10;
		num = num / 10;
		if (num < 1) {
			break;
		}
	}

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

	return 0;
}

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

const ll INF = pow(10, 9) + 7;

int main() {
  int n;
  string s;
  cin >> n >> s;
  if(n>=3200) cout << s << endl;
  else cout << "red" << endl;
}

Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.InputStreamReader;


class Main {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static String S, T;
    static int result = 0;

    public static void main(String[] args) throws Exception {
        S = br.readLine();
        T = br.readLine();
        
        for(int i = 0; i < S.length(); i++){
           if(S.charAt(i) != T.charAt(i)){
                result++;
           }
        }
        System.out.println(result);
    }

}

Measured memory_bytes: 36544
#include <stdio.h>
int main(void){
    int v[20];
    int n,c,i,sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",(v+i));
    }
    for(i=0;i<n;i++){
        scanf("%d",&c);
        if(v[i]-c>=0){
            sum+=v[i]-c;
        }
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define pb         push_back
#define mp         make_pair
typedef long long ll;

ll mypow(ll n,ll a){
  if (n == 0)return 1;
  ll ret = mypow(n/2,a);
  ret=ret*ret;
  if (n%2 == 1)ret*=a;
  return ret;
}

ll val[255];
//div=27 46 -> 27 47
ll compute(string &a,ll div,int base){
  ll nowbase=mypow((int)a.size()-1,base);
  ll ret=0;
  ll rem=0;
  for(int i=0;i<a.size();i++){
    ret+=(rem+val[a[i]]*nowbase)/div;
    rem =(rem+val[a[i]]*nowbase)%div;
    nowbase/=base;
  }
  return ret;
}

void fact(int n,int *base,int *basenum,int &p){
  for(int i=2;i<=n;i++){
    if (n%i == 0){
      base[p]=i;
      basenum[p]=0;
      while(true){
	if (n/i == 0 || n%i != 0)break;
	n/=i;
	basenum[p]++;
      }
      p++;
    }
  }
}

ll count(int p,int *basenum,ll *cnt){
  ll ret=(1LL<<62);
  rep(i,p){
    ret=min(ret,cnt[i]/basenum[i]);
  }
  return ret;
}

main(){
  //  check();
  for(int i=0;i<10;i++){
    val['0'+i]=i;
  }
  for(int i='A';i<='Z';i++){
    val[i]=i-'A' + 10;
  }

  int base[100];
  int basenum[100];
  ll cnt[100];
  int num[100];
  int in;
  string inp;
  while(cin>>in>>inp && in){
    int p=0;
    fact(in,base,basenum,p);

    rep(i,p){
      ll now=base[i];
      cnt[i]=0;
      while(true){
	ll tmp = compute(inp,now,in);
	if (tmp == 0)break;
	cnt[i]+=tmp;
	now*=base[i];
      }
    }
    cout << count(p,basenum,cnt) << endl;

  }
  return false;
}

Measured memory_bytes: 936
#include<iostream>
#include<numeric>
#include<cmath>
#define pans cout<<ans<<endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
long gcd(long a, long b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

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


int main(){
  	long a,b,c,d;cin>>a>>b>>c>>d;
  	long divc=0;
    long divd=0;
  	long e=lcm(c,d);
    long dive=0;
    
	if(a==b){
      cout<<0<<endl;
      return 0;
    }
  
    if(c==d){
      divc=long(b/c)-long(a/c);
    	if(a%c==0){
     	 ++divc;
    	}
      cout<<b-a+1-divc<<endl;
      return 0;
    }
  
  	//まずc
  	divc=long(b/c)-long(a/c);
    if(a%c==0){
      ++divc;
    }
  
    //d
  	divd=long(b/d)-long(a/d);
  	if(a%d==0){
      ++divd;
    }
  
    //e
    dive=long(b/e)-long(a/e);
  	if(a%e==0){
      ++dive;
    }
    //cout<<divc<<" "<<divd<<" "<<dive<<" "<<endl;
    cout<<b-a+1-divc-divd+dive<<endl;
  	
	return 0;
}

Measured memory_bytes: 888
def divisors(N):
    res = []
    i = 1
    while i * i < N:
        if N % i == 0:
            res.append(i)
            res.append(N // i)
        i += 1
    if i * i == N and N % i == 0:
        res.append(i)
    res.sort()
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> sunuke(N);
    for(int i = 0; i < N; i++) {
        cin >> sunuke.at(i);

    }
    int A = sunuke.at(0);
    for (int i = 1; i < N; i++) {
        A = A^sunuke.at(i);
    }
    vector<int> ans(N);
    for (int i = 0; i < N; i++) {
        ans.at(i) = A^sunuke.at(i);
    }
    for (int i = 0; i < N; i++) {
        cout << ans.at(i) << " ";

    }



}

Measured memory_bytes: 4616
#include <iostream>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

string S;

int main(void) {
  cin >> S;

  int ans = 100000000;
  REP(i, 0, 26) {
    char c = 'a' + i;
    int prev = -1;
    int m = 0;
    REP(j, 0, S.length()) {
      if(S[j] == c) {
        m = max(m, j - prev - 1);
        prev = j;
      }
    }
    m = max(m, (int) S.length() - prev - 1);
    ans = min(ans, m);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	while(1){
	int e, x, y, z, m ,min = 10000000;
	cin >> e;
	if(e==0){
		break;
	}
	for(z=0;z*z*z<=e;z++){
		for(y=0;y*y+z*z*z<=e;y++){
			m =e-(y*y+z*z*z)+y+z;
			if(m<min){
				min = m;
			}
		}
	}
	cout<< min << endl;
	}
	return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

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

    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;

    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			int n = in.nextInt();
			if (n != 0) {
				int[] sumLine = new int[n];
				Arrays.fill(sumLine, 0);
				int sum = 0;
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < n; j++) {
						int v = in.nextInt();
						System.out.printf("%5d", v);
						sum += v;
						sumLine[j] += v;
					}
					System.out.printf("%5d", sum);
					System.out.println();
					sum = 0;
				}
				for (int i = 0; i < n; i++) {
					System.out.printf("%5d", sumLine[i]);
					sum += sumLine[i];
				}
				System.out.printf("%5d", sum);
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;

int main(){
  int n,m;
  cin >> n >> m;
  if(n==m)cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using namespace std;

#define MOD 1000000007

char cl[5] = {'x','A','C','G','T'};

int n;
int dp[5][5][5][101];

int f(char c, char a, char b, int d){
	if(d==n)return 1;
	if(dp[c][a][b][d]!=-1)return dp[c][a][b][d];
	int sum = 0;
	for(int i = 1;i < 5;i++){
		if(cl[a] == 'A' && cl[b] == 'G' && cl[i] == 'C')continue;
		if(cl[a] == 'A' && cl[b] == 'C' && cl[i] == 'G')continue;
		if(cl[a] == 'G' && cl[b] == 'A' && cl[i] == 'C')continue;
		if(cl[c] == 'A' && cl[a] == 'G' && cl[b] == 'G' && cl[i] == 'C')continue;
		if(cl[c] == 'A' && cl[a] == 'T' && cl[b] == 'G' && cl[i] == 'C')continue;
		if(cl[c] == 'A' && cl[a] == 'G' && cl[b] == 'T' && cl[i] == 'C')continue;
		sum += f(a, b, i, d+1);
		sum %= MOD;
	}
	return dp[c][a][b][d] = sum;
}

int main(){
	cin >> n;
	fill_n(***dp,5*5*5*101,-1);
	cout << f(0, 0, 0, 0) << endl;

	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	immutable MAX = 1000000;

	bool p[MAX];
	p[] = 1;
	p[0..2] = 0;
	foreach (i; 2..sqrt(MAX*1.0).ceil.to!int) {
		if (p[i]) {
			foreach (j; iota(i*2, MAX, i))
				p[j] = 0;
		}
	}
	int[] plist;
	foreach (i; 0..MAX) {
		if (p[i]) plist ~= i;
	}

	int n;
	while (n = readln.chomp.to!int, n) {
		int f, b = plist.length.to!int - 1, cnt;
		while (f <= b) {
			auto tmp = plist[f] + plist[b];
			if (tmp == n) {
				cnt++;
				f++;
				b--;
			}else if (tmp < n) {
				f++;
			} else {
				b--;
			}
		}
		cnt.writeln;
	}
}

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

char s[MX][MX];
int dist[MX][MX];

int main() {
  int h,w;
  scanf("%d%d",&h,&w);
  rep(i,h) scanf("%s",s[i]);

  queue<P> q;
  rep(i,h)rep(j,w) {
    if (s[i][j] == '.') {
      dist[i][j] = INF;
    } else {
      q.push(P(i,j));
      dist[i][j] = 0;
    }
  }

  int ans = 0;
  while (sz(q)) {
    int i = q.front().fi;
    int j = q.front().se;
    q.pop();
    rep(v,4) {
      int ni = i+di[v], nj = j+dj[v];
      if (ni<0||nj<0||ni>=h||nj>=w) continue;
      if (dist[ni][nj] != INF) continue;
      dist[ni][nj] = dist[i][j]+1;
      maxs(ans,dist[ni][nj]);
      q.push(P(ni,nj));
    }
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 13328
// Problem : D - Teleporter
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

 // #pragma optimize("03")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    //int T; cin >> T;
    //while(T--) 
 	//{
  //    
  //  }
	int N;
	ll K;
	cin>>N>>K;
 	vi v;
 	vi vis;
 	v.reserve(N);
 	vis.reserve(N);
	F0R(x,N)
	{
		int nb;
		cin>>nb;
		nb--;
		v.pb(nb);
		vis.pb(0);
	}
	int S=0,len=0;
	while(!vis[S])
	{
		vis[S]=1;
		S=v[S];
		len++;
		if(len==K)
		{
			cout<<S+1<<endl;
			return 0;
		}
	}
	int sze=1,cpy=S;
	vi ans;
	ans.pb(S);
	S=v[S];
	ans.pb(S);
	while(S!=cpy)
	{
		sze++;
		S=v[S];
		ans.pb(S);
	}
	// ll ans=;
	int val=(int)((K-len)%sze);
	
	// S=cpy;
	// while(val!=0)
	// {
		// S=v[S];	
		// val--;
	// }
	cout<<ans[val]+1<<endl;
	return 0;
}
 



Measured memory_bytes: 5400
#include <iostream>
#include <algorithm>

using namespace std;

bool pal(string a)
{
    string b = a;
    reverse(b.begin(), b.end());
    return a == b;
}

int main()
{
    ios_base::sync_with_stdio(0);
    string a;
    cin >> a;
    int n = a.size();
    if (n % 2 == 0)
    {
        cout << "No";
        return 0;
    }
    string x = "", y = "";
    for (int i = 0; i < n; ++i)
    {
        if (i < n / 2)
            x += a[i];
        if (i > n / 2)
            y += a[i];
    }
    if (pal(a) && pal(x) && pal(y))
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
from collections import deque

n, k, l = map(int, input().split())

graphs = [[[] for _ in range(n)], [[] for _ in range(n)]]
cands = [set(), set()]
for _ in range(k):
    x, y = map(int, input().split())
    graphs[0][x - 1].append(y - 1)
    graphs[0][y - 1].append(x - 1)
    cands[0].add(x - 1)
for _ in range(l):
    x, y = map(int, input().split())
    graphs[1][x - 1].append(y - 1)
    graphs[1][y - 1].append(x - 1)
    cands[1].add(x - 1)

groups = [[], []]
groups_inv = [[-1] * n, [-1] * n]
def dfs(start, case, num):
    q = deque()
    q.append(start)
    used = {start}
    groups[case].append(used)
    groups_inv[case][start] = num
    while q:
        node = q.popleft()
        for to in graphs[case][node]:
            if to in used:
                continue
            q.append(to)
            used.add(to)
            groups_inv[case][to] = num

for i in range(2):
    count = 0
    for node in cands[i]:
        if groups_inv[i][node] == -1:
            dfs(node, i, count)
            count += 1

ret = [-1] * n
for i in range(n):
    if groups_inv[0][i] == -1 or groups_inv[1][i] == -1:
        ret[i] = 1
    elif ret[i] == -1:
        cities = groups[0][groups_inv[0][i]] & groups[1][groups_inv[1][i]]
        for city in cities:
            ret[city] = len(cities)
print(*ret)


Measured memory_bytes: 84364
#include <bits/stdc++.h>
using namespace std;
int n;
int a[2000005];
int x=0;
long long ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=2;i<=n;i++)
	{
		if(a[i]<a[i-1])
		{
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 4464
import sys
import math
import copy
sys.setrecursionlimit(4100000)

n = int(input())
a = [int(i) for i in input().split()]
m = {}
m[0] = 0
m[1] = a[0] - m[0]/2
while True:
    # m[0] += 1
    for i in range(1,n):
        m[i] = 2*(a[i-1] - m[i-1]/2)
    if (m[0] + m[n-1])//2 == a[n-1]:
        break
    else:
        temp = a[n-1] - (m[0] + m[n-1])//2
        m[0] += temp

b = [int(m[i]) for i in m]
print(* b)

Measured memory_bytes: 26072
use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
  input! {
    N: usize,
    K: u32,
    cities: [[u32]; K],
  }

  let mut cat: Vec<u32> = cities
    .iter()
    .fold(vec![], |acc, curr| [acc, curr.clone()].concat())
    .iter()
    .unique()
    .cloned()
    .collect();
  cat.sort();

  let count = N - cat.len();
  println!("{}", count);
}


Measured memory_bytes: 2368
#include <bits/stdc++.h>
using namespace std;
int main() {
  long N; int t = 11; cin >> N;
  for(long i = 1; i <= 100000; i++) if(N % i == 0) t = min(t, (int)to_string(max(i, N / i)).size());
  cout << t << endl;
}


Measured memory_bytes: 256
import math
ans=[]
while(True):
	n=int(input())
	if(n==0):
		break
	s=list(map(int,input().split()))
	ave=sum(s)/n
	diff_sum_bi=sum([(s[i]-ave)**2 for i in range(n)])
	variance=diff_sum_bi/n
	ans.append(math.sqrt(variance))

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


Measured memory_bytes: 5704
#include <stdio.h>
int main(void)
{
	long n,a[10000],min=1000000,max=-1000000,sum=0,i;
	scanf("%ld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%ld" ,&a[i]);
		if(a[i] < min)
		{
			min = a[i];
		}
		if(a[i] > max)
		{
			max = a[i];
		}
		sum = sum + a[i];
	}
	printf("%ld %ld %ld\n",min,max,sum);
	return 0;
}

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

int main() {
  ll n;
  cin>>n;
  vector<ll> a(n+5);
  ll sum=0;
  rep(i,n){
    cin>>a[i];
    sum^=a[i];
  }
  //cout<<sum<<endl;

  //sumが１のところを０にする
  rep(i,n)a[i]&=~sum;
  vector<ll> t(n);

  //吐き出し
  ll now=0;
  for(ll i=60;i>=0;i--){
    ll j=now;
    for(;j<n;j++){
      if (1 & a[j]>>i){
        swap(a[now],a[j]);
  //      cout<<now<<"now"<<a[now]<<'a'<<endl;
      //  cout<<i<<' '<<a[now]<<endl;
        now++;
      //  cout<<now<<endl;
        break;
      }
    }

    if (j==n)continue;
    t[now-1]=i;
    rep(j,n){
      if (j==now-1)continue;
      if (1 & a[j]>>i){
        a[j]^=a[now-1];
      //  cout<<a[j]<<'j'<<a[now-1]<<endl;
      }
    }
  }

  //一つずつくらいを試す
  ll cnt=0;
  ll ans=cnt;
  bool ok=false;
   for(ll i=60; i>=0;i--){
    ll cntpre=cnt;
    cnt^=(1ll<<i);
    ll temp=cnt;
    //cout<<cnt<<endl;
    rep(j,now){
    //  cout<<t[j]<<endl;
      if((temp>>t[j])&1) {
        temp^=a[j];
      //  cout<<cnt<<'c'<<t[j]<<"tj"<<temp<<'t'<<a[j]<<'a'<<endl;
      }

    }
    if ((temp&cnt)!=0){
    //  cout<<"no"<<endl;
      cnt=cntpre;
    }
  //  cout<<temp<<'t'<<cnt<<'c'<<endl;

  }
  ans=cnt*2;
  ans+=sum;
  cout<<ans;

}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

/*
int	gcd(int A, int B) {
	while (0!=B) {
		A %=B;
		swap(A, B);
	}
	return A;
}

long	gcd(long A, long B) {
	while (0!=B) {
		A %=B;
		swap(A, B);
	}
	return A;
}

long	lcm(long A, long B) {
	long G=gcd(A, B);
	return A/G*B;
}

long	GCD(vector<long> &A) {
	long B=A.at(0);
	for (long i=1; i<A.size(); i++)
		B =gcd(B, A.at(i));
	return B;
}

long	LCM(vector<long> &A) {
	long B=A.at(0);
	for (long i=1; i<A.size(); i++)
		B =lcm(B, A.at(i));
	return B;
}
*/

int	main() {
	int a, b;
	cin >>a >>b;
	if (a>b)
		swap(a, b);
	for (int i=0; i<b; i++)
		cout <<a;
	cout <<endl;
	return 0;
}



Measured memory_bytes: 256