akhauriyash/Code-Regression huggingface dataset:
def f():
    n,m = map(int,input().split(" "))
    s = []
    w = [[] for i in range(n+2)]
    for i in range(m):
        a,b = map(int,input().split(" "))
        
        if a==1:
            s.append(b)
        if b==1:
            s.append(a)
        w[a].append(b)
        w[b].append(a)
    for i in s:
        if n in w[i]:
            print("POSSIBLE")
            return 0
    print("IMPOSSIBLE")
    return 0
f()

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void printVec(vector<int>& vec) {
    for (auto& e : vec) {
        cout << e << " ";
    }
    cout << endl;
}

int func(long long a, long long b) {
    // cout << fixed << setprecision(8);
    if (a >= 10) {
        cout << -1 << endl;
        return 0;
    }
    if (b >= 10) {
        cout << -1 << endl;
        return 0;
    }

    cout << a * b << endl;

    return 0;
}

int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);

    func(A, B);

    return 0;
}


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

using namespace std ;

typedef long long ll ;
const int MAX = 1e5 + 10 ;

vector< vector< pair<int, pair<ll , ll> > > >adj(MAX) ;
long long dist[2][MAX] ;
int n , m , s , t ;

void dijkstra(int src , int st)
{
	for(int i = 1 ; i <= n ; ++i)
		dist[st][i] = 1e18 ;
	dist[st][src] = 0 ;
	priority_queue< pair<ll , int> , vector< pair<ll, int> > , greater< pair<ll , int> > >q ;
	q.push({0 , src}) ;
	dist[st][src] = 0 ;
	while(!q.empty())
	{
		pair<ll , int>p = q.top() ;
		q.pop() ;
		int node = p.second ;
		ll cost = p.first ;
		if(dist[st][node] < cost)
			continue ;
		for(auto &child : adj[node])
		{
			int to = child.first ;
			ll tocost = cost ;
			if(st == 0)
				tocost += child.second.first ;
			else
				tocost += child.second.second ;
			if(tocost < dist[st][to])
			{
				dist[st][to] = tocost ;
				q.push({tocost , to}) ;
			}
		}
	}
	return ;
}
int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>m>>s>>t ;
	for(int i = 0 ; i < m ; ++i)
	{
		int x , y ;
		long long z1 , z2;
		cin>>x>>y>>z1>>z2 ;
		adj[x].push_back({y , {z1 , z2}}) ;
		adj[y].push_back({x , {z1 , z2}}) ;
	}
	dijkstra(s , 0) ;
	dijkstra(t , 1) ;
	ll cons = 1e15 ;
	ll suff[n+1] ;
	suff[n] = dist[0][n] + dist[1][n] ;
	for(int i = n-1 ; i >= 0 ; --i)
		suff[i] = min(suff[i+1] , dist[0][i] + dist[1][i]) ;
	for(int i = 1 ; i <= n ; ++i)
		cout<<cons-suff[i]<<"\n" ;
	return 0 ;
}

Measured memory_bytes: 13124
#include <iostream>
#include <cmath>

int main(void) {
	// in
	int n, m;
	std::cin >> n >> m;

	// calc
	int c = 100 * n + 1800 * m;
	int x = c * std::pow(2, m);

	std::cout << x << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    while (1) {
        ll b;
        cin >> b;
        if (b == 0) return 0;
        
        for (int i = pow(b * 2, 0.5); i > 0; i--) {
            if ((b - (i * (i - 1)) / 2) % i == 0) {
                cout << (b - (i * (i - 1)) / 2) / i << " " << i << endl;
                break;
            }
        }
        
        
    }
}



Measured memory_bytes: 3244
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();

		int ans = 0;
		if (K > N) {
			ans = N * X;
		}else{
			ans = K * X + (N - K) * Y;
		}
		System.out.println(ans);

		sc.close();
	}
}


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

int main(void){
	int N, K;
	cin >> N >> K;
	int x[N];
	rep(i,N) cin >> x[i];
	
	int dist = 0;
	rep(i,N){
		dist += 2*min(x[i], K- x[i]);
	}
	cout << dist << endl;

	return 0;
}


Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main(){
    int h,w;
    
    for(;;){
        cin >> h >> w;
        if(h == 0 && w == 0){
            break;
        }
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

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

	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
import sys

inputLine=input()
A=int(inputLine.split(" ")[0])
B=int(inputLine.split(" ")[1])
C=int(inputLine.split(" ")[2])
D=int(inputLine.split(" ")[3])

while True:
    C = C - B
    if C <= 0:
        print("Yes")
        sys.exit()

    A = A - D
    if A <= 0:
        print("No")
        sys.exit()




Measured memory_bytes: 9048
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,t,a;
  cin >> n >> t >> a;

  double minh = 99999;
  int ans = -1;
  rep(i,n)
  {
    int h;
    cin >> h;
    double tt = t - h * 0.006;

    if(abs(tt - a) < minh)
    {
      ans = i;
      minh = abs(tt - a);
    }
  }
  cout << ans + 1 << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define mp make_pair
using namespace std;
const int MAXN = 1e5 + 10;

//int a[MAXN], b[MAXN];

int main()
{
    int n;
    cin>>n;
    vector<int> v1,v2;
    for(int i=0;i<n;i++)
    {
        int t;
        cin>>t;
        v1.push_back(t);
    }
    v2=v1;
    int c=0;
    sort(v2.begin(),v2.end());
    for(int i=0,j=0;i<v1.size();i++,j++)
    {
        if(v1[i]!=v2[j])
        {
            c++;
        }
    }
if(c<=2)
{
    cout<<"YES"<<endl;
}
else
{
    cout<<"NO"<<endl;
}

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  set<int> st = {a, b, c};
  cout << ((int) st.size() == 2 ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[n+1];
    for (int i=0;i<n;i++)   cin>>a[i];
    int res=2147483647;
    for (int i=0;i<n-k+1;i++){
        res=min(res,abs(a[i+k-1]-a[i])+min(abs(a[i]),abs(a[i+k-1])));
    }
    cout<<res;
    return 0;
}

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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

int main()
{
    boost;
    time_t tic, toc;

    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, h, w, u, v, x, y;
    ll l = 0, r = 0;
    ll ans = 0;

    bool poss = true;

    string s, t, tmp;

    // cin >> tt;
    tic = clock();
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> s >> t;
        n = sz(s);
        
        ans = 0;
        for(i = 0; i < n; i++){
            if(s[i] != t[i]) ans++;
        }
        cout << ans << nl;
    } 
    // cerr << (clock() - tic*1.0) / CLOCKS_PER_SEC << nl;
    return 0;
}

Measured memory_bytes: 3848
import kotlin.math.*
import kotlin.system.exitProcess

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() //single long
private fun readDouble() = readLn().toDouble() //single double

private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main() {
    val n = readInt()
    val h = readLongs()

    val inf = Long.MAX_VALUE
    val dp = LongArray(n){inf}

    dp[0] = 0 //初期位置にいる時はコスト0
    dp[1] = abs(h[0] - h[1])
    if(n == 2){
        println(dp[1])
        exitProcess(0)
    }

    for(i in 2 until n){
        val jump2 = dp[i-2] + abs(h[i-2] - h[i])
        val jump1 = dp[i-1] + abs(h[i-1] - h[i])
        dp[i] = min(jump1, jump2)
    }

    println(dp[n-1])

}

Measured memory_bytes: 51244
H, W, K = map(int, input().split())
arr = [list(input()) for _ in range(H)]

ans = 0
for h_combo in range(2**H):
    for w_combo in range(2**W):
        curr_cnt = 0

        for i in range(H):
            for j in range(W):
                if (h_combo >> i) & 1 == 0 and (w_combo >> j) & 1 == 0:
                    if arr[i][j] == '#':
                        curr_cnt += 1
        
        if curr_cnt == K:
            ans += 1

print(ans)

Measured memory_bytes: 9004
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  vector<int>v(n);

  
  
 
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
    int ans = v[0];
    for(int i=1;i<n;i++){
      if(v[i-1] < v[i]) ans += v[i]-v[i-1];
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    if(s[0]==t[2]&&s[1]==t[1]&&s[2]==t[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

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

int main(void) {
	long long a, b=360,c, r, x, tmp;

	cin >> c;
    a = c;
    x = a * b;

    /* 自然数 a > b を確認・入替 */
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }


	cout << (x / b)/c << endl;
	return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;

 		
int main() {

string S;
cin>>S;
int count=0;
fx(3){
	if(S.at(x)=='1'){
		count++;
	}
}
ce(count)

}

Measured memory_bytes: 256
from collections import Counter
from collections import deque
import math
import bisect
import sys
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))


n,k=mp()
h=lmp()
h.insert(0,0)
dp=[float("inf")]*(n+1)
dp[1]=0
for i in range(1,n+1):
    for j in range(1,k+1):
        if i+j<=n:
            dp[i+j]=min(dp[i+j],abs(h[i+j]-h[i])+dp[i])
print(dp[n])


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

using namespace std;

typedef long long ll;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int x,y,z;
	cin>>x>>y>>z;
	int tmp=(x/(y+z));
	if(x%(y+z)>=z)
		cout<<tmp<<endl;
	else
		cout<<tmp-1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    char str[27];
    scanf(" %s",str);
    int n=strlen(str);
    int cnt[26]={0};
    for(int i=0;i<n;i++)
        cnt[str[i]-'a']++;
    for(int i=0;i<26;i++)
    {
        if(cnt[i]==0)
        {
            printf("%s%c\n",str,'a'+i);
            return 0;
        }
    }
    int mark=-1;
    for(int i=n-2;i>=0;i--)
    {
        if(str[i]>str[i+1])
            continue;
        else
        {
            mark=i;
            break;
        }
    }
    if(mark==-1)
    {
        printf("-1\n");
        return 0;
    }
    for(int i=0;i<mark;i++)
    {
        printf("%c",str[i]);
    }
    char mn='z'+1;
    for(int i=mark+1;i<n;i++)
    {
        if(str[i]>str[mark]&&str[i]<mn)
            mn=str[i];
    }
    printf("%c\n",mn);
    return 0;
}


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

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long unsigned int ll;
typedef pair<ll, ll> P;

int main(){
  ll w,h,x,y;
  cin >> w >> h >> x >> y;
  if(x*2==w && y*2==h){
    cout << w*(h/2.0) << " " << 1 << endl;
  }else{
    cout << w*(h/2.0) << " " << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
int S[MAX_N], A[MAX_N], C[MAX_N];

void solve() {
	cin >> N >> M;
	rep(i, 0, N) {
		int a; cin >> a; a--;
		A[i] = a;
		if(a - C[a] >= 0) S[a - C[a]]++;
		C[a]++;
	}
	int res = 0;
	rep(i, 0, N) res += S[i] ? 1 : 0;
	rep(i, 0, M) {
		int a, b;
		cin >> a >> b; a--; b--;
		int pb = A[a];
		A[a] = b;
		if(pb - C[pb] + 1 >= 0) {
			S[pb - C[pb] + 1]--;
			if(!S[pb - C[pb] + 1]) res--;
		}
		C[pb]--;
		if(b - C[b] >= 0) {
			S[b - C[b]]++;
			if(S[b - C[b]] == 1) res++;
		}
		C[b]++;
		cout << N - res << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 3840
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    LL ans = 0;
    LL n;
    scanf("%lld", &n);
    for (LL i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 3828
#include <stdio.h>
#define max 100000
#define nel 2000000000
#define n_max 9000000000
struct card{
  char it;
  int lue;
};

struct card L[max/2+2],R[max/2+2];

void c_merge(struct card *,int ,int  ,int , int );
void c_sort(struct card *,int ,int ,int );
int c_p (struct card *,int ,int ,int );
void c_q(struct card *,int ,int ,int );



int main(){
  int n,i,v,O[n_max],M[n_max];
  struct card P[max],Q[max];
  char S[10];
  int ble=1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    P[i].it=Q[i].it=S[0];
    P[i].lue=Q[i].lue=v;
  }
  c_sort(P,n,0,n);
  c_q(Q,n,0,n-1);
  for(i=0;i<n;i++){
    if(P[i].it !=Q[i].it)ble=0;
  }

  if(ble==1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",Q[i].it,Q[i].lue);
  }
  return 0;
}


void c_merge(struct card P[],int n,int left ,int mid, int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++)L[i]=P[left+i];
  for(i=0;i<n2;i++)R[i]=P[mid+i];
  L[n1].lue=R[n2].lue=nel;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].lue<=R[j].lue){
      P[k]=L[i++];
    }else {
      P[k]=R[j++];
    }
  }
}


void c_sort(struct card P[],int n,int left,int right){
  int mid;
  if (left+1<right){
    mid=(left+right)/2;
    c_sort(P,n,left,mid);
    c_sort(P,n,mid,right);
    c_merge(P,n,left,mid,right);
  }
}

int c_p (struct card P[],int n,int p,int r){
  int i,j;
  struct card t,x;
  x=P[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(P[j].lue<=x.lue){
      i++;
      t=P[i];
      P[i]=P[j];
      P[j]=t;
    }
  }
  t=P[i+1];
  P[i+1]=P[r];
  P[r]=t;
  return i+1;
}

void c_q(struct card P[],int n,int p,int r){
  int q;
  if(p<r){
    q=c_p(P,n,p,r);
    c_q(P,n,p,q-1);
    c_q(P,n,q+1,r);
  }
}




Measured memory_bytes: 4100
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
    int n,k,mi,ma;
    long long sum,ans;
    long long x[200010],y[200010],p[200010],a[200010];
int main()
{
    cin >> n;
    cin >> k;
    p[k]++;
    a[1]=k;
    mi=k;
    ma=k;
    for (int i=2;i<=n;i++)
    {
        cin >> k;
        p[k]++;
        if (k>ma) ma=k;
        if (k<mi) mi=k;
        a[i]=k;
    }
    sum=0;
    for(int i=mi;i<=ma;i++)
    {
        if (p[i]<=1) x[i]=0;
        else x[i]=p[i]*(p[i]-1)/2;
        if (p[i]<=2) y[i]=0;
        else y[i]=(p[i]-1)*(p[i]-2)/2;
        sum+=x[i];
    }
    for (int i=1;i<=n;i++)
    {
        k=a[i];
        ans=sum-x[k]+y[k];
        printf("%lld\n",ans);
    }

}


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

int bfs(vector<vector<char>> s, int x, int y) {
  int H = s.size(), W = s.at(0).size();
  vector<vector<int>> dist(H, vector<int>(W, -1));
  dist.at(x).at(y) = 0;
  vector<int> mx(4), my(4);
  mx = {1, 0, -1, 0}, my = {0, 1, 0, -1};
  queue<pair<int,int>> Q;
  Q.push({x, y});

  int res = 0;
  while (Q.size()) {
    int x = Q.front().first, y = Q.front().second;
    res = max(res, dist.at(x).at(y));
    Q.pop();
    for (int i = 0; i < 4; i++) {
      int nx = x + mx.at(i), ny = y + my.at(i);
      if (s.at(nx).at(ny) == '.' && dist.at(nx).at(ny) == -1) {
        dist.at(nx).at(ny) = dist.at(x).at(y) + 1;
        Q.push({nx, ny});
      }
    }
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(H + 2, vector<char>(W + 2, 'w'));
  for (int i = 1; i < H + 1; i++)
    for (int j = 1; j < W + 1; j++) cin >> S.at(i).at(j);

  int ans = 0;
  for (int x = 1; x < H + 1; x++) 
    for (int y = 1; y < W + 1; y++)
      if (S.at(x).at(y) == '.') ans = max(ans, bfs(S, x, y));

  cout << ans << endl;
}

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

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    string S;
    cin >> S;
    int slen = (int) S.size();
    int K;
    cin >> K;

    set<string> se;
    for (int i = 0; i < slen; i++) {
        string acc = "";
        for (int j = i; j < min(slen, i + 5); j++) {
            acc += S[j];
            se.insert(acc);
        }
    }

    // for (auto s : se) {
    //     cout << s << endl;
    // }

    int i = 0;
    for (auto x : se) {
        i++;
        // cout << x << endl;
        if (i == K) {
            cout << x << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 1664
a = input()
if a == 'SUN':
  print(7)
elif a == 'MON':
  print(6)
elif a == 'TUE':
  print(5)
elif a == 'WED':
  print(4)
elif a == 'THU':
  print(3)
elif a == 'FRI':
  print(2)
else:
  print(1)



Measured memory_bytes: 9016
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read(){
	char ch=getchar();
	int o=0;
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){
		o=(o<<3)+(o<<1)+(ch^48);
		ch=getchar();
	}
	return o;
}
inline void write(int x){
	if(x>9)write(x/10);
	putchar(x%10^48);
}
int n,last,b[101],a[101],ans;
int main(){
	n=read();
	for(register int i=1;i<n;i++)b[i]=read();
	ans=b[1];
	for(register int i=1;i<n;i++)ans+=min(b[i],b[i+1]);
	write(ans+b[n-1]);
}

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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

ll calc_score(ll D, const vector<ll> &c, const vector<vector<ll>> &s, const vector<ll> &t) {
  vector<ll> last(26, -1);
  ll score = 0;
  REP(d, D) {
    ll i = t[d];
    score += s[d][i];
    last[i] = d;
    REP(j, 26) {
      score -= c[j] * (d - last[j]);
    }
  }
  return score;
}

ll area(ll D, ll d, const vector<ll> &t, ll target) {
  ll l = -1;
  for (int i = d - 1; i >= 0; i--) {
    if (t[i] == target) {
      l = i;
      break;
    }
  }
  ll r = D;
  FOR(i, d + 1, D) {
    if (t[i] == target) {
      r = i;
      break;
    }
  }
  ll x = r - d;
  ll y = d - l;
  return x * y;
}

ll calc_diff(ll D, ll pre, ll next, const vector<ll> &c, const vector<vector<ll>> &s, ll d, const vector<ll> &t) {
  ll diff = s[d][next] - s[d][pre];
  diff += c[next] * area(D, d, t, next);
  diff -= c[pre] * area(D, d, t, pre);
  return diff;
}

void solve(ll D, vector<ll> c, vector<vector<ll>> s) {
  vector<ll> t(D, 0);
  REP(d, D) {
    ll m = 0;
    ll cur = 0;
    FOR(i, 1, c.size()) {
      t[d] = i;
      ll diff = calc_diff(d + 1, 0, i, c, s, d, t);
      if (diff > m) {
        m = diff;
        cur = i;
      }
    }
    t[d] = cur;
  }

  auto start = std::chrono::system_clock::now();
  std::mt19937 mt{0};
  std::uniform_int_distribution<int> dist1(0, D - 2);
  std::uniform_int_distribution<int> dist2(0, D - 1);
  std::uniform_int_distribution<int> dist3(0, 25);
  ll count = 0;
  while (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start).count() <
         1980) {
    count++;
    if (count % 2 == 0) {
      ll d = dist1(mt);
      ll d2 = d + 1;
      ll pre = t[d];
      ll next = t[d2];
      t[d] = next;
      ll diff = calc_diff(D, pre, next, c, s, d, t);
      t[d2] = pre;
      diff += calc_diff(D, next, pre, c, s, d2, t);
      if (diff > 0) {
        // cout << "swap" << endl;
      } else {
        swap(t[d], t[d2]);
      }
    } else {
      ll d = dist2(mt);
      ll pre = t[d];
      ll next = dist3(mt);
      t[d] = next;
      ll diff = calc_diff(D, pre, next, c, s, d, t);
      if (diff > 0) {
        // cout << "change" << endl;
      } else {
        t[d] = pre;
      }
    }
  }

  REP(d, D) {
    cout << t[d] + 1 << "\n";
  }
}

int main() {
  ll D;
  scanf("%lld", &D);
  vector<ll> c(26);
  for (int i = 0; i < 26; i++) {
    scanf("%lld", &c[i]);
  }
  vector<vector<ll>> s(D, vector<ll>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      scanf("%lld", &s[i][j]);
    }
  }
  solve(D, move(c), move(s));
  return 0;
}


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

int main()
{
  	string s;
  	cin >> s;
  	for(int i=1;i<4;i++)
    {
		if(s[i]==s[i-1])
        {
          	cout << "Bad" << endl;
          	return 0;
        }
    }
    cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	double A, B, H, M;
	cin >> A >> B >> H >> M;
	H = H * 60 + M;
	double T = abs(0.5 * H - 6.0 * M);
	if (T >= 180.0) T = 360.0 - T;
	T = T / 180.0 * 3.141592653589793;
	double C = sqrt(A * A + B * B - 2 * A * B * cos(T));
	cout << fixed << setprecision(10) << C << endl;
}

Measured memory_bytes: 4228
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n;
deque<int> d;

void solve(){
    cin >> n;
    for(int i = 0, x; i < n; ++i){
        cin >> x;
        if(i % 2)
            d.push_front(x);
        else
            d.push_back(x);
    }

    if(n % 2){
        while(!d.empty()){
            cout << d.back() << " ";
            d.pop_back();    
        }
    }else{
        while(!d.empty()){
            cout << d.front() << " ";
            d.pop_front(); 
        }
    }
}

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

    solve();
    
    return 0;
}


Measured memory_bytes: 3072
import numpy as np
from sys import stdin


def get_result(data):
    N, M = data[0]
    A = np.array(data[1])
    total = sum(A)
    pop_goods = A[A >= total/(4*M)]
    if len(pop_goods) >= M:
        return 'Yes'
    return 'No'


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


Measured memory_bytes: 21652
#include <cstdio>
#include <algorithm>
#include <cassert>

using namespace std;

int a[111111*3];
long long sum[111111*3];
long long res = 0;
int n;

long long C(int s,int e)
{
  long long lim = sum[e]-sum[s];
  //printf("[%d,%d) [%d,%d)\n",s,e,e,s+n);
  s += n;
  int l = e, r = s;
  while( e < s ) {
    int m = (s+e)/2;
    assert(sum[m]-sum[l]+lim+sum[r]-sum[m]==sum[n]);
    //printf("%d %d %d %lld %lld %lld %lld\n",e,m,s,sum[m]-sum[l],lim,sum[r]-sum[m],sum[m]-sum[l]+lim+sum[r]-sum[m]);
    if( sum[m]-sum[l] >= sum[r]-sum[m] ) {
      s = m;
    } else {
      e = m+1;
    }
  }
  //s = e;
  assert(lim+sum[r]-sum[s]+sum[s]-sum[l]==sum[n]);
  //printf(":%d %d %lld %lld %lld %lld %d %d\n",l,r,lim,sum[r]-sum[s],sum[s]-sum[l],lim+sum[r]-sum[s]+sum[s]-sum[l],sum[n],l,r);
  long long ret = min(min(lim,sum[r]-sum[s]),sum[s]-sum[l]);
  res = max(res,ret);
  return ret;
}

int main(void)
{
  scanf("%d",&n);
  for( int i = 0; i < n; i++ ) {
    scanf("%d",a+i);
    a[i+n] = a[i];
    a[i+2*n] = a[i];
  }
  for( int j = 0; j < 3*n; j++ ) {
    sum[j+1] = sum[j]+a[j];
  }
  int s,e;
  s = 0;
  e = 1;
  for(;e<2*n;++e) {
    while( e < 2*n && C(s,e) > sum[e]-sum[s] ) {
      ++e;
    }
    while( s < e && C(s,e) < sum[e]-sum[s] ) {
      ++s;
    }
  }
  printf("%lld\n",res);
  return 0;
}

Measured memory_bytes: 4548
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int MOD=998244353;
const int maxn=4005;
int n,k;
int po[maxn],C[maxn][maxn];
inline void ini(){
	po[0]=1;
    for (int i=1;i<maxn;i++)
        po[i]=po[i-1]*2%MOD;
    for (int i=0;i<maxn;i++)
        C[i][0]=C[i][i]=1;
    for (int i=1;i<maxn;i++)
        for (int j=1;j<i;j++)
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
}
int c(int n,int m){
	if(m<0||n<0)return 0;
	return C[n][m];
}
inline int calc(int x,int n,int k){
	int ans=0;
	int tot=max(0,x/2-max(0,x-1-k));
	for(register int i=0;i<=tot;i++){
		ans=(1LL*po[i]*C[tot][i]%MOD*c(n+k-2*tot-1,k-tot*2+i-1)+ans)%MOD;
	}
	return ans;
}
int main(){
	ini();
	scanf("%d%d",&k,&n);
	for(register int i=2;i<=2*k;i++){
		if(i&1){
			printf("%d\n",calc(i,n,k));
		}
		else {
			printf("%d\n",(calc(i-1,n,k-1)+calc(i-1,n-1,k-1))%MOD);
		}
	}
}

Measured memory_bytes: 61440
N = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
  if p[i] == i + 1:
    p[i], p[i + 1] = p[i + 1], p[i]
    ans += 1
if p[N - 1] == N:
  ans += 1
print(ans)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

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

int main() {
  ll N, K;
  std::cin >> N >> K;
  ll h[N];
  REP(i, N) std::cin >> h[i];
  ll dp[N];
  REP(i, K) {
    if (i < N) {
      dp[i] = abs(h[i] - h[0]);
    } else {
      break;
    }
  }
  ll min_;
  REP(i, N - K) {
    REP(j, K) {
      if (j == 0) {
        min_ = dp[i] + abs(h[K + i] - h[i]);
      } else {
        min_ = min(min_, dp[i + j] + abs(h[K + i] - h[i + j]));
      }
    }
    dp[i + K] = min_;
  }
  std::cout << dp[N - 1] << '\n';
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


Measured memory_bytes: 1792
import queue

def shortestpath(y0, x0):
    step_cnt = [[-1] * w for _ in range(h)]
    step_cnt[y0][x0] = 0
    q.put((y0, x0))
    while not q.empty():
        y, x = q.get()
        for i in range(4):
            y_next = y + dy[i]
            x_next = x + dx[i]
            if 0 <= y_next < h and 0 <= x_next < w\
            and maze[y_next][x_next] == '.'\
            and step_cnt[y_next][x_next] == -1:
                q.put((y_next, x_next))
                step_cnt[y_next][x_next] = step_cnt[y][x] + 1
                    
    return step_cnt[y][x]

h, w = map(int, input().split())      
maze = [[x for x in input()] for _ in range(h)]
dy = [-1, 0, 1, 0]
dx = [0, -1, 0, 1]
q = queue.Queue()

max_steps = -1
for y0 in range(h):
    for x0 in range(w):
        if maze[y0][x0] != '#':
            max_steps = max(max_steps, shortestpath(y0, x0))

print(max_steps)

Measured memory_bytes: 3948
n = int(input())
a = list(map(int, input().split()))

import collections
cnt = collections.Counter(a)

sum_cnt = 0
for v in cnt.values():
    sum_cnt += v*(v-1)//2

res = []
for value in a:
    res.append(str( sum_cnt - (cnt[value]-1) ))
print('\n'.join(res))

Measured memory_bytes: 34684
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n),b(n);

    rep(i,n){
        ll tmp;
        cin >> tmp;
        a[i] = tmp + i;
        b[i] = i - tmp;
    }

    map<ll,ll> c,d;

    rep(i,n){
        c[a[i]] +=1;
        d[b[i]] +=1;
    }
    ll sum =0;
    for(auto iter=c.begin(), end=c.end(); iter!=end; ++iter){
        sum+= d[iter->first] * iter->second;
    } 
    cout <<sum<<endl;
    
    return 0;
}

Measured memory_bytes: 40664
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> T& chmin(T &a, const U &b){return a = (a<=b?a:b);}
template <typename T, typename U> T& chmax(T &a, const U &b){return a = (a>=b?a:b);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

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

    int ans = 0;
    REP(i,n){
      FORE(j,i+1,n){
	string t = s.substr(i,j-i);
	if(all_of(ALL(t), [](char c){return c=='A' or c=='T' or c=='G' or c=='C';})){
	  chmax(ans, j-i);
	}
      }
    }
    cout << ans << endl;
  }
  
  return 0;
}


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

using namespace std;

long long N;
vector<long long> v,w;

int main(){
    cin >> N;
    v.resize(N);
    for(int i=0;i<N;i++) cin >> v[i];
    for(int i=1;i<=N;i++) v[i-1] -= i;
    w = v;
    sort(w.begin(),w.end());
    long long a=0,b=0;
    for(int i=0;i<N;i++){
        a += abs(v[i] - w[N/2-1]);
        b += abs(v[i] - w[N/2]);
    }
    cout << min(a,b) << endl;
    return 0;
}

Measured memory_bytes: 3328
//
//  main.cpp
//  C - 100 to 105
//
//  Created by Hashizo on 2019/12/01.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
	string ans = "1";


	ll x;
	cin >> x;

	ll count;
	ll fraction;
	
	
	
	count = x / 100;
	fraction = x % 100;
	
	if (ceil((((double)fraction) / 5.0 )) > count) {
		cout << 0 << endl;
	}
	else {
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 		9223372036854775807
#define DIVISOR      10000000000000000


int main(){

	ull count[2000];

	for(int i = 0; i < 2000; i++)count[i] = 0;

	ull N,K;
	ull x_0;
	scanf("%lld %lld %lld",&N,&K,&x_0);
	if(x_0 == 0){
		printf("0\n");
		return 0;
	}

	ull x = x_0;
	for(int i = 0; i < N; i++){
		count[(ull)(NUM+(ll)x)/DIVISOR]++;
		x ^= x << 13;
		x ^= x >> 7;
		x ^= x << 17;
	}

	int sum = 0;
	ull loc;

	for(ull i = 0; i < 2000; i++){
		if(sum+count[i] >= K){
			loc = i;
			break;
		}
		sum += count[i];
	}

	vector<ll> V;

	x = x_0;
	for(int i = 0; i < N; i++){

		if(loc == (ull)(NUM+(ll)x)/DIVISOR){
			V.push_back(x);
		}
		x ^= x << 13;
		x ^= x >> 7;
		x ^= x << 17;
	}

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

	printf("%lld\n",V[(K-sum)-1]);

	return 0;
}

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



int main(void){
	//GCD=?????§??¬?´???°
	//LCM=????°???¬?????°

	long int a, b,Max,Min,GCD,LCM,count;


	while (cin>>a>>b){
		count = 0;
		Max = max(a, b);
		Min = min(a, b);
		//GCD

		//????°????????????£????????£????????????????????????????????§??¬?´???°??§??????
		for (int i = 1;;i++){

			if (Min %i == 0 && Max%(Min/i)==0){//?????????????????????
				GCD = Min/i; 
				count++;
			}		
			if (count == 1)break;
		}

		//LCM

		for (int i = 1;; i++){
			if ((Max*i) % Min == 0){
				LCM = (Max*i);
				count++;
			}if (count == 2)break;
		}


		cout << GCD << " " << LCM << endl;
	
	}
	
	
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> mp(H, vector<char>(W));
    rep(i, H) rep(j, W) { cin >> mp[i][j]; }
    rep(i, H) rep(j, W) {
        if(mp[i][j] == '.') {
            int cnt = 0;
            rep(k, 8) {
                int nx = j + dx[k], ny = i + dy[k];
                if(nx >= 0 && nx < W && ny >= 0 && ny < H) {
                    if(mp[ny][nx] == '#')
                        cnt++;
                }
            }
            mp[i][j] = (char)(cnt + '0');
        }
    }
    rep(i, H) {
        rep(j, W) { cout << mp[i][j]; }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  LINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  string  a,b,c;
  cin >> a >> b >> c;
  
  cout << (*a.rbegin() == *b.begin() && *b.rbegin() == *c.begin() ? "YES" : "NO")  << endl;
  return 0;
} 

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

int main() {
	ll n;
	cin >> n;
	vector<ll> soin(1000001);
	ll lim = sqrt(n);
	FOR(i, 2, lim) {
		if (n%i == 0) {
			while (n%i == 0) {
				soin[i]++;
				n /= i;
			}
		}
	}
	ll res = 0;
	FOR(i, 2, lim) {
		if (soin[i]) {
			ll cnt = 1;
			while (1) {
				soin[i] -= cnt;
				if (soin[i] >= cnt + 1) {
					cnt++;
					continue;
				}
				else { break; }
			}
			res += cnt;
		}
	}
	if (n != 1) {
		res++;
	}
	pv(res)
	return(0);
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 100 * 1000 + 13;

int n;
vector<int> g[N];

bool read () {
	if (scanf("%d", &n) != 1)
		return false;
	forn(i, n)
		g[i].clear();
	forn(i, n - 1){
		int x, y;
		scanf("%d%d", &x, &y);
		--x, --y;
		g[x].pb(y);
		g[y].pb(x);
	}
	return true;
}

int dp[N][2];

void dfs(int v, int p = -1){
	if (sz(g[v]) == 1 && p != -1)
		dp[v][0] = dp[v][1] = 1;
	int sum0 = 1, sum1 = 1;
	for (auto u : g[v]) if (u != p){
		dfs(u, v);
		sum1 = (sum1 * li(dp[u][0])) % MOD;
		sum0 = (sum0 * li(dp[u][0] + dp[u][1])) % MOD;
	}
	dp[v][0] = sum0;
	dp[v][1] = sum1;
}

void solve(){
	if (n == 1){
		puts("2");
		return;
	}
	
	memset(dp, 0, sizeof(dp));
	dfs(0);
	printf("%d\n", (dp[0][0] + dp[0][1]) % MOD);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

	while(read()) {	
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 13440
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Resale
{
    class Program
    {
        static void Main(string[] args)
        {
            int otpt = 0;
            int n = Convert.ToInt16(Console.ReadLine());
            string[] temp1 = Console.ReadLine().Split(' ');
            int[] v = new int[n];
            for (int i=0;i<n;i++)
            {
                v[i]= Convert.ToInt16(temp1[i]);
            }
            string[] temp2 = Console.ReadLine().Split(' ');
            int[] c = new int[n];
            for (int i = 0; i < n; i++)
            {
                c[i] = Convert.ToInt16(temp2[i]);
            }

            for (int i = 0; i < n; i++)
            {
                if (v[i]>c[i])
                {
                    otpt = otpt + v[i] - c[i];
                }
            }
            Console.WriteLine(otpt);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11220
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	for i := 0; i < len(s); i++ {
		if (s[i:] + s[:i]) == t {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


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

#define forn(i,n) for(ll i = 0;i<n;i++)
#define forne(i,j,n) for(ll i = j;i<n;i++)
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ll INF = 1000000001;
const ll N = 100001;
const lld PI = 3.141593;
#define F first
#define pb(a) push_back(a)
#define S second
#define pii pair<int,int>
typedef pair<ll,ll> pll;

ll powm(ll base,ll exp) {
	ll ans=1;
	while(exp){
		if(exp&1) ans=(ans*base)%mod;
		exp>>=1,base=(base*base)%mod;
	}
	return ans;
}

// ll dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
// bool valid(ll i, ll j) {
// 	return i >= 1 && i <= n && j >= 1 && j <= m; 
// }
// int maxdepth = INT_MAX;
// vector<int> edgeVector[100000];
// ll minans = 1;
// printf("1 %d D\n",abs(r));
// priority_queue<ll,vector<ll>,greater<ll>> pq;
// ll a[N],b[N];
// vector<vector<ll>> adj(N);
// vector<set<ll>> adjs(N);
// ll adj[1001][1001];
// vector<vector<ll>> ans(1001);
// bool visited[N];
// ll cnt[1001];
// ll h,c,t;
// vector<pair<int, pair<int, int> > > g[300043];



int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output1.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll n;
cin>>n;
ll a[n];
forn(i,n) cin>>a[i];
sort(a,a+n);
ll fa = 0;
forne(i,n/2,n){
	fa+=(2*a[i]);
}
if(n%2 == 0){
	fa-=a[n-1];
}
else{
	fa-=a[n-1];
	fa-=a[n/2];
}
cout<<fa<<endl;
}

Measured memory_bytes: 5228