akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>

using namespace std;
// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }


#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;


template<typename T>
struct SqrtTree {

  vector<T> data;
  vector<T> bucket;
  T sq;

  SqrtTree( vector<T> const& v) : data(v) {
    int d_size = data.size();
    sq = sqrt( d_size );
    bucket.resize( (d_size + sq - 1) / sq);
    for(int i = 0; i < d_size; i++) {
      if(i % sq == 0) {bucket[i / sq] = data[i]; }
      bucket[i / sq] += data[i]; // change here!
    }
  }

  // [l, r]
  T query(int l, int r) {
    T res = 0;// change here!
    int i = l;
    while(i <= r) {
      if(i % sq == 0 && i + sq <= r) {
        // change here!
        res += bucket[ i / sq ];
        // res = min(res,  bucket[ i / sq ]); RMQ
        i += sq;
      } else {
        // change here!
        res += data[i];
        i++;
      }
    }
    return res;
  }

  void update(int i, T x) {
    // change here!
    // bucket[i / sq] -= data[i];
    data[i] += x;
    bucket[i / sq] += x;

    // RMQ
    // bucket[i / sq] = min(x, bucket[i / sq]);
    // data[i] = x;
  }

  void print() {

    for(int i = 0; i < (int)bucket.size(); i++ ) {
      cout << setw(2*sq) << bucket[i];
    }

    cout << "\n";

    for(int i = 0; i < (int)data.size(); i++ ) {
      cout << setw(2) << data[i];
    }

    cout << "\n";
  }

};



int main() {
  ios::sync_with_stdio(false);

  int N, Q;
  cin >> N >> Q;

  vector<int> data(N, 0);
  SqrtTree<int> sqtree(data);

  for(int i = 0; i < Q; i++) {
    int com, x, y;
    cin >> com >> x >> y;
    // add
    if(com == 0) {
      x--;                      // 0 index
      sqtree.update(x, y);
    }
    if(com == 1) {
      // sqtree.print();
      x--; y--;        // 0 index
      cout << sqtree.query(x, y) << "\n";
    }

  }

  return 0;
}

Measured memory_bytes: 3512
#include <iostream>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;

// 入力
int a, b;


int main() {
  cin >> a >> b;
  auto c = a*b;
  if(c %2 == 0)
  {
  cout <<  "Even" << endl;
  }
  else
  {
  cout <<  "Odd" << endl;
  }
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();

    int ans = 0;
    int l = 0, r = n-1;
    while(l < r){
        if(s.at(l) == s.at(r)){
            l++;
            r--;
        } else if(s.at(l) == 'x'){
            l++;
            ans++;
        } else if(s.at(r) == 'x'){
            r--;
            ans++;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
  int N;
  cin >> N;
  vi a(N + 1);
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    cin >> a[i];
    if (a[i] % 2 == 1 && i % 2 == 1) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b;
	int ans;
	cin >> a >> b;
	if (b % a == 0)
		ans = a + b;
	else
		ans = b - a;
	cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int x,k,d;cin>>x>>k>>d;
    x=abs(x);
    int num=x/d;
    if(num > k)	
    {
    	cout<<x-k*d<<endl;
    	return 0;
    }
    int diff=k-num;
    if(diff&1)
    {
    	cout<<d*(num+1)-x<<endl;
    }
    else
    	cout<<x-d*num<<endl;
    return 0;
}

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

int main(void){
    int N,K;
    cin >> N >> K;
    int x[N] = {0};
    for(int i=0;i<N;i++){
        cin >> x[i];
    }

    int ans = INT_MAX;
    for(int i=0;i<N-K+1;i++){
        ans = min(ans,abs(x[i]) + abs(x[i+K-1] - x[i]));
        ans = min(ans,abs(x[i+K-1]) + abs(x[i+K-1] - x[i]));
    }

    if(ans == INT_MAX){
        cout << x[0];
    }else{
        cout << ans; 
    }

    return 0;
}

Measured memory_bytes: 640
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		String a = s.next();
		int b = s.nextInt();
		DecimalFormat df1 = new DecimalFormat("00");
		String bb=df1.format(b);

		int c=Integer.parseInt(a+bb);

		if(101<=c&&c<202){
			System.out.println(1);
		}else if(201<c&&c<303){
			System.out.println(2);
		}else if(302<c&&c<404){
			System.out.println(3);
		}else if(403<c&&c<505){
			System.out.println(4);
		}else if(504<c&&c<606){
			System.out.println(5);
		}else if(605<c&&c<707){
			System.out.println(6);
		}else if(706<c&&c<808){
			System.out.println(7);
		}else if(807<c&&c<909){
			System.out.println(8);
		}else if(908<c&&c<1010){
			System.out.println(9);
		}else if(1009<c&&c<1111){
			System.out.println(10);
		}else if(1110<c&&c<1212){
			System.out.println(11);
		}else{
			System.out.println(12);
		}





	}

}


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

using namespace std;

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

    sort(a.begin(), a.end());
    if (a[0]==5&&a[1]==5&&a[2]==7) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
#define VLCIN(a, n) REP(i,n){cin >> a[i];}
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll n;
vl l;
/******* define variable end *******/
int solve() {
	cin >> n;
	l.resize(n);
	REP(i, n){
		cin >> l[i];
	}
	ll ans = 0;
	FOR(i, 0, n){
		FOR(j, i+1, n){
			FOR(k, j+1, n){
				if(l[i] != l[j] && l[j] != l[k] && l[k] != l[i]){
					if(l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]){
						ans++;
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}
int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3672
import std.stdio, std.conv, std.string;

void main()
{
  int[] num = readln.chomp.split(' ').to!(int[]);
  int ret = 0;
  for(int X = 0; X <= num[0]; X++)
    {
      for(int Y = 0; Y <= num[0]; Y++)
	{
	  int remain = num[1] - (X + Y);
	  if(remain >= 0 && remain <= num[0])ret++;
	}
    }
  ret.writeln;
}


Measured memory_bytes: 256
#include<stdio.h>
int N = 100;
int main(){
    int n,p[N+1],m[N+1][N+1];
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
        scanf("%d %d",&p[i-1],&p[i]);
    }
    for(int i = 1;i <= n;i++) m[i][i]=0;
    for(int l = 2;l <= n;l++){
        for(int i = 1;i <= n - l + 1;i++){
            int j = i + l - 1;
            m[i][j] = 1000000;
            for(int k = i;k <= j - 1;k++){
                if(m[i][j] >= m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j])
                m[i][j] =  m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];
            }
        }
    }
    printf("%d\n",m[1][n]);
    return 0;
}


Measured memory_bytes: 2148
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>

using namespace std;



int main() {

	int a,b;

	cin >> a >> b;

	int m;

	m = max(a + b, a*b);
	m = max(m, a - b);

	cout << m << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

    int N = scanner.nextInt();
    int T = scanner.nextInt();
    int[] a = new int[N];
    int[] b = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = scanner.nextInt();
      b[i] = scanner.nextInt();
    }

    int[][] dp = new int[N + 1][T];
    for (int i = 1; i <= N; i++) {
      for (int j = 0; j < T; j++) {
        dp[i][j] = dp[i - 1][j];
        if (j >= a[i - 1]) {
          int newValue = dp[i - 1][j - a[i - 1]] + b[i - 1];
          if (newValue > dp[i][j]) {
            dp[i][j] = newValue;
          }
        }
      }
    }
    Set<Integer> selected = new HashSet<>();
    int j = T - 1;
    for (int i = N; i > 0; i--) {
      if (j >= a[i - 1] && dp[i - 1][j] < dp[i - 1][j - a[i - 1]] + b[i - 1]) {
        selected.add(i - 1);
        j -= a[i - 1];
      }
    }
    int max = 0;
    for (int i = 0; i < N; i++) {
      if (!selected.contains(i)) max = Math.max(max, b[i]);
    }
    System.out.println(dp[N][T - 1] + max);
  }
}


Measured memory_bytes: 69908
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
 
const int INF = 1<<29;
 
int dp[256][16][128];
int stones[256][16][2];
int col[256];
 
int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
 
  while (true) {
    int N, M;
    cin >> N >> M;
    if (N == 0 && M == 0) break;
   
    REP(i, N) {
      cin >> col[i];
      REP(j, col[i]) {
	cin >> stones[i][j][0] >> stones[i][j][1];
      }
    }
 
    REP(i, N) REP(j, col[i]) REP(k, M+1) dp[i][j][k] = INF;
    REP(j, col[0]) dp[0][j][0] = 0;
    REP(j, col[1]) dp[1][j][1] = 0;
    REP(i, N-1) {
      REP(j, col[i+1]) {
	int x_now = stones[i+1][j][0], d_now = stones[i+1][j][1];
	REP(k, col[i]) {
	  int x_prev = stones[i][k][0], d_prev = stones[i][k][1];
	  int safe = (d_now + d_prev) * abs(x_now - x_prev);
	  REP(m, M+1) {
	    dp[i+1][j][m] = min(dp[i+1][j][m], dp[i][k][m] + safe);
	  }
	}
	if (i > 0) {
	  REP(k, col[i-1]) {
	    int x_prev = stones[i-1][k][0], d_prev = stones[i-1][k][1];
	    int safe = (d_now + d_prev) * abs(x_now - x_prev);
	    REP(m, M) {
	      dp[i+1][j][m+1] = min(dp[i+1][j][m+1], dp[i-1][k][m] + safe);
	    }
	  }
	}
      }
    }
 
    int ans = INF;
    REP(j, col[N-1]) REP(m, M+1) ans = min(ans, dp[N-1][j][m]);
    REP(j, col[N-2]) REP(m, M) ans = min(ans, dp[N-2][j][m]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2416
a, b, k = map(int, input().split())
if b-a+2 >2*k:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)

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


int main(){
  int x, y;
  cin >> x >> y;
  if (2*x <= y && y <= 4*x && y%2 == 0) cout << "Yes\n";
  else cout << "No\n";
}



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

int main(){

    int N;
    cin>>N;
    vector<int> S;
    if(N>=0){
        if(N%2==0) S.push_back(0);
        else S.push_back(1);
        N=N/2;
        while(N>0){
            if(N%4==0){S.push_back(0);
                S.push_back(0);
                N=N/4;
            }
            else if(N%4==1){S.push_back(1);
                S.push_back(1);
                N=N/4;
            }
            else if(N%4==2){S.push_back(0);
                S.push_back(1);
                N=N/4;
            }
            else if(N%4==3){S.push_back(1);
                S.push_back(0);
                N=(N+1)/4;
            }
            }
        reverse(S.begin(),S.end());
        for(int i=0;i<S.size();i++){
            cout<<S.at(i);
        }
        cout<<endl;
    }
    else if(N<-1){
        while(N!=0){
            if(N%4==0){S.push_back(0);
                S.push_back(0);
                N=N/4;
            }
            else if(N%4==-1){S.push_back(1);
                S.push_back(1);
                N=N/4;
            }
            else if(N%4==-2){S.push_back(0);
                S.push_back(1);
                N=N/4;
            }
            else if(N%4==-3){S.push_back(1);
                S.push_back(0);
                N=(N-1)/4;
            }
        }
        reverse(S.begin(),S.end());
        for(int i=0;i<S.size();i++){
            cout<<S.at(i);
        }
        cout<<endl;
    }
            
        }


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};
const int MAX_N = 100000;
const ll MOD = 1000000000 + 7;

class SegmentTree{
public:
    SegmentTree(){}
    SegmentTree(int n){init(n);}
    void init(int n){
        size = 1;
        while(size < n){
            size *= 2;
        }
        
        REP(i, size*2-1){
            data[i] = 0ll;
        }
    }
    void update(int k, ll v){
        k += size - 1;
        data[k] = v;
        
        while(k > 0){
            k = (k-1) / 2;
            data[k] = data[k*2+1] + data[k*2+2];
        }
    }
    ll query(int l, int r){
        return _query(l, r, 0, 0, size);
    }
private:
    ll _query(int a, int b, int k, int l, int r){
        if(b <= l || r <= a){return 0ll;}
        if(a <= l && r <= b){return data[k];}
        return _query(a, b, 2*k+1, l, (l+r)/2) +
            _query(a, b, 2*k+2, (l+r)/2, r);
    }
    ll data[MAX_N*4];
    int size;
};

int N, R;
SegmentTree st;
int perm[100000];
ll fact[100000];

int main(){
    st.init(MAX_N);

    fact[0] = 1;
    FOR(i, 1, 100000){fact[i] = (fact[i-1] * i) % MOD;}

    while(std::cin >> N, N){
        std::cin >> R;

        REP(i, N){
            st.update(i, 1ll);
            perm[i] = i;
        }

        REP(i, R){
            int x, y;
            std::cin >> x >> y;
            x -= 1; y -= 1;

            std::swap(perm[x], perm[y]);
        }
    
        ll res = 0ll;
        REP(i, N){
            res = (res + (st.query(0, perm[i]) * fact[N-i-1]) % MOD) % MOD;
            st.update(perm[i], 0ll);
        }

        std::cout << res << std::endl;
    }
}

Measured memory_bytes: 5252
#include <bits/stdc++.h>
#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() {
  int n;
  cin>>n;
  int ans=n/2;
  if (n%2==0) ans--;
  cout<<ans<<endl;
  return 0;
}

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

int main(){
    int S, W;
    cin >> S >> W;
    string ans;

    if(S<=W){
        ans = "unsafe";
    }else{
        ans="safe";
    }

    cout << ans << endl;

    return 0;
}

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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

int main() {
	reg n = read();
	if(n == 3) puts("2 5 63");
	else {
		reg kk = 0;
		while(n >= 8) {
			printf("%d %d %d %d %d %d %d %d ", kk + 2, kk + 3, kk + 4, kk + 6, kk + 8, kk + 9, kk + 10, kk + 12);
			kk += 12, n -= 8;
		} if(n == 1) printf("%d\n", kk + 6);
		else if(n == 2) printf("%d %d\n", kk + 2, kk + 4);
		else if(n == 3) printf("%d %d %d\n", kk + 2, kk + 4, kk + 6);
		else if(n == 4) printf("%d %d %d %d\n", kk + 2, kk + 3, kk + 4, kk + 9);
		else if(n == 5) printf("%d %d %d %d %d\n", kk + 2, kk + 3, kk + 4, kk + 6, kk + 9);
		else if(n == 6) printf("%d %d %d %d %d %d\n", kk + 2, kk + 3, kk + 4, kk + 8, kk + 9, kk + 10);
		else if(n == 7) printf("%d %d %d %d %d %d %d\n", kk + 2, kk + 3, kk + 4, kk + 6, kk + 8, kk + 9, kk + 10);
	}
	return 0;
}



Measured memory_bytes: 384
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest042-B
#  TODO https://atcoder.jp/contests/abc042/tasks/abc042_b
import time
from contextlib import contextmanager
# from time import sleep
@contextmanager
def timer(title):
	t0 = time.time()
	yield
	print("{} - done in {:.0f}s".format(title,time.time()-t0) )

def  makeString(givenStringCount):
	givenStringsList = []
	lineRange = range(0,givenStringCount,+1)
	for i in lineRange:
		givenStringsList.append(input().strip())
	givenStringsSortedList = sorted(givenStringsList,reverse=False)
	smallString = "".join(givenStringsSortedList)
	answer = smallString
	return answer


if __name__ == '__main__':
	N,_ = map(int,input().strip().split(' '))
#	with timer("makeString"):
	solution=makeString(N)
	print("{}".format(solution))

Measured memory_bytes: 3692
import java.util.*;

class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int max = 0;
      	int sec = 0;
      	int N = sc.nextInt();
      	int[] A = new int[N];
      	for(int i = 0;i < N;i++){
          	A[i] = sc.nextInt();
          	if(A[i] > max){
              	max = A[i];
            }else if(A[i] <= max && A[i] > sec){
              	sec = A[i];
            }
        }
      	for(int i = 0;i < N;i++){
        	System.out.println(A[i]==max ? sec : max);
        }
    }
}

Measured memory_bytes: 85340
D = ["A","T","G","C"]
S = input().strip()
N = len(S)
cnt = 0
for k in range(N):
    for i in range(k+1):
        ind = 1
        for j in range(i,i+N-k):
            if S[j] not in D:
                ind = 0
                break
        if ind == 1:
            cnt = N-k
            break
    if ind==1:break
print(cnt)

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
#define bmi(mass, height) mass / (pow(height, 2))

int main(void) {
    int number;
    double mass, height;
    int count = 0;
    
    while(scanf("%d,%lf,%lf", &number, &mass, &height) != EOF) {
        if(bmi(mass, height) >= 25) {
            printf("%d\n", number);
            count++;
        }
    }
    if(count == 0) {
        printf("該当なし\n");
    }
    
    return(0);
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int n;
    cin>>n;
    vector<int>l(n);
    rep(i,n)cin>>l[i];
    sort(l.begin(),l.end());
    int sum=0;
    rep(i,n-1)sum+=l[i];
    if(sum>l[n-1])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
h,n = io.read("*n","*n","*l")
al = io.read()
for a in string.gmatch( al,"%d+" ) do
    h = h - a
  io.stderr:write(tostring(h).."\n")
end

if h <= 0 then 
    print("Yes")
else 
    print("No")
end

Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string S;
	cin>>S;
	int s=S.size();
	string A="abcdefghijklmnopqrstuvwxyz";
	FDS(i,26){
	    int t=0;
		FDS(j,s){
			if(S[j]!=A[i]){
				t++;
			}
		}
		
		if(t==s){
    		cout<<A[i]<<endl;
    		return 0;
		}
	}
	cout<<"None"<<endl;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back

#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i++)
#define RepA(x) for(auto item : (x))
#define output_s(a) printf("%s\n",(a).c_str())

//library----------------------------------------------


int main(){
    int n,m;cin>>n>>m;
    printf(n>m?"No":"Yes");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

const ll MAX_N = 200010;
ll fact[MAX_N];
ll fact_inv[MAX_N];

ll pow_mod(ll x, ll y, ll m = MOD) { //x^y mod m
    if (x == 0) return 0;
    ll prod = 1;
    while (y > 0) {
        if (y % 2 == 1) prod = (prod * x) % m;
        x = (x * x) % m;
        y /= 2;
    }
    return prod % m;
}

inline ll inv(ll a) {
    return pow_mod(a, MOD - 2);
}

void init_fact() {
    fact[0] = fact_inv[0] = 1;

    REP(i, 1, MAX_N) {
        fact[i] = (fact[i - 1] * i) % MOD;
        fact_inv[i] = inv(fact[i]);
    }
}

ll C_mod(ll n, ll r) {
    if (n < r) return 0;
    else return ((fact[n] * fact_inv[n - r]) % MOD * fact_inv[r]) % MOD;
}

inline ll H_mod(ll n, ll r) {
    return C_mod(n + r - 1, r);
}

inline ll P_mod(ll n, ll r) {
    return C_mod(n, r) * fact[r];
}

ll free_cnt(ll len) {
    if (len == 0) return 1;
    return pow_mod(3, len);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    init_fact();
    string L;
    cin >> L;
    ll ans = 0;
    ll prod = 1;

    rep(i, L.length()) { //a+bの先頭i文字がLと一致,i文字目(0-indexed)でa+b＜Lとなる
        if (L[i] == '0') continue;
        ans += free_cnt((ll) L.length() - i - 1) * prod;
        ans %= MOD;
        prod = prod * 2 % MOD;
    }
    ans += prod; //a+b=L
    ans %= MOD;
    cout << ans << endl;
    return 0;
}



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

using namespace std;

using Edge = pair<int, long long>;
using Graph = vector<vector<Edge>>;


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

int N, Q, K;
long long dist[100010];

void dfs(Graph &G, int v, int p, long long cost){
    dist[v] = cost;

    for(auto e : G[v]){
        if(e.first == p) continue;
        dfs(G, e.first, v, cost+e.second);
    }
}

int main(){
    cin >> N;
    Graph G(N);
    REP(i,N-1){
        int a, b;
        long long c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }

    cin >> Q >> K;
    K--;
    dfs(G, K, -1, 0);
    REP(j,Q){
        int x, y;
        cin >> x >> y;
        x--, y--;
        cout << dist[x] + dist[y] << "\n";
    }

    return 0;
}

Measured memory_bytes: 15872
#include<iostream>
using namespace std;
int a[107];
int main()
{
    int n;
    cin>>n;
    int ans=0;
    int x=1;
    for(int i=1;i<=n;++i)
    {
        cin>>a[i];
        if(a[i-1]==a[i])x++;
        else{ans+=x/2;x=1;}
    }
    ans+=x/2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
int read() {
	int x = 0, f = 1; char ch;
	while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
	for(x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
	return x * f;
}
template <class T> T Max(T a, T b) { return a > b ? a : b; }
template <class T> T Min(T a, T b) { return a < b ? a : b; }
string s, t;
int n, m, k;
int main() {
	n = read(); m = read(); k = read(); cin >> s >> t;
	reverse(s.begin(), s.end()); reverse(t.begin(), t.end());
	for(int i = 1; i <= m + k + 5; ++ i) s.push_back('0');
	for(int i = 1; i <= n + k + 5; ++ i) t.push_back('0');
	for(int i = n + m - 1; i >= 0; -- i) {
		if(s[i] == '1' && t[i] == '1') {
			s[i] = t[i] = '0'; s[i + 1] ++; t[i + 1] ++;
			int li = k - 1, j = i + 1;
			while(li) {
				if(s[j] == '2') s[j] = '0', s[j + 1] ++;
				else if(t[j] == '2') t[j] = '0', t[j + 1] ++;
				else if(s[j] == '1' && t[j] == '1') {
					li --; s[j] = t[j] = '0';
					s[j + 1] ++; t[j + 1] ++;
				}
				else break;
				j ++;
			}
			if(s[j] == '2') s[j] = '0', s[j + 1] ++;
			if(t[j] == '2') t[j] = '0', t[j + 1] ++;
		}
	}
	while(s.back() == '0') s.pop_back();
	while(t.back() == '0') t.pop_back();
	reverse(s.begin(), s.end()); reverse(t.begin(), t.end());
	cout << s << endl << t << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


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

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N, K; cin >> N >> K;
  ll x, y; cin >> x >> y;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  // vector<ll> a(N); rep(i, N) cin >> a[i];
  
  ll ans = (x - 2) * (y- 2);

  if(x == 1) {
    if(y == 1) {
      ans = 1;
    } else {
      ans = y - 2;
    }
  } else {
    if(y == 1) {
      ans = x - 2;
    }
  }
  
  cout << ans << endl;

}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e5 + 10; 

int n,k,c;
char s[maxn];
vector<int>p,q;

int main()
{
	fastIO;
	cin >> n >> k >> c >> (s + 1);
	for(int i = 1; i <= n; ++i) {
		if(s[i] == 'o') {
			p.pb(i);
			i += c ;
		}
	}
	for(int i = n; i >= 1; --i) {
		if(s[i] == 'o') {
			q.pb(i);
			i -= c ;
		}
	}
	if(p.size() > k || q.size() > k || p.size() != q.size()) return 0;
	reverse(all(q));
	rep(i,0,SZ(p)) {
		//cout << p[i] << "" << q[i] << endl;
		if(p[i] == q[i]) cout << p[i] << endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long;

int main(){
    int n, k = 2; cin >> n;
    cin >> k;
    vector<int> heights(n), ans(n, INT_MAX);
    for(int i=0; i<n; i++){
        cin >> heights[i];
        if(!i) ans[i] = 0;
        else
            for(int j=i-1; j>=max(0,i-k); j--){
                ans[i] = min(ans[j] + abs(heights[i] - heights[j]), ans[i]);
            }
    }
    cout<<ans[n-1]<<endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    static int MAX = 10010017;  // (1 ≦ k ≦ n ≦ 10^7 程度)
    static int MOD = 1000000007;
    static long[] fac;  // 階乗
    static long[] finv;
    static long[] inv;  // 逆元
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        COMinit();
        int n = sc.nextInt();
        int k = sc.nextInt();
        k = Math.min(k, n - 1);
        
        long ans = 0;
        for (int i = 0; i <= k; i++) {
            ans = ans + (nCkMOD(n, i) * nCkMOD(n - 1, i)) % MOD;
            ans %= MOD;
        }
        
        System.out.println(ans);
    }
    
    // テーブルを作る前処理
    public static void COMinit() {        
        fac = new long[MAX];
        finv = new long[MAX];
        inv = new long[MAX];
        
        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;
        }
    }
    
    // 二項係数計算(1 ≦ k ≦ n ≦ 10^7 程度)
    public static long nCkMOD(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;
    }
    
    public static long modpow(long a, long n) {
        long res = 1;
        while (n > 0) {
            long tmp = n & 1;
            if (tmp > 0) res = res * a % MOD;
            a = a * a % MOD;
            n >>= 1;
        }
        return res;
    }
}

Measured memory_bytes: 260436
import sys

import math
import numpy as np

def main():
    n = int(input())
    vec = [tuple(map(int, input().split())) for i in range(n)]
    vec.sort(key=lambda x: math.atan2(x[1], x[0]))

    maxx = 0
    for i in range(n):
        for j in range(1, n+1):
            now = [0, 0]
            for k in range(j):
                idx = (i + k) % n
                now[0] += vec[idx][0]
                now[1] += vec[idx][1]
            maxx = max(maxx, now[0]*now[0] + now[1]*now[1])

    print(math.sqrt(maxx))
    return 0

if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 13440
#include<bits/stdc++.h>
#define clr(x, y) memset(x, y, sizeof(x))
#define fl(a, b) for(int i=a; i<b; i++)
using namespace std;
typedef long long ll;
const int maxn = 100000 + 5;
const int inf = INT_MAX;

int main() {
	int N;
	cin >> N;
	bool vis[11];
	clr(vis, false);
	int cnt = 0, cc = 0;
	while(N--) {
		int x;
		cin >> x;
		if(x<=3199&&!vis[x/400]) {
			cnt ++;
			vis[x/400] = true;
		} else if(x>3199) cc++;
	}
	printf("%d %d\n", cnt==0?1:cnt, cnt + cc);
}

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

using namespace std;

int main() {
    string s;
    cin >> s;

    int len = s.length();
    int cnt = 0;
    for (int i = 0; i < len / 2; i++) {
        if ( s[i] != s[len-i-1] ) {
            cnt++;
        }
    }
    cout << cnt;

    return 0;
}


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

const int N=1e5;
int n;
long long int l;
string s[N+87];
string t="";
long long int ans=0;
int now=0;
int pre=0;

inline long long int lowbit(long long int x){return x&(-x);}

void dfs(int i){
    if(now<n&&t==s[now]){
        now++;
        pre=0;
        while(now<n&&pre<t.size()&&pre<s[now].size()&&t[pre]==s[now][pre])pre++;
    }
    else if(now==n||pre<i){
        ans=ans^lowbit(l+1-i);
    }
    else{
        t=t+"0";
        if(pre==i&&i<t.size()&&i<s[now].size()&&t[i]==s[now][i])pre++;
        dfs(i+1);
        if(pre==i+1&&i<t.size()&&i<s[now].size()&&t[i]==s[now][i])pre--;
        t.erase(i);

        t=t+"1";
        if(pre==i&&i<t.size()&&i<s[now].size()&&t[i]==s[now][i])pre++;
        dfs(i+1);
        if(pre==i+1&&i<t.size()&&i<s[now].size()&&t[i]==s[now][i])pre--;
        t.erase(i);
    }
}

int main(){
    cin>>n>>l;
    for(int i=0;i<n;i++)cin>>s[i];
    sort(s,s+n);

    dfs(0);
    if(ans==0)cout<<"Bob\n";
    else cout<<"Alice\n";
}


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

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    if (a.at(a.size() - 1) == b.at(0) && b.at(b.size() - 1) == c.at(0))
    {
        puts("YES");
    }
    else
    {
        puts("NO");
    }
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
using namespace std;
 
int main(void)
{
    int d, t;
    char c;
    double x = 0.0, y = 0.0, r = 0.0;
    while(cin >> d >> c >> t) {
        if (d == 0 && t == 0)
            break;
        y += d * cos(r / 180 * M_PI);
        x += d * sin(r / 180 * M_PI);
        r += t;
    }
 
    cout << (int)x << endl;
    cout << (int)y << endl;
    return 0;
}


Measured memory_bytes: 3400
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,cnt,mon[12]={0,31,29,31,30,31,30,31,31,30,31,30};
  string day[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
  while(cin >> a >> b){
    if(a==0 and b==0){
      break;
    }
    cnt=b;
    for(int i=0;i<a;i++){
      cnt+=mon[i];
    }
    cout << day[cnt%7] << endl;
  }
  return 0;
}


Measured memory_bytes: 3116
def ma():
  n,m=map(int,input().split())
  ans=0
  e=[set(list(map(int,input().split()))[1:]) for i in range(m)]
  f=list(map(int,input().split()))
  for i in range(2**n):
    l={a for a,b in zip(range(1,n+1),bin(i)[2:].zfill(n)) if b=="1"}
    for j in range(1,m+1):
      if len(e[j-1]&l)%2!=f[j-1]:break
    else:ans+=1
  print(ans)

if __name__=="__main__":
  ma()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    string s; cin >> s;
    ll K; cin >> K;

    int N = s.size();
    rep(i,N) {
        if (s[i] == 'a') continue;
        int cost = 26 - (s[i] - 'a');
        if (cost <= K) {
            K -= cost;
            s[i] = 'a';
        }
    }
    if (K > 0) {
        int x = (s.back() - 'a' + K)%26;
        s.back() = 'a' + x;
    }
    cout << s << '\n';
    return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
 
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }
 
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
 
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
 
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    ll n , m ; cin >> n >> m;
    UnionFind tree(n);
    while(m--){
        ll x,y,z; cin >> x >> y >> z;
        x--; y--;
        tree.unite(x,y);        
    }
    ll cnt = 0;
    rep(i,n){
        if(tree.par[i]==i) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *p,const void *q){
	return *(int*)p-*(int*)q;
}
int main(void){
	int N;
	scanf("%d",&N);
	int *history=malloc(sizeof(int)*N);
	for(int i=0;i<N;i++){
		scanf("%d",&history[i]);
	}
	qsort(history,N,sizeof(int),cmp);
	for(int i=0;i<N-1;i++){
		if(history[i]==history[i+1]){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
    private static Scanner scanner = new Scanner(System.in);

    private static long[][] dp; // heap

    public static void main(String[] args) {
        int N = scanner.nextInt();
        int W = scanner.nextInt();

        int[] w = new int[N];
        long[] v = new long[N];
        for (int i = 0; i < N; i++) {
            w[i] = scanner.nextInt();
            v[i] = scanner.nextInt();
        }

        dp = new long[N + 1][W + 1];

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < W + 1; j++) {
                if (w[i] > j) {
                    dp[i + 1][j] = dp[i][j];
                } else {
                    dp[i + 1][j] = Math.max(dp[i][j], dp[i][j - w[i]] + v[i]);
                }
            }
        }

        System.out.println(dp[N][W]);
    }
}


Measured memory_bytes: 129492
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
string a,b; 
int main(){
	cin>>a>>b;
	if(int(b.size())!=int(a.size())+1)
	{
		cout<<"No";
		return 0;
	}
	for(int i=0;i<a.size();i++)
	{
		if(a[i]!=b[i])
		{
			cout<<"No";
			return 0;
		}
	}
  	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

//0-index ?????????????????°?????????(????????´??°or?????? , ????°????or?????§???or???) verified AOJ DSL_2,DSL_3
template<class T>
class segtree{
private:
    vector<T> dat;
    int _size;  //the number of leaves
    T _init;
    
public:
    segtree(int __size=0 , T init=numeric_limits<T>::max() ):_size(__size) , _init(init){
        if(__size==0)return ;
        int x=1;
        while(x<_size)x*=2;
        _size = x;
        dat.resize(_size*2);
    }
    
    void init(vector<T> v){
        for(int i=_size;i<_size+v.size();i++) dat[i] = v[i-_size];
        //for(int i=_size-1;i>=1;i--)dat[i] = min(dat[i*2],dat[i*2+1]); //minimum
        //for(int i=_size-1;i>=1;i--)dat[i] = max(dat[i*2],dat[i*2+1]); //maximum
        for(int i=_size-1;i>=1;i--)dat[i] = dat[i*2]+dat[i*2+1];      //sum
    }
    
    void update(int m,T x){
        int i = m+_size;
        dat[i] += x;    //addition
        //dat[i] = x;     //initialize
        for(; i!=1; i/=2){
            //dat[i/2] = min(dat[i],dat[i^1]);    //minimum
            //dat[i/2] = max(dat[i],dat[i^1]);    //maximum
            dat[i/2] = dat[i]+dat[i^1];         //sum
        }
    }
    
    // call find(s,t)
    T find(int s,int t,int num=1,int l=0,int r=-1){
        if(r==-1)r=_size; //I couldn't "int b=_size".
        if(r<=s||t<=l)return _init;
        if(s<=l&&r<=t)return dat[num];
        //return min( find(s,t,num*2,l,(l+r)/2) , find(s,t,num*2+1,(l+r)/2,r) );    //minimum
        //return max( find(s,t,num*2,l,(l+r)/2) , find(s,t,num*2+1,(l+r)/2,r) );    //maximum
        return find(s,t,num*2,l,(l+r)/2) + find(s,t,num*2+1,(l+r)/2,r);           //sum
    }
    int size(){return _size;}
};
int main(){
    int n,q;
    cin>>n>>q;
    segtree<int> st(n,0);
    st.init(vector<int>(st.size(),0));
    rep(i,q){
        int type;
        cin>>type;
        if(type==0){
            int j,x;
            cin>>j>>x;
            j--;
            st.update(j,x);
        }else{
            int s,t;
            cin>>s>>t;
            s--;
            cout<<st.find(s,t)<<endl;
        }
    }
    
}

Measured memory_bytes: 4368
#include <cstdio>
#include <cstring>
using namespace std;
char s[1003],t[1003];
int ls,lt,minn=0x7fffffff;
void check(int x){
	int diff=0;
	for(int i=0;i<lt;++i){
		if(t[i]!=s[x+i])++diff;
	}
	minn=(minn>diff?diff:minn);
}
int main(){
	scanf("%s%s",s,t);
	ls=strlen(s);
	lt=strlen(t);
	for(int i=0;i+lt<=ls;++i)check(i);
	printf("%d\n",minn);
	return 0;
}


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

#define fill(x,y) memset(x,y,sizeof(x))
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define pb push_back
#define smp(x,y,z) mp(x,mp(y,z))
#define reads(x) scanf("%s",&x)
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)

typedef long long ll;
typedef string s;
typedef pair<ll,ll> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vector<int> > matrix;

const ll oo = 1e16;
const int maxSize = 100100;
const int mod = 1e9+7;

const double EPS = (1e-9);

int dcmp(double x, double y){return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;}

int n,arr[100100]={0} ;


int main(){
    cin >> n ;
    for(int i=0 ;i<n ;i++){
        int num ; cin >> num ; arr[num]++ ; arr[num+1]++; arr[num-1]++;
    }
    int maxi=1 ;
    for(int i=0;i<100010;i++){
        maxi = max(maxi,arr[i]) ;
    }
    cout << maxi ;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    string s;
    cin >> s;
    bool ans = false;
    rep(i, s.size()-1)if(s[i] == 'A' && s[i + 1] == 'C')ans = true;
    if (ans) {
        Yes;
    }else{
        No;
    }
    return 0;
}

Measured memory_bytes: 256