akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        FastReader reader = new FastReader();
        int n = reader.nextInt();
        int m = reader.nextInt();
        int[] result = new int[n];
        HashMap<Integer, List<Integer>> edges = new HashMap<>();
        for (int i = 0; i < m; i++) {
            int from = reader.nextInt();
            int to = reader.nextInt();
            edges.computeIfAbsent(from, k -> new ArrayList<>()).add(to);
            edges.computeIfAbsent(to, k -> new ArrayList<>()).add(from);
        }

        ArrayDeque<Integer> bfs = new ArrayDeque<>();
        bfs.addLast(1);
        int visited = 1;
        result[0] = -1;
        while (bfs.size() > 0) {
            int current = bfs.pollFirst();
            for (int next : edges.getOrDefault(current, Collections.emptyList())) {
                if (result[next - 1] == 0) {
                    result[next - 1] = current;
                    bfs.addLast(next);
                    visited++;
                }
            }
        }

        if (visited == n) {
            System.out.println("Yes");
            StringBuilder sb = new StringBuilder();
            for (int i = 1; i < result.length; i++) {
                sb.append(result[i]).append('\n');
            }
            System.out.println(sb.toString());
        } else {
            System.out.println("No");
        }
    }

    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

Measured memory_bytes: 77484
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <numeric>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

// 結構勉強になった気がする！

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

	ll mmod = 998244353;

	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	ll sum = 0;
	// ベクトルの要素をすべて足す関数 これからどんどん使ってきたい
	sum = accumulate(allof(a), 0);
	ll ans = 1;

	rep(i, n) {
		ans *= 3;
		ans %= mmod;
	}


	// dp[t][r]:=最初のt個の整数を塗り分け、赤い整数の和がrであるような場合の数
	vector<vector<ll>> dp(n + 1, vector<ll>(sum + 2, 0));
	dp[0][0] = 1;
	auto dp2 = dp;

	Rep(i, 0, n) {
		rep(j, sum + 2) {
			if (j - a[i] >= 0) {
				dp[i + 1][j] += dp[i][j - a[i]];
				dp[i + 1][j] %= mmod;
			}
			// 青か緑の2通り
			dp[i + 1][j] += dp[i][j] * 2;
			dp[i + 1][j] %= mmod;
		}
	}

	ll tmp = 0;
	ll halfSum = sum / 2;
	if (sum % 2) halfSum++;
	Rep(i, halfSum, sum + 2) {
		tmp += dp[n][i];
		tmp %= mmod;
	}
	tmp *= 3;
	tmp %= mmod;
	ans -= tmp;

	if (sum % 2 == 0) {
		// R = G = sum / 2、　R = B = sum / 2のときも考える
		rep(i, n) {
			rep(j, sum + 2) {
				if (j - a[i] >= 0) {
					dp2[i + 1][j] += dp2[i][j - a[i]];
					dp2[i + 1][j] %= mmod;
				}
				// 片方だけに入れる
				dp2[i + 1][j] += dp2[i][j];
				dp2[i + 1][j] %= mmod;
			}
		}
		// RG GB BRの3通り
		ans += dp2[n][halfSum] * 3;
	}

	if (ans < 0) {
		ans += mmod;
	}

	cout << ans % mmod << endl;

	return 0;
}

Measured memory_bytes: 423104
import heapq
import collections

n, m = map(int, input().split())
work = collections.defaultdict(list)
hp = [[] for _ in range(m+1)]
ignore = []
ans = 0
for _ in range(n):
    x, y = map(int, input().split())
    work[x].append(-y)
candidate = []
for x in range(1, m+1):
    if work[x]:
        for e in work[x]:
            heapq.heappush(candidate, e)
    if candidate:
        ans += heapq.heappop(candidate)
print(abs(ans))

Measured memory_bytes: 34636
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    String s=sc.next();
    int count=0;
    for(int i=0;i<n-1;i++)if(s.charAt(i)!=s.charAt(i+1))count++;
    System.out.println(n-1-Math.max(0,count-k*2));
  }
}

Measured memory_bytes: 27240
#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eps 1e-12
#define int long long
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
    int ans = 1;
    for (; b; b >>= 1, a = a * a % mod)
        if (b & 1)
            ans = ans * a % mod;
    return ans;
}
int dp[300000][4];
char s[300000];
void upd(int &x,int y){
    if(x<y)x=y;
}
signed main()
{
    io;
    cin>>s+1; int n=strlen(s+1);
    //dp[0][10]=1;
    for(int i=1;i<=n;i++){
        rep(j,1,3){
            rep(k,1,3){
                if(i-j>=0 && j!=k){
                   // cout<<i<<" "<<j<<" "<<k<<endl;
                  //  cout<<dp[i][j]<<" "<<dp[i-j][k]<<endl;
                    upd(dp[i][j],dp[i-j][k]+1);
                }
            }
        }
        rep(j,1,3){
          //  cout<<dp[i][j]<<" ";
          if(i-j-j>=0){
              string a="",b="";
              for(int k=i-j-j+1;k<=i;k++){
                  if(k<=i-j)a+=s[k];
                  else b+=s[k];
              }
              if(a!=b)upd(dp[i][j],dp[i-j][j]+1);
          }
        }
      //  cout<<endl;
    }
    int ans=1;
    rep(i,1,3)upd(ans,dp[n][i]);
    cout<<ans<<endl;
    getchar(); //0
    getchar();
}


Measured memory_bytes: 8320
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  string s;cin>>s;
  int ans = 0;
  for(int i = 0; s.size()/2 > i; i++){
    if(s[i] != s[s.size()-i-1])ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define no_of_test(x)   int x; cin>>x; while(x--)

const int mod = 1e9 + 7;
void very_fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}

int32_t main()
{
	very_fast();
	//no_of_test(x)
	{
		string s;
		cin >> s;
		int w = s.length();
		int a[w];
		int sum = 0;
		for (int i = 0; i < w; i++)
		{
			a[i] = s[i] - '0';
			sum += a[i];
		}
		if (sum % 9 == 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 5344
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  char a[100][100];
  cin>>h>>w;
  for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
          cin>>a[i][j];
      }
  }
  for(int i=0;i<w+2;i++){
      cout<<'#';
  }
  cout<<endl;
  for(int i=0;i<h;i++){
      cout<<'#';
      for(int j=0;j<w;j++){
          cout<<a[i][j];
      }
      cout<<'#'<<endl;
  }
  for(int i=0;i<w+2;i++){
      cout<<'#';
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n, a;
	cin >> n >> a;
	
	while(n >= 500)
	{
		n -= 500;
	}
	
	if(n <= a)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
MOD=10**9+7
def com(n,k,mod):
    res=1
    tmp=1
    for i in range(1,k+1):
        res=res*(n-i+1)%mod
        tmp=tmp*i%mod
    a=pow(tmp,mod-2,mod)
    return res*a%mod

N,K=map(int,input().split())
X=N-K

for i in range(1,K+1):
    print(com(X+1,i,MOD)*com(K-1,i-1,MOD)%MOD)

Measured memory_bytes: 42736
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
	long int i, j;
	long int n, k;
	long int sum;
	long int max;
	long int count;
	long int a[100];
	long int b[100];
	long int c[100];
	
	scanf("%ld", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%ld", &a[i]);
	}
	
	for(i = 0; i < n; i++) {
		scanf("%ld", &b[i]);
	}
	
	for(i = 0; i < n - 1; i++) {
		scanf("%ld", &c[i]);
	}
	
	sum = b[n - 1];
	
	for(i = 0; i < n - 1; i++) {
		if(a[i] + 1 == a[i + 1]) {
			sum += c[a[i] - 1];
		}
		sum += b[i];
	}
	
	
	printf("%ld\n", sum);
	
	
	return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int top = in.nextInt();
		int kizi = in.nextInt();
		int cost = in.nextInt();
		int kcal = in.nextInt();
		int ping[] = new int[top];
		int kane=kizi;
		for(int i=0;i<top;i++)ping[i]=in.nextInt();
		java.util.Arrays.sort(ping);
		for(int s=top-1;s>=0;s--){
			double a = kcal/kane;
			double b = (kcal+ping[s])/(kane+cost);
			if(a<=b){
				kcal+=ping[s];
				kane+=cost;
			}else break;
		}
		System.out.println(kcal/kane);
	}
}

Measured memory_bytes: 18116
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k,s;
    cin >> k >> s;
    int ans = 0;
    for(int x = 0; x <= k; x++){
        for(int y = 0; y <= k; ++y){
            int z = s - x - y;
            if(0 <= z && z <= k)
                ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
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 A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class B3CardGameForThreeABCEdit {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string sa, sb, sc;
	    in >> sa >> sb >> sc;

	    char now = 'a';
	    char res = 'a';
	    while(true){
            if(now == 'a'){
                if(sa.length() == 0){
                    res = 'A';
                    break;
                }
                now = sa[0];
                sa = sa.substr(1, sa.length());
            }else if(now == 'b'){
                if(sb.length() == 0){
                    res = 'B';
                    break;
                }
                now = sb[0];
                sb = sb.substr(1, sb.length());
            }else if(now == 'c'){
                if(sc.length() == 0){
                    res = 'C';
                    break;
                }
                now = sc[0];
                sc = sc.substr(1, sc.length());
            }
	    }

	    out << res << endl;
	}
};


int main() {
	B3CardGameForThreeABCEdit solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

//ポイント、駒の動きはパスカルの三角形、これを利用するか、単に連立方程式を立ててコンビネーションか、個人的には連立方程式のほうが好み
const ll MAX = 10000000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(void) {

    COMinit();
    int x,y;
    cin >> x >> y;
    //a+2b=X,2a+b=Yの連立方程式をaを全探索することによって解く
    rep(a,x+1){
        int b = x - a;
        if(b%2 == 1)continue;
        b /=2;
        if(2*a+b == y){
            fin(COM(a+b,a));
            return 0;
        }
    }

    fin(0);
}

Measured memory_bytes: 234752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int A, B;
  cin >> A >> B;
  if(A % 2 == 0) {
    if(A / 2 >= B) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
  else {
    if((A + 1) / 2 >= B) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void)
{
    int n,m,i,a[1001],b[1000],e,r;
	while(1){
	    scanf("%d %d",&n,&m);
		if(n==0&&m==0) break;
		for(i=1;i<=n;i++){
		    scanf("%d",&a[i]);
		}
		for(i=0;i<m;i++){
		    scanf("%d",&b[i]);
		}
		e=1; r=0;
		for(i=0;i<m;i++){
		    r++;
			e+=b[i];
			e=e+a[e];
			if(e>=n) break;
		}
		printf("%d\n",r);
	}
	return 0;
}

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

int main(){
    int n , k;
    cin>>n>>k;
    long long int minm;
    int arr[1000000];
    for(int i =0;i<n;i++)
        cin>>arr[i];
    long long int dp[1000000] ;
    dp[0]=0;
    dp[1] = abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++){
        minm = 1000000000;
        for(int j = 1;j<=k;j++){
            if(i-j>=0){
                minm = min(minm,dp[i-j]+abs(arr[i-j]-arr[i]));
            }
        }
        dp[i]=minm;
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4764
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=a[0]
cnt=n-2
for i in range(1,n):
    if cnt>1: ans+=a[i]*2;cnt-=2
    elif cnt==1: ans+=a[i];break
    else: break
print(ans)

Measured memory_bytes: 105312
#include<stdio.h>
#include<stdlib.h>
 
  void merge(long int arr[], int l, int m, int r) 
{ 
    int i, j, k; 
    int n1 = m - l + 1; 
    int n2 =  r - m; 
  
    long int L[n1],R[n2] ;
  
    for (i = 0; i < n1; i++) 
        L[i] = arr[l + i]; 
    for (j = 0; j < n2; j++) 
        R[j] = arr[m + 1+ j]; 
  
    i = 0; 
    j = 0; 
    k = l; 
    while (i < n1 && j < n2) 
    { 
        if (L[i] <= R[j]) 
        { 
            arr[k] = L[i]; 
            i++; 
        } 
        else
        { 
            arr[k] = R[j]; 
            j++; 
        } 
        k++; 
    } 
  
    while (i < n1) 
    { 
        arr[k] = L[i]; 
        i++; 
        k++; 
    } 
  
    while (j < n2) 
    { 
        arr[k] = R[j]; 
        j++; 
        k++; 
    } 
} 
  
void mergeSort(long int arr[], int l, int r) 
{ 
    if (l < r) 
    { 
        int m = l+(r-l)/2; 
  
        mergeSort(arr, l, m); 
        mergeSort(arr, m+1, r); 
  
        merge(arr, l, m, r); 
    } 
} 
  int main()
  {
    int n,i;
    long int *a;
    scanf("%d",&n);
    
    
    a=(long int*)malloc(n*sizeof(long int));
    
    for(i=0;i<n;i++)
       scanf("%ld",&a[i]);
    
    mergeSort(a,0,n-1);
    
    for(i=0;i<n-1;i++)
    {
      if(a[i]==a[i+1])
         {
           printf("NO");
           break;
         }
    }
    if(i==n-1)     
    printf("YES");   
  }

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int A,B,C,D;
int main(){
    cin>>A>>B>>C>>D;
    int mi=max(A,C);
    int ma=min(B,D);
    if(ma-mi<0){
       cout<<0<<endl;
    }else{
       cout<<ma-mi<<endl;
    }
	return(0);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
//AC, WA, TLE, RE,

int main() {
    int n, k, sum = 1;
    scanf("%d %d", &n, &k);

    for (int i = 0; i < n; i++)
    {
        if ((sum * 2) < (sum + k))
        {
            sum *= 2;
        }
        else
        {
            sum += k;
        }
    }
    printf("%d\n",  sum);

    return 0;
}

Measured memory_bytes: 1692
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	string b;
	cin >> b;

	if (b == "A") {
		cout << "T" << endl;
	}
	else if (b == "T") {
		cout << "A" << endl;
	}
	else if (b == "C") {
		cout << "G" << endl;
	}
	else if (b == "G") {
		cout << "C" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    ll N, M, s, c;
    sll(N);
    sll(M);
    vector<ll> digits(N,-1);
    bool ng = false;
    rep(i, M){
        sll(s);
        sll(c);
        if(digits[N-s] != -1 && digits[N-s] != c){
            ng = true;
        }
        digits[N-s] = c;
    }
    ng = ng || (digits[N-1] == 0 && N>1);
    if(ng){
        cout << "-1" <<endl;
        return ;
    }
    if(N==1 && (digits[N-1] == 0 || digits[N-1] == -1)){
        cout << "0" <<endl;
        return;
    }
    ll ans;
    bool found = false;
    for(ll d=pow(10, N-1);d<pow(10, N); d++){
        // cout << "d = "<<d<<endl;
        bool is_ok = true;
        rep(i, N){
            ll base = pow(10, i);
            ll digit = (d % (base*10)) / base;
            if(digit == digits[i] || digits[i] == -1){
                is_ok = is_ok && true;
            }else{
                is_ok = is_ok && false;
            }
        }
        if(is_ok){
            ans = d;
            found = true;
            break;
        }
    }
    if(found){
        cout << ans <<endl;
    }else{
        cout << "-1" <<endl;
    }

}

int main(){
    Main();
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;

signed main() {
  int N, K;
  cin >> N >> K;

  string S;
  cin >> S;

  int ans = N;
  int cnt = 0;
  REP(i, N-1) if(S[i] != S[i+1]) cnt++;

  cnt++;
  cnt -= K*2;
  if(cnt < 1) cnt = 1;

  cout << ans-cnt << endl;

  return 0;
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<int> P(M), Y(M), ord[100010]; 
    for (int i = 0; i < M; i++) {
        cin >> P[i] >> Y[i];
        ord[P[i]].push_back(Y[i]);
    }
    for (int i = 1; i <= N; i++) sort(ord[i].begin(), ord[i].end());
    for (int i = 0; i < M; i++) {
        printf("%06d", P[i]);
        int d = lower_bound(ord[P[i]].begin(), ord[P[i]].end(), Y[i]) - ord[P[i]].begin() + 1;
        printf("%06d\n", d);
    }
    return 0;
}

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

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, a, b) for (int i = (a); i >= (b); i--)
#define ALL(container) (container).begin(), (container).end()

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const int MAX_N = 100000;
const ll modNum = 1000000007;
ll memo[MAX_N+1];

ll fib(int n) {
  if (n <= 1) return 1;
  if (memo[n] != -1) return memo[n];
  return memo[n] = fib(n-1) % modNum + fib(n-2) % modNum;
}

int main() {
  int N, M;
  cin >> N >> M;
  REP(i, 0, N+1) {
    memo[i] = -1;
  }
  vector<ll> a(M);
  vector<ll> combi(M+1);
  ll ans;
  if (M != 0) {
    cin >> a[0];
    REP(i, 1, M) {
      cin >> a[i];
      if (a[i] == a[i-1]+1) {
        cout << 0 << endl;
        return 0;
      }
    }
    int pre = -1;
    int stageNum;
    REP(i, 0, M) {
      stageNum = a[i] - pre - 2;
      combi[i] = fib(stageNum);
      pre = a[i];
    }
    combi[M] = fib(N-a[M-1]-1);
    ans = 1;
    REP(i, 0, M+1) {
      ans *= combi[i];
      ans %= modNum;
    }
  } else {
    ans = fib(N);
    ans %= modNum;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4096
import collections
n=int(input())
c=collections.Counter(list(map(int,input().split())))
p=-1
for x in sorted(c.keys())[::-1]:
    if p==-1 and c[x]>=4:print(x*x);break
    elif p==-1 and c[x]>=2:p=x
    elif p!=-1 and c[x]>=2:print(p*x);break
else:print(0)

Measured memory_bytes: 18600
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] str = br.readLine().split(" ");
        int tHP = Integer.parseInt(str[0]);
        int tATK = Integer.parseInt(str[1]);
        int aHP = Integer.parseInt(str[2]);
        int aATK = Integer.parseInt(str[3]);
        
        while(true){
            aHP -= tATK;
            if(aHP <= 0){
                out.println("Yes");
                break;
            }
            tHP -= aATK;
            if(tHP <= 0){
                out.println("No");
                break;
            }
        }
        
        out.close();
        
    }
}

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

using namespace std;

const int MAX_N = 300005;

int _left[MAX_N], _right[MAX_N];

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    rep(i,n-1){
        _left[i+1] = _left[i] + (s[i] == 'W');
    }
    for(int i = n-2; i >= 0; --i){
        _right[i] = _right[i+1] + (s[i+1] == 'E');
    }
    int ans = MAX_N;
    rep(i,n){
        ans = min(ans, _left[i] + _right[i]);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 2948
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;

int func(int x, int y, int z) {
	return x * x + y * y + z * z + x * y + y * z + z * x;
}
int main() {
	int Max = 100000;
	vi master(Max);
	for (int x = 1; x < 101; x++) {
		for (int y = 1; y < 101; y++) {
			for (int z = 1; z < 101; z++) {
				int f = func(x, y, z);
				master[f]++;
			}
		}
	}

	int N; cin >> N;
	for (int i = 1; i <= N; i++) {
		cout << master[i] << endl;
	}
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define dump(x)      cerr << #x << " = " << (x) << endl;


int main() {
    LL N, M;
    cin >> N >> M;
    VVI K(M);
    VI P(M);
    REP(i, M) {
        LL k;
        cin >> k;
        K[i].resize(k);
        REP(j, k) {
            cin >> K[i][j];
        }
    }
    REP(i, M) {
        cin >> P[i];
    }

    LL ans = 0;
    REP(i, 1 << N) {
        VB X(N + 1);
        REP(k, N) {
            if (i & ((LL)1 << k)) {
                X[k + 1] = true;
            } else {
                X[k + 1] = false;
            }
        }
        bool flag = true;
        REP(j, M) {
            LL sum = 0;
            REP(k, SZ(K[j])) {
                if (X[K[j][k]]) sum++;
            }
            if (sum % 2 != P[j]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            ans++;
        }
    }
    cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000


int main(){

	int N,M;
	cin>>N>>M;
	
	int beki = 1;
	for(int i=0;i<M;i++){
		beki *= 2;
	}
	
	int C = 1900*M+100*(N-M);
	
	cout<<C*beki<<endl;
	
    return 0;
}



Measured memory_bytes: 256
from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat
import math
 
# sys.stdin = open('input')
 
def inp(force_list=False):
    re = map(int, raw_input().split())
    if len(re) == 1 and not force_list:
        return re[0]
    return re
 
def inst():
    return raw_input().strip()
 
def gcd(x, y):
   while(y):
       x, y = y, x % y
   return x
 
mod = 1000000007
def idx(c):
    return ord(c) - ord('a')

class Fenwick(object):
    def __init__(self, n):
        self.n = n
        self.da = [0] * n
    
    def add(self, pos, x):
        while pos < self.n:
            self.da[pos] += x
            pos |= pos + 1

    def ps(self, pos):
        re = 0
        while pos >= 0:
            re += self.da[pos]
            pos &= pos + 1
            pos -= 1
        return re

    def sum(self, x, y):
        return self.ps(y) - self.ps(x-1)

def my_main():
    n, nq = inp()
    da = inp()
    q = []
    for i in range(nq):
        l, r = inp()
        q.append((l, r, i))
    q.sort(key=lambda e:e[-2])
    mp = [-1] * (n+5)
    now = -1
    fw = Fenwick(n)
    ans = [0] * nq
    for l, r, idx in q:
        l -= 1
        r -= 1
        while now < r:
            now += 1
            try:
                if mp[da[now]]!=-1:
                    fw.add(mp[da[now]], -1)
                mp[da[now]] = now
            except:
                pass
            fw.add(now, 1)
        ans[idx] = fw.sum(l, r)

    print '\n'.join(map(str, ans))


            

 
 
 
 
my_main()

Measured memory_bytes: 245492
#include <iostream>
#include <set>
#include <cstring>
using namespace std;

int node[101][101];
int visit[101];
int ans,last;
int die[101];
int flag;

void dfs(int now, int cnt, int *st){
	if( cnt>ans ){
		ans=cnt;
		last = now;
		flag = 1;
	}
	for(int next=0; next<101; next++)if( node[now][next] && !visit[next] ){
		visit[next] = die[next] = 1;
		st[cnt] = next;
		dfs(next,cnt+1,st);
		visit[next] = 0;
	}
	return ;
}

int main(){
	int n;
	while(cin>>n,n){
		set<int> s;
		ans = 0;
		memset(node,0,sizeof(node));
		memset(visit,0,sizeof(visit));
		memset(die,0,sizeof(die));
		for(int i=0; i<n; i++){
			int a,b; cin>>a>>b;
			node[a][b] = node[b][a] = 1;
			s.insert(a);
			s.insert(b);
		}
		int tmp[101];
		for(set<int>::iterator it=s.begin(); it!=s.end(); it++)if( !die[*it] ){
			flag = 0;
			
			visit[*it]=1;
			tmp[0] = *it;
			dfs(*it,1,tmp);
			visit[*it]=0;
			
			die[last] = 0;
			//printf("*it:%d\n",*it);

		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 956
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

vector<vector<int> > psum(vector<string>& grid,char c)
{
	int m=grid.size(),n=grid[0].size();
	vector<vector<int> > a(m+1,vector<int>(n+1));
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)
			a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+(grid[i-1][j-1]==c);
	return a;
}

int calc(vector<vector<int> >& a,int i1,int j1,int i2,int j2)
{
	return a[i2][j2]-a[i1][j2]-a[i2][j1]+a[i1][j1];
}

int main()
{
	for(int m,n,k;cin>>m>>n>>k;){
		vector<string> grid(m);
		for(int i=0;i<m;i++)
			cin>>grid[i];
		
		vector<vector<int> > js=psum(grid,'J'),os=psum(grid,'O'),is=psum(grid,'I');
		
		while(k--){
			int a,b,c,d; cin>>a>>b>>c>>d;
			cout<<calc(js,a-1,b-1,c,d)<<' ';
			cout<<calc(os,a-1,b-1,c,d)<<' ';
			cout<<calc(is,a-1,b-1,c,d)<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>


int plus(int I, int N, int S){

  int i;
  int count=0;

  if(S<0) return(0);
  if(N==0 && S==0) return(1);
  else if(N==0) return(0);

  for(i=I; i<10; i++){
    count+=plus(i+1, N-1, S-i);    
  }

  return(count);
}



int main(void){

  int n, s;
  int count;
  int i;


  while(1){
    scanf("%d %d", &n, &s);
    if(n==0 && s==0) break;

    count=0;
    for(i=0; i<10; i++){
      count+=plus(i+1, n-1, s-i);
    }

    printf("%d\n", count);
  }

  return(0);

}



Measured memory_bytes: 2060
package main

import (
	"fmt"
	"time"
)

const (
	yyyymmdd = "2006/01/02"
)

func main() {
	// solveA
	{
		// var dateS, resA string
		// _, _ = fmt.Scan(&dateS)
		// resA = solveA(dateS)
		// fmt.Println(resA)
	}

	//solveB
	{
		var n int
		fmt.Scan(&n)
		a := make([]float64, n)
		b := make([]string, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
			fmt.Scan(&b[i])
		}
		res := solveB(a, b)
		fmt.Println(res)
	}
}

func solveA(dateS string) string {

	t1, _ := time.Parse(yyyymmdd, dateS)
	t2, _ := time.Parse(yyyymmdd, "2019/04/30")

	if t1.Unix() <= t2.Unix() {
		return "Heisei"
	} else {
		return "TBD"
	}
}

func solveB(a []float64, b []string) float64 {

	total := 0.0
	for index := 0; index < len(a); index++ {
		if b[index] == "JPY" {
			total += a[index]
		} else if b[index] == "BTC" {
			total += a[index] * 380000.0
		}
	}
	return total
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<climits>
using namespace std;

#define NONE INT_MAX>>1

vector< vector<int> > WarshallFloyd(vector< vector<int> >A)
{
  for(int k=0;k<A.size();k++)for(int i=0;i<A.size();i++)for(int j=0;j<A.size();j++)
    A[i][j]=min(A[i][j],A[i][k]+A[k][j]);
  return A;
}

int main()
{
  int n,m,a,b,c,d,x1,x2,y1,y2;
  vector< vector<int> >M;
  cin>>n>>m;
  M.resize(n);
  for(int i=0;i<n;i++)M[i].resize(n,NONE);
  for(int i=0;i<m;i++){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    a--;b--;
    M[a][b]=c;
    M[b][a]=d;
  }
  scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
  x1--;x2--;
  vector< vector<int> >A=WarshallFloyd(M);
  cout<<(y1-y2-A[x1][x2]-A[x2][x1])<<endl;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c < 22) {
        cout << "win" << endl;
    }else{
        cout << "bust" << endl;
    }
    return 0;
}



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

using namespace std;

#define int long long

void solve() {
    int x;
    cin >> x;
    int mi = x / 100;
    if (x - mi * 100 <= mi * 5) {
        cout << 1;
        return;
    }
    cout << 0;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int n, l[1000], i, j, a, b=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&l[i]);
	
	a=l[0];
	for(i=1;i<n;i++){
	    if(a<l[i]){
	        a=l[i];
	        j=i;
	    }
	}
	for(i=0;i<n;i++){
	    if(j!=i) b+=l[i];
	}
	if(a<b) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

vector<ll> tree[200200];
vector<ll> ans(200200, 0);
vector<bool> al(200200, false);

void dfs(ll p, ll plus){
	ans[p] += plus;
	al[p] = true;
	if(tree[p].size()==0)return ;
	rep(i,tree[p].size()){
		if(al[tree[p][i]])continue;
		dfs(tree[p][i], ans[p]);
	}
	return ;
}

int main(){
	ll n,q;
	cin>>n>>q;
	rep(i,n-1){
		ll a,b;
		cin>>a>>b;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	rep(i,q){
		ll p,x;
		cin>>p>>x;
		ans[p] += x;
	}
	dfs(1,0LL);
	REP(i,n)cout<<ans[i]<<' ';
	cout<<endl;
	return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int main() {
    int k;
    int a, b;
    cin >> k >> a >> b;
    for(int i=a;i<= b;i++){
        if(i%k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}


Measured memory_bytes: 3620
a,b = input().split()

i = 0
a_str = ""
while i < int(b):
    a_str += a
    i += 1

i = 0
b_str = ""
while i < int(a):
    b_str += b
    i +=1

if a_str > b_str:
    print(b_str)
else:
    print(a_str)


Measured memory_bytes: 38256
from itertools import combinations_with_replacement
def solve():
    n, m, q = map(int, input().split())
    l = [list(map(int, input().split())) for _ in range(q)]

    com = [int(x) for x in range(1, m+1)]
    ans = 0
    for i in combinations_with_replacement(com, n-1):
        cur = list(i)
        A = [1] + cur
        tot = 0
        for k in range(q):
            a, b, c, d = l[k]
            if A[b-1] - A[a-1] == c:
                tot += d
        ans = max(ans, tot)
    
    return ans


print(solve())


Measured memory_bytes: 9216
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
using namespace std;

int main(void) {
  long long dog, monkey, pat = 1, ern = 1;
  cin >> dog >> monkey;
  if (abs(dog - monkey) > 1) {
    cout << 0 << endl;
    return 0;
  }
  if (abs(dog - monkey) == 1) {
    for (int i = min(dog, monkey); i > 0; i--) {
      pat *= i;
      pat %= 1000000007;
    }
    ern = pat;
    ern %= 1000000007;
    ern *= max(dog, monkey);

    ern %= 1000000007;
  }
  if (dog - monkey == 0) {
    for (int i = max(dog, monkey); i > 0; i--) {
      pat *= i;
      pat %= 1000000007;
    }
    ern = pat;
    ern *= 2;
  }
  cout << (pat * ern) % 1000000007 << endl;
  return 0;
}


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

vector<pair<long long, long long> > prime_factorize(long long N) {
	vector<pair<long long, long long> > res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0; // 指数

		 // 割れる限り割り続ける
		while (N % a == 0) {
			++ex;
			N /= a;
		}

		// その結果を push
		res.push_back({ a, ex });
	}

	// 最後に残った数について
	if (N != 1) res.push_back({ N, 1 });
	return res;
}

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

	ll const mod = 1000000007;
	ll const p = 1001;
	
	vector<ll> num(p, 0);
	for (int i = 1; i <= n; i++) {
		vector<pair<long long, long long>> a_prime;  // a^x ならば { a, x }
		a_prime = prime_factorize(i);
		for (int j = 0; j < a_prime.size(); j++) {
			num[a_prime[j].first] += a_prime[j].second;
		}	
	}
		
	ll ans = 1;
	for (int i = 0; i < p; i++) {
		ans *= num[i] + 1;
		ans %= mod;
	}

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

Measured memory_bytes: 256
<?php

$length = trim(fgets(STDIN));
$cnt = 0;
$array=[];

while ($cnt < $length) {
	$input = trim(fgets(STDIN));
	$input = explode(" ", $input);
	foreach ($input as $value) {
		$array[] = $value;
		++$cnt;
	}
}

$sum = 0;
foreach ($array as $value) {
	$sum += $value -1;
}

out($sum);

function out($var){
	echo $var , PHP_EOL;
}




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

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, W;
  cin >> n >> W;
  int w[n];
  long v[n];
  long dp[W+1];
  for(int i = 0;i < n;i++)
    cin >> w[i] >> v[i];
  for(int i = 0;i <= W;i++)
    dp[i]=0;
  for(int i = 0;i < n;i++){
    for(int j = W;j >= w[i];j--){
      dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
    }
  }
  cout << dp[W] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)






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

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int N, K;
	string S;
	cin >> N >> K >> S;
	S[K-1] = tolower(S[K - 1]);
	cout << S << endl;

	return 0;
}


Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut mp = std::collections::BTreeMap::new();
    let mut vs = vec![];
    let mut cs = vec![0; n];
    let mut ci = 0;
    for _ in 0 .. n {
    	let a = get!();
        if let Some(&i) = mp.get(&a) {
            cs[i] += 1;
            continue;
        }
        vs.push(a);
        mp.insert(a, ci);
        cs[ci] = 1;
        ci += 1;
    }
    if ci > 3 {
        println!("No");
        return;
    }
    if ci == 1 {
        if vs[0] == 0 {
            println!("Yes");
        } else {
            println!("No");
        }
        return;
    }
    let p0 = vs[0];
    for j in 1 .. vs.len() {
        let p1 = vs[j];
        let mut rs = vec![0; n];
        if let Some(&i) = mp.get(&p0) {
            rs[i] += 1;
        }
        if let Some(&i) = mp.get(&p1) {
            rs[i] += 1;
        }
        let mut pa = p0;
        let mut pb = p1;
        let mut ok = true;
        for _ in 2 .. n {
            let p = pa ^ pb;
            if let Some(&i) = mp.get(&p) {
                if rs[i] < cs[i] {
                    rs[i] += 1;
                } else {
                    ok = false;
                    break;
                }
            } else {
                ok = false;
                break;
            }
            pa = pb;
            pb = p;
        }
        if pa ^ pb != p0 {
            ok = false;
        }
        if pb ^ p0 != p1 {
            ok = false;
        }
        if ok {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    string s,t;cin >> s>>t;
    lint ans=0;
    REP(i,SZ(s)){
        ans += (s[i] != t[i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3916
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll inf = 1e5;
ll w[105], v[105];
ll dp[105][100005];
int main(){
	ll a, b;
	cin >> a >> b;
	ll sum = a, sum2 = b;
	ll tmp;
	
	int ans = a%b;
	while (ans!=0) {
		a = b;
		b = ans;
		ans = a % b;
		
	}
	
	cout <<b*(sum/b)*(sum2/b)<< endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;


int main()

{
    int n;cin>>n;
    int w[n];
    int sum=0;
	for(int i=0;i<n;i++)
    {
    	cin>>w[i];
    	sum+=w[i];
	}
	int a[n];
	a[0]=w[0];
	for(int i=1;i<n;i++)
	{
		a[i]=a[i-1]+w[i];
	}
	int res=sum;
	for(int i=0;i<n-1;i++)
	{
		res=min(res,abs(sum-2*a[i]));
	}
	cout<<res;
	

}



Measured memory_bytes: 256