akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }

    int fact[1000005];
    bool ok=false;

    void f(int x){
        if(ok==true)
            return;
        for(int i=1;i*i<=x;i++){
            if(x%i==0){
                int a=i;
                int b=x/i;
                if(a==b){
                    a=i;
                    b=1;
                }
                if(a!=1){
                    if(fact[a]){
                        ok=true;
                        return;
                    }
                    fact[a]++;
                }
                if(b!=1){
                    if(fact[b]){
                        ok=true;
                        return;
                    }
                    fact[b]++;
                }
            }
        }
    }

    void solve(){  
        int n;
        cin>>n;
        vector<int>a(n);
        for(int i=0;i<n;i++)
            cin>>a[i];
        int gcd=a[0];
        // cout<<"in "<<ok<<"\n";
        f(a[0]);
        // cout<<"in "<<ok<<"\n";
        for(int i=1;i<n;i++){
            f(a[i]);
            gcd=__gcd(gcd,a[i]);
            // cout<<"in "<<ok<<"\n";
        }
        if(!ok){
            cout<<"pairwise coprime";
        }
        else if(gcd==1){
            cout<<"setwise coprime";
        }
        else{
            cout<<"not coprime";
        }
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }


Measured memory_bytes: 7488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<int>;
using A = array<int, 2>;
using P = pair<int, int>;
constexpr int MOD{1000000000 + 7};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr array<int, 4> dx{1, 0, -1, 0}, dy{0, 1, 0, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int div_roundup(int a, int b)
{
    return (a + b - 1) / b;
}

// vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));

// *****************************************************************************

void solve()
{
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}

// *****************************************************************************

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

    solve();
}


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

int main()
{
    int a,b,k;
    cin >> a >> b >> k;
    for(int i=0;i<k;i++){
        if(i%2){
            if(b%2){
                b-=1;
            }
            b/=2;
            a+=b;
        }else{
            if(a%2){
                a-=1;
            }
            a/=2;
            b+=a;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,m;
  	ci(n>>m);
  vll A(n);
  FOR(i,0,n){
    ci(A[i]);
  }
  SORT(A);
  REV(A);
  ll ans=0;
  FOR(i,0,m){
    ans+=A[i];
  }
  co(ans)
}

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

using namespace std;

int n, h[100002], dp[100002][3];

int sol(int i, int choice){
    if(i==0) return 0;
    if(i<0) return 1E9;

    int &ret = dp[i][choice];
    if(~ret) return ret;

    return ret = min(abs(h[i]-h[i-1]) + sol(i-1, 1), abs(h[i]-h[i-2]) + sol(i-2, 2));
}

int main()
{
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> h[i];

    memset(dp, -1, sizeof dp);
    cout << min(sol(n-1, 1), sol(n-1, 2));
}


Measured memory_bytes: 4096
A,B,C = map(int,input().split())
i = 1
ans = "NO"
modlist = []
while True:
    if (B * i + C) % A == 0:
        ans = "YES"
        break
    else:
        modlist.append((B * i + C) % A)
        i += 1
    if len(modlist) != len(set(modlist)):
        break
print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		int x = x2 - x1;
		int y = y2 - y1;
		System.out.println((x2-y) + " " + (y2+x) + " " + (x1-y) + " " + (y1+x));
	}
}


Measured memory_bytes: 22996
import java.io.*
import java.util.*

fun solve(A: Int, B: Int, C: Int, X: Int, Y: Int){
    if ((A + B) <= 2*C){
        println(A*X + B*Y)
        return
    }
    val m = Math.min(X, Y)
    val M = Math.max(X, Y)
    val ans = m*2*C + (M-m) * Math.min(2*C, (if(X >= Y) A else B))
    println(ans)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val A = sc.next().toInt()
    val B = sc.next().toInt()
    val C = sc.next().toInt()
    val X = sc.next().toInt()
    val Y = sc.next().toInt()
    solve(A, B, C, X, Y)
}



Measured memory_bytes: 31640
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

k,n = inm()
a = inl()
mx = a[0]+k-a[n-1]
for i in range(n-1):
    mx = max(mx, a[i+1]-a[i])
print(k-mx)


Measured memory_bytes: 78412
#include<stdio.h>
#include<string.h>
#include<math.h>
void fanc(int,int,int);
int a,s,f,g[13],h[13],z;
int main(void)
{
	int i,j,d;
	for(i=0;i<12;i++) g[i]=0;
	scanf("%d",&a);
	z=0;
	fanc(0,0,1);
	d=0;
	for(i=12;i>=0;i--){
		if(g[i]==-1){
			printf("-");
			d=1;
		}
		else if(g[i]==1){
			printf("+");
			d=1;
		}
		else if(g[i]==0&&d==1) printf("0");
	}
	printf("\n");
	return 0;
}
void fanc(int s,int d,int f)
{
	int i,j,k;
	if(s<13){
		if(d==a){
			for(i=0;i<s;i++) g[i]=h[i];
			z=1;
		}
		if(z==0){
			for(i=-1;i<=1;i++){
				h[s]=i;
				fanc(s+1,d+i*f,f*3);
			}
		}
	}
}

Measured memory_bytes: 2624
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

constexpr int INF = 1e8;
constexpr int MOD = 1e9+7;

int main(void) {
    ll a, b;
    cin >> a >> b;
    if (a * b < 0)
        cout << "Zero" << endl;
    else if (a > 0 && b > 0)
        cout << "Positive" << endl;
    else if ((b - a + 1) % 2 == 0)
        cout << "Positive" << endl;
    else
        cout << "Negative" << endl;
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll k, s;
  cin >> k >> s;
  ll ans = 0;
  rep(i, 0, k + 1) rep(j, 0, k + 1)if(s - i - j >= 0 && s - i - j <= k) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MP make_pair
#define endl '\n'
const int mod = 1e9 + 7;
const int MAXN = 3e5 + 5;
const int INF = 0x3f3f3f3f;

int main(int argc, char* argv[]) {
#ifdef local
    // freopen("in.txt", "r", stdin);
#endif
    string a, b;
    cin >> a >> b;
    cout << b << a << endl;
    return 0;
}


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

using namespace std;

#define ll long long
#define vi vector<int>

ll N, K, ans = 1LL<<60, diff, buff, a[100005];

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

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

    for(int i = 0; i + K - 1 < N;i++){
        ll left = a[i], right = a[i + K - 1];
        ans = min(ans, min(abs(left),abs(right))+right-left);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;


ll Donguri(ll N, vec & A, vec & B)
{
	vec dp(N + 1, -1);
	dp[N] = 0;
	ll rtn = 0;
	for (ll don = N; don >= 0; --don)
	{
		if (dp[N] < 0) { continue; }
		for (int r = 0; r < 3; ++r)
		{
			if (don - A[r] < 0)continue;
			dp[don - A[r]] = max(dp[don - A[r]], dp[don] + B[r] - A[r]);
			rtn = max(rtn, dp[don - A[r]]);
		}
	}

	return rtn;
}


int main()
{
	ll N; cin >> N;
	vec A(3);
	vec B(3);

	cin >> A[0] >> A[1] >> A[2];
	cin >> B[0] >> B[1] >> B[2];
	
	N += Donguri(N, A, B);

	N += Donguri(N, B, A);

	cout << N << endl;

	return 0;
}

Measured memory_bytes: 195584
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    long N, P;
    cin >> N >> P;

    if (N == 1) {
        cout << P << endl;
        return 0;
    }

    long res = 1;

    long p = ceil(sqrt(P));
    for (long a = 2; a <= p; a++) {
        long cnt = 0;
        while (P % a == 0) {
            cnt++;
            P /= a;
        }
        for (int i = 0; i < cnt / N; i++) res *= a;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ld r;
	cin >> r;
	printf("%.5Lf %.5Lf\n",acos(-1)*r*r,2*acos(-1)*r);
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep_ll(i,n) for(ll i = 0; i < (ll)(n); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
const long double PI = (acos(-1));
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1};
ll mod = 1000000007;
int main(){
    ll a, b;
    ll v, w, t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;
    int ans=0;
        //if(a==b) ans=1;
        ll dis=abs(a-b);
        ll bb= dis+t*w;
        ll aa= t*v;
        if(bb<=aa){
       ans=1;
      }
        if(ans) cout << "YES";
        else cout << "NO"; 
    //}
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

int s(int O[],int n, int key)
{
  int i = 0;
  O[n] = key;
  while( O[i] != key) i++;
  return i != n;
}

int main()
{
  int i, n,t,key,goukei =0;
  int O[10000+1];

  scanf("%d",&n);
 
  for( i = 0; i < n; i++ ) scanf("%d",&O[i]);

  scanf("%d",&t);

  for( i = 0; i < t; i++ )
    {
      scanf("%d", &key);
      if ( s(O,n,key)) goukei++;
    }
  printf("%d\n" , goukei);

  return 0;
}
       
  
      



Measured memory_bytes: 2740
#include <iostream>
    #include <algorithm>
    #include <string>
     
    using namespace std;
     
    int main(){
    	int n;
    	cin>>n;
    	string s;
    	cin>>s;
    	
    	int ans=0;
    	for(int i=1;i<n;i++){
    		int cnt=0;
    		
    		for(char c='a';c<='z';c++){
    			bool left=false,right=false;
    			
    			for(int j=0;j<i;j++)
    				if(s[j]==c)
    					left=true;
    			
    			for(int j=i;j<n;j++)
    				if(s[j]==c)
    					right=true;
    			
    			if(left&&right)
    				cnt++;
    		}
    		
    		if(ans<cnt)
    			ans=cnt;
    	}
    	
    	cout<<ans<<endl;
    }

Measured memory_bytes: 384
#include <iostream>

using namespace std;

const long long mod = 1e9 + 7;

long long mod_pow(long long m, long long n){
    
    if (n == 1) return m;
    
    if (n % 2 == 1) return (m * mod_pow(m, n-1)) % mod;
    
    long long t = mod_pow(m, n/2);
    return (t*t)%mod;
}


int main(){
    
    long long m, n;
    cin >> m >> n;
    
    cout << mod_pow(m, n) << endl;
    return 0;
}


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

int main(void){
  map<pair<int, int>, int> p;
  int cnt = 1;
  for(int t = 0; t <= 180; t+= 30){
    for(int r = 100; r <= 500; r+= 100){
      p[make_pair(t, r)] = cnt++;
    }
  }
  /*
  for(map<pair<int, int>, int>::iterator it = p.begin(); it != p.end(); it++){
    cout << (*it).first.first << " " << (*it).first.second << " " << (*it).second << endl;
  }
  */
  int N, r, t;
  cin >> N;
  for(int i=0; i < N; i++){
    cin >> r >> t;
    pair<int ,int> arg;
    pair<int, int> len;
    if(r % 100 == 0){
      len.first = len.second = r;
    }else{
      for(int i = 100; i < 500; i += 100){
	if(i < r && r < i + 100){
	  len.first = i;
	  len.second = i + 100;
	  break;
	}
      }
    }

    if(t % 30 == 0){
      arg.first = arg.second = t;
    }else{
      for(int i=0; i < 180; i += 30){
	if(i < t && t < i + 30){
	  arg.first = i;
	  arg.second = i + 30;
	  break;
	}
      }
    }
    vector<int> ans;
    if(len.first == len.second){
      if(arg.first == arg.second){
	ans.push_back(p[make_pair(arg.first, len.first)]);
      }else{
	ans.push_back(p[make_pair(arg.first, len.first)]);
	ans.push_back(p[make_pair(arg.second, len.first)]);
      }
    }else{
      if(arg.first == arg.second){
	ans.push_back(p[make_pair(arg.first, len.first)]);
	ans.push_back(p[make_pair(arg.first, len.second)]);
      }else{
	ans.push_back(p[make_pair(arg.first, len.first)]);
	ans.push_back(p[make_pair(arg.first, len.second)]);
	ans.push_back(p[make_pair(arg.second, len.first)]);
	ans.push_back(p[make_pair(arg.second, len.second)]);
      }
    }
    for(int i=0; i < (signed int)ans.size() - 1; i++){
      cout << ans[i] << " ";
    }
    cout << ans[ans.size() - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
   string s; 
  cin >> s  ;
  int n=s.size();
  if(s.at(n-1)=='3') cout << "bon" << endl;
  else if(s.at(n-1)=='0' || s.at(n-1)=='1'  ||s.at(n-1)=='6' ||s.at(n-1)=='8'){
     cout << "pon" << endl;
  }
  else cout << "hon" << endl;
}

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

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

void solve(long N, long K) {
  double ans(0.0);
  FOR(i, 1, N) {
    if (i >= K) {
      ans += 1.0 / N;
      continue;
    }
    long x(i), n(0);
    while (x < K) {
      x *= 2;
      n++;
    }
    ans += 1.0 / (N * pow(2, n));
  }
  cout << fixed << setprecision(9) << ans << endl;
}

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

  long N, K;
  cin >> N >> K;

  solve(N, K);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

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(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int h,w;
	cin>>h>>w;
	vector<string> g;
	rep(i,h){
		string s;
		cin>>s;
		bool flag=false;
		rep(j,w){
			if(s[j]=='#') flag=true;
		}
		if(flag){
			g.push_back(s);
		}
	}
	set<int> ind;
	rep(j,w){
		bool flag=false;
		rep(i,g.size()){
			if(g[i][j]=='#') flag=true;
		}
		if(flag) ind.insert(j);
	}
	rep(i,g.size()){
		rep(j,w){
			if(ind.count(j)) cout<<g[i][j];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int Par[100],Rank[100];
void Init(int n) {
	for(int i=0;i<n;i++) {
		Par[i]=i;
		Rank[i]=0;
	}
}
int Find(int x) {
	if(Par[x]==x) {
		return x;
	}else {
		return Par[x]=Find(Par[x]);
	}
}
void Unite(int x,int y) {
	x=Find(x);
	y=Find(y);
	if(x==y) return;
	if(Rank[x]<Rank[y]) {
		Par[x]=y;
	}else {
		Par[y]=x;
		if(Rank[x]==Rank[y])Rank[x]++;
	}
}
bool Same(int x,int y) {
	return Find(x)==Find(y);
}
struct Edge {
	int from,to,cost;
	Edge(int _f,int _t,int _c) {from=_f,to=_t,cost=_c;}
	bool operator < (const Edge& E) const {return cost<E.cost;}
};
int main() {
	int s,d;
	while(scanf("%d %d",&s,&d),s) {
		vector<Edge> es;
		for(int i=0;i<s;i++) {
			for(int j=0;j<d;j++) {
				int cost;
				scanf("%d",&cost);
				if(cost!=0)
					es.push_back(Edge(i,j+50,cost));
			}
		}
		for(int i=0;i<(d-1);i++) {
			for(int j=0;j<(d-i-1);j++) {
				int cost;
				scanf("%d",&cost);
				if(cost!=0)
					es.push_back(Edge(i+50,i+(j+1)+50,cost));
			}
		}
		sort(es.begin(),es.end());
		Init(100);
		int sum=0;
		for(int i=0;i<es.size();i++) {
			if(!Same(es[i].from,es[i].to)) {
				bool a=false,b=false;
				for(int j=0;j<s;j++) {
					a|=Same(j,es[i].from);
					b|=Same(j,es[i].to);
				}
				if(a&&b) continue;
				Unite(es[i].from,es[i].to);
				sum+=es[i].cost;
			}
		}
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 1084
import sys
n = int(input())
a = list(map(int, input().split()))

total = 1
a.sort()
if a[0] == 0:
	print(0)
	sys.exit()
for i in range(n):
	total *= a[i]
	if total > 10**18:
		print('-1')
		sys.exit()
print(total)
	

Measured memory_bytes: 21652
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<usize>();
    let mut array = Vec::new();
    for n in 0..N {
        let tmp = read::<i32>();
        array.push(tmp);
    }

    array.sort();
    array.reverse();
    println!("{}", array[0] - array[N-1]);

}


Measured memory_bytes: 4352
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int A=scan.nextInt();
		int B=scan.nextInt();
		int C=scan.nextInt();
		int d[][]=new int[B][A];
		for(int i=0;i!=B;i++) {
			for(int j=0;j!=A;j++) {
				d[i][j]=1;
			}
		}
		for(int i=0;i!=C;i++) {
			int a=scan.nextInt();
			int b=scan.nextInt();
			int c=scan.nextInt();
			if(c==1) {
				for(int j=a-1;j!=-1;j--) {
					for(int k=0;k!=B;k++) {
						d[k][j]=0;
					}
				}
			}	if(c==2) {
				for(int j=a;j!=A;j++) {
					for(int k=0;k!=B;k++) {
						d[k][j]=0;
					}
				}
			}	if(c==3) {
				for(int j=B-b;j!=B;j++) {
					for(int k=0;k!=A;k++) {
						d[j][k]=0;
					}
				}
			}	if(c==4) {
				for(int j=B-b-1;j!=-1;j--) {
					for(int k=0;k!=A;k++) {
						d[j][k]=0;
					}
				}
			}
		}
		int ans=0;
		for(int j=0;j!=B;j++) {
			for(int k=0;k!=A;k++) {
				if(d[j][k]==1) {
					ans++;
			}
			}
	}
		System.out.println(ans);
	}
}

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

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

  int k;
  cin >> k;

  sort(a.begin(), a.end());

  for(int i = 0; i < k; i++) a[2] *= 2;

  cout << a[0] + a[1] + a[2] << endl;

  return 0;

}



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

using namespace std;

int main(){
	ll N;
	ll m[110][110];
	ll dp[110][110];

	memset(dp, -1, sizeof dp);

	cin >> N;
	for(int i = 0; i < 2; ++i){
		for(int j = 0; j < N; ++j){
			cin >> m[i][j];
		}
	}
	
	priority_queue<pair<ll, pair<ll, ll> > > q;
	
	q.push(pair<ll, pair<ll, ll> >(0, pair<ll, ll>(0, 0)));

	while(!q.empty()){
		auto top = q.top(); q.pop();
		auto x = top.second.first;
		auto y = top.second.second;
		auto value = top.first + m[x][y];

		//cout << x << " " << y << " " << " " << top.first << " + " << m[x][y] << " = " << value << " " << dp[x][y] << endl;
		if(value <= dp[x][y]) continue;
		
		dp[x][y] = value;
		if(y + 1 < N) q.push(pair<ll, pair<ll, ll> >(value, pair<ll, ll>(x, y + 1)));
		if(x + 1 < 2) q.push(pair<ll, pair<ll, ll> >(value, pair<ll, ll>(x + 1, y)));
	}

	cout << dp[1][N-1] << endl;

	return 0;
}


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

int main(void){
    string n;
    cin>>n;
    int size=n.length();
    int cnt=0;
    rep(i,size){
        int c=n[i]-'0';
        cnt+=c;
    }
    if(cnt%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  for(int i=0;i<5;i++){
    ll a;
    cin >> a;
    if(a==0)cout << i+1 << endl;
  }

}

Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
int main()
{
	int a,b;
	std::cin>>a>>b;
	if((a+b)%2==0){
		std::cout<<(a+b)/2<<'\n';
	}else{
		std::cout<<"IMPOSSIBLE"<<'\n';
	}
	return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

using namespace std;

#define MAX_N 1005

#define int long long

int N;
int M;

class edge{
public:
  int from, to, cost;
};

vector<edge> EdgeVec;

LL d[MAX_N];

void solve()
{
  for (int i = 0; i < MAX_N; i++) {
    d[i] = INF_LL_MAX;
  }

  d[0] = 0;

  int cnt = 0;

  while(cnt < 2*N){
    cnt++;
    bool update = false;
    for (int i = 0; i < EdgeVec.size(); i++) {
      edge e = EdgeVec[i];
      if(d[e.from] != INF_LL_MAX && d[e.to] > d[e.from] - e.cost){
        d[e.to] = d[e.from] - e.cost;
        update = true;
      }
    }
    if(!update){
      break;
    }
  }

  LL ans = -d[N-1];


  cnt = 0;
  while(cnt < 2*N){
    cnt++;
    bool update = false;
    for (int i = 0; i < EdgeVec.size(); i++) {
      edge e = EdgeVec[i];
      if(d[e.from] != INF_LL_MAX && d[e.to] > d[e.from] - e.cost){
        d[e.to] = d[e.from] - e.cost;
        update = true;
      }
    }
    if(!update){
      break;
    }
  }

  if(ans != -d[N-1]){
    cout << "inf" << endl;
  }
  else{
    cout << ans << endl;
  }
}

signed main()
{
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int A, B; LL C;
    cin >> A >> B >> C;
    A--; B--;
    edge e; e.from = A, e.to = B; e.cost = C;
    EdgeVec.push_back(e);
  }

  solve();

  return 0;
}


Measured memory_bytes: 384
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int S=1e5;
vector<int> m[S];
int x[S];
int N,L;

/*
int g(int a,int k){
	if(k==0){
		return a;
	}
	if(m[a].size()==0){
		int v=upper_bound(x+a,x+N,x[a]+L)-x-1;
		m[a].push_back(v);
	}
	int e=0;
	int j=1;
	while(a%(2*j)==0&&2*j<=k){
		if(m[a].size()==e+1){
			int v=g(m[a][e],j);
			if(m[a][e]==N){
				return N;
			}
			m[a].push_back(v);
		}
		e++;
		j*=2;
	}
	return g(m[a][e],k-j);
}
*/
int main() {
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> x[i];
	}
	cin >> L;
	int cur=0;
	for(int i=0;i<N;i++){
		while(x[cur]+L<x[i]){
			m[cur].push_back(i-1);
			cur++;
		}
	}
	while(cur<N){
		m[cur].push_back(N-1);
		cur++;
	}
	for(int j=1;;j++){
		bool updated=false;
		for(int i=0;i<N;i++){
			if(m[i].back()!=N-1){
				m[i].push_back(m[m[i].back()].back());
				updated=true;
			}
		}
		if(!updated){
			break;
		}
	}

	int Q;
	cin >> Q;
	for(int i=0;i<Q;i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		if(a>b){
			swap(a,b);
		}
		int ret=0;
		while(a<b){
			int j=0;
			int k=1;
			while(j+1<m[a].size()&&m[a][j+1]<b){
				j++;
				k*=2;
			}
			ret+=k;
			a=m[a][j];
		}
		cout << ret << endl;
	}


	return 0;
}



Measured memory_bytes: 15616
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

#define rep(i,i0,n) for (int (i) = (i0); (i) < (n); ++(i))

using namespace std;

int n = 0;
vector<int> edges[101010];
bool visited[101010];

int dfs(int v, int b, bool r = false) {
    if (!r) {
        fill(visited, visited + 101010, false);
    }

    visited[v] = true;
    vector<int> lengths;

    for (auto c : edges[v]) {
        if (!visited[c]) {
            int k = dfs(c, b, true);
            if (!k || b < k) return 0;
            lengths.push_back(k);
        }
    }

    if (edges[v].size() & 1) {
        lengths.push_back(0);
    }

    int hold = 0;
    sort(lengths.begin(), lengths.end());
    while (1 < lengths.size()) {
        int k = lengths.back();
        lengths.pop_back();
        auto i = upper_bound(lengths.begin(), lengths.end(), b - k);
        if (i == lengths.begin()) {
            if (r && !hold) {
                hold = k;
            } else {
                return 0;
            }
        } else {
            lengths.erase(i - 1);
        }
    }

    if (hold) {
        lengths.push_back(hold);
    }

    if (lengths.size()) {
        return lengths[0] + 1;
    } else {
        return 1;
    }
}


tuple<int, int> solve() {
    int root = -1;
    int a = 1;

    rep(i, 0, n) {
        size_t c = edges[i].size();
        if (3 <= c) {
            a += (c - 1) / 2;
            root = i;
        }
    }

    if (root < 0) {
        return make_tuple(1, n - 1);
    }

    int ok = n - 1;
    int ng = 1;

    while (ng + 1 < ok) {
        int mid = (ok + ng) / 2;
        if (dfs(root, mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    return make_tuple(a, ok);
}

int main(int argc, const char * argv[]) {
    int a, b;
    
    cin >> n;
    rep(i, 0, n - 1) {
        cin >> a >> b;
        --a;
        --b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    auto p = solve();

    cout << get<0>(p) << ' ' << get<1>(p) << endl;

    return 0;
}


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int A = c-a;
  int B = d-b;
  cout << c-B <<" "<< d+A <<" "<< a-B <<" "<< b+A << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int mod = 1000000007;

int main(){
    int n,k,m=mod,mn;
    cin>>n>>k;
    rep(i,n){
        int a;
        m=min(m,a);
        if(m==a) mn=i;
    }
    int ans=(mn+(k-2))/(k-1)+((n-mn-1)+(k-2))/(k-1);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long a = Long.parseLong(sc.next());
		long b = Long.parseLong(sc.next());
		//		int[] x = new int[n];
		//
		//		for (int i = 0; i < n; i++) {
		//			x[i] = Integer.parseInt(sc.next());
		//		}

		long gcd = gcd(a, b);
		double loot_gcd = Math.sqrt(gcd);
		int cnt = 1;

		boolean watta2 = false;
		while (gcd % 2 == 0) {
			gcd /= 2;
			watta2 = true;
		}
		if (watta2) {
			cnt++;
		}

		for (long i = 3; i <= loot_gcd; i += 2) {
			boolean watta = false;
			while (gcd % i == 0) {
				gcd /= i;
				watta = true;
			}
			if (watta) {
				//				System.out.println(i+"_");
				cnt++;
			}
		}

		if (loot_gcd <= gcd && loot_gcd != 1) {
			cnt++;
		}

		System.out.println(cnt);
		sc.close();
	}

	public static long gcd(long m, long n) {
		if (m < n)
			return gcd(n, m);
		if (n == 0)
			return m;
		return gcd(n, m % n);
	}
}

Measured memory_bytes: 22740
using System;

namespace ABC050_A_Addition_and_Subtraction_Easy
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			String[] input = Console.ReadLine().Split(' ');
			int a = int.Parse(input[0]);
			int b = int.Parse(input[2]);

			if (input[1] == "+")
			{
				Console.WriteLine(a + b);
			}
			else
			{
				Console.WriteLine(a - b);
			}
		}
	}
}

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

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;

    int ans = 0;
    for (int i = A; i <= B; ++i) {
        string N = to_string(i);
        string N_rev = N;
        reverse(N_rev.begin(), N_rev.end());

        if (N == N_rev) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 768
#include<stdio.h>
int main(){
	int	n[6],i,j,t;
	for(i=0;i<5;i++)scanf("%d",&n[i]);
	for(i=0;i<5;i++){
		for(j=i;j<5;j++){
			if(n[i]<n[j]){
				t=n[i];n[i]=n[j];n[j]=t;
			}
		}
	}
	for(printf("%d",n[0]),i=1;i<5;i++)printf(" %d",n[i]);
	printf("\n");
	exit(0);
}

Measured memory_bytes: 0
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace AtcoderProblem
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = System.Console.ReadLine();
            var stArrayData = line.Split(' ');
            var D = int.Parse(stArrayData[0]);
            var T = int.Parse(stArrayData[1]);
            var S = int.Parse(stArrayData[2]);

            if (S*T >= D)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }         
    }
}


Measured memory_bytes: 27508
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  unsigned long long a;
  double b; cin >> a >> b;
  b *= 100;
  cout << a * ((int)round(b)) /100 << endl;
  return 0;
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    vector<int> x(5);
    for (int i=0; i<5; i++)
        cin >> x[i];

    for (int i=0; i<5; i++)
        if (x[i] == 0)
            cout << i + 1 << "\n";

    return 0;
}


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

int main() {
    int N,ans,r,j,i,l;
    cin >> N;
  	int h[1100] = {0};
    for(int i = 0; i < N; ++i) cin >> h[i];
    ans = 0;
    for(int l=0; l<N; l++){
        while(h[l]>0){
            int r;
            for(r = l+1; r<N; r++){
                if(h[r] == 0) break;
            }

            for(int i = l; i<r; i++) --h[i];
            ans++;
        }
    }

    cout << ans << endl;
}


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

const int maxn = 2e5 + 7;

int a[maxn];
int first[maxn], second[maxn];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

	for (int i = 0; i < 20; i++) first[i] = -1, second[i] = 0;

	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 20; j++) 
			if ((1 << j) & a[i]) {
				first[j] = second[j];
				second[j] = i;
			}
		int cur = 0;
		for (int j = 0; j < 20; j++) 
			cur = max(cur, first[j] + 1);
		cur = max(cur, 1);
		ans += (i - cur + 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i + 100*j + 50*k == X:
                ans += 1
print(ans)

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

void fnTrace(const vector<int> &argviSort)
{
  for (int i = 0; i < argviSort.size(); i++)
  {
    if (i) cout << " ";
    cout << argviSort[i];
  }
  cout << endl;
}

void fnInsertionSort(vector<int> &argviSort)
{
  for (int ixSorting = 1; ixSorting < argviSort.size(); ixSorting++)
  {
    int iTarget = argviSort[ixSorting];
    int ixSorted = ixSorting - 1;
    while (iTarget  < argviSort[ixSorted] &&
           ixSorted >= 0                    )
    {
      argviSort[ixSorted + 1] = argviSort[ixSorted];
      ixSorted--;
    }
    argviSort[ixSorted + 1] = iTarget;
    fnTrace(argviSort);
  }
}

int main()
{
  vector<int> viSort;
  int iMaxSize;
  
  cin >> iMaxSize;
  for (int i = 0; i < iMaxSize; i++)
  {
    int iNum;
    cin >> iNum;
    viSort.push_back(iNum);
  }

  fnTrace(viSort);
  fnInsertionSort(viSort);

  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for(int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        a[i] = {temp, i};
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++)
    {
        cout << a[i].second + 1 <<" ";
    }
    cout << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main(){
  int A, B, C;
  cin >> A >> B >>C;
  if(A == B && A != C) cout << "Yes";
  else if(A == C && B != C) cout << "Yes";
  else if(B == C && B != A) cout << "Yes";
  else cout << "No";
}

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

using namespace std;

int main() {
  int n;
  vector<int> a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  vector<int> ans;
  // ans.push_back(a[0]);
  for (int i = 0; i < n; i++) {
    auto it = upper_bound(ans.begin(), ans.end(), -a[i]);
    if (it == ans.end()) {
      ans.push_back(-a[i]);

    } else {
      *it = -a[i];
    }
    // sort(ans.begin(), ans.end());
  }
  cout << ans.size() << endl;
  return 0;
}

Measured memory_bytes: 1400
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
N,K,Q=map(int,input().split())

A=[int(input()) for _ in range(Q)]
S=[K-Q]*N


for i in range(Q):
	S[A[i]-1]+=1	
	
for k in range(N):
	if S[k]>0:
		print("Yes")
	else:
		print("No")
	

Measured memory_bytes: 11880
#include <iostream>
#include <set>

using namespace std;

int main(){
  int s;
  cin >> s;
  set<int> st;
  int x = s;
  while(st.count(x) == 0){
    st.insert(x);
    if(x % 2 == 0){
      x /= 2;
    }
    else{
      x = x * 3 + 1;
    }
  }

  cout << (st.size() + 1) << endl;

  return 0;
}


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

bool visited[100001];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    if (n & 1) {
        FOR(i, 1, m + 1) cout << i << ' ' << n - i + 1 << '\n';
    } else {
        for (int i = 1, j = n / 2; m && i < j; i++, j--, m--)
            cout << i << ' ' << j << '\n';
        for (int i = n / 2 + 1, j = n - 1; m && i < j; i++, j--, m--)
            cout << i << ' ' << j << '\n';
    }
    return 0;
}

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

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
   
    int n,m; cin>>n>>m; vector<vector<int>> g(n);
    for (int i = 0; i < m; i++){
        int a,b; cin>>a>>b; a--; b--;
        g[a].push_back(b); g[b].push_back(a);
    }
    int a[n]; for (int i = 0; i < n; i++)a[i]=i;
    int ans=0;
    do{
        bool ok=true;
        for (int i = 0; i < n-1; i++){
            bool key=false;
            for (int j = 0; j < g[a[i]].size(); j++)key|=a[i+1]==g[a[i]][j];
            if(!key){ok=false; break;}
        }
        if(ok)ans++;
    }while(next_permutation(a+1,a+n));
    cout<<ans<<'\n';
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  vector<string> v;
  string s,t;
  cin>>s>>t;
  rep(i,s.size()-t.size()+1){
    string tmp=s.substr(i,t.size());
    bool flag=true;
    rep(j,t.size()) if(!(t[j]==tmp[j] || tmp[j]=='?')) flag=false;
    if(flag){
      string ans;
      if(i==0) ans=t+s.substr(i+t.size());
      else ans=s.substr(0,i)+t+s.substr(i+t.size());
      rep(j,ans.size()) if(ans[j]=='?') ans[j]='a';
      v.push_back(ans);
    }
  }
  if(v.size()!=0){
    sort(ALL(v));
    cout<<v[0]<<endl;
  }else{
    cout<<"UNRESTORABLE"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    int d;
    cin >> d;
    vec.at(i) = d;
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int sum = 1;
  for(int i = 1; i < N; i++){
    if(vec.at(i) != vec.at(i-1)){
      sum += 1;
    }
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b,c,d,e,f=0;
  cin>>a>>b>>c;
  rep(i,a){
    d=i+1;
    e=0;
    while(d){
      e+=d%10;
      d/=10;
    }
    if(b<=e&&e<=c)f+=i+1;
  }
  cout<<f;
}


Measured memory_bytes: 256