akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int N,A[MAXN], O[MAXN], E[MAXN];

pi oddcand(){
	pi res = {-1, -1};
	int x = max_element(O, O+MAXN) - O;
	int tmp = O[x];
	res.first = x;
	O[x] = 0;
	x = max_element(O, O+MAXN) - O;
	res.second = x;
	O[res.first] = tmp;
	return res;
}

pi evencand(){
	pi res = {-1, -1};
	int x = max_element(E, E+MAXN) - E;
	int tmp = E[x];
	res.first = x;
	E[x] = 0;
	x = max_element(E, E+MAXN) - E;
	res.second = x;
	E[res.first] = tmp;
	return res;
}

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	
	FOR(i,1,N) {
		cin >> A[i];
		if (i%2==0) E[A[i]]++;
		else O[A[i]]++;
	}
	//db(O[3]), db(E[1]);
	pi x = oddcand(), y = evencand();
	//db(x.first), db(x.second), db(y.first), db(y.second);
	if (x.first != y.first){
		//db(O[x.first]), db(E[y.first]);
		cout << N - O[x.first] - E[y.first];
		exit(0);
	}
	else{
		cout << min(N - O[x.second] - E[y.first], N - O[x.first] - E[y.second]);
		exit(0);
	}
}


Measured memory_bytes: 1408
a, b, c, d = gets.chomp.chars
%w(+ -).each do |op1|
  %w(+ -).each do |op2|
    %w(+ -).each do |op3|
      expr = a + op1 + b + op2 + c + op3 + d
      if eval(expr) == 7
        puts "#{expr}=7"
        exit
      end
    end
  end
end


Measured memory_bytes: 1788
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << " = "; for (auto xxxx: a) cerr << xxxx << " "; cerr << endl


using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int main() {
#ifdef LOCAL
  freopen("a.in", "r", stdin);
  freopen("a.out", "w", stdout);
#endif

  int d;
  while (scanf("%d", &d) == 1) {
    double ang = d / 180.0 * M_PI;
    double x = 0;
    double y = 0;
    int cnt = 0;
    do {
      cnt++;
      x += cos(ang * cnt);
      y += sin(ang * cnt);
    } while (abs(x) > 1e-9 || abs(y) > 1e-9);
    printf("%d\n", cnt);
  }

  return 0;
}


Measured memory_bytes: 4152
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

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

    ll x, k, d;
    cin >> x >> k >> d;

    if(x < 0) x = -x;

    ll a = x % d;
    ll b = x / d;

    if(k <= b) {
        cout << x - k * d << endl;
        return 0;
    }

    k -= b;

    if(k & 1)
        cout << abs(a - d) << endl;
    else
        cout << a << endl;

    return 0;
}

Measured memory_bytes: 3648
#!/usr/bin/env python3
#ABC140 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
s = input()
score = 0
for i in range(n):
    if s[i] == 'L':
        if i > 0:
            if s[i-1] == 'L':
                score += 1
    else:
        if i < n-1:
            if s[i+1] == 'R':
                score += 1
print(min(score+2*k,n-1))


Measured memory_bytes: 39536
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int n,ans = 1;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  for(int i = 1; i < n; i++) {
    bool flag = true;
    for(int j = 0; j < i; j++) {
      if(h[j] > h[i]) {
        flag = false;
        break;
      }
    }
    if(flag) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
///age yekam bekeshi beham is no problem ._.
#include<bits/stdc++.h>
#define size(a) (int)a.size()
#define int long long
#define F first
#define S second
#define pb push_back
using namespace std;
void null(){return ;}
const int maxn=1e5+7,INF=3e18+9237,mod=1e9+7;
int a[maxn],cnt;

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<=n-1;i++){
		if(a[i]==i+1)cnt++;
		if(a[i]==i+1&&a[i+1]==i+2)swap(a[i],a[i+1]);
	}
	cout<<cnt;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N, K;
	cin >> N >> K;
	map<int, int> m;
	rep(i, 0, N) {
		int a;
		cin >> a;
		m[a]++;
	}

	vector<int> v;
	int var = 0;
	for(map<int, int>::iterator it = m.begin(); it != m.end(); it++) {
		v.push_back(it->second);
		var++;
	}
	vsort(v);
	int res = 0;
	rep(i, 0, var - K) {
		res += v[i];
	}
	cout << res << endl;


}


Measured memory_bytes: 10744
#pragma warning(disable:4996)
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wwrite-strings"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 200

int main() {

	char sInputString[MAX_STRING]="";
	char sInputNumber[MAX_STRING]="";
	char* psInput=NULL;
	int i=0;
	int j=0;
	long long nK=0;
	int nLen=0;
	int nLimit=0;
	int nAnswer=1;

	// read line 1
	gets(sInputString);
	nLen=strlen(sInputString);

	
	// read line2
	gets(sInputNumber);
	nK=atoll(sInputNumber);
	
	if(nK>nLen){
		nLimit=nLen;
	} else{
		nLimit=nK;
	}

	for(i=0;i<nLimit;i++){
		if(sInputString[i]!='1'){
			nAnswer=sInputString[i]-0x30;
			break;
		} else {
			
		}
	}

	printf("%d\n",nAnswer);

    return 0;
}


Measured memory_bytes: 1680
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = 2000000000;
// const ll MOD = 1000000007;

int a, b, c, d, e;
int k;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> a >> b >> c >> d >> e;
  cin >> k;

  if (e - a <= k) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }

  return 0;
}

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

using namespace std;

template< typename T >
struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x) {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;

struct UnionFind {
    vector< int > data;
    
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
    
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }
    
    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }
    
    int size(int k) {
        return (-data[find(k)]);
    }
};

template< typename T >
T kruskal(Edges< T > &edges, int V) {
    sort(begin(edges), end(edges), [](const edge< T > &a, const edge< T > &b) {
        return (a.cost < b.cost);
    });
    UnionFind tree(V);
    T ret = 0;
    for(auto &e : edges) {
        if(tree.unite(e.src, e.to)) ret += e.cost;
    }
    return (ret);
}

struct Point {
    int id, x, y;
};

int main(void) {
    int N;
    cin >> N;
    vector< Point > point(N);
    for(int i=0; i<N; i++) {
        point[i].id = i;
        cin >> point[i].x >> point[i].y;
    }

    Edges<int> G;

    sort(point.begin(), point.end(), [](auto &lhs, auto &rhs) {return lhs.x < rhs.x;});
    for(int i=1; i<N; i++) {
        int dist = point[i].x - point[i-1].x;
        G.emplace_back(point[i-1].id, point[i].id, dist);
    }

    sort(point.begin(), point.end(), [](auto &lhs, auto &rhs) {return lhs.y < rhs.y;});
    for(int i=1; i<N; i++) {
        int dist = point[i].y - point[i-1].y;
        G.emplace_back(point[i-1].id, point[i].id, dist);
    }

    cout << kruskal(G, N) << endl;
    return 0;
}


Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
int n,a[200],s;
int main(){
  cin>>n;
  for(int i=0;i<2*n;++i)cin>>a[i];
  sort(a,a+2*n);
  for(int i=0;i<n;++i)s+=a[i*2];
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
/*      Chill raho be kuch nhi rakha sadness me. 
               Author: Maskman_lucifer                   */
               
#include <bits/stdc++.h>   
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define pll pair<ll,ll>
#define pb push_back
#define M 1000000007
#define lc '\n'
using namespace std;
int main()
{
    IO
    ll h,w;
    cin>>h>>w;
    ll dp[h][w];
    char a[h][w];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(ll i=0;i<h;i++)
    {
        string s;
        cin>>s;
        for(ll j=0;j<s.length();j++)
        {
            a[i][j]=s[j];
        }
    }
    
    for(ll i=0;i<h;i++)
    {
        for(ll j=0;j<w;j++)
        {
            if(a[i][j]=='.')
            {
                if(i-1>=0 and a[i-1][j]=='.')
                {
                    dp[i][j]+=dp[i-1][j];
                    dp[i][j]%=M;
                }
                if(j-1>=0 and a[i][j-1]=='.')
                {
                    dp[i][j]+=dp[i][j-1];
                    dp[i][j]%=M;
                }
            }
        }
    }
    cout<<dp[h-1][w-1]<<lc;
    return 0;
}

Measured memory_bytes: 12456
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================



	ll N;
	cin >> N;
	vll T(N), A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> T[i] >> A[i];
	}

	ll choku = T[0];
	ll aoki = A[0];

	for (int i = 1; i < N; i++)
	{
		ll multi_T = (choku + T[i] - 1) / T[i];
		ll multi_A = (aoki + A[i] - 1) / A[i];

		ll multi = max(multi_A, multi_T);

		choku = T[i] * multi;
		aoki = A[i] * multi;
	}

	cout << aoki + choku << endl;










}





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

#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;


int main() {
  int a[3][3];
  REP(i,3){
    REP(j,3){
      cin >> a[i][j];
    }
  }
  
  int n;
  cin >> n;
  vector<vector<bool>> ok(3,vector<bool>(3,false));
  int b;
  REP(i,n){
    cin >> b;
    REP(j,3){
      REP(k,3){
        ok[j][k] = ok[j][k] | (a[j][k] == b);
      }
    }
  }
  
  bool res = false;
  
  REP(i,3){
    res |= ok[0][i] && ok[1][i] && ok[2][i];
    res |= ok[i][0] && ok[i][1] && ok[i][2];
  }
  
  res |= ok[0][0] && ok[1][1] && ok[2][2];
  
  res |= ok[0][2] && ok[1][1] && ok[2][0];
  if(res){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  vector<vector<int>> B(n+1, vector<int>(60));
  ll ans = 0;
  rep(i, n) {
    rep(j, 60) {
      (ans += ((A[i]>>j)&1 ? i-B[i][j] : B[i][j]) * ((1LL<<j) % mod)) %= mod;
      B[i+1][j] = B[i][j] + ((A[i]>>j)&1);
    }
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 87608
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int[][] s = new int[H+2][W+2];
		boolean able = true;
		for(int i = 1; i <= H; i++){
			String scan = sc.next();
			for(int j = 1; j <= W; j++){
				if(scan.charAt(j-1) == '#')
					s[i][j] = 1;
				else
					s[i][j] = 0;
			}
		}
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(s[i][j] == 1){
					if(s[i-1][j] == 0 && s[i+1][j] == 0 && s[i][j-1] == 0 && s[i][j+1] == 0)
						able = false;
				}
			}
		}
		System.out.println(able ? "Yes":"No");
	}

}

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

int main(void){
	ios::sync_with_stdio(false);
	int s, m, i, j, k;
	cin >> s;
	int a[1000000];
	a[0] = s;
	m = 0;
	for (i = 1; i < 1000000; i++) {
		if (a[i - 1] % 2 == 0) a[i] = a[i - 1] / 2;
		else a[i] = 3 * a[i - 1] + 1;
		for (j = 0; j < i; j++) {
			if (a[i] == a[j]) {
				m = i;
				break;
			}
		}
		if (m == i) break;
	}
	cout << m+1;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i,n,syakkin;

	scanf("%d",&n);
	syakkin=100000;
	for(i=0;i<n;i++){
		syakkin=syakkin*1.05+999;
		
		syakkin=(syakkin/1000)*1000;

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

	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

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

// 素集合データ構造
struct UnionFind
{
	// par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
	vector<int> par;
	// sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
	vector<ll> sizes;

	UnionFind(int n) : par(n), sizes(n, 1) {
		// 最初は全てのデータiがグループiに存在するものとして初期化
		for (int i = 0; i < n; i++) par[i] = i;
	}

	// データxが属する木の根を得る
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
	}

	// 2つのデータx, yが属する木をマージする
	void unite(int x, int y) {
		// データの根ノードを得る
		x = find(x);
		y = find(y);

		// 既に同じ木に属しているならマージしない
		if (x == y) return;

		// xの木がyの木より大きくなるようにする
		if (sizes[x] < sizes[y]) swap(x, y);

		// xがyの親になるように連結する
		par[y] = x;
		sizes[x] += sizes[y];
		sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// データxが含まれる木の大きさを返す
	int size(int x) {
		return sizes[find(x)];
	}
};


// value
int N, M;
vi A, B;

void solve() {

	cin >> N >> M;
	A.resize(M);
	B.resize(M);

	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
	}

	vl ans(M + 1);
	ans[M] = N * (N - 1LL) / 2LL;
	UnionFind data(N + 1);

	for (int i = M - 1; i >= 1; i--) {
		if (data.same(A[i], B[i])) {
			ans[i] = ans[i + 1];
		}
		else {
			ans[i] = ans[i + 1] - data.size(A[i]) * data.size(B[i]);
		}
		data.unite(A[i], B[i]);
	}

	for (int i = 1; i <= M; i++) {
		cout << ans[i] << endl;
	}

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 4096
# coding: utf-8
from math import ceil
from statistics import median, mean
N = int(input())
A = list(map(int, input().split()))
ans = 10**9
for m in range(-100, 101):
    tmp = 0
    for i in range(N):
        tmp += (A[i] - m)**2
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 5276
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s;
  cin >> s;
  char bef[2] = {0, 0};
  for (int i = 0, len = s.length(); i < len; i++) {
    if (bef[0] == s[i]) {
      cout << i - 1 << " " << i + 1 << endl;
      return 0;
    }
    else if (bef[1] == s[i]) {
      cout << i << " " << i + 1 << endl;
      return 0;
    }
    bef[0] = bef[1];
    bef[1] = s[i];
  }
  cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
# 問題を意訳するとai、biの出現回数をカウントするのが目的
import numpy as np
N,M = map(int,input().split())
ab = [list(map(int,input().split())) for __ in range(M)]

ab = np.array(ab).flatten()
for i in range(1,N+1):
    print(len(np.where(ab == i)[0]))

Measured memory_bytes: 12500
a = map(int,raw_input().split(" "))
b = a[0]
c = a[1]
d = a[2]
cnt = 3
if b == c:
    cnt = cnt -1
if b == d:
    cnt = cnt -1
if c == d:
    cnt = cnt -1
if c == d and c == b and b == d:
    cnt = cnt + 1
print cnt


Measured memory_bytes: 2568
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1e9 + 7;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    x = 1 - x;
    cout << x;
    //
    return 0;
}

Measured memory_bytes: 3160
*t,=map(int,open(0).read().split())
a=t[:9]
s={10}
for b in t[10:]:
  if b in a:s|={a.index(b)}
print('NYoe s'[any(s>={i*3,i*3+1,i*3+2}or s>={i,i+3,i+6}for i in(0,1,2))or s>={0,4,8}or s>={2,4,6}::2])

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int n, j = 0, l = 0;
long long ans = 0;
int a[100010], b[100010], c[100010];
long long ac[100010] = { 0 };
long long bc[100010] = { 0 };
int main() {
	cin >> n;
	for (int a1 = 0; a1 < n; a1++) {
		cin >> a[a1];
	}
	for (int b1 = 0; b1 < n; b1++) {
		cin >> b[b1];
	}
	for (int c1 = 0; c1 < n; c1++) {
		cin >> c[c1];
	}
	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);
	for (int i = 0; i < n; i++) {
		for (;; j++) {
			if (j == n || b[i] <= a[j]) {
				ac[i] += ac[i - 1];
				break;
			}
			else {
				ac[i]++;
			}
		}
	}
	for (int k = 0; k < n; k++) {
		for (;; l++) {
			if (l == n || c[k] <= b[l]) {
				bc[k] += bc[k - 1];
				break;
			}
			else {
				bc[k] += ac[l];
			}
		}
	}
	for (int m = 0; m < n; m++) {
		ans += bc[m];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3072
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        right = bisect_left(L, a+b, j+1, N) - 1
        ans += right - j
print(ans)

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

int main(void)
{
	static char prime[1000001];
    static char ok[1000001];
	int i, j;
	int n, t;
    int a[30];
    int max;
	
	for (i = 3; i <= 1000000; i += 2){
		prime[i] = 1;
	}
	prime[2] = 1;
	
	for (i = 3; i <= 1000; i += 2){
		if (prime[i] == 1){
			for (j = 3; j <= 1000000 / i; j += 2){
				prime[i * j] = 0;
			}
		}
	}
	
	while (1){
        scanf("%d%d", &t, &n);
		
        if (t + n == 0){
            break;
        }
        
        for (i = 0; i < t; i++){
            scanf("%d", &a[i]);
        }
        
        memset(ok, 0, sizeof(ok));
        ok[0] = 1;
        max = -100;
        for (i = 0; i < t; i++){
            for (j = 0; j + a[i] <= n; j++){
                if (ok[j] != 0){
                    ok[j + a[i]] = ok[j];
                    if (j + a[i] > max && prime[j + a[i]]){
                        max = j + a[i];
                    }
                }
            }
        }
        
        if (max != -100){
		    printf("%d\n", max);
        }
        else {
            printf("NA\n");
        }
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;

int n;
double dp[301][301][301];
bool used[301][301][301];

double solve(int a,int b,int c){
    if(a+b+c==0)return 0;
    if(used[a][b][c])return dp[a][b][c];
    used[a][b][c]=1;
    double res=1;
    if(a){
        res+=solve(a-1,b,c)*(1.0*a/(double)n);
    }
    if(b){
        res+=solve(a+1,b-1,c)*(1.0*b/(double)n);
    }
    if(c){
        res+=solve(a,b+1,c-1)*(1.0*c/(double)n);
    }
    res*=(1.0*n/(double)(a+b+c));
    return dp[a][b][c]=res;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n;
    int a[3]={};
    for(int i=0;i<n;i++){
        int x; cin >> x;
        a[x-1]++;
    }
    printf("%.9f\n",solve(a[0],a[1],a[2]));
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

int main(){
	int n; cin >> n;
	rep(i,n){
		int x;
		cin >> x;
		if(x%2==0){
			if(x%3!=0 && x%5!=0){
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" <<endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007

char change(int a){
	if(a<26)return a+'a';
	if(a==26)return '.';
	if(a==27)return '?';
	if(a==28)return '!';
	if(a==29)return ' ';
	return '\0';
}



int main(){
	int a,b;
	string s;
	char c;
	while(cin>>s){
		string t;
		bool f=true;
		if(s.size()%2!=0)f=false;
		else{
			for(int i=0; i<s.size(); i+=2){
				a=s[i]-'1';
				b=s[i+1]-'1';
				if(a>5||b>4||a<0||b<0){
					f=false;
					break;
				}
				t+=change(a*5+b);
			}
		}
		cout<<(f?t:"NA")<<endl;
	}
	
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main()
{
    int n,m,i,j,k=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%2!=0)
        {
            k++;
        }
    }
    printf("%.12lf",(k*1.0)/(n*1.0));
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    int[] array = {a,b,c};
    Arrays.sort(array);
    
    String result = "No";
    if(array[2] == (array[0]+array[1])){
      result = "Yes";
    }
	
    System.out.println(result);
  }
}

Measured memory_bytes: 21844
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()

class UnionFind(object):
    def __init__(self, n, recursion = False):
        self._par = list(range(n))
        self._size = [1] * n
        self._recursion = recursion

    def root(self, k):
        if self._recursion:
            if k == self._par[k]:
                return k
            self._par[k] = self.root(self._par[k])
            return self._par[k]
        else:
            root = k
            while root != self._par[root]: root = self._par[root]
            while k != root: k, self._par[k] = self._par[k], root
            return root

    def unite(self, i, j):
        i, j = self.root(i), self.root(j)
        if i == j: return False
        if self._size[i] < self._size[j]: i, j = j, i
        self._par[j] = i
        self._size[i] += self._size[j]
        return True

    def is_connected(self, i, j):
        return self.root(i) == self.root(j)

    def size(self, k):
        return self._size[self.root(k)]

def resolve():
    n, m = map(int, input().split())
    uf = UnionFind(n)

    for _ in range(m):
        u, v = map(int, input().split())
        u -= 1; v -= 1
        uf.unite(u, v)

    print(max(uf.size(v) for v in range(n)))
resolve()

Measured memory_bytes: 73212
#include <cstdio>
int main(){
    int a, b, c;
    scanf("%d%d%d",&a,&b,&c);
    if(a>=b){
        if(c<=b){
            printf("%d %d %d\n",c,b,a);
        }else{
            if(a>=c){
                printf("%d %d %d\n",b,c,a);
            }else{
                printf("%d %d %d\n",b,a,c);
            }
        }
    }else{
        if(c<=a){
            printf("%d %d %d\n",c,a,b);
        }else{
            if(b>=c){
                printf("%d %d %d\n",a,c,b);
            }else{
                printf("%d %d %d\n",a,b,c);
            }
        }
    }
    return 0;
}


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

typedef long long i64;
i64 a[100010], b[100010];
i64 add;

int main()
{
    int n;
    cin >> n;
    for (int i(1); i <= n; i++)
        cin >> a[i] >> b[i];

    for (int i(n); i >= 1; i--)
        add += (b[i] - (a[i] + add) % b[i]) % b[i];

    cout << add;
    return 0;
}


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

vector<P>E[100000];
ll d[100000];
void dfs(int v,int p){
	for(P u:E[v]){
		if(u.second!=p){
			d[u.second]=d[v]+u.first;dfs(u.second,v);
		}
	}
}
int main(){
	int n;scanf("%d",&n);
	rep(i,n-1){
		int a,b,c;scanf("%d%d%d",&a,&b,&c);a--;b--;
		E[a].push_back(P(c,b));E[b].push_back(P(c,a));
	}
	int q,k;scanf("%d%d",&q,&k);k--;
	dfs(k,-1);
	rep(i,q){
		int x,y;scanf("%d%d",&x,&y);x--;y--;
		printf("%lld\n",d[x]+d[y]);
	}
}

Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int x1,y1,x2,y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int a = x2 - x1;
	int b = y2 - y1;
	int x3 = x2 - b;
	int y3 = y2 + a;
	int x4 = x3 - a;
	int y4 = y3 - b;
	cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << "\n";
	return 0;
}

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

int main(){
	int a, b, c, x, ans = 0;
	scanf("%d%d%d%d", &a, &b, &c, &x);
	for(int i = 0;i <= a;i++){
		for(int j = 0;j <= b;j++){
			for(int k = 0;k <= c;k++){
				if(i*500+j*100+k*50 == x)ans++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
  ll l, r;
  cin >> l >> r;
  ll ans = 10000;
  for(ll i=l; i <= l+2020; i++){
    if(i==r) break;
    for(ll j=l+1; j <= l+2021; j++){
      ans = min(ans, (i*j)%2019);
      if(j == r) break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
n, k = map(int, input().split())
a = []
for i in range(k):
    d = int(input())
    a.append(list(map(int, input().split())))

listn = []
for i in range(n):
    listn.append(i+1)

for i in range(len(a)):
    a_ex = a[i]
    for j in range(len(a_ex)):
        if (a_ex[j] in listn):
            listn.remove(a_ex[j])

print(len(listn))

Measured memory_bytes: 9148
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int a,b;
  cin >> a >> b;
  cout << 6 - a - b << endl;
  return 0;
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

struct UnionFind {
  std::vector<int> par, rank;

  UnionFind(int n) : par(n , -1), rank(n, 0) {}

  void init(int n) {
    par.assign(n, -1); rank.assign(n, 0);
  }

  int root(int x) {
    if (par[x] == -1) return x;
    else return par[x] = root(par[x]);
  }

  bool issame(int x, int y) {return root(x) == root(y);}

  void unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return;
    if (rank[x] < rank[y]) std::swap(x, y);
    if (rank[x] == rank[y]) ++rank[x];
    par[y] = x;
    return;
  }
};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m; cin >> n >> m;
  vector<int> x(m), y(m), z(m);
  for (int i = 0; i < m; ++i) cin >> x[i] >> y[i] >> z[i];

  UnionFind uf(n);

  for (int i = 0; i < m; ++i){
    uf.unite(x[i] - 1, y[i] - 1);
  }

  set<int> st;
  for (int i = 0; i < n; ++i){
    st.insert(uf.root(i));
  }
  print((int) st.size());

  return 0;
}

Measured memory_bytes: 6912
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abc095_c();
	}

  
  	public static void solve_abc095_c(){

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		
		int ans_a = 0;
		int ans_b = 0;
		int ans_ab = 0;
		int ans_price = 0;

		int tmp_ans_a = 0;
		int tmp_ans_b = 0;
		int tmp_ans_ab = 0;
		int tmp_ans_price = 0;

		// all a & all b
		tmp_ans_a = X;
		tmp_ans_b = Y;
		tmp_ans_ab = 0;
		tmp_ans_price = A * tmp_ans_a + B * tmp_ans_b + C * tmp_ans_ab;
		
		ans_price = tmp_ans_price;
		
		// ab & a
		if(X > Y){
			tmp_ans_a = X -Y;
			tmp_ans_b = 0;
			tmp_ans_ab = Y * 2;
			tmp_ans_price = A * tmp_ans_a + B * tmp_ans_b + C * tmp_ans_ab;
			
			ans_price = Math.min(ans_price, tmp_ans_price);
		}
		// ab & b
		else if(X < Y){
			tmp_ans_a = 0;
			tmp_ans_b = Y - X;
			tmp_ans_ab = X * 2;
			tmp_ans_price = A * tmp_ans_a + B * tmp_ans_b + C * tmp_ans_ab;

			ans_price = Math.min(ans_price, tmp_ans_price);
		}
		
		// all ab
		tmp_ans_a = 0;
		tmp_ans_b = 0;
		tmp_ans_ab = Math.max(X, Y) * 2;
		tmp_ans_price = A * tmp_ans_a + B * tmp_ans_b + C * tmp_ans_ab;

		ans_price = Math.min(ans_price, tmp_ans_price);
		
		System.out.println(ans_price);
		
		sc.close();

	}
}

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

void solve() {
    string a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = 0; i < 3; i++)
        ans += (a[i] == b[i]);
    cout << ans;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int a,b,k;
	cin>>a>>b>>k;
	vector<int> v;
	for(int i=0;i<k;i++){
		if(a+i>b||b-i<a) continue;
		v.push_back(a+i),v.push_back(b-i);	
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	for(int i=0;i<v.size();i++) cout<<v[i]<<"\n";
	return 0;
}

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

using namespace std;
typedef long long ll;
const int MOD=1e9+7;

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

  int n;cin>>n;
  ll res=1;
  for(int i=1;i<=n;i++)res=(res*i)%MOD;
  cout<<res<<endl;
}


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

int main(){
    string S, SS;

    cin >> S;
    SS = S;
    reverse(SS.begin(), SS.end());

    if(SS.compare(S) != 0){
        cout << "No\n";
        return 0;
    }
    string subL = S.substr(0, S.size()/2);
    string subR = S.substr(S.size()/2+1, S.size()/2);
    string rL, rR;
    rL = subL;
    rR = subR;
    reverse(rL.begin(), rL.end());
    reverse(rR.begin(), rR.end());
    
    if(subL.compare(rL)==0 && subR.compare(rR)==0){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }

    // cout << subL << endl;
    // cout << subR << endl;

    return 0;
}

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


int main()
{
  int N,L;
  scanf("%d %d", &N, &L);
  char text[100][101],senten[10001],tem[101];
  int i,j;
  
  
  for(i=0; i<N; i++)
  {
   scanf("%s",text[i]); 
  }
  
  for(i=1; i<N; i++)
  {
   for(j=i; j<N; j++)
   {
     if(strcmp(text[i-1], text[j]) > 0)
     {
       strcpy(tem, text[j]);
       strcpy(text[j], text[i-1]);
       strcpy(text[i-1], tem);
     }
   }
  }
  for(i=0; i<N; i++)
  {
  	strcat(senten, text[i]);
  }
  
  printf("%s",senten );
  return 0;
}


Measured memory_bytes: 128
n = int(input())
a = [0] + [int(input()) for _ in range(n)]
s, i, ans = set([1]), a[1], 1
while(i != 2):
    if(not a[i] in s):
        s.add(a[i])
        i = a[i]
        ans += 1
    else:
        ans = -1
        break
print(ans)

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

using vc = std::vector<char>;
using vvc = std::vector<vc>;

using vi = std::vector<long long>;

long long solve()
{
	int H, W;
	scanf("%d%d", &H, &W);
	vvc area(H + 2, vc(W + 2));
	for (int i{}; i < H + 2; i++)
		area[i][0] = area[i][W + 1] = '#';
	for (int i{}; i < W + 2; i++)
		area[0][i] = area[H + 1][i] = '#';
	
	int start[2], goal[2];
	for (int i{1}; i <= H; i++)
		for (int j{1}; j <= W; j++)
		{
			scanf(" %c", &area[i][j]);	
			if (area[i][j] == 'S')
			{
				start[0] = i;
				start[1] = j;
			}
			if (area[i][j] == 'G')
			{
				goal[0] = i;
				goal[1] = j;
			}
		}

	int N;
	scanf("%d", &N);
	int time{1};
	std::vector<vi> pre(H + 2, vi(W + 2, 1ll << 30));
	pre[start[0]][start[1]] = 0;
	int dir[4][2]{{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
	long long min{1ll << 30};
	for (int n_i{}; n_i < N; n_i++)
	{
		int T;
		scanf("%d", &T);
		for (; time < T; time++)
		{
			std::vector<vi> distance(H + 2, vi(W + 2, 1 << 30));
			for (int i{1}; i <= H; i++)
				for (int j{1}; j <= W; j++)
				{
					if (area[i][j] == '#') continue;
					distance[i][j] = pre[i][j];
					for (int k{}; k < 4; k++)
						distance[i][j] = std::min(distance[i][j], pre[i + dir[k][0]][j + dir[k][1]] + 1);
				}
			min = std::min(min, distance[goal[0]][goal[1]]);
			std::swap(distance, pre);
		}
		for (int h_i{1}; h_i <= H; h_i++)
			for (int w_i{1}; w_i <= W; w_i++)
				scanf(" %c", &area[h_i][w_i]);
	}
	for (int i{}; i < 500; i++)
	{
		std::vector<vi> distance(H + 2, vi(W + 2, 1 << 30));
		for (int i{1}; i <= H; i++)
			for (int j{1}; j <= W; j++)
			{
				if (area[i][j] == '#') continue;
				distance[i][j] = pre[i][j];
				for (int k{}; k < 4; k++)
					distance[i][j] = std::min(distance[i][j], pre[i + dir[k][0]][j + dir[k][1]] + 1);
			}
		min = std::min(min, distance[goal[0]][goal[1]]);
		std::swap(distance, pre);
	}

	if (min == (1ll << 30)) return -1;
	else return min;
}

int main()
{
	printf("%lld\n", solve());
	return 0;
}


Measured memory_bytes: 3304
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,x,y;
    long long ans=0;
    ios::sync_with_stdio(false);
    cin>>n>>k>>x>>y; 
    for(int i=1;i<=n;++i){
        if(i<=k){
            ans+=x; 
        }             
        if(i>k){
            ans+=y;
        }
    }
    cout<<ans<<"\n";  
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<deque>
#include<stack>
#include<map>
#include <random>
#include<queue>
#include<iterator>
#include <bitset>
#include <unordered_set>
#include<set>

using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
const ll integer = pow(2, 32) - 1; // 4294967295
#define N 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
void AIA() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
//cout<<fixed<<setprecision(20);
// freopen("stand.in","r",stdin);
// freopen("stand.out","w",stdout);

/*
 _____________              __                ___        ___       ___________________________     ____        ____
|             |            /\ \              |   |      |   |     |                           |    \   \      /   /
|   __________|           / /\ \             |   |      |   |     |      _____      _____     |     \   \    /   /
|  |                     / /  \ \            |   |      |   |     |     |     |    |     |    |      \   \  /   /
|  |                    / /    \ \           |   |      |   |     |     |     |    |     |    |       \   \/   /
|  |______             / /      \ \          |   |______|   |     |     |     |    |     |    |        \      /
|         |           / /        \ \         |              |     |     |     |    |     |    |         \    /
|   ______|          / /          \ \        |    ______    |     |     |     |    |     |    |          |  |
|  |                / /============\ \       |   |      |   |     |     |     |    |     |    |          |  |
|  |               / /==============\ \      |   |      |   |     |     |     |    |     |    |          |  |
|  |              / /                \ \     |   |      |   |     |     |     |    |     |    |          |  |
|  |             / /                  \ \    |   |      |   |     |     |     |    |     |    |          |  |
|__|            /_/                    \_\   |___|      |___|     |_____|     |____|     |____|          |__|

										  <<<<<<<<<<< NEVER GIVE UP !! >>>>>>>>>>>
										<<<<<<<< YOU CAN DO IT IF YOU WANT !! >>>>>>>>
										 <<<<<<<<< BELIEVE IN YOURSELF !! >>>>>>>>>

*/
string tis(int n) {
	string num="";
	while (n > 0) {
		num = char((n % 10)+'0') + num;
		n /= 10;
	}
	return num;
}
ll tin(string s) {
	ll re = 0;
	for (int i = 0; i < s.size(); i++) {
		re *= 10;
		re += int(s[i] - '0');
	}
	return re;
}
const ll ex = 1e18;
int main()
{
	//cout << fixed << setprecision(6);
	//freopen("stand.in","r",stdin);
	//freopen("stand.out","w",stdout);
	AIA();
	unsigned ll a, c;
	long double b;
	cin >> a >> b;
	c = a * b;
	cout << c;
	return 0;
}

Measured memory_bytes: 3788
#include <stdio.h>
int main(void){
  int i;
  long long int a,b,c,k,w;
  w=0;
  scanf("%lld",&a);
  scanf("%lld",&b);
  scanf("%lld",&c);
  scanf("%lld",&k);

  for(i=0;i<k;i++){
    if(a>0){
      w++;
      a--;
    }else if(b>0){
      b--;
    }else if(c>0){
      w=w-1;
    }
  }
  printf("%lld",w);
  return 0;
  }

Measured memory_bytes: 1736