akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

using T = tuple<int32, int32, int32>;

int32 N, P;
vector<T> G[1010];
vector<int32> a, inv;
vector<bool> visited;

void visit(int32 v){
	if(!visited[v]){
		visited[v] = 1;
		REP(i, G[v].size()){
			visit(get<2>(G[v][i]));
		}
		a.push_back(v);
	}
}

int64 dp[1010][1010][2] = {};

int main(void){
	cin >> N >> P;
	visited = vector<bool>(N);

	REP(i, 1010) REP(j, 1010) REP(k, 2) dp[i][j][k] = INF_LL;

	REP(i, P){
		int32 u, v, t1, t2;
		cin >> u >> v >> t1 >> t2; u--; v--;
		G[u].push_back(T(t1, t2, v));
	}
	REP(i, N) visit(i);
	reverse(all(a));
	inv.resize(N);
	REP(i, N){
		inv[a[i]] = i;
	}
	dp[0][0][0] = 0;

	REP(i, N){
		REP(j, N){
			REP(l, 2){
				if(i <= j){
					REP(k, G[a[i]].size()){
						int32 c1, c2, v;
						tie(c1, c2, v) = G[a[i]][k];
						v = inv[v];
						if(v == j){
							if(l == 1)
								chmin(dp[v][j][0], dp[i][j][l]+c2);
							else
								chmin(dp[v][j][0], dp[i][j][l]+c1);
						}else{
							if(j < v && i == j)
								chmin(dp[v][j][1], dp[i][j][l]+c1);
							else
								chmin(dp[v][j][0], dp[i][j][l]+c1);
						}
					}
				}
				if(j <= i){
					REP(k, G[a[j]].size()){
						int32 c1, c2, v;
						tie(c1, c2, v) = G[a[j]][k];
						v = inv[v];
						if(v == i){
							if(l == 1)
								chmin(dp[i][v][0], dp[i][j][l]+c2);
							else
								chmin(dp[i][v][0], dp[i][j][l]+c1);
						}else{
							if(i < v && i == j)
								chmin(dp[i][v][1], dp[i][j][l]+c1);
							else
								chmin(dp[i][v][0], dp[i][j][l]+c1);
						}
					}
				}
			}
		}
	}
	cout << min(dp[N-1][N-1][0], dp[N-1][N-1][1]) << endl;
}



Measured memory_bytes: 19172
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[110000] = {}, DP2[110000] = {};

long long int pow_m1(long long int num){
	long long int pow_num = MOD - 2;
	long long int mod_num = MOD;
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

int main(){
	long long int N, X;
	cin >> N >> X;
    long long int S[300];
	for(int i = 0; i < N; i++){
		cin >> S[i];
	}
    sort(S, S + N);
    long long int num = 1;
    for(int i = 1; i <= N; i++){
        num *= i;
        num %= MOD;
    }
    DP[X] = num;
    for(int i = N - 1; i >= 0; i--){
        num = pow_m1(i + 1);
        for(int j = 0; j <= X; j++){
            DP2[j] = 0;
        }
        for(int j = 0; j <= X; j++){
            DP2[j % S[i]] += DP[j] * num;
            DP2[j % S[i]] %= MOD;
            DP2[j] += DP[j] * (num * i % MOD);
            DP2[j] %= MOD;
        }
        for(int j = 0; j <= X; j++){
            DP[j] = DP2[j];
        }
    }
    long long int ans = 0;
    for(int i = 1; i <= X; i++){
        ans += i * DP[i];
        ans %= MOD;
    }
    cout << ans << endl;
}

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

std::vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

map<int, int> factorization(int x){
    map<int, int> pn;
    for (int i=2; i*i<=x; i++)
    {
        while (x % i == 0) { x/=i; pn[i]++; }
    }
    if (x != 1) pn[x]++;
    return pn;
}

void Main()
{
    int n;
    cin >> n;
    int M = 1000000;
    sieve(M);
    // vector<long> sosu;
    // for (int i = 2; i <= M; i++)
    // {
    //     if(IsPrime[i]) sosu.push_back(i);
    // }
    // vector<int> sum(sosu.size());
    vector<int> sum(M+1);
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        map<int, int> fac = factorization(a);
        // for (int j = 0; j < sosu.size(); j++)
        // {
        //     if(a % sosu[j] == 0) sum[j]++;
        // }
        for (auto j: fac) {
            sum[j.first]++;
        }
    }
    
    int maxsum = 0;
    for (int i = 0; i < sum.size(); i++)
    {
        maxsum = max(maxsum, sum[i]);
    }
    
    if (maxsum <= 1)
        cout << "pairwise coprime" << endl;
    else if (maxsum <= n-1)
        cout << "setwise coprime" << endl;
    else
        cout << "not coprime" << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 7136
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#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__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;

int main(){
    fastio
    int n ;
    cin >> n ;
    int ans = 0 ; 
    for(int i=0;i<n;i++){
    	int x ; 
    	cin >> x ; 
    	ans += x-1 ; 
    }
    cout << ans << endl;
    return 0 ;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int K,N;
ll mo=998244353;
ll p2[2020];

ll combi(ll N_, ll C_) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
ll hcomb(int P_,int Q_) { return ((P_==0&&Q_==0)?1:combi(P_+Q_-1,Q_));}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	p2[0]=1;
	FOR(i,2010) p2[i+1]=p2[i]*2%mo;
	
	cin>>K>>N;
	for(i=2;i<=2*K;i++) {
		int p=0,q;
		for(j=1;j<=K;j++) if(j<i-j && i-j<=K) p++;
		ll ret=0;
		for(q=0;q<=min(N,p);q++) {
			if(i%2==0) {
				ret+=p2[q]*combi(p,q)%mo*(hcomb(K-2*p-1+q,N-q)+hcomb(K-2*p-1+q,N-q-1))%mo;
			}
			else {
				ret+=p2[q]*combi(p,q)%mo*hcomb(K-2*p+q,N-q)%mo;
			}
		}
		cout<<ret%mo<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 9728
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    double n;
    cin>>n;
    double ans=2.0*PI*n;
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3792
n,m,x = map(int, input().split())
books = [list(map(int, input().split())) for _ in range(n)]
ans_cost = []

def calc_cost(book, next_book):
  result = []
  for i, a in enumerate(next_book):
    result.append(book[i] + a) 
  return result

def search_cost(num, sum_book):
  if num >= n:
    for a in sum_book[1:]:
      if a < x:
        return
    ans_cost.append(sum_book[0])
    return
  next_book = calc_cost(sum_book, books[num])
  num += 1
  search_cost(num, next_book)
  search_cost(num, sum_book)

empty_book = [0 for _ in range(m+1)]
search_cost(0, empty_book)
if len(ans_cost) ==0 :
  print(-1)
else:
  print(min(ans_cost))

Measured memory_bytes: 9248
fn main() {
    let x: f64 = read();
    let mut mon = 100.0;
    for i in 1..1000000 {
        mon = (mon * 1.01f64).floor();
        if mon >= x {
            println!("{}", i);
            exit(0);
        }
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


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

using namespace std;

typedef long long ll;
typedef long long unsigned int llui;
typedef long long int lli;
typedef long double float64;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-9
#define DEBUG(x) cout<< '>' << #x << ':' << x << "\n";
#define all(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define tr(container, it) \
    for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 

// #define sz(a) int((a).size())
// #define pb push_back
// #define fill(a,v) memset(a,v,sizeof a)


#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;

#define trace3(x,y,z) cout<< '>' << #x << ':' << x \
        << " | " << #y << ':' << y <<" | " << #z << ':' << z << endl;

#define trace4(x,y,z,w) cout<< '>' << #x << ':' << x \
    << " | " << #y << ':' << y <<" | " << #z << ':' << z << " | " << #w << ':' << w << endl;


inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }

#define LSOne(S) (S&(-S))

const double pi = acos(-1);

/////////////////////////////////////////////////////////////////////

/*bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second < b.second);
}*/

template<class T> inline T gcd(T a,T b) //NOTES:__gcd(0,0) gives exception
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}




const int MAX_N = 1234567;


int main() { 
    int N;
    ll x;
    llui ans=0;
    scanf("%d",&N);
    vector<ll> A,B,C,nB(N),nC(N),pB(N);
    for(int i=0;i<N;i++){
        scanf("%lld",&x);
        A.push_back(x);
    }
    for(int i=0;i<N;i++){
        scanf("%lld",&x);
        B.push_back(x);
    }
    for(int i=0;i<N;i++){
        scanf("%lld",&x);
        C.push_back(x);
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    for(int i=0;i<N;i++){
        x=B[i];
        nB[i]=(lower_bound(A.begin(),A.end(),x)-A.begin());
    }
    pB[0]=nB[0];
    for(int i=1;i<N;i++){
        pB[i]=pB[i-1]+nB[i];
    }
    for(int i=0;i<N;i++){
        x=C[i];
        nC[i]=(lower_bound(B.begin(),B.end(),x)-B.begin());
    }
    for(int i=0;i<N;i++){
        if(nC[i]>0)
            ans+=pB[nC[i]-1];
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7284
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

a, b, c = inl()


def solve():
    return min([a + b, b + c, a + c])


print(solve())


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

ll C[51][51];

void comb(int n){
	for(int i=0;i<=n;++i){
		for(int j=0;j<=i;++j){
			if(j==0) C[i][j]=1;
			else C[i][j]=C[i-1][j-1] + C[i-1][j];
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b;cin >> n >> a >> b;
	vector<ll> v(n);
	rep(i,n) cin >> v[i];
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	comb(n);
	double sum=0;
	rep(i,a) sum+=v.at(i);
	sum/=a;
	if(sum==v.at(0)){
		int cnt=0;
		rep(i,n){
			if(v.at(i)==v.at(0)) cnt++;
		}
		ll ans=0;
		for(int i=a;i<=min(cnt,b);++i){
			ans+=C[cnt][i];
		}
		cout.precision(20);
		cout << fixed << sum << endl;
		cout << ans << endl;
	}
	else{
		int cnt=0,cnt_a=0;
		rep(i,a){
			if(v.at(i)==v.at(a-1)) cnt_a++;
		}
		rep(i,n){
			if(v.at(i)==v.at(a-1)) cnt++;
		}
		cout.precision(20);
		cout << fixed << sum << endl;
		cout << C[cnt][cnt_a] << endl;
	}
}

Measured memory_bytes: 256
def solve():
    H,W,A,B = map(int, input().split())
    matrix = [[0 for j in range(W)] for i in range(H)]
    for i in range(H):
        for j in range(W):
            if i <= B-1:
                if j <= A-1:
                    print(1,end="")
                else:
                    print(0,end="")
            else:
                if j <= A-1:
                    print(0,end="")
                else:
                    print(1,end="")
        print("")
solve()

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int key = N;
		int []hairetu = new int[10];
		for(int i=0;i<10;i++){
			hairetu[i] = N%10;
			N = N /10;
		}
		int sum =0;
		for(int i=0;i<10;i++){
			sum = sum + hairetu[i];
		}
		if(key % sum==0){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
#include <cstdio>
#include <bits/stdc++.h>
using ll = long long ;
using namespace std ;

int read() {
  int x = 0 , f = 1 ; char c = getchar() ;
  while(c < '0' || c > '9') { if(c == '-') f = -1 ; c = getchar() ; }
  while(c >= '0' && c <= '9') { x = (x << 1) + (x << 3) + (c & 15) ; c = getchar() ; }
  return x * f ;
}

template < class T > void print(T x , char c = '\n') {
  static char _st[100] ; int _stp = 0 ;
  if(x == 0) { putchar('0') ; }
  if(x < 0) { putchar('-') ; x = -x ; }
  while(x) { _st[++ _stp] = (x % 10) ^ 48 ; x /= 10 ; }
  while(_stp) { putchar(_st[_stp --]) ; }
  putchar(c) ;
}

int main() {
  string s ;
  cin >> s ;
  if(s == "SUN") print(7) ;
  if(s == "MON") print(6) ;
  if(s == "TUE") print(5) ;
  if(s == "WED") print(4) ;
  if(s == "THU") print(3) ;
  if(s == "FRI") print(2) ;
  if(s == "SAT") print(1) ;

  return 0 ;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> count(26, INF);
    long i, j;
    for(i=0; i<n; i++) {
        long zz[26]={0};
        char str[51]={0};
        scanf("%s", str);
        for(j=0; j<strlen(str); j++) {
            zz[str[j]-'a'] ++;
        }
        for(j=0; j<26; j++) {
            count[j] = MIN(count[j], zz[j]);
        }
    }

    for(i=0; i<26; i++) {
        for(j=0; j<count[i]; j++) {
            printf("%c", i+'a');
        }
    }
    printf("\n");

    return 0;
}



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

int main(){
    int n;
    cin >> n;
    int t,x,y;
    int rt = 0;
    int rx = 0;
    int ry = 0;
    int p;
    for(int i=0; i!=n; i++){
        cin >> t >> x >> y;
        if(x - rx < 0){
            p = (x - rx) * -1;
        }else{
            p = x - rx;
        }
        rx = x;
        if(y - ry < 0){
            p = (y - ry) * -1 + p;
        }else{
            p = y - ry + p;
        }
        ry = y;
        t = t - rt;
        if(t < p || (t - p) % 2 != 0){
            cout << "No\n";
            return 0;
        }
        rt = rt + t;
    }
    cout << "Yes\n";
    return 0;
}


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

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};
};

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;

int main() {
    int n;
    std::cin >> n;

    Graph<int> graph(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        std::cin >> u >> v;
        --u, --v;
        graph[u].emplace_back(u, v, i);
        graph[v].emplace_back(v, u, i);
    }

    std::vector<int> ans(n - 1);
    std::function<void(int, int, int)> dfs =
        [&](int v, int r, int rc) {
            int c = 0;
            for (auto& e : graph[v]) {
                if (e.dst == r) continue;
                do {
                    ++c;
                } while (c == rc);
                ans[e.cost] = c;
                dfs(e.dst, e.src, c);
            }
        };
    dfs(0, -1, 0);

    std::cout << *max_element(ans.begin(), ans.end()) << std::endl;
    for (auto c : ans) {
        std::cout << c << std::endl;
    }
    return 0;
}


Measured memory_bytes: 8320
while True:
  b = int(input())
  if b == 0:break
  x = b * 2
  for k in range(int(x ** (1 / 2)), 0, -1):
    if x % k == 0:
      if (-k + 1 + (x // k)) % 2 == 0:
        a = (-k + 1 + x // k) // 2
        if a > 0:
          print(a, k)
          break


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

using namespace std;

#define MOD 1000000007

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());
    if(n&1) {
        if(a[0]!=0) {
            cout << 0 << endl;
            return 0;
        }
        int pairs = n / 2;
        for(int i=1; i<=pairs; i++) {
            if(a[2*i-1]!=2*i || a[2*i]!=2*i) {
                cout << 0 << endl;
                return 0;
            }
        }
        int res = 1;
        for(int i=0; i<pairs; i++) res = (res * 2) % MOD;
        cout << res << endl;
        return 0;
    } else {
        int pairs = n / 2;
        for(int i=0; i<pairs; i++) {
            if(a[2*i]!=2*i+1 || a[2*i+1]!=2*i+1) {
                cout << 0 << endl;
                return 0;
            }
        }
        int res = 1;
        for(int i=0; i<pairs; i++) res = (res * 2) % MOD;
        cout << res << endl;
        return 0;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int check(int x,int y, vvi ch) {
  int flg = 1;
  REP(i,8) {
    if(ch[x][i]==1) {
      flg=0;
      break;
    }
    if(ch[i][y]==1)  {
      flg=0;
      break;
    }
    if(x+i<8&&y+i<8) {
      if(ch[x+i][y+i]==1)  {
      flg=0;
      break;
    }
    }
    if(x-i>=0&&y+i<8) {
      if(ch[x-i][y+i]==1)  {
      flg=0;
      break;
    }
    }
    if(x+i<8&&y-i>=0) {
      if(ch[x+i][y-i]==1)  {
      flg=0;
      break;
    }
    }
    if(x-i>=0&&y-i>=0) {
      if(ch[x-i][y-i]==1)  {
      flg=0;
      break;
    }
    }
  }
  return flg;
}

int solution(double t,double p) {
  double f=1.0-(1/1.5)*log(2)*p*pow(2,-t/1.5);
  if(f>=0) return 1;
  else if(f<0) return 0; 
}

int main() {
  ll x;
  cin >> x;
  int a,b;
  REPD(i,-120,121) {
    REPD(j,-120,121) {
      if(pow(i,5)-pow(j,5)==x) {
        a=i;
        b=j;
        break;
      }
    }
  }
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 3988
class dice:
    def __init__(self,dice):
        self.dice = dice

    def roll_n(self):
        d = self.dice
        self.dice = [d[1],d[5],d[2],d[3],d[0],d[4]]

    def roll_e(self):
        d = self.dice
        self.dice = [d[3],d[1],d[0],d[5],d[4],d[2]]

    def roll_s(self):
        d = self.dice
        self.dice = [d[4],d[0],d[2],d[3],d[5],d[1]]
    
    def roll_w(self):
        d = self.dice
        self.dice = [d[2],d[1],d[5],d[0],d[4],d[3]]

    def top(self):
        return self.dice[0]

    def roll(self,command):
        if command=='N':self.roll_n()
        if command=='E':self.roll_e()
        if command=='S':self.roll_s()
        if command=='W':self.roll_w()

    def same(self,b):
        com1 = 'SSSWSSSE'
        com2 = 'WWWW'
        for c in com1:
            if self.dice[1]==b.dice[1]:break
            if c=='E':return False
            b.roll(c)
        for c in com2:
            if self.dice==b.dice:return True
            b.roll(c)
        return False

def main():
    n = int(input())
    dices = []
    for _ in range(n):
        dices.append(dice(list(map(int,input().split()))))
    for i in range(n):
        for j in range(i+1,n):
            if dices[i].same(dices[j]):
                print('No')
                return
    print('Yes') 

if __name__ == '__main__':
    main()




Measured memory_bytes: 5612
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>

#define ll long long int

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

priority_queue<int> pque;

string str;

int main()
{
  int a;
  int i;

  for(i=0;i<5;i++){
    cin>>a;
    pque.push(a);
  }
  for(i=0;i<5;i++){
    cout<<pque.top();;
    pque.pop();
    if(i<4)cout<<" ";
    else cout<<endl;
  }
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define pii pair<int,int> 
#define mp make_pair
using namespace std;
vector<int> a,b;
void print(pii x){
	printf("(%d %d)\n",x.first,x.second);
}
void work(vector<int> a,pii &x,pii &y){
	map<int,int> cnt;
	for(int i=0;i<a.size();i++)cnt[a[i]]++;
	for(auto it:cnt){
		pii t = pii(it);
		if(t.second>x.second){
			y = x;
			x = t;
		}
		else if(t.second>y.second){
			y = t;
		}
	} 
}
int main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		if(i%2==0)a.push_back(x);
		else b.push_back(x);
	}
	pii ax,ay,bx,by;
	ax = ay = bx = by = mp(0,0);
	work(a,ax,ay);
//	print(ax);print(ay);
	work(b,bx,by);
//	print(bx);print(by);
	int ans = 0;
	if(ax.first==bx.first){
		ans = max(ax.second+by.second,ay.second+bx.second);
	}
	else ans = ax.second+bx.second;
	cout << n - ans << endl;
	return 0;
} 

Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
// #define mp make_pair
#define S second
#define F first
ll mod=1e9+7 ;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std::chrono; 

int main(){                         fastIO
  // input_from_file
  ll n;string s;cin>>s;
  ll ans=0,ctr=0;
  for(int i=0;i<3;i++){
    if(s[i]=='R') ctr++;
    else{
      ans=max(ans,ctr);ctr=0;
    }
  }
  ans=max(ans,ctr);
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    char str[n];
    scanf("%s", str);
    int nCount = 0;
    for(int i = 0; i < n - 2; i++){
        if(str[i] =='A' && str[i+1] == 'B' && str[i+2] == 'C'){
            nCount++;
        }
    }
    
    printf("%d", nCount);
    return 0;
}


Measured memory_bytes: 3228
from collections import deque, defaultdict

def topological_sort(V, E):
    '''
    Kahn's Algorithm (O(|V| + |E|) time)
    Input:
    V = [0, 1, ..., N-1]: a list of vertices of the digraph
    E: the adjacency list of the digraph (dict)
    Output:
    If the input digraph is acyclic, then return a topological sorting of the digraph.
    Else, return None.
    '''
    indeg = {v: 0 for v in V}
    for ends in E.values():
        for v in ends:
            indeg[v] += 1
    
    q = deque([v for v in V if indeg[v] == 0])
    top_sorted = []
    while q:
        v = q.popleft()
        top_sorted.append(v)
        
        for u in E[v]:
            indeg[u] -= 1
            if indeg[u] == 0:
                q.append(u)
    if len(top_sorted) == len(V): # The input digraph is acyclic.
        return top_sorted
    else: # There is a directed cycle in the digraph.
        return None

N, M = map(int, input().split())
V = range(N)
E = defaultdict(list)
for _ in range(M):
    s, t = map(int, input().split())
    E[s].append(t)
print(*topological_sort(V, E), sep='\n')


Measured memory_bytes: 9896
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < (int)n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
#endif

int K, S;
int main() {
	cin >> K >> S;
	int count = 0;
	REP(i, 0, K + 1) {
		REP(j, 0, K + 1) {
			if (i + j <= S && S - i - j <= K) {
				++count;
			}
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

/**
   ceil(0, 2) == 0
   ceil(1, 2) == 1
   ceil(2, 2) == 1
   ceil(3, 2) == 2
   ceil(4, 2) == 2
*/
template<class T>
T ceil(T dividend, T divisor)
{
    return (dividend + (divisor - 1)) / divisor;
}

int main()
{
    int64_t N, K;
    std::cin >> N >> K;

    int64_t P = 0;

    for (decltype(N) i = i; i <= N; ++i) {
        int64_t t;
        std::cin >> t;

        if (t == 1) {
            P = t;
            break;
        }
    }

    if (N == K) {
        std::cout << 1 << std::endl;
    }
    else {
        std::cout << ceil(P-1, K-1) + ceil(N-P, K-1) << std::endl;
    }

    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,M;
  cin>>N>>M;
  vector<int>x(M),y(M);
  for(int i=0;i<M;i++)cin>>x[i]>>y[i];
  vector<bool>red(N,false);
  vector<int>ball(N,1);
  red[0]=true;
  for(int i=0;i<M;i++){
    if(red[x[i]-1]){
      red[y[i]-1]=true;
    }
    ball[y[i]-1]++;
    ball[x[i]-1]--;
    if(ball[x[i]-1]==0)red[x[i]-1]=false;
  }
  int ans=0;
  for(int i=0;i<N;i++)ans+=red[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

int main(void){
  int a,b,ans=0;
  cin>>a>>b;
  if(a>b){
    ans=2*a-1;
  }else if(a<b){
    ans=2*b-1;
  }else{
    ans=2*a;
  }
  cout<<ans<<endl;
  return 0;
}


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

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1000000007
#define PI 3.141592653
#define inf 100007
#define P pair<ll,ll>

using namespace std; 

int main(){
    string s,d="";
    cin>>s;
    int n=s.size(),ans=0,i=0;
    while(i<n){
        if(s[i]==s[n-1]){
            i++,n--;
        }
        else{
            if(s[i]=='x') ans++,i++;
            else if(s[n-1]=='x') ans++,n--;
            else{
                ans=-1;
                break;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
  int a, b, d, r;
  double f;

  cin >> a >> b;

  1 <= a;
  b <= 10^9;

  d = a/b;
  r = a%b;
  f = 1.0*a/b;

  cout << d << " " << r << " ";
  printf("%.5lf\n",f);

  return 0;
}

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

int main(){
	int N, K, a=0;
	cin >> N >> K;
	int l[N];
	for(int i=0; i<N; i++) cin >> l[i];
	sort(l, l+N);
	for(int i=0; i<K; i++){
		a += l[N-i-1];
	}
	cout << a;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
int a,b,x;
cin>>a>>b>>x;
if(a>x||a+b<x)
cout<<"NO";
else
cout<<"YES";
system("pause");
return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

int a[N], b[N], c[N];

void solve() {
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
    if (!i) {
      b[0] = a[0];
    } else {
      b[i] = __gcd(b[i-1], a[i]);
    }
  }
  c[n-1] = a[n-1];
  for (int i = n-2; i >= 0; --i) {
    c[i] = __gcd(c[i+1], a[i]);
  }
  int ans = c[1];
  for (int i = 1; i < n-1; ++i) {
    ans = max(ans, __gcd(b[i-1], c[i+1]));
  }
  ans = max(ans, b[n-2]);
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 5020
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

const int N = 81;

bool dp[N][N][2*N*N];

int main() {
    int h, w;
    cin >> h >> w;

    vvl a(h, vl(w)), b(h, vl(w));
    rep(i, h) {
        rep(j, w) {
            cin >> a[i][j];
        }
    }
    rep(i, h) {
        rep(j, w) {
            cin >> b[i][j];
        }
    }
    
    dp[0][0][abs(a[0][0] - b[0][0])] = true;
    rep(i, h) {
        rep(j, w) {
            rep(k, 2*N*N) {
                if(!dp[i][j][k]) {
                    continue;
                }
                if(i < h-1) {
                    int x = abs(a[i+1][j] - b[i+1][j]);
                    dp[i+1][j][abs(k + x)] = true;
                    dp[i+1][j][abs(k - x)] = true;
                }
                if(j < w-1) {
                    int x = abs(a[i][j+1] - b[i][j+1]);
                    dp[i][j+1][abs(k + x)] = true;
                    dp[i][j+1][abs(k - x)] = true;
                }
            }
        }
    }

    ll ans = INF;
    rep(k, 2*N*N) {
        if(dp[h-1][w-1][k]) {
            chmin(ans, k);
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 83456
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int n = 0;
	int *h;
	int candidate = 0;
	int x = 0;
	scanf("%d", &n);
	h = (int *)malloc(sizeof(int) * n);
	for(int i = 0; i < n; i++){
		scanf("%d", &h[i]);
	}
	for(int j = 0; j < n-1; j++){
		if(h[j] >= h[j+1]){
			candidate++;
		}
		else{
			if(x < candidate){
				x = candidate;
			}
			candidate = 0;
		}
	}
	if(x < candidate){
		x = candidate;
	}
	printf("%d\n", x);
	return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main { 
	static ArrayList<Data> list = new ArrayList<Data>();
	static int n;
	static int q;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		 n = stdIn.nextInt();
		 q = stdIn.nextInt();
		for(int i = 0; i < n; i++) {
			double a = stdIn.nextDouble();
			double b = stdIn.nextDouble();
			double c = stdIn.nextDouble();
			list.add(new Data(a,b,c));
		}
		double ans = solv(0,0,new ArrayList<Data>());
		System.out.println(ans);
	}
	public static double solv(int a, int b, ArrayList<Data> c) {
		if(b == q) {
			double data = 0;
			for(int i = 0; i < q; i++) {
				for(int j = i+1; j < q; j++) {
					Data ad = c.get(i);
					Data bd = c.get(j);
					data += (bd.x-ad.x)*(bd.x-ad.x) + (bd.y-ad.y)*(bd.y-ad.y) + (bd.z-ad.z)*(bd.z-ad.z);
				}
			}
			return data;
		}
		if(a == n) return 0.0;
		double ret = 0.0;
		ArrayList<Data> b1 = new ArrayList<Data>();
		ArrayList<Data> b2 = new ArrayList<Data>();
		b1.addAll(c);
		b1.add(list.get(a));
		b2.addAll(c);
		double a1 = solv(a+1,b+1,b1);
		double a2 = solv(a+1,b,b2);
		
		return((a1 > a2)?a1:a2);
	}
}

class Data {
	double x;
	double y;
	double z;
	Data(double a, double b, double c) {
		x = a;
		y = b;
		z = c;
	}
}

	

Measured memory_bytes: 171184
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    if (b == 'A') b = 'T';
    else if (b == 'T') b = 'A';
    else if (b == 'C') b = 'G';
    else if (b == 'G') b = 'C';

    cout << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define mod (ll)(1e9+7)
#define nax (ll)(1e5)
#define INFL LLONG_MAX
#define INF INT_MAX
#define disp(a,n,arr) for(int i=a;i<(ll)n;i++) cout << arr[i] << " "; cout << "\n";
#define check cout << "Working\n";
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vpl vector<pl>
#define vpi vector<pi>
#define vb vector<bool>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;



int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	FIO;

	// Write your code here

	int t = 1;
	//cin >> t;
	while (t--) {
		ll a, b, c, k;
		cin >> a >> b >> c >> k;
		if (a + b >= k) {
			cout << min(a, k) << "\n";
		} else {
			k -= a + b;
			cout << a - k << "\n";
		}
	}


	return 0;
}

Measured memory_bytes: 3660
S = [ord(s) - 97 for s in input()]
T = [ord(t) - 97 for t in input()]
ls = len(S)

indexes = [[] for _ in range(26)]
for i, s in enumerate(S):
    indexes[s].append(i)
m = [[-1] * 26 for _ in range(ls)]
for s in range(26):
    inds = indexes[s]
    if not len(inds):
        continue
    for r in range(1, len(inds)):
        for i in range(inds[r-1], inds[r]):
            m[i][s] = inds[r] - i
    l = inds[-1]
    r = inds[0]
    i = l
    while True:
        m[i][s] = (r - i - 1) % ls + 1
        if i == (r - 1) % ls:
            break
        i = (i + 1) % ls

ans = 0
i = ls - 1
for t in T:
    cnt = m[i][t]
    if cnt == -1:
        print(-1)
        exit()
    ans += cnt
    i = (i + cnt) % ls
print(ans)


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

using namespace std;
const int N = 1e6 + 1;
int a[N];

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m, sum = 0, res = 0;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    if (sum > n)
        cout << "-1\n";
    else
        cout << n - sum << endl;
}

Measured memory_bytes: 3584
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int a[101];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    int minj, tmp;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        minj = i;
        for(int j = i; j < N; j++){
            if(a[j] < a[minj]){
                minj = j;
            }
        }
        if(a[i] != a[minj]){
            tmp = a[i];
            a[i] = a[minj];
            a[minj] = tmp;
            cnt++;
        }
    }
    
    for(int i = 0; i < N; i++){
        if(i < N - 1)   cout << a[i] << " ";
        else    cout << a[i] << endl;
    }
    cout << cnt<< endl;
    
    return 0;
}



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

using namespace std;

int main() {
    int T, H, S;
    while (scanf("%d %d %d", &T, &H, &S), (T != -1)) {
        int sec = 120 * 60 - T * 3600 - H * 60 - S;
        int h = sec / 3600, m = sec % 3600 / 60, s = sec % 60;
        
        printf("%02d:%02d:%02d\n", h, m, s);

        sec *= 3;
        h = sec / 3600, m = sec % 3600 / 60, s = sec % 60;
        
        printf("%02d:%02d:%02d\n", h, m, s);
    }

    return 0;
}


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

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr ll TEN(int n){return n==0?1:10*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

const int mod = TEN(9) + 7;

int mn = inf;
int N;
ll A[200010];
ll sum[200010];

signed main()
{
    cin >> N;
    rep1(i, N) cin >> A[i];

    for (int i = 0; i < N; ++i) {
        sum[i + 1] = A[i + 1] + sum[i];
        sum[i + 1] %= mod;
    }

    ll ans = 0;

    for (int i = N; i >= 2; --i) {
        ans += sum[i - 1] * A[i] % mod;
        ans %= mod;
    }

    cout << ans << endl;
}


Measured memory_bytes: 6724
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    long long c;
    cin >> c;

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

    vector<long long> best = {0LL};
    vector<long long> bestret = {0LL};
    {
        long long cur = 0;
        long long curx = 0;
        for(int i = 0; i < n; ++i)
        {
            cur -= (x[i] - curx);
            cur += v[i];
            curx = x[i];
            best.push_back(max(best.back(),cur));
            bestret.push_back(max(bestret.back(), cur - curx));
        }
    }



    reverse(begin(x), end(x));
    reverse(begin(v), end(v));

    for(auto& t : x)
        t = c - t;

    vector<long long> best2 = {0LL};
    vector<long long> bestret2 = {0LL};
    {
        long long cur = 0;
        long long curx = 0;
        for(int i = 0; i < n; ++i)
        {
            cur -= (x[i] - curx);
            cur += v[i];
            curx = x[i];
            best2.push_back(max(best2.back(),cur));
            bestret2.push_back(max(bestret2.back(), cur - curx));
        }
    }

    long long ans = 0;
    for(int i = 0; i <= n; ++i)
    {
        ans = max(ans, best[i] + bestret2[n - i]);
        ans = max(ans, best2[i] + bestret[n - i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5740
#include <bits/stdc++.h>
#define inf (int)(1e8)
using namespace std;

int n;
string a, b;
vector<int> l, r;

int solve();
int calc();

int main() {
  cin >> a >> b;
  n = a.size();
  a += a;
  cout << solve() << endl;
  return 0;
}

int solve() {
  int res = min(inf, calc());
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  res = min(res, calc());
  if (res == inf) return -1;
  return res;
}

int calc() {
  int res = inf;
  l.assign(n, inf);
  r.assign(n, inf);
  for (int t = 0; t < 2; ++t)
    for (int i = 0; i < n; ++i) {
      if (b[i] == '1') l[i] = r[i] = 0;
      r[(i + 1) % n] = min(r[(i + 1) % n], r[i] + 1);
    }
  for (int t = 0; t < 2; ++t)
    for (int i = n - 1; i >= 0; --i) l[i] = min(l[i], l[(i + 1) % n] + 1);
  for (int i = 0; i <= n; ++i) {
    string s = a.substr(i, n);
    int now = 0, len = 0;
    using P = pair<int, int>;
    vector<P> v(1, P(0, 0));
    for (int j = 0; j < n; ++j)
      if (s[j] != b[j]) {
        ++now;
        v.emplace_back(l[j], r[j]);
      }
    len = v.size();
    sort(v.begin(), v.end());
    for (int j = len - 2; j >= 0; --j)
      v[j].second = max(v[j].second, v[j + 1].second);
    for (int j = 0; j < len - 1; ++j) v[j].second = v[j + 1].second;
    v[len - 1].second = 0;
    for (int j = 0; j < len; ++j) {
      auto [ml, mr] = v[j];
      int score = 0;
      if (ml == inf || mr == inf) continue;
      score = min(max(ml - i, 0) + mr, n - i) * 2 + i;
      res = min(res, score + now);
    }
  }
  return res;
}

Measured memory_bytes: 3700
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ').Select(txt => int.Parse(txt)).ToList();
        var X = inputs[0];
        var Y = inputs[1];

        bool found = false;
        for (int x1 = 0; x1 <= X; x1++)
        {
            var x2 = X - x1;

            if ((x1 * 2 + x2 * 4) == Y)
            {
                found = true;
                break;
            }
        }

        Console.WriteLine(found ? "Yes" : "No");
    }
}

Measured memory_bytes: 28236
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




int main(){
    LL k;cin >> k;
    LL s = 7;
    for (int i = 1; i <= k; i++) {
        if(s % k == 0){
            cout << i << endl;
            return 0;
        }
        s = (s * 10 + 7)%k;
    }
    puts("-1");
    return 0;
}


Measured memory_bytes: 3636