akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;

int MOD = 998244353;

struct edge{
    int from;
    int to;
    int cost;
};
int n,m;
int d[2510];

signed main(){
    vector<edge> es;

    int n,m,p;
    cin >> n >> m >> p;
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        edge e1 = {a-1,b-1,c-p};
        es.push_back(e1);
    }

    fill(d,d+n,-INF);
    d[0] = 0;
    rep(i,n){
        rep(j,m){
            struct edge e = es[j];
            if(d[e.from] != -INF && d[e.to] < d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }
    int neg[2510] = {0};
    rep(i,n){
        rep(j,m){
            struct edge e = es[j];
            if(d[e.from] != -INF && d[e.to] < d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                neg[e.to] = 1;
            }
        }
    }
    // rep(i,n) cerr << d[i] << " ";
    // cerr << endl;
    if(neg[n-1] == 1)cout << -1 << endl;
    else cout << max(d[n-1],0LL)<< endl;
 
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc137.contest.atcoder.jp/tasks/abc137_b


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int L, R, d; cin >> L >> R >> d;

	int ans = 0;
	FOR(i,L,R+1){
		if(i%d == 0) ans++;
	}

	cout << ans << endl;

	return 0;

}


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

#include<string.h>
 
#define T int t, q; scanf("%d", &t); for(q=1; q<=t; q++)
 typedef long long int ll;

 int main(){
 	ll n,m,c,l,k;
 	cin >> n;
 	l=n/100;
 	n=n%100;
 	c=n/5;
 	n=n%5;
 	c=c+n/4;
 	n=n%4;

 	c=c+n/3;
 	n=n%3;

 	c=c+n/2;
 	n=n%2;

 	c=c+n/1;
 	n=n%1;

 	if(c<=l)
 		cout <<"1" <<endl;

 	else
 		cout <<"0" << endl;
 }


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
long long INF = (1LL<<62);

string X;
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> X;
	string s;

	for(int i=0; i<X.size(); i++){
		if(i == 0){
			s.push_back(X[i]);
		}
		else{
			if(s[s.size()-1] == 'S' && X[i] == 'T'){
				s.pop_back();
			}
			else{
				s.push_back(X[i]);
			}
		}
	}
	printf("%d\n", (int)s.size());
	return 0;
}

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

int main(void) {

  char s[100001];
  scanf("%s", s);
  long length = strlen(s);
  long left = 0;
  long right = length-1;
  long insert = 0;
  while (left < right) {
    if (s[left] == s[right]) {
      left++;
      right--;
    } else if (s[left] == 'x') {
      left++;
      insert++;
    } else if (s[right] == 'x') {
      right--;
      insert++;
    } else {
      printf("-1\n");
      return 0;
    }
  }
  printf("%ld\n", insert);

  return 0;
}

Measured memory_bytes: 256
import math

def main():
    while True:
        n = int(input())
        if n == 0: break

        count = 0
        for i in range(n + 1, 2*n + 1):
            count += isprime(i)
        print(count)
    return 0

def isprime(a):
    if a == 0 or a == 1: return 0
    sq = int(math.sqrt(a))
    for i in range(2, sq + 1):
        if a % i == 0:
            return 0
    return 1
main()



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

void solve(int h[], int n, int k){
	
	int dp[n+1];	memset(dp,0,sizeof(dp));
	
	
	
	for(int i=2 ;i<=n ; i++){
		int val = INT_MAX;
		for(int j=max(i-k,1); j<i; j++){
			val = min(val , dp[j] + abs(h[i] - h[j]));
		}
		dp[i] = val;
	}
	cout << dp[n];
}

int main(){
	int n,k;	cin >> n >> k;	int h[n+1];
	for(int i=1; i<=n ;i++)	cin >> h[i];
	solve(h,n,k);
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;

    vector<int> num;
    int now = 1;
    int cnt = 0;
    REP(i, N) {
        if (s[i] == (char)('0' + now))
            cnt++;
        else {
            num.push_back(cnt);
            now = 1 - now;
            cnt = 1;
        }
    }
    if (cnt != 0)
        num.push_back(cnt);

    if (num.size() % 2 == 0)
        num.push_back(0);

    int add = 2 * K + 1;

    int ans = 0;

    int tmp   = 0;
    int left  = 0;
    int right = 0;

    FORSTEP(i, 0, num.size(), 2) {
        int nextLeft  = i;
        int nextRight = min(i + add, (int)num.size());

        while (nextLeft > left) {
            tmp -= num[left];
            left++;
        }
        while (nextRight > right) {
            tmp += num[right];
            right++;
        }

        ans = max(tmp, ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1020
//============================================================================
// 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define succ(x) ((x)+1)
#define pred(x) ((x)-1)
//============================================================================
void enter()
{
    int i,s,a,b,c;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    for (i=a, s=0; i<=b; i++)
        if (c % i ==0)
             s++; 
    printf("%d\n", s);
}
//============================================================================
int main(void)
{
    enter();
    return 0;
}
//============================================================================

Measured memory_bytes: 596
#include<iostream>
#include<vector>

int main(){
    int N;
    std::cin >> N;
    
    std::vector< std::string > W;
    std::vector< char > maxword;
    std::vector< std::string > W_tmp;
    std::vector< char > maxword_tmp;
    W.push_back("a");
    maxword.push_back('a');
    for(int i=1; i<N; i++){
        for(int j=0; j<W.size(); j++){
            for(char k='a'; k<=maxword[j]+1; k++){
                W_tmp.push_back(W[j] + k);
                char maxword_add = maxword[j] < k ? k : maxword[j];
                maxword_tmp.push_back(maxword_add);
            }
        }
        W = W_tmp;
        maxword = maxword_tmp;
        W_tmp.clear();
        maxword_tmp.clear();
    }
    for(int i=0; i<W.size(); i++){
        std::cout << W[i] << std::endl;
    }
    
    
}



Measured memory_bytes: 10188
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k < a) {
        cout << k << endl;
    } else if(a <= k && k <= a+b) {
        cout << a << endl;
    } else {
        cout << a - (k - a - b) << endl;
    }
}


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

int main() {
    ll n,temp;
    cin>>n;
    vector<int> a(n,0);
    rep(i,n-1) {
        cin>>temp;
        a[temp-1]++;
    }
    rep(i,n) {
        cout<<a[i]<<endl;
    }
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REP2D(i,j,h,w) for(long long i=0;i<h;i++) for(long long j=0;j<w;j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=h;i++) for(long long j=1;j<=w;j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) (a.begin()),(a.end())
#define RANGE(a) (a),(a+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<(a)<<endl
#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << a << endl
#define DBSTART if(1){
#define DBEND }
#else
#define DBPRT(a) do{}while(0)
#define DBSTART if(0){
#define DBEND }
#endif
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 305
#define INF (INF_LL >> 10ll)
//---------------------
ll n,k;
ll h[MAXN];
ll dp[MAXN][MAXN];
int main(){
    cin >> n >> k;
    REP1(i,n) cin >> h[i];
    h[0] = 0;
    REP(i,MAXN) REP(j,MAXN) dp[i][j] = INF;
    dp[0][0] = 0;
    
    REP1(i,n) REP1(j,i) REP(m,i){
    DBPRT(m);
    DBPRT((j-1));
        dp[i][j] = min(dp[i][j],dp[m][j-1]+max(0ll,h[i]-h[m]));
    }
    
    DBSTART
    PRTLST2(dp,n+1,n-k+1);
    DBEND
    
    ll res = INF;
    REP(i,n+1) res = min(res,dp[i][n-k]);
    PRT(res);
	return 0;
}









Measured memory_bytes: 1024
s = gets.chomp.chars
t = gets.chomp.chars
n = s.size
m = t.size

dp = Array.new(n+1){Array.new(m+1, 0)}
n.times do |i|
  dp_cur, dp_next = dp[i], dp[i+1]
  m.times do |j|
    if s[i] == t[j]
      dp_next[j+1] = dp_cur[j] + 1
    else
      a = dp_cur[j+1]
      b = dp_next[j]
      dp_next[j+1] = a > b ? a : b
    end
  end
end

i, j = n, m
ans = ''
while i > 0 && j > 0 do
  if dp[i][j] == dp[i-1][j]
    i -= 1
  elsif dp[i][j] == dp[i][j-1]
    j -= 1
  else
    ans << s[i-1]
    i -= 1
    j -= 1
  end
end

puts ans.reverse


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int x, y;
  cin >> x >> y;

  bool ok=false;
  rep(i,101){
    rep(j,101){
      if(i+j==x && 2*i+4*j==y) ok=true;
    }
  }

  prtok(ok);
}


Measured memory_bytes: 3588
def solve
  n, t = gets.scan(/-?[\d\.]+/).map(&:to_i)
  ts = gets.scan(/-?[\d\.]+/).map(&:to_i)

  tt = t
  bt = ts[0] + t

  (1...n).each do |i|
    if ts[i] >= bt
      tt += t
    else
      tt += t - bt + ts[i]
    end
    bt = ts[i] + t
  end

  puts tt
end

solve



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

int n;
vector<vector<int>> a(1010, vector<int>(1010));
vector<vector<int>> ofs(1000010);
vector<int> memo(1000010, -1);
set<int> st;
int cal(int i, int j) {
    if (i > j)
        swap(i, j);
    int m = n * (n - 1) / 2 - (n - i) * (n - i + 1) / 2;
    return m + j - i - 1;
}

int dfs(int i) {
    if (st.find(i) != st.end()) {
        memo[i] = 10000000;
        return memo[i];
    }
    st.insert(i);
    if (memo[i] != -1) {
        st.erase(i);
        return memo[i];
    }
    if (ofs.size() == 0) {
        st.erase(i);
        return memo[i] = 1;
    }
    int res = 1;
    for (auto x : ofs[i])
        res = max(res, dfs(x) + 1);
    st.erase(i);
    return memo[i] = res;
}

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

    cin >> n;
    rep(i, 1, n + 1) rep(j, 0, n - 1) cin >> a[i][j];
    rep(i, 1, n + 1) rep(j, 1, n - 1) {
        ofs[cal(i, a[i][j - 1])].push_back(cal(i, a[i][j]));
    }
    int ans = 0;
    rep(i, 0, n * (n - 1) / 2) ans = max(ans, dfs(i));
    if (ans >= 10000000)
        ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 47488
#include<iostream>
#include <stdio.h>
#include <string.h>

using namespace std;
int main()
{
	int i, j = 0;
	int N, M = 0;
	int A[50] = {};
	int a, b = 0;

	cin >> N;
    cin >> M;

	for (i = 0; i <= M-1; i++) {
		cin >> a;
		cin >> b;
		A[a-1] += 1;
		A[b-1] += 1;
	}

	for (j = 0; j <= N-1; j++) {

		printf("%d\n", A[j]);
	}

	cin >> i;

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
par = [i for i in range(N+1)]
h = [1 for _ in range(N+1)]

def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]

def unite(x,y):
    rx = root(x)
    ry = root(y)
    if h[rx] < h[ry]:
        rx, ry = ry, rx
    h[rx] += h[ry]
    par[ry] = rx

for _ in range(M):
    x,y,z = map(int, input().split())
    unite(x,y)

for i in range(1,N+1):
    par[i] = root(i)

print(len(set(par[1:])))


Measured memory_bytes: 14760
class UnionFind:  # 0-index
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n  # 親の番号 要素が根の場合は-(そのグループの要素数)を格納

    def find(self, x):  # 要素xが属するグループの根を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # 要素xが属するグループと要素yが属するグループとを併合する
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):  # 要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]

    def same(self, x, y):  # 要素x, yが同じグループに属するかどうかを返す
        return self.find(x) == self.find(y)

    def members(self, x):  # 要素xが属するグループに属する要素をリストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):  # すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):  # グループの数を返す
        return len(self.roots())

    def all_group_members(self):  # {根: [グループに含まれる要素のリスト], ...}の辞書を返す
        return {root: self.members(root) for root in self.roots()}

# ---------------------- #

n, m = (int(x) for x in input().split())
L = [tuple(int(x) for x in input().split()) for _ in range(n)]

uf = UnionFind(n + m)
for i in range(n):
    for l in L[i][1:]:
        l -= 1
        uf.union(i, n + l)

roots = uf.roots()
if len(roots) == 1 or roots[1] >= n:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 96236
#include <iostream>
#include <cstdio>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
	int a,b,c,d;
	cin >> a >> b >> c >>d;
	if(d<a||b<c){cout << 0;}
	else if(a<=c&&b<=d){cout << b-c;}
	else if(c<=a&&d<=b){cout << d-a;}
	else if(a<=c&&d<=b){cout << d-c;}
	else if(c<=a&&b<=d){cout << b-a;}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    if a[i] <= b[i]:
        m = min(a[i + 1], b[i] - a[i])
        ans += a[i] + m
        a[i + 1] -= m
    else:
        ans += b[i]
print(ans)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
 
#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) ( (n % k) + k ) % k
#define isOn(S, j) (S & (1 << j) )
#define setBit(S, j) (S | (1 << j ) )
#define LSB(S) (S & (-S))

vvi assp, bs(305, vi(305, 1));
int n, x, m = 0;
ll res = 0;

bool esMin () {
    for (int k = 0; k < n; k++)
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                if (assp[i][j] > assp[i][k] + assp[k][j])
                    return false;

    return true;
}

ll obtRes () {
    ll res = 0;
    for (int i = 0; i < n; i++)
        for (int j = i; j < n; j++) {
            bool b = true;

            for (int k = 0; k < n; k++)
                b &= i == k || k == j || assp[i][j] < assp[i][k] + assp[k][j];

            if (b)
                res += ll(assp[i][j]);
        }

    return res;
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    cin >> n;
    assp = vvi(n, vi(n));

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) {
            cin >> x;
            assp[i][j] = x;
        }

    if (!esMin()) {
        cout << -1 << endl;
        return 0;
    }

    cout << obtRes() << endl;

    return 0;
}  

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

using namespace std;

long long n,h,N;

int main()
{
	std::ios_base::sync_with_stdio(false);
	cin>>N;
	for (n=1;n<=3500;++n)
	{
		for (h=1;h<=3500;++h)
		{
			long long aw=4*h*n;
			long long bw=n*N,cw=h*N,d=n*h*N;
			//cout<<aw<<' '<<bw<<' '<<cw<<' '<<d<<endl;
			if ((aw-bw-cw)>0 && d>0 && d%(aw-bw-cw)==0)
			{
				cout<<h<<' '<<n<<' '<<d/(aw-bw-cw)<<endl;
				return 0;
			}
		}
	}
}


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

typedef long long ll;


int main()
{
	int n, m;

	cin >> n >> m;
	if(n==0)
		cout << m*(m-1)/2;
	if(m==0)
		cout << n*(n-1)/2;
	if(n&&m)
		cout << (n)*(n-1)/2+m*(m-1)/2;

	return 0;
}


Measured memory_bytes: 256
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
from decimal import Decimal
# from fractions import Fraction
# sys.setrecursionlimit(100000)
mod = int(1e9) + 7
INF=float('inf')

ans=0
cnt=0
for i in range(int(data())):
    d1,d2=mdata()
    if d1==d2:
        cnt+=1
    else:
        ans = max(ans, cnt)
        cnt=0
ans=max(ans,cnt)
if ans>2:
    out("Yes")
else:
    out("No")

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

using namespace std;

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

    int a, b;
    cin >> a >> b;
    string x = to_string(a);
    string y = to_string(b);
    string r;
    if(a <= b){
        for(int i = 0; i < b; i++){
            r += x;
        }
        cout << r << endl;
    }
    else{
        for(int i = 0; i < a; i++){
            r += y;
        }
        cout << r << endl;
    }  
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    loop {
        let mut s = sc.next::<String>();
        if s == "-" {
            break;
        }
        let m = sc.next::<u32>();

        for _ in 0..m {
            let h = sc.next::<usize>();
            s = format!("{}{}", &s[h..], &s[0..h]);
        }
        println!("{}", s);
    }
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn char(&mut self) -> char {
        self.next::<String>().chars().next().unwrap()
    }
}



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

using namespace std;

int main(){

    int n;
    cin >> n;

    int p;
    int pmin = 100000;
    int pmax = 0;
    for(int i = 0; i < n; i++){
        cin >> p;
        pmin = min(pmin,p);
        pmax = max(pmax,p);
    }
    cout << pmax - pmin << endl;
}

Measured memory_bytes: 256
from collections import deque
import sys

h, w = map(int, input().split())
map_size = h * w
maze = [list(input()) for _ in range(h)]
goal = (h - 1, w - 1)


def shortest_path(start, goal):
    que = deque()
    que.append(start)
    visited = [[-1] * w for _ in range(h)]
    visited[start[0]][start[1]] = 0
    while que:
        now = que.popleft()
        for iy, ix in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            ny = now[0] + iy
            nx = now[1] + ix
            if (0 <= ny < h) and (0 <= nx < w):
                if ny == goal[0] and nx == goal[1]:
                    visited[ny][nx] = visited[now[0]][now[1]] + 1
                    return visited[ny][nx]
                # if not maze[nx][ny] == '.':
                #    continue
                if maze[ny][nx] != '#' and visited[ny][nx] == -1:
                    visited[ny][nx] = visited[now[0]][now[1]] + 1
                    que.append((ny, nx))
    return -1


# def restore_path(visited):
#     path = [(h - 1, w - 1)]
#     cnt = visited[h - 1][w - 1]
#     x = w - 1
#     y = h - 1
#     while cnt > 0:
#         for iy, ix in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
#             ny = y + iy
#             nx = x + ix
#             if (0 <= ny < h) and (0 <= nx < w):
#                 if visited[ny][nx] != (cnt - 1):
#                     continue
#                 y = ny
#                 x = nx
#                 cnt -= 1
#                 path.append((y, x))
#                 break
#     return path


move_cnt = shortest_path((0, 0), goal)
if move_cnt == -1:
    print(-1)
    sys.exit()

cnt = 0
for y in range(h):
    for x in range(w):
        if maze[y][x] == '#':
            cnt += 1

print(map_size - cnt - move_cnt - 1)

Measured memory_bytes: 3316
a = []
try :
    while True:
        a.append(int(input()))
except EOFError:
    pass
# print('@', a)

counts = [0] * 101
# counts[n]  n の個数を数える

for n in a:
    counts[n] += 1

# print('@', counts)
# print('@', max(counts))

for n in range(len(a)):
    if counts[n] == max(counts):
        print(n)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n;
    ll x, y;
    vector<pair<ll, ll>> xy;
    cin >> n;
    rep(i, n){
        cin >> x >> y;
        xy.push_back(make_pair(x, y));
    }

    vector<pair<ll, ll>> diffs;
    rep(i, xy.size()){
        rep(j, xy.size()){
            if(i==j) continue;
            diffs.push_back(make_pair(xy[i].first-xy[j].first, xy[i].second-xy[j].second));
        }
    }

    sort(all(diffs));

    ll maxcnt = 0;
    ll cnt = 0;
    ll nowx=inf, nowy=inf;
    for(auto const& e : diffs){
        if(e.first == 0 && e.second == 0){
            continue;
        }
        if(nowx==inf && nowy==inf){
            nowx = e.first;
            nowy = e.second;
            continue;
        }
        if(nowx == e.first && nowy == e.second){
            cnt++;
        }else{
            if(cnt != 0) chmax(maxcnt, cnt);
            cnt = 0;
        }
        nowx = e.first;
        nowy = e.second;
    }


    ll res;
    res = n!=1 ? (n-1)-maxcnt : 1;

    cout << res << endl;

    // for(auto const& e : diffs){
    //     cout << e.first sp e.second << endl;
    // }

    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, c;
    cin >> n >> c;

    vector<vector<int>> d(c, vector<int>(c));
    vector<vector<int>> g(n, vector<int>(n));

    for (int i = 0; i < c; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cin >> d[i][j];
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> g[i][j];
            g[i][j]--;
        }
    }

    vector<vector<int>> change_color(3, vector<int>(c + 1, 0));

    for (int i = 0; i < c; i++)
    {
        for (int j = 0; j < n; j++)
        {
            for (int k = 0; k < n; k++)
            {
                if ((j + k) % 3 == 0)
                {
                    change_color[0][i] += d[g[j][k]][i];
                }
                else if ((j + k) % 3 == 1)
                {
                    change_color[1][i] += d[g[j][k]][i];
                }
                else if ((j + k) % 3 == 2)
                {
                    change_color[2][i] += d[g[j][k]][i];
                }
            }
        }
    }

    ll ans = INF;

    for (int i = 0; i < c; i++)
    {
        for (int j = 0; j < c; j++)
        {
            for (int k = 0; k < c; k++)
            {
                if (i == j || j == k || k == i)
                {
                    continue;
                }

                ll tmp = change_color[0][i] + change_color[1][j] + change_color[2][k];
                ans = min(ans, tmp);
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 4540
N = int(input())
S = [input() for i in range(N)]

cnt_ab_from_S = sum([s.count('AB') for s in S])
start_from_b_and_end_at_a = sum([(s[0] == 'B') and (s[-1] == 'A') for s in S])
not_start_from_b_and_end_at_a = sum([(s[0] != 'B') and (s[-1] == 'A') for s in S])
start_from_b_and_not_end_at_a = sum([(s[0] == 'B') and (s[-1] != 'A') for s in S])

ans = cnt_ab_from_S
if (start_from_b_and_end_at_a == 0):
    ans += min(not_start_from_b_and_end_at_a, start_from_b_and_not_end_at_a)
elif (not_start_from_b_and_end_at_a + start_from_b_and_not_end_at_a == 0):
    ans += (start_from_b_and_end_at_a - 1)
else:
    ans += (start_from_b_and_end_at_a + min(not_start_from_b_and_end_at_a, start_from_b_and_not_end_at_a))
print(ans)


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

int main()
{
	ll ans = 0,n;
	cin >> n;
	string s;
	cin >> s;

	for(int i = 0;i<n;i++)
	{
		ll l = 0;
		for(int j = 0;j+i<n;j++)
		{
			if(s[j]==s[i+j])
			{
				l = min<ll>(l+1,i);
			}
			else l = 0;
			ans = max(ans,l);
		}
	}
	cout << ans << endl;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  string s[n];
  for(int i=0; i<n; i++) cin >> s[i];
  int ans=n*m;
  for(int x=1; x<n; x++) {
    for(int y=x+1; y<n; y++) {
      int cnt=0;
      for(int i=0; i<n; i++) {
        for(int j=0; j<m; j++) {
          if(i<x&&s[i][j]!='W') cnt++;
          if(i>=x&&i<y&&s[i][j]!='B') cnt++;
          if(i>=y&&s[i][j]!='R') cnt++;
        }
      }
      ans=min(ans,cnt);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
int dxx[8] = { 1, 1, 1, 0, 0, -1, -1, -1 }, dyy[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int n, m, q;
int A[20], a[55], b[55], c[55], d[55];
int ans = 0;

void dfs (int cnt) {
    if (cnt == n) {
        int sum = 0;
        rep (i, q) {
            if (A[b[i] - 1] - A[a[i] - 1] == c[i]) {
                sum += d[i];
            }
        }
        ans = max (sum, ans);
        return;
    }
    for (int i = max (1, A[cnt]); i <= m; i++) {
        A[cnt + 1] = i;
        dfs (cnt + 1);
    }
}

int main() {
    cin >> n >> m >> q;
    rep (i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    A[0] = 1;
    dfs (0);
    cout << ans << "\n";
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
"""
Contents   : ARC098 C問題
Author     : (製作者の名前) (製作者の所属)
LastUpdate : (更新日YYYY/MM/DD)
Since      : (作成日YYYY/MM/DD)
"""
N = int(input())
S = input()
cnt = 0
for s in S[1:]:
    if s == "E":
        cnt += 1
cnt_list = []
cnt_list.append(cnt)
for i in range(len(S)-1):
    if S[i] == "E" and S[i+1] == "E":
        cnt -= 1
        cnt_list.append(cnt)
    elif S[i] == "E" and S[i+1] == "W":
        cnt_list.append(cnt)
    elif S[i] == "W" and S[i+1] == "E":
        cnt_list.append(cnt)
    else:
        cnt += 1
        cnt_list.append(cnt)
print(min(cnt_list))

Measured memory_bytes: 15520
import math

n = int(input())

for _ in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())

    var = abs((x2-x1) * (y4-y3) - (x4-x3) * (y2-y1))

    if var < 1e-10:
        print("YES")
    else:
        print("NO")



Measured memory_bytes: 5664
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	lint X;
	cin >> X;
	lint now = 0;
	lint cnt = 0;
	for (lint i = 1; i < 100000; i++) {
		now += i;
		cnt++;
		if (now >= X) {
			cout << cnt << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int M, D;
	cin >> M >> D;
	int res = 0;
	for (int i = 1; i <= M; i++) {
		for (int j = 1; j <= D; j++) {
			int d1 = j % 10;
			int d10 = j / 10;
			if (d1 >= 2 && d10 >= 2) {
				if (d1 * d10 == i) {
					res++;
				}
			}

		}
	}
	cout << res << endl;
}

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



int main(){
    int N,right,index=1,result=1;
    cin>>N;
    vector<pair<int,int> > rob(N);
    for(int i=0;i<N;i++){
        int x,l;
        cin>>x>>l;
        rob.at(i).second=x-l;
        rob.at(i).first=x+l;
    }
    sort(rob.begin(),rob.end());
    right=rob.at(0).first;
    while(index<N){
        if(rob.at(index).second>=right){
            right=rob.at(index).first;
            result++;
        }
        index++;
    }
    cout<<result<<endl;
    
    
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;

int main(void)
{
    ll n, k;
    scanf("%lld%lld", &n, &k);

    n = n % k;
    printf("%lld\n", min(llabs(n - k), n));
    
    return 0;
}

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

using namespace std;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(long long i = 0;i < n;i++)
int main()
{
  long long N;
  int A[300000];
  long long  sum=0;
  long long  ans=0;
  cin>>N;
  if(N==0)cout<<1;
  else cout<<0;
  
  return 0;
}




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

int main() {
  int input;
  cin >> input;
  long sum = 0;

  for(int i=1; i<=input; i++) {
    if(i%3 != 0 && i%5 != 0) {
      sum += i;
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
	char s[3];
	scanf("%s",s);
	if(s[0]=='S'&&s[1]=='U') printf("7\n");
	if(s[0]=='M') printf("6\n");
	if(s[0]=='T'&&s[1]=='U') printf("5\n");
	if(s[0]=='W') printf("4\n");
	if(s[0]=='T'&&s[1]=='H') printf("3\n");
	if(s[0]=='F') printf("2\n");
	if(s[0]=='S'&&s[1]=='A') printf("1\n");
	return 0;
}


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

int main(){
  int n,k,s; cin >>n >>k >>s;
  rep(i,n){
    if(i<k) cout << s;
    else {
      if(s<1e9) cout << s+1;
      else cout << 1;
    }
    cout << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

double seq_sum(double a0);

int main(int argc, const char *argv[])
{
	double a0;
	while(scanf("%lf", &a0)!=EOF)
		printf("%.8f\n", seq_sum(a0));	
	return 0;
}

double seq_sum(double a0)
{
	int cnt;
	double now = a0, next, sum = a0;
		
	for(cnt=2; cnt<=10; cnt++){
		if(cnt%2) next = now/3;
		else next = now*2;
		sum += next;
		now = next;	
	}
	return sum;	
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int,input().split()))
a.sort()
memo = [0 for i in range(10**6 + 5)]
memo[0] = 2

for i in a:
    if memo[i] == 2:
        continue
    for j in range(0,len(memo),i):
        memo[j]+= 1

ans = 0
for i,v in enumerate(a):
#    print(v,memo[v])
    if memo[v] == 1:
        ans+=1

print(ans)



Measured memory_bytes: 32300
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;


int main() {
  int n,a;
  cin>>n>>a;
  int ma=0,mi=101;
  ma=max(a,n);
  mi=min(a,n);
  rep(i,ma)cout<<mi;
  cout<<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {
	int a,b;
	cin >> a >> b;
	if (a <= 9 && b <= 9) cout << a*b << endl;
	else cout << -1 << endl;

  return 0;
}


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

x = sum(a) // n
count1 = 0
count2 = 0
for i in range(n):
    count1 += (a[i] - x)**2
    count2 += (a[i] - (x + 1))**2

print(min(count1, count2))


Measured memory_bytes: 9040
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>

#define div1 1000000007

using namespace std;

int main(void)
{
    long long N, h[100001], i, dp[100010];

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> h[i];
    }

    dp[1] = 0;

    dp[2] = abs(h[1]-h[2]);

    if(i == 2){
        cout << dp[2] << endl;
    }

    else{
        for(i=3; i<=N; i++){
            dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]));
        }

        cout << dp[N] << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

const int MOD = 1e9+7;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int lnum = 0;
  ll ans = 1;
  rep(i, n*2) {
    if (s[i]=='B' ^ lnum%2)
      lnum++; //保留にする(=区間の左端として使う)
    else {
      (ans *= lnum) %= MOD;
      lnum--; //保留を一つ消費した
    }
  }
  if (lnum)
    cout << 0 << endl;
  else {
    for (int i=1; i<=n; i++)
      (ans *= i) %= MOD;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 640
//#pragma  GCC optimize("Ofast")

//#ifdef  DEBUG
//#define _GLIBCXX_DEBUG
//#endif

// -Ofast
// -O3
// -O2
// -fsanitize=address
// -fsanitize=undefined

// add_compile_options()

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include <iomanip>
#include <unordered_map>
#include <cmath>
#include <cassert>
#include <random>

using namespace std;
//using namesparsace __gnu_pbds;

void solve();

signed main() {
    srand(time(0));
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    //freopen("input.txt", "r", stdin);
    //freopen("trench.out", "w", stdout);
    solve();
    return 0;
}

#define ld double
#define int long long

const int maxN = 3010, maxK = 1e5 + 10, inf = 2e18 + 10, mod = 1e9 + 7;

int n, a[maxN], dp[maxN][maxN], pref[maxN];

void solve() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        pref[i] = pref[i - 1] + a[i - 1];
    }
    for (int i = 0; i < n; i++) {
        dp[i][i] = a[i];
    }
    for (int len = 1; len < n; len++) {
        for (int l = 0; l + len < n; l++) {
            int r = l + len;
            dp[l][r] = pref[r + 1] - pref[l] - min(dp[l + 1][r], dp[l][r - 1]);
        }
    }
    cout << 2 * dp[0][n - 1] - pref[n];
}

Measured memory_bytes: 70144
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
    int x=0,p=1;char c=getchar();
    while (c<=32)c=getchar();
    if(c==45)p=-p,c=getchar();
    while (c>32)x=x*10+c-48,c=getchar();
    return x*p;
}
using namespace std;
//ruogu
const int N=3010;
int n,mod,res,p[N],pw[N*N],C[N][N],S[N][N];
//
inline void add(int &x,int y){x+=y;if(x>=mod)x-=mod;}
inline void sub(int &x,int y){x-=y;if(x<0)x+=mod;}
inline int mul(int x,int y){ll ans=1ll*x*y;return ans%mod;}
inline int modpow(int x,int y){
	int ans=1;
	while(y){
		if(y&1)ans=mul(ans,x);
		x=mul(x,x);
		y>>=1;
	}
	return ans;
}
int main(){
	n=getint();mod=getint();
	pw[0]=1;
	for(int i=1;i<N*N;i++){
		pw[i]=pw[i-1];
		add(pw[i],pw[i]);
	}
	rep(i,N){
		--mod;
		int tmp=modpow(2,i);
		++mod;
		p[i]=modpow(2,tmp);	
	}
	rep(i,N)C[i][0]=1;
	for(int i=1;i<N;i++)for(int j=1;j<=i;j++){
		C[i][j]=C[i-1][j];
		add(C[i][j],C[i-1][j-1]);
	}
	S[0][0]=1;
	for(int i=1;i<N;i++)for(int j=1;j<=i;j++){
		if(j)S[i][j]=S[i-1][j-1];
		add(S[i][j],mul(j,S[i-1][j]));
	}
	rep(i,n+1){
		int tmp=0;
		rep(j,i+1)add(tmp,mul(pw[(n-i)*j],S[i+1][j+1]));
		tmp=mul(tmp,mul(C[n][i],p[n-i]));
		if(i&1)sub(res,tmp);
		else add(res,tmp);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 105088
#include <bits/stdc++.h>
#define FOR(i,a,b) for(register int i=(a);i<(b);++i)
#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
#define pi pair<int,int>
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 200005;
const int maxm = 100;
const int inf = 2147483647;
typedef long long ll;
const double eps = 1e-9;
const long long INF = 9223372036854775807ll;
ll qpow(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c;b>>=1;}return ans;}
struct Node{
	int l,r,d;
	bool operator <(const Node a)const{
		return abs(r-l)>abs(a.r-a.l);
	}
}s[maxn];
vector<int>a,b;
bool cmp1(int a,int b){
	return s[a].d<s[b].d;
}
bool cmp2(int a,int b){
	return s[a].d>s[b].d;
}
priority_queue<Node>aa,bb;
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n;
		scanf("%d",&n);
		a.clear(),b.clear();
		ll ans=0;
		FOR(i,0,n){
			scanf("%d%d%d",&s[i].d,&s[i].l,&s[i].r);
			if(s[i].l>s[i].r)a.push_back(i);else if(s[i].l<s[i].r)b.push_back(i);
			else ans+=s[i].l;
		}
		sort(a.begin(),a.end(),cmp1);
		sort(b.begin(),b.end(),cmp2);
		FOR(i,0,a.size()){
			if(aa.size()==s[a[i]].d){
				if(aa.top().l-aa.top().r<s[a[i]].l-s[a[i]].r){
					ans+=aa.top().r;
					aa.pop();
					aa.push(s[a[i]]);
				}else{
					ans+=s[a[i]].r;
				}
			}else aa.push(s[a[i]]);
		}
		FOR(i,0,b.size()){
			if((int)bb.size()==n-s[b[i]].d && n-s[b[i]].d){
				if(bb.top().r-bb.top().l<s[b[i]].r-s[b[i]].l){
					ans+=bb.top().l;
					bb.pop();
					bb.push(s[b[i]]);
				}else ans+=s[b[i]].l;
			}else if((int)bb.size()<n-s[b[i]].d){
				bb.push(s[b[i]]);
			}else ans+=s[b[i]].l;
		}
		while(!aa.empty())ans+=aa.top().l,aa.pop();
		while(!bb.empty())ans+=bb.top().r,bb.pop();
		printf("%lld\n",ans);
	} 
}


Measured memory_bytes: 9688
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[111],maxs=0,count=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    maxs=max(maxs,a[i]);
  }
  for(int i=0;i<maxs;i++){
    int flag=0;
    for(int j=0;j<n;j++){      
      if(flag==0&&a[j]>i){
	flag=1;
	count++;
      }else if(flag==1&&a[j]<=i) flag=0;
    }
  }
  cout<<count<<endl;
  return(0);
}


Measured memory_bytes: 256