akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1000000007;

const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

//********************************template END****************************************//

void solve(void)
{
	int N, M;
	cin >> N >> M;

	mat m(N);

	vec ps(M), ys(M);

	rep(M, i)
	{
		cin >> ps[i] >> ys[i];
		m[ps[i]-1].pb(ys[i]);
	}

	map<int, int> mp[N];

	rep(N, i)
	{
		sort(all(m[i]));
		int cnt = 1;
		for (int v : m[i])
		{
			mp[i][v] = cnt++;
		}
	}

	rep(M, i)
	{
		printf("%06d", ps[i]);
		printf("%06d\n", mp[ps[i]-1][ys[i]]);
	}

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

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

using namespace std;
using ll = long long;

struct UnionFind{
    vector<int> d;
    UnionFind(int n=0): d(n,-1){}
    int find(int x) {
        if(d[x] < 0) return x;
        return find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y])  swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

int deg[100005];
vector<int> to[100005];

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

    int n,m,k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a;--b;
        deg[a]++;
        deg[b]++;
        uf.unite(a,b);
    }
    rep(i,k) {
        int a,b;
        cin >> a >> b;
        --a;--b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i,n){
        int ans = uf.size(i)-1-deg[i];
        for(int u : to[i]) {
            if(uf.same(i,u)) --ans;
        }
        printf("%d%c",ans,i==n-1?'\n':' ');
    }

    return 0;
}

Measured memory_bytes: 6784
import fractions

N,K = map(int,input().split())
A = list(map(int,input().split()))
M = max(A)

if N == 1:
    if A[0] == K:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    G = A[0]
    for i in range(1,N):
        G = fractions.gcd(A[i],G)
    if K <= M and K % G == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Measured memory_bytes: 16236
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    double a,b,c,d=0,e=0;
    cin>>a>>b>>c;
    if(a>b && a>c){
            a=(c*b)/2;
            cout<<a;
    }
    if(b>a && b>c){
            b=(a*c)/2;
            cout<<b;
    }
    if(c>a && c>b){
            c=(a*b)/2;
            cout<<c;
    }
    return 0;
}


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

int main() {
		
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int leftA = a[0];
	int rightA = a[n - 1];
	int ans = 2147483647;
	for (int j = leftA; j <= rightA; j++) {
		int tmpSum = 0;
		for (int i = 0; i < n; i++) {
			tmpSum += (a[i] - j) * (a[i] - j);
		}
		ans = min(ans, tmpSum);
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    int n,k;
    string s;
    cin >> n >> s >> k;
    char c=s[k-1];
    for(int i=0;i<n;i++){
        if(s[i]==c) cout << c;
        else cout << '*';
    }
    cout << endl;
    return 0;
}











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

using pii = pair<int, int>;
using ll  = long long;
#define rep(i, j) for (int i = 0; i < (int)(j); i++)
#define repeat(i, j, k) for (int i = (j); i < (int)(k); i++)
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " : " << x << endl

template <class T>
bool set_min(T &a, const T &b) {
    return a > b ? a = b, true : false;
}

template <class T>
bool set_max(T &a, const T &b) {
    return a < b ? a = b, true : false;
}
// vector
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &a : v) is >> a;
    return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &t : v) os << "\t" << t;
    return os << endl;
}
// pair
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &v) {
    return os << "<" << v.first << ", " << v.second << ">";
}

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    cin >> A;

    ll ans = 0;
    map<ll, ll> cnt;
    for (int i = N - 1; i >= 0; i--) {
        ans += cnt[i + A[i]];
        cnt[i - A[i]]++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 27388
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		
		//?????°
		int num = Integer.parseInt(bf.readLine());
		
		//??????????´?
		int[] array = new int[num];
		
		//?????????
		String[] arrayString = bf.readLine().split(" ");
		
		for(int i=0;i<num;i++){
			array[i]=Integer.parseInt(arrayString[i]);
		}		
		selectionSort(array,num);
	}
	
	private static void selectionSort(int[] array, int num) {
		int count=0;
		for(int i=0;i<num;i++){
			int min=i;
			for(int j=i;j<num;j++){
				if(array[j]<array[min]){
					min=j;
				}
			}
			if(min!=i){
			int tmp=array[i];
			array[i]=array[min];
			array[min]=tmp;
			count++;
			}
		}
		
		for(int i=0;i<array.length;i++){
			System.out.printf("%d",array[i]);
			if(i!=array.length-1){
				System.out.printf(" ");
			}
		}
		System.out.println("");
		System.out.println(count);
	}
}

Measured memory_bytes: 24680
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    double L;
    cin >> L;

    double a = L / 3.0;
    double ans = a * a * a;

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(i);
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	ll n;
	cin>>n;
	ll x = n;
	ll cnt = 0;
	int y;
	int z;
	int flag=-1;
	if(x>=500)
	{
		 y = x%500;
		 z = x/500;
		 cnt = cnt+(z*1000);
		 flag=1;
	}
	if(y>=5 && flag==1)
	{
		 cnt = cnt+((y/5)*5);
	}
	else if(flag==-1)
	{
		cnt = cnt + ((x/5)*5);
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif

const unsigned BITS_WIDTH = 1e+5 + 10;
typedef std::bitset<BITS_WIDTH> Animals;

#ifdef __DEBUG__
std::ostream& operator<<(std::ostream &os, const Animals &a)
{
  os << a.to_string();
  return os;
}
#endif

bool search(unsigned N, const std::string &s, Animals &result)
{
  std::vector<Animals> dp[2];
  dp[0] = std::vector<Animals>();
  dp[1] = std::vector<Animals>();
  
  for (unsigned i = 0; i < 4; ++i) {
    dp[0].emplace_back(3 - i);
  }
  
  for (unsigned n = 1; n <= N; ++n) {
    for (const Animals &a : dp[(n - 1) % 2]) {
      Animals b(a);
      if (s[n - 1] == 'o') {
        b[n + 1] = a[n] ?  a[n - 1] : !a[n - 1];
      } else {
        b[n + 1] = a[n] ? !a[n - 1] :  a[n - 1];
      }
      dp[n % 2].push_back(b);
    }
    
    if ((n + 1) <= N) dp[(n - 1) % 2].clear();
  }
  
  N_TIMES(i, 4) {
    if (
      (dp[N % 2][i][0] == dp[N % 2][i][N + 0])
      &&
      (dp[N % 2][i][1] == dp[N % 2][i][N + 1])
    ) {
      result = Animals(dp[N % 2][i]);
      return true;
    }
  }
  
  return false;
}

int main()
{
  unsigned N;
  std::cin >> N;
  
  std::string s;
  std::cin >> s;
  
  Animals a;
  if (!search(N, s, a)) {
    std::cout << -1 << std::endl;
  } else {
    for (unsigned n = 1; n <= N; ++n) {
      std::cout << (a[n] ? 'S' : 'W');
    }
    std::cout << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B > C + D) {
        cout << "Left" << endl;
    } else if (A + B < C + D) {
        cout << "Right" << endl;
    } else {
        cout << "Balanced" << endl;
    }
    return 0;
}

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

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

const int sqn = 710;
const int maxn = 5e5;

int n, q;
vector<int> c(maxn + 1, 0);
vector<int> ans(maxn + 1, 0);
vector<int> freq(maxn + 1, 0);
vector<vector<int>> queries(maxn + 1, vector<int>(3, 0));

class myComp {
public:
	bool operator()(const vector<int>& a, const vector<int>& b) {
		// if ((a[0] / sqn) == (b[0] / sqn)) return a[1] < b[1];
		// return a[0] < b[0];
		if (a[0] / sqn != b[0] / sqn)
			return a[0] < b[0];
		return a[0] / sqn % 2 ? a[1] < b[1] : a[1] > b[1];

	}
};

int main() {

	cin >> n >> q;
	for (int i = 0; i <= n - 1; i++) cin >> c[i];
	for (int i = 0; i <= q - 1; i++) cin >> queries[i][0] >> queries[i][1], queries[i][0]--, queries[i][1]--, queries[i][2] = i;

	sort(queries.begin(), queries.begin() + q, myComp());

	int beg = 0, en = 1, cnt = 0;
	freq[c[0]]++;
	cnt = 1;

	for (int i = 0; i <= q - 1; i++) {
		int l = queries[i][0], r = queries[i][1];
		while (en <= r) {
			freq[c[en]]++;
			if (freq[c[en]] == 1) cnt++;
			en++;

		}

		while (beg < l) {
			freq[c[beg]]--;
			if (freq[c[beg]] == 0) cnt--;
			beg++;
		}

		while (beg > l) {
			beg--;
			freq[c[beg]]++;
			if (freq[c[beg]] == 1) cnt++;
		}

		while (en > r + 1) {
			en--;
			freq[c[en]]--;
			if (freq[c[en]] == 0) cnt--;
		}
		ans[queries[i][2]] = cnt;

	}

	for (int i = 0; i <= q - 1; i++) cout << ans[i] << '\n';
	return 0;
}

Measured memory_bytes: 36988
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin >> n;
    ll ans = n*(n-1)/2;
    cout << ans << endl;
    return 0;
}

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

int main(void)
{
    int pxi, pyi;
    int n;
    int sx[10], sy[10];
    int pn;
    int px[10], py[10];
    int pn_next;
    int px_next[10], py_next[10];
    int map[10][10];
    int si, pi;
    int i, j, k;
    int dx[] = {-2, -2, -2, -1,  0,  1,  2, 2, 2, 1, 0, -1};
    int dy[] = { 1,  0, -1, -2, -2, -2, -1, 0, 1, 2, 2,  2};

    
    while (1){
        
        // 入力
        scanf("%d%d", &pxi, &pyi);
        if (pxi== 0 && pyi == 0){
            break;
        }

        scanf("%d", &n);
        for (i = 0; i < n; i++){
            scanf("%d%d", &sx[i], &sy[i]);
        }
        
        //　初期設定
        px[0] = pxi;
        py[0] = pyi;
        pn = 1;
        memset(map, -1, sizeof(map));

        
        for (si = 0; si < n; si++){     // スプリンクラー毎のループ

            // 散水領域をマーク
            for (i =  sy[si] - 1; i <= sy[si] + 1; i++){
                for (j =  sx[si] - 1; j <= sx[si] + 1; j++){
                    if (0 <= i && i <= 9 && 0 <= j && j <= 9){
                        map[i][j] = si;
                    }
                }
            }

            pn_next = 0;                // 飛び先数を初期化

            for (pi = 0; pi < pn; pi++){
//printf("(px=%d, py=%d)", px[pi], py[pi]);
                for (i = 0; i < 12; i++){ // 12通りの飛び先を試す
                    if (0 <= px[pi] + dx[i] && px[pi] + dx[i] <= 9 &&
                        0 <= py[pi] + dy[i] && py[pi] + dy[i] <= 9){
                            
                                        // とんだ先がスプリンクラーの範囲か
                        if (map[py[pi] + dy[i]][px[pi] + dx[i]] == si){
                            px_next[pn_next] = px[pi] + dx[i];
                            py_next[pn_next] = py[pi] + dy[i];
                            pn_next++;
                            map[py[pi] + dy[i]][px[pi] + dx[i]] = 0;
//printf("<%d=%d,%d >", si, px[pi] + dx[i], py[pi] + dy[i]);
                        }
                    }
                }
            }
//printf("\n");
            if (pn_next == 0){     // 飛べたか
                break;
            }
            pn = pn_next;
            memcpy(px, px_next, sizeof(px_next));
            memcpy(py, py_next, sizeof(py_next));
        }
        if (si == n){
            printf("OK\n");
        }
        else {
            printf("NA\n");
        }
    }
    
    return (0);
}

Measured memory_bytes: 584
import Control.Applicative
import Data.List

addSum :: [Int] -> [Int]
addSum list = list ++ [(sum list)]

main = do{
    n <- getLine;
    s <- map (unwords . map show) . transpose . map addSum . transpose . map ( addSum . map (read::String->Int)) . map words . lines <$> getContents;
    mapM_ putStrLn $ s;
}

Measured memory_bytes: 8160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int A, B;
const int w = 100, h = 100;
int grids[w][h];

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

  int nw = 1, nb = 1;
  for(int i = 50; i < w; i++) {
    rep(j,h) grids[i][j] = 1;
  }

  for(int i = 1; i < 50; i += 2) {
    for(int j = 1; j < h; j += 2) {
      if(nb == B) break;
      grids[i][j] = 1;
      nb++;
    }
  }

  for(int i = 51; i < w; i += 2) {
    for(int j = 1; j < h; j += 2) {
      if(nw == A) break;
      grids[i][j] = 0;
      nw++;
    }
  }

  printf("%d %d\n", w, h);
  rep(i,w) {
    rep(j,h) {
      cout << (grids[i][j] ? "#" : ".");
    }
    cout << endl;
  }

  return 0;
}


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

using namespace std;
int N, A, B;
int P[101];

int main() {
   cin >> N >> A >> B;
   int q1 = 0;
   int q2 = 0;
   int q3 = 0;
   for (int i = 0; i < N; i++) {
      cin >> P[i];
      if (P[i] <= A) q1++;
      else if (P[i] <= B) q2++;
      else q3++;
   }
   cout << min(min(q1, q2), q3) << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

int main(){
	string s;
	cin >> s;
	for(int i=0; i<s.size(); i++){
		for(int j=i+1; j<s.size(); j++){
			if(s[i] == 'C' && s[j] == 'F'){
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
const ll mod = 1e9 + 7;
ll inf = 1e16;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)

struct all{
	ll a,b,c;
};
void solve()
{



}

int main()
{
   fastio;
   ll n;
   cin>>n;
   all arr[n];
   for(int i=0;i<n;++i){
   	cin>>arr[i].a>>arr[i].b>>arr[i].c;
   }
   all dp[n+1];
   dp[0].a = dp[0].b = dp[0].c = 0;
   for(int i=1;i<=n;++i){
   	   dp[i].a = arr[i-1].a + max(dp[i-1].b, dp[i-1].c);
   	   dp[i].b = arr[i-1].b + max(dp[i-1].a, dp[i-1].c);
   	   dp[i].c = arr[i-1].c + max(dp[i-1].a , dp[i-1].b);
   }
   cout<<max(dp[n].a, max(dp[n].b , dp[n].c))<<endl;
   
   return 0;
}



Measured memory_bytes: 8340
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let a = io.read::<char>();
    io.writeln(if a.is_lowercase() { "a" } else { "A" });
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


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

int cmp(const void *a, const void *b){
	return strcmp(*(char**)a, *(char**)b);
}

int main(void){
	char **str;
	int n, l;
	scanf("%d %d", &n, &l);
	str = malloc(sizeof(char*) * n);
	for(int i = 0; i < n; i++){
		str[i] = malloc(sizeof(char) * (l + 5));
		scanf("%s", str[i]);
	}
	qsort(str, n, sizeof(char*), cmp);
	for(int i = 0; i < n; i++)
		printf("%s", str[i]);
	putchar('\n');
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = 998244353;
const int MX = (int)2e5;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int n;
	cin >> n;
	cout << (1000 - (n % 1000)) % 1000 << endl;
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> P;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
#define MAX 100000


int main(){
   char a;
   cin>>a;

   if(isupper(a))cout<<'A';
   else cout<<'a';
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,y,a,b,c;cin>>x>>y>>a>>b>>c;
    vector<int> v1(a),v2(b),v3(c);
    for(int &i:v1) cin>>i; 
    for(int &i:v2) cin>>i; 
    for(int &i:v3) cin>>i;
    sort(v1.rbegin(),v1.rend());
    sort(v2.rbegin(),v2.rend());
    for(int i=0;i<x;i++) v3.push_back(v1[i]);
    for(int i=0;i<y;i++) v3.push_back(v2[i]);
    sort(v3.rbegin(),v3.rend());
    cout<<accumulate(v3.begin(),v3.begin()+x+y,0LL);
    return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n; std::cin >> n;
  vi route(n); rep(i, n) route[i] = i;
  vector<pi> points;
  rep(i, n) {
    int x, y; std::cin >> x >> y;
    points.pb({x, y});
  }
  double ans = 0;
  int pn = 0;
  do {
    double tmp = 0;
    srep(i, 1, n) {
      int dx = points[route[i-1]].fi-points[route[i]].fi,
          dy = points[route[i-1]].se-points[route[i]].se;
      dx *= dx, dy *= dy;
      tmp += sqrt(dx + dy);
    }
    ans += tmp;
    pn++;
  } while (next_permutation(rng(route)));
  std::cout << ans / pn << "\n";
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	auto n = readln.chomp.to!int;
	auto ans = new int[6];

	foreach (_; 0..n) {
		auto x = readln.chomp.to!double;
		foreach (i, a; iota(165, 195, 5).array) {
			if (x < a) {
				ans[i]++;
				break;
			}
		}
	}

	foreach (i, a; ans) {
		writeln(i+1, ":", a.iota.map!(b=>"*").join);
	}
}

Measured memory_bytes: 1076
import sys
from collections import deque
from itertools import product

read = sys.stdin.read
readline = sys.stdin.readline

H, W = map(int, readline().split())
S = [list(readline()) for i in range(H)]


def bfs(grid, start):
    distance = [[-1] * W for _ in range(H)]
    queue = deque([start])
    distance[start[0]][start[1]] = 0
    while queue:
        x, y = queue.popleft()

        for i, j in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            new_y, new_x = y + j, x + i
            if 0 <= new_y < W and 0 <= new_x < H:
                if grid[new_x][new_y] == '.' and distance[new_x][new_y] == -1:
                    distance[new_x][new_y] = distance[x][y] + 1
                    queue.append((new_x, new_y))
    return max(map(max, distance))


answer = 0
for i, j in product(range(H), range(W)):
    if S[i][j] == '#':
        continue

    tmp = bfs(S, (i, j))
    if tmp > answer:
        answer = tmp

print(answer)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;
const double EPS = 1e-3;

ll solve(ll a, ll b){
	ll x = pow(a, 5);
	ll y = pow(b, 5);
	return x-y;
}
int main(){
	ios::sync_with_stdio(0);
	ll l = 1, r = 100000;
	ll x;
	cin >> x;
	for(ll a=l; a<=r; ++a){
		ll k = pow(a, 5);
		ll b1 = pow(x+k, 1/double(5));
		ll b2 = pow(k-x, 1/double(5));
		ll b3 = pow(x-k, 1/double(5));
		if(solve(b1, a)==x){
			cout << b1 << " " << a << endl;
			return 0;
		}
		if(solve(a, b2)==x){
			cout << a << " " << b2 << endl;
			return 0;
		}
		if(solve(a, -b3)==x){
			cout << a << " " << -b3 << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 4068
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s = "000";
    for(auto& c: s)
        cin >> c;
    cout << ((stoi(s) % 4 == 0) ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
    int N;
    cin >> N;
    vector<int> p(N);
    for (int& x : p) cin >> x;

    vector<int> a = p;
    sort(a.begin(), a.end());

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        cnt += a[i] != p[i];
    }
    cout << (cnt == 2 || cnt == 0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int A[2000],n;

int answer(int x,int y)
{
  if(y == 0) return 1;
  if(x >= n) return 0;
  int res = answer(x+1,y) || answer(x+1,y-A[x]);
  return res;
}




int main()
{
  int m,i,q;

  scanf("%d",&n);

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

  scanf("%d",&q);

  

  for(i=0;i<q;i++)
    {
      scanf("%d",&m);
      if(answer(0,m)) printf("yes\n");
      else printf("no\n");
    }
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int a, b, h, x;
	cin >> a >> b >> h >> x;
	double n = h, m = x;
	n = (n >= 12 ? n - 12 : n);
	n *= 30;
	n += m * .5;
	m *= 6;
	double ans = abs(n - m);
	ans = ans > 180 ? 360 - ans : ans;
	ans = ans * PI / 180.;

	double le = a + b + sqrt(a * a + b * b - 2 * a * b * cos(ans));
	cout << d20 << le - a - b << endl;

	return 0;
}

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

using namespace std;
long long i,n,a[200005];
map <long long, long long> m;
long long ans;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        m[a[i]]++;
    }

    for(auto it : m)
        ans+=it.second*(it.second-1)/2;

    for(i=1;i<=n;i++)
        cout<<ans-m[a[i]]+1<<'\n';
    return 0;
}


Measured memory_bytes: 11032
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;

int main(){
	int n, i, ans=0;
	bool oddflag=false;
	cin>>n;
	int a[n];
	for(i=0; i<n; i++){
		cin>>a[i];
	}
	while(true){
		for(i=0; i<n; i++){
			if(a[i]%2!=0){
				oddflag=true;
			}
		}
		if(oddflag){
			break;
		}
		ans++;
		for(i=0; i<n; i++){
			a[i]/=2;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

static const ll MAX_N = 100001;
static const ll MAX_M = 200001;
ll n, q;

ll par[MAX_N];
ll rak[MAX_N];

void init_uf(ll n) {
	rep(i, 0, n) {
		par[i] = i;
		rak[i] = 0;
	}
}
ll find(ll n) {
	if (n == par[n]) {
		return n;
	}
	else {
		return par[n] = find(par[n]);
	}
}
void unite(ll x, ll y) {
	x = find(x);
	y = find(y);

	if (x == y) return;
	if (rak[x] < rak[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rak[x] == rak[y])rak[x]++;
	}
}

bool same(ll x, ll y) {
	return find(x) == find(y);
}
int main() {
	cin >> n >> q;
	init_uf(n);

	rep(i, 0, q) {
		ll com, x, y; cin >> com >> x >> y;
		if (com == 0) {//unite
			unite(x, y);
		}
		else {//same
			if (same(x, y)) {
				cout << 1 << endl;
			}
			else {
				cout << 0 << endl;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define ul unsigned long long
#define inf 1e18
const int _=2e5+5;
inline int read()
{
	char ch='!';int z=1,num=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')z=-1,ch=getchar();
	while(ch<='9'&&ch>='0')num=(num<<3)+(num<<1)+ch-'0',ch=getchar();
	return z*num;
}
int n,X;
ul d[_];
int main()
{
	n=read(),X=read();
	for(int i=1;i<=n;++i)d[i]=read(),d[i]+=d[i-1];
	ul ans=inf;
	for(int k=1;k<=n;++k)
	{
		ul s=0,xi=3;
		s+=(d[n]-d[max(0,n-k)])*2;
		for(int i=n;i>=1;i-=k,xi+=2)
			s+=(d[i]-d[max(0,i-k)])*xi;
		ans=min(ans,s+1ll*(n+k)*X);
	}
	printf("%llu\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int N;
	cin >> N;
	vector<int> A(N);
	int mx1 = 0, mx2 = 0;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		if (mx1 < tmp)
			mx1 = tmp;
		else
			mx2 = max(mx2, tmp);
		A[i] = tmp;
	}
	for (int i = 0; i < N; i++)
	{
		if (A[i] < mx1)
			cout << mx1 << endl;
		else
			cout << mx2 << endl;
	}
}



Measured memory_bytes: 2432
#include <cstdio>
#include <set>
#include <tuple>

std::set <std::tuple <int, int, int> > dic;

int main () {
	int A, B, C;
	scanf ("%d%d%d", &A, &B, &C);
	int t = 0;
	while (!(A & 1) && !(B & 1) && !(C & 1)) {
		if (dic.find (std::make_tuple (A, B, C)) != dic.end ()) {
			puts ("-1");
			return 0;
		}
		dic.insert (std::make_tuple (A, B, C));
		int a = B / 2 + C / 2, b = A / 2 + C / 2, c = A / 2 + B / 2;
		A = a; B = b; C = c;
		++t;
//		printf ("%d %d %d\n", A, B, C);
	}
	printf ("%d\n", t);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<int> i_vec;
ll gcd(ll a,ll b){while(b){ll tmp = a % b;a = b;b = tmp;}return a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) for(auto i : x) cout << i << " "; cout << endl;
#define outln(x) for(auto i : x) cout << i << " " << endl;
#define vec_push(to,from) copy(all(to),back_inserter(from))
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define MOD = 1000000007; 
#define DEBUG true

int main(){
  int n,h,w; cin >> h >> w >> n;
  getchar();
  str a_line; getline(cin,a_line);
  i_vec ans[h];
  int itr = 0,line = 0;
  split_str(a_line,' ')
    rep(i,stoi(res)){
      ans[line].pb(cnt + 1);
      if(itr == w - 1){
        line++;
        itr = 0;
      }else itr++;
    }

  rep(i,h){
    if(i % 2 == 0) reverse(all(ans[i]));
    for(int j : ans[i]) cout << j << " ";
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 384
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    if s[2] == s[3] && s[4] == s[5] {
       println!("Yes");
    } else {
      println!("No");
    }
}


Measured memory_bytes: 4352
class UnionFind:
    def __init__(self, n):
        self.p = [i for i in range(n)]
        self.components = [1]*n  # 各連結成分の大きさ

    def root(self, x):
        if self.p[x] != x:
            stack = [x]
            while True:
                top = stack[-1]
                if self.p[top] == top:
                    break
                else:
                    stack.append(self.p[top])
            for v in stack:
                self.p[v] = top
        return self.p[x]
    
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            self.p[x] = y
            size_x , size_y = self.components[x], self.components[y]
            self.components[x] = size_x + size_y
            self.components[y] = size_x + size_y

            return size_x * size_y

        return 0


    
    def same(self, x,y):
        return (self.root(x) == self.root(y))

N, M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]
AB.reverse()

UF = UnionFind(N)

ans = [N*(N-1)//2]
for a, b in AB:
    a, b = a-1, b-1
    ans.append(ans[-1] - UF.unite(a,b))

ans.reverse()
for a in ans[1:]: 
    print(a)
   

Measured memory_bytes: 97268
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}
bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i == 0)
			return false;
	}
	return (num < 2) ? false : true;
}



int main() {
	int N, K, i, j;
	ll ans = 1000000000;
	cin >> N >> K;
	vector<int> vec(100000,0);
	REP(i, N) {
		cin >> j;
		vec[i]=j;
	}
	sort(vec.begin(), vec.begin() + N);
	REP(i, N-K+1) {
		if ((vec[i + K - 1] - vec[i]) < ans)
			ans = vec[i + K - 1] - vec[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int cnt[100000];
int main(){
  int Lj4PdHRW;
  int res = 0;
  int KL2GvlyY = rd_int();
  for(Lj4PdHRW=(0);Lj4PdHRW<(KL2GvlyY);Lj4PdHRW++){
    if(cnt[rd_int()-1]++==0){
      res++;
    }
  }
  if(res%2==0){
    res--;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190921-1

// --- original code ---
// int cnt[1d5];
// {
//   int res = 0;
//   REP(rd_int()) if(cnt[rd_int()-1]++==0) res++;
//   if(res%2==0) res--;
//   wt(res);
// }


Measured memory_bytes: 640
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include "bits/stdc++.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    ost;
#define rep(i,l,r)   for (int i = (l); i < (r); i++)
#define here cout << " Hey!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
template <typename T>
void etch(T V) {
	for (auto x : V)	cout << x << ' ' ;
	cout << '\n';
}
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld EPS = 1e-12;
const ld PI = 3.141592653589793116;

int32_t main()
{
	SYNC
	int x; cin >> x;
	int lcm = 360*x/__gcd(360LL,x);
	cout << lcm/x;
	return 0;
}

Measured memory_bytes: 3660
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

   String nyuA=sc.nextLine();
  // String nyuB=sc.nextLine();
 
//    String[] s=sc.nextLine().split("");
//     String[] e=sc.nextLine().split(" ");

int n=Integer.parseInt(nyuA);

//int A=Integer.parseInt(s[0]);
//int B=Integer.parseInt(s[1]);
boolean[] list=new boolean[100005];
for(int i=0;i<n;i++){
String[] s=sc.nextLine().split(" ");
int be=Integer.parseInt(s[0]);
int ed=Integer.parseInt(s[1]);
for(int j=be;j<=ed;j++)list[j]=true;
}
int res=0;
for(int i=0;i<list.length;i++){
if(list[i])res++;
}

System.out.println(res);

//long H=Long.parseLong(t[0]);
//long W=Long.parseLong(t[1]);
//long C=Long.parseLong(t[2]);


	}
}

Measured memory_bytes: 25172
def runLength(str):
    """文字列strをランレングス圧縮して返す関数
    ex: "0000111101" => [(0,4), (1,4), (0,1), (1,1)]
    """
    res = []
    data, count = str[0], 1
    for i in range(1, len(str)):
        if str[i] == data:
            count += 1
        else:
            res.append((data, count))
            data, count = str[i], 1
    res.append((data, count))
    return res

S = input()  # S[0] == "R", S[-1] == "L"

ans = [0] * len(S)
ind = -1
for rl in runLength(S):
    if rl[0] == "R":
        ind += rl[1]
        ans[ind] += rl[1] - rl[1] // 2
        ans[ind+1] += rl[1] // 2
        #print("now", rl, *ans)
    else:
        ans[ind] += rl[1] // 2
        ans[ind+1] += rl[1] - rl[1] // 2
        ind += rl[1]
        #print("now", rl, *ans)

print(*ans)


Measured memory_bytes: 11124
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define hell 998244353
#define hell1 1000000006
#define pb push_back
#define x first
#define y second
#define MAXL 100005
#define pll pair<ll,ll>
#define pii pair<int,int>
#define L LLONG_MAX
#define all(v) (v).begin(),(v).end()
#define tcFile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;
//vector<int>prime(15000005,0);
ll mM(ll a,ll b,ll p=hell){ll res = 0;if(a>=p)a %= p;while(b){if (b & 1ll)res = (res + a);if(res>=p) res%= p;a = (2 * a); if(a>=p)a%=p;b >>= 1ll;}return res;}
ll fpow(ll x,ll y,ll p=hell){if(x>=p)x=x%p;ll res=1;while(y){if(y&1ll)res*=x;if(res<0)res+=p;if(res>=p)res%=p;y=y>>1ll;x*=x;if(x<0)x+=p;if(x>=p)x%=p;}return res;}
ll inv(ll n,ll p=hell){return fpow(n,p-2,p);}
ll modmul(ll x,ll y,ll p = hell){if(x<0)x+=p;if(x>=p)x%=p;if(y<0)y+=p;if(y>=p)y%=p;return (x*y)%p;}
ll modadd(ll x,ll y,ll p = hell){if(x<0)x+=p;if(x>=p)x%=p;if(y<0)y+=p;if(y>=p)y%=p;ll temp=x+y;if(temp>=p)temp%=p;return temp;}
/*void sieve(){
    prime[0] = -1;
    prime[1] = 0;
    for(int i=2;i<=15000000;i++)
        if(!prime[i])
            for(int j=i;j<=15000000;j+=i)
            	if(!prime[j])
            		prime[j] = i;
}*/
int main(){
	ios
	int t = 1,tc = 0;
	//cin >> t;
	while(t--){
		int n;
		cin >> n;
		vector<vector<ll>>a(n, vector<ll>(3));
		for (int i = 0; i < n; i++)
			for (int j = 0; j < 3; j++)
				cin >> a[i][j];
		for (int i = 1; i < n; i++)
			for (int j = 0; j < 3; j++) {
				ll mn = 0;
				for (int k = 0; k < 3; k++)
					if (k != j)
						mn = max(mn, a[i-1][k]);
				a[i][j] += mn;
			}
		ll ans = 0;
		for (int i = 0; i < 3; i++)
			ans = max(ans, a[n-1][i]);
		cout << ans << "\n";
	}
}


Measured memory_bytes: 8724
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}
int h,w;
char buf[405][405];
struct uf{

  static const int MAXN=405*405;
  int par[MAXN];
  int size1[MAXN];
  int size2[MAXN];
  void init(){
    memset(par,-1,sizeof(par));
    REP(i,h) REP(j,w){
      if(buf[i][j]=='#') size1[i*w+j]=1;
      else size2[i*w+j]=1;
    }
  }
  int root(int a){
    if(par[a]==-1) return a;
    return par[a]=root(par[a]);
  }
  void unite(int a,int b){
    a=root(a);b=root(b);
    if(a==b) return;
//    if(size[a]<size[b]) swap(a,b);

    par[b]=a;
    size1[a]+=size1[b];
    size2[a]+=size2[b];
  }
  bool same(int a,int b){
    return root(a)==root(b);
  }
};



//const int INF=5e8;
uf u;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int main(){
  cin>>h>>w;
  REP(i,h) scanf("%s",buf[i]);
  /*
  REP(i,h) REP(j,w) if((i+j)&1){
    buf[i][j]=(buf[i][j]=='#'?'.':'#');
  }
  */
  u.init();
  REP(i,h) REP(j,w){
    REP(d,4){
      int px=j+dx[d],py=i+dy[d];
      if(py<h && px<w && px>=0 && py>=0 && buf[i][j]!=buf[py][px]){
        u.unite(i*w+j,py*w+px);
      }
    }
  }
  lint res=0;
  REP(i,h*w) if(u.root(i)==i){
    lint c1=u.size1[i],c2=u.size2[i];;
    res+=c1*c2;
  }
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 2304