akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
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; }

const ll INF=1LL<<60;

ll dp[110][100010],N,W;
ll w[110];
ll v[110];

int main() {
  //入力
  cin >> N >> W;
  rep(i,N){
    cin >> w[i] >> v[i];  
  }

  //DPテーブルの初期化
  rep(i,110){
    rep(j,100010){
      dp[i][j]=INF;
    }
  }

  //DPテーブルの初期条件
  dp[0][0]=0;
  
  //DPテーブルの更新
  for(int i=0;i<N+1;i++){
    rep(sum_v,100010){
      if (sum_v>=v[i]){
        chmin(dp[i+1][sum_v],dp[i][sum_v-v[i]]+w[i]);
      }
      chmin(dp[i+1][sum_v],dp[i][sum_v]);
      
    }
  }

  //出力
  ll ans;
  for(int i=0;i<100010;i++){
    if(dp[N][i]<=W)ans=i;
  }
  cout << ans << endl;
  
  return 0;
}

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

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

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

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

fn main() {
  let n: usize = read();
  let d: Vec<usize> = read_vec();
  let mut ans = 0;

  for i in 0..n {
    for j in i+1..n {
      ans += d[i] * d[j];
    }
  }

  println!("{}", ans);
}


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


int main(){
    int n;
    cin>>n;
    int flag=0;
    vector<long long> a(n);
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a.begin(),a.end());
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    
    return 0;
}


Measured memory_bytes: 1792
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
const double PI = acos(-1);

int main() {
	int n, r, p, c;
	while (cin >> n >> r&&n&&r) {
		vector<int> vec;
		for (int i = n; i >= 1; i--) {
			vec.emplace_back(i);
		}
		for (int i = 0; i < r; i++) {
			cin >> p >> c;
			for (int j = 0; j < c; j++) {
				vec.insert(vec.begin(),vec[p + c - 2]);
				vec.erase(vec.begin() + p + c - 1);
			}
		}
		cout << vec[0] << endl;
	}
}

Measured memory_bytes: 3076
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws java.lang.Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader((System.in)));
        StringTokenizer st = new StringTokenizer(br.readLine());
        char[] s = st.nextToken().toCharArray();
        for (int i = 0, j = s.length-1; i <= j; i++, j--) {
            if (s[i] == s[j]) continue;
            else {
                System.out.println("No");
                return;
            }
        }
        for (int i = 0, j = (s.length - 2) / 2; i <= j; i++, j--) {
            if (s[i] == s[j]) continue;
            else {
                System.out.println("No");
                return;
            }
        }
        for (int i = (s.length + 1) / 2, j = s.length - 1; i <= j; i++, j--) {
            if (s[i] == s[j]) continue;
            else {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
//        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
//        bw.write("\n");
//        bw.close();
    }

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ld> vld;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<double> vd;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 27;
const lli INF = 1e18;
const lli MOD = 13;
const double EPS=1e-6;

bool mm[N];
vi primes(1,2);
void sieve(){
	for(int i = 4; i<N; i+=2)mm[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!mm[i])for(int j = i*i; j<N; j+=i)mm[j]=1;
	for(int i = 3; i<N; i+=2)if(!mm[i])primes.pb(i);
}

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

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7


int main(){ _
	lli n; cin>>n;
	vl v(n+1,0);
	fore(i,1,n+1)for(int j = i;j<=n;j+=i)v[j]++;
	lli sum = 0; fore(i,1,n+1)sum+=(v[i]*i);
	cout<<sum<<ENDL;
}


Measured memory_bytes: 81284
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

// ll fact(long n){
//     if(n ==1) return 1;
//     else{
//         return n * fact(n-1);
//     }
// }

// ll permutation(long a, long b){
//     ll ans = fact(a)/fact(a-b);

//     return ans;
// }

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    ll n;
    cin >> n;

    // Logic: permutation of i means randomize i'S position, and find its largest sum of modulo, between i and permutation
    /* Largest example:
        1 2 3 4 5 
        randomized
        2 3 4 5 0 <- modulo operand
        modulo would be: 1 + 2 + 3 + 4 + 0 = 10. This just means to take the sum of the numbers except the last number..?
    */
    ll ans;
    ans = n * (n-1)/2; // Sum of 0,1,2,...,n-1


    // long ans = 0;
    // for(long i = 1; i <= n; i++){
    //     ll perm = permutation(n,n);
    //     long mod = n % perm;
    //     ans += mod;
    // }
    

    cout << ans;

	return 0;
}


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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  i64 n;
  cin >> n;

  i64 sum = 0;
  i64 i = 1;
  vector<i64> vec;
  while (true) {
    if (sum >= n) {
      i64 x = sum - n;
      for (auto e : vec) {
        if (e == x) continue;
        cout << e << "\n";
      }
      break;
    }

    sum += i;
    vec.push_back(i);
    ++i;
  }

  return 0;
}

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

struct Info{
  	int seq;
	std::string name;
  	int point;
  	Info(int _s, const std::string& _n, int _p) : seq(_s), name(_n), point(_p) {}; 
};

struct Comp{
	bool operator()(const Info& lhs, const Info& rhs){
    	if(lhs.name == rhs.name) return lhs.point > rhs.point;
      	else return lhs.name < rhs.name;
    }
};

int main(void){
	std::vector<Info> book;
  	int N;
  	std::cin >> N;
  	int i = 1;
  	std::string name;
  	int point;
  	while(N-- > 0){
      	std::cin >> name >> point;
    	book.emplace_back(Info(i++, name, point));
    }
  	std::sort(book.begin(), book.end(), Comp());
  	for(auto iter = book.begin(); iter != book.end(); ++iter){
    	std::cout << iter->seq << std::endl;
    }
  
  	return 0;
}

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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e18;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert

int main(){
    //freopen("input00.txt","r",stdin);
    ll T = 1;
    //cin>>T;
    while(T--){
        ll a,b,m;
        cin>>a>>b>>m;
        vector<ll> A(a) , B(b);
        ll minA = oo , minB = oo;
        for(ll i=0;i<a;i++){
            cin>>A[i];
            minA = min(minA,A[i]);
        }
        for(ll j=0;j<b;j++){
            cin>>B[j];
            minB = min(minB , B[j]);
        }
        ll MIN = oo;
        for(ll i=0;i<m;i++){
            ll x,y,c;
            cin>>x>>y>>c;
            x--;y--;
            ll tot = A[x] + B[y];
            ll tmp = tot - c;
            MIN = min(MIN , tmp); 
        }
        MIN = min(MIN , minA + minB);
        cout << MIN;

    }
    return 0;
}

Measured memory_bytes: 1792
END { load __FILE__ unless $stdin.eof? }

n = gets.to_i
points = Array.new(n) { gets.split.map!(&:to_i) }

s_min, s_max = points.map { |x, y| x - y }.minmax
t_min, t_max = points.map { |x, y| x + y }.minmax

puts [s_max - s_min, t_max - t_min].max


Measured memory_bytes: 30612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	public static void main(String[] args)throws IOException, NumberFormatException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		Deque<Integer> list=new ArrayDeque<Integer>();
		for(int i=0;i<n;i++){
			String command=br.readLine();
			if(command.charAt(0)=='i'){
				list.offerFirst(Integer.parseInt(command.substring(7)));
			}else if(command.charAt(6)==' '){
				list.remove(Integer.parseInt(command.substring(7)));
			}else if(command.charAt(6)=='F'){
				list.removeFirst();
			}else if(command.charAt(6)=='L'){
				list.removeLast();
			}
		}
		while(list.size()!=1){
			System.out.print(list.poll()+" ");
		}
		System.out.println(list.poll());
	}

}

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

    if(s.size()<=n)
    {
        cout<<s<<endl;
    }

    else
    {
        cout<<s.substr(0,n)<<"..."<<endl;
    }

    exit(0);
}


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

#define int long long
#define MAXN 200005

int n;
int ft[MAXN];

int maxf(int r){
	int mxf = 0;
	for(; r>=0; r=(r&(r+1))-1){
		mxf = max(mxf, ft[r]);
	}
	return mxf;
}

void upd(int idx, int v){
	for(; idx<n; idx|=(idx+1)){
		ft[idx] = max(ft[idx],v);
	}
}

int32_t main(){
	cin>>n;
	int h[n],a[n];
	for(int i=0; i<n; i++) cin>>h[i];
	for(int i=0; i<n; i++) cin>>a[i];
	pair<int,int> sh[n];
	for(int i=0; i<n; i++) sh[i]=make_pair(h[i],i);
	sort(sh,sh+n);
	int tos[n];
	for(int i=0; i<n; i++){
		tos[sh[i].second] = i;
	}
	memset(ft,0,sizeof(ft));
	int dp[n];
	int an=0;
	for(int i=0; i<n; i++){
		dp[i] = maxf(tos[i])+a[i];
		upd(tos[i],dp[i]);
		an=max(an,dp[i]);
	}
	cout<<an;
}

Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		n = n%10;
		if(n==2||n==4||n==5||n==7||n==9) {
			System.out.println("hon");
		}
		if(n==0||n==1||n==6||n==8) {
			System.out.println("pon");
		}
		if(n==3) {
			System.out.println("bon");
		}

	}


	static long divn(int target, int times) {//10_9+7のあまり累乗版
		int sqtimes = (int)Math.sqrt(times);
		long ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		long holder = ans;
		ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans*holder)%(1000000000+7);
		}
		for(int i=0;i<times - sqtimes*sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		return ans;
	}

	static long div(long a) {//10_9+7のあまり
		if(a<0)a+=1000000000+7;
		return a%(1000000000+7);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 35728
(defn card-game-for-two [n a]
  (let [arr (sort > a)]
    (loop [counter 0 alice 0 bob 0]
      (if (>= counter n)
          (int (- alice bob))
          (if (even? counter)
              (recur (inc counter) (+ alice (nth arr counter)) bob)
              (recur (inc counter) alice (+ bob (nth arr counter))))))))

(defn create-data [s]
  (map #(bigint %) (.split s " ")))

(println (card-game-for-two (Long/parseLong (read-line)) (create-data (read-line))))

Measured memory_bytes: 64728
#include <stdio.h>

#define NUM 10

int main(void){

int mount[NUM];
 int i, j;
 int tmp;

 for(i = 0; i < NUM; i++){
  scanf("%d", &mount[i]);
 }

 for(i = 0; i < NUM - 1; i++){
   for(j = NUM - 1; j > i; j--){ 
     if(mount[j - 1] < mount[j]){
     tmp = mount[j];
   mount[j] = mount[j - 1];
   mount[j - 1] = tmp;
   }
 }
 }

 printf("%d\n%d\n%d\n", mount[0], mount[1], mount[2]);

 return 0;
}

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

    int a,b,c,d;
    l1 e,f,g,h;

    cin>>a>>b;
    int x[a],memo[a];

    for(int i=0;i<a;i++){
        memo[i]=0;
    }
    for(int i = 0;i<a;i++){
        cin>>c;
        for(int l=0;l<c;l++){
            int me;
            cin>>me;
            memo[me-1]=1;
        }
    }
    d=0;
    for(int i=0;i<a;i++){
        if(memo[i]==0)d++;
    }



    cout<<d;

return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main()
{
  int i,n,a[10000],min,max;
  long int sum;
  scanf("%d",&n);
  sum=0;
  for(i=1;i<=n;i++)
    {
      scanf("%d",&a[i]);
      min=a[1];
      max=a[1];
    }
  for(i=1;i<=n;i++)
    {
      sum=a[i]+sum;

      if(a[i]<=min){
        min=a[i];
      }
      else if(a[i]>=max){
        max=a[i];
      }
    }
  printf("%d %d %ld\n",min,max,sum);

  return 0;
}



Measured memory_bytes: 2148
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define xx first
#define yy second
#define $1 first
#define $2 second

typedef struct _cond {
	ll a, b, c, d;
}cond;

ll ans = 0;
ll n, m, q;
vector<cond> v;

void solve(vector<ll> a, ll left_pick) {
	if (left_pick == 0) {
		ll temp = 0;
		for (int i = 0; i < v.size(); i++) {
			if (a[v[i].b-1] - a[v[i].a-1] == v[i].c) temp += v[i].d;
		}
		ans = max(temp, ans);
		return;
	}
	ll smallest = a.back();
	for (ll i = smallest; i <= m; i++) {
		a.push_back(i);
		solve(a, left_pick - 1);
		a.pop_back();
	}
}

void solveCase() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin >> n >> m >> q; v.resize(q);
	for (int i = 0; i < q; i++) { cin >> v[i].a >> v[i].b >> v[i].c >> v[i].d; }
	for (int i = 1; i <= m; i++) {
		vector<ll> a; a.push_back(i);
		solve(a, n-1);
		a.clear();
	}
	cout << ans;

}

int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solveCase();
}

Measured memory_bytes: 3672
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int count=-1;
		char c ='c';
		int[][] an = new int[w+1][h+1];
		for(int i=0;i<h;i++){
			char[] s = sc.next().toCharArray();
			for(int j=0;j<w;j++){
				if(c==s[j]){
					count=0;
					an[j][i]=0;
				}
				else{
					if(count>=0){
						count+=1;
						an[j][i]=count;
					}
					else an[j][i]=count;
				}
			}
			count=-1;
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(j==w-1) System.out.println(an[j][i]);
				else {
					System.out.print(an[j][i]);
					System.out.print(" ");
				}
			}
		}
    }
}

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

long long sum1[200005],sum2[200005];
int n,m,k,ans;

int main()
{
	scanf("%d%d%d",&n,&m,&k);

    int x;
	for (int i=1 ; i<=n ; i++)
	    scanf("%d",&x),sum1[i]=sum1[i-1]+x;
	for (int i=1 ; i<=m ; i++)
	    scanf("%d",&x),sum2[i]=sum2[i-1]+x;
	
	int j=m;
	for (int i=0 ; i<=n ; i++)
	{
		if (sum1[i]>k) break;
		while (sum2[j]>k-sum1[i]) j--;
		ans=max(ans,i+j);
	}
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6892
import math

list = []
for i in range(5):
    list.append(int(input()))
sum = 0
zeroList = [list[i] for i in range(len(list)) if list[i]%10 == 0]
otherList = [list[i] for i in range(len(list)) if not list[i]%10 == 0]
def func(x):
    return x % 10
otherList.sort(key=func)
for i in range(len(zeroList)):
    sum += zeroList[i]
for i in (otherList[1:]):
    sum += math.ceil(i/10)*10
if not len(otherList) == 0:
    sum += otherList[0]
print(sum)

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
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;}

int main(){
  LL A[3];
  cin>>A[0]>>A[1]>>A[2];
  if(A[0]+A[1]+A[2]>21)cout<<"bust"<<endl;
  else cout<<"win"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
    if(a<b) return b%a==0? a : gcd(b%a,a);
    else return a%b==0? b : gcd(a%b,b);
}
int dp[200005],rdp[200005],num[200005];
int main()
{
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> num[i];
    dp[0]=num[1]; rdp[n+1]=num[n];
    for(int i=1;i<=n;i++) dp[i]=gcd(dp[i-1],num[i]);
    for(int i=n;i>0;i--) rdp[i]=gcd(rdp[i+1],num[i]);
    int ans=dp[n];
    for(int i=1;i<=n;i++) {
        if(i==1) ans=max(ans,rdp[i+1]);
        else if(i==n) ans=max(ans,dp[i-1]);
        else ans=max(ans,gcd(dp[i-1],rdp[i+1]));
    }
    cout << ans;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n, d;
  cin >> n >> d;
  int cnt = 0;

  rep(i, 0, n) {
    int a, b;
    cin >> a >> b;
    if (hypot(a, b) <= d) ++cnt;
  }

  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
const int maxn=5010,mod=1e9+7;
typedef long long ll;
int n,cnt;
ll c[maxn][maxn],fac[maxn],f[maxn],g[maxn];
int sz[maxn],mx[maxn],rt[maxn],a[maxn];
vector<int> G[maxn];
void init_Binom(){
	c[0][0]=1;
	for(int i=0;i<=n;++i)c[i][0]=c[i][i]=1;
	for(int i=1;i<=n;++i)
		for(int j=1;j<i;++j){
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
		}
	fac[0]=1;
	for(int i=1;i<=n;++i){
		fac[i]=fac[i-1]*i%mod;
	}
}
ll C(int n,int m){
	if(n<0||m<0||n<m)return 0;
	return c[n][m];
}
void dfs(int u,int fa){
	sz[u]=1;mx[u]=0;
	for(auto v: G[u])if(v!=fa){
		dfs(v,u);
		sz[u]+=sz[v];
		mx[u]=max(mx[u],sz[v]);
	}
	mx[u]=max(mx[u],n-sz[u]);
	if(mx[u]<mx[rt[cnt]])rt[cnt=1]=u;
	else if(mx[u]==mx[rt[cnt]])rt[++cnt]=u;
}
void dfs2(int u,int fa){
	sz[u]=1;
	for(auto v: G[u])if(v!=fa){
		dfs2(v,u);
		sz[u]+=sz[v];
	}
}
void solve(){
	cin>>n;
	for(int i=1,u,v;i<n;++i){
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	init_Binom();
	mx[0]=INT_MAX;
	dfs(1,0);
	if(cnt==2){
		dfs2(rt[1],rt[2]);
		dfs2(rt[2],rt[1]);
		cout<<fac[sz[rt[2]]]*fac[sz[rt[1]]]%mod<<endl;
		exit(0);
	}
	cnt=0;dfs2(rt[1],0);
	for(auto v: G[rt[1]])a[++cnt]=sz[v];
	f[0]=1;
	int cur=0;
	for(int i=1;i<=cnt;++i){
		memset(g,0,sizeof(ll)*(cur+1));
		for(int j=0;j<=cur;++j)
			for(int k=0;k<=a[i];++k)
				(g[j+k]+=f[j]*C(a[i],k)%mod*C(a[i],k)%mod*fac[k]%mod)%=mod;
		cur+=a[i];
		memcpy(f,g,sizeof(ll)*(cur+1));
	}
	ll ans=0;
	for(int i=0;i<=n;++i){
		
		if(i&1)ans=(ans+mod-f[i]*fac[n-i]%mod)%mod;
		else (ans=ans+f[i]*fac[n-i]%mod)%mod;
	}
	cout<<ans<<endl;
}
int main(){
	solve();
	
	return 0;
}

Measured memory_bytes: 195200
#include<bits/stdc++.h>
#define MAXN 200005
using namespace std;
vector <int> g[MAXN];
int v[MAXN][3];int n;
bool bfs(pair <int,int> p)
{
    queue<pair<int,int> > q;
    q.push(p);
    while(!q.empty())
    {
        pair<int,int> x=q.front();
        q.pop();
        if(x.first==n&&x.second==2)
            return true;
        if(x.second==2)
            continue;
        for(int i=0;i<g[x.first].size();i++)
        {
            int a=g[x.first][i];
            int b=x.second+1;
            if(!v[a][b])
            {
                v[a][b]=1;
                q.push(make_pair(a,b));
            }
        }
    }
    return false;
}
int main()
{
    int m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
    }
    bool ans=bfs(make_pair(1,0));
    if(ans)
        cout<<"POSSIBLE";
    else
        cout<<"IMPOSSIBLE";
    return 0;
}


Measured memory_bytes: 11640
import math
while True:
    N,M,P=map(int,input().split())
    if N==M==P: break
    divSum=0
    for i in range(N):
        temp=int(input())
        divSum+=temp*100
        if i==M-1:
            numWin=temp
    divSum=int(divSum*(100-P)/100)
    if numWin!=0:
        dividents=math.floor(divSum/numWin)
    else: dividents=0
    print(dividents)


Measured memory_bytes: 5680
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = scanner.nextInt();
        int D = scanner.nextInt();
        int prev = -D-1;
        int ans = 0;
        for(int i = 0; i < N; i++) {
            if (i - prev > 2*D) {
                prev = i;
                ans++;
            }
        }
        if (N-1 - prev > D) {
            ans++;
        }
        out.println(Math.max(ans, 1));
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N,x[10],y[10];
  cin>>N;
  for(int i(0);i<N;i++) cin>>x[i]>>y[i];
  double ans(0);
  rep(i,N){
    for (int j(i+1);j<N;j++){
      ans += sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
    }
  }
  cout <<setprecision(10) << ans / (N*(N-1)/2) * (N-1)<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    intf n,in;
    cin >>n;
    list<intf> a;
    rep(i,n) cin >> in,a.emplace_back(in);

     while(1){
        if(a.size()==1){
            break;
        }
        a.sort();
        for(std::list<intf>::iterator i = a.begin();i!=a.end();i++){
            if(i==a.begin()) continue;
            *i %= *a.begin() ;
        }
        a.remove(0);
     }
     cout << *a.begin() <<endl;
}

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

#define ll long long
const int N = 1e6 + 5, MOD = 1e9 + 7;

int suffix[N], dp[N];

int add(int a, int b){
	int res = (a + b) % MOD;
	if(res < 0)	res += MOD;
	return res;
}

int mult(int a, int b){
	ll res = (a * 1LL * b) % MOD;
	if(res < 0)	res += MOD;
	return res;
}

int main(){
	int n;
	cin>>n;
	dp[n] = suffix[n] = n;
	for(int i = n - 1; i >= 1; i--){
		dp[i] = add(add(i + 1, mult(n - 1, n - 1)), add(dp[i + 1], suffix[i + 3]));
		if(i == n - 1)	dp[i] = add(dp[i], -1);
		suffix[i] = add(suffix[i + 1], dp[i]);
	}
	cout<<dp[1]<<endl;
}

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

int main(){
  string t = "CODEFESTIVAL2016";
  string s;
  int ans = 0;
  
  cin >> s;
  for ( int i = 0; i < 16; i++ ){
    if ( t[i] != s[i] ) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define fi first
#define se second
const int LEN = 2e5+5;
const int LEN5 = 1e5+5;
const int MOD = 1e9+7;
typedef long long ll;
int n; double p[3005];
double dp[3005][3005];
int main() {

   // freopen ("myfile.txt","r",stdin);
   // freopen ("myfile.txt","w",stdout);

   // ios_base::sync_with_stdio(0); cin.tie(NULL);
   cin>>n;
   for(int i =1;i<=n;i++) {
      cin>>p[i];
   }
   dp[1][1] = p[1];
   dp[1][0] = 1-p[1];

   for(int i =2;i<=n;i++) {
      for(int k = 0;k<=i;k++) {
         dp[i][k] = dp[i-1][k] * (1-p[i]) + dp[i-1][k-1] * p[i];
      }
   }
   double ans = 0;
   for(int i =(n+1)/2;i<=n;i++) {
      ans += dp[n][i];
   }
   cout<<setprecision(10)<<ans<<endl;

}   

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

int main()
{
  int N, M, X;
  std::cin >> N >> M >> X;
  std::vector<int> A(M);
  for (int i = 0; i < M; i++) std::cin >> A.at(i);
  sort(A.begin(), A.end());
  int cost_N = 0, cost_0 = 0;
  for (int i = 0; i < A.size(); i++)
  {
    if (A.at(i) > X) cost_N++;
    else cost_0++;
  }
  std::cout << std::min(cost_0, cost_N) << std::endl;
}


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

using namespace std;
using ll = long long int;

int main() {
    int N, M;
    cin >> N >> M;

    vector<ll> A(N);
    ll sum = 0;
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
    }

    ll ans = 0;
    const double miman = (double)sum / (4 * (double)(M));
    for (size_t i = 0; i < N; i++)
    {
        if (miman <= A[i]) {
            ans++;
        }
    }

    if (ans >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<chrono>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);


int d;
int s[365][26];
int c[26];


int calc(vector<int> &v) {
	int sum = 0;
	int las[26]; rep(i, 26)las[i] = 0;


	int dec = 0;
	rep(j, 26)dec += c[j];

	int aldec = 0;

	rep(i, d) {
		aldec -= c[v[i]] * (i - las[v[i]]);

		sum += s[i][v[i]];
		las[v[i]] = i;

		sum -= aldec;
		aldec += dec;
	}
	return sum;
}

void query(vector<int> v) {
	rep(i, d) {
		cout << v[i] + 1 << "\n";
	}
}
void solve() {
	cin >> d;
	rep(i, 26)cin >> c[i];
	rep(i, d)rep(j, 26)cin >> s[i][j];

	//init_answer
	vector<int> v;
	int las[26]; rep(j, 26)las[j] = 0;
	int sum = 0;

	rep(i, d) {
		int ma = -mod;
		int chk = -1;
		rep(j, 26) {
			int ad = s[i][j];
			ad += c[j] * (i - las[j]);
			if (ma < ad) {
				ma = ad;
				chk = j;
			}
		}
		v.push_back(chk);
		las[chk] = i;

		sum += s[i][chk];
		rep(j, 26) {
			sum -= c[j] * (i - las[j]);
		}
	}

	mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
	uniform_int_distribution<> ud(0, d - 1);
	uniform_real_distribution<> rd(0.0, 1.0);
	vector<int> alt = v;


	int cur = sum;
	//cout << cur << "\n";

	rep(i, 80000) {
		int id = ud(mt);
		rep(j, 26) {
			if (j == v[id])continue;
			alt[id] = j;
			int val = calc(alt);
			if (cur < val) {
				//cout <<i<<" "<< val - cur << "\n";
				v = alt;
				cur = val;
			}
		}
		alt = v;
	}

	//cout << cur << "\n";
	query(v);
}


signed main() {
	solve();
	return 0;
}


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

int main(void)
{
    size_t n, l;
    scanf("%zu %zu", &n, &l);

    char s[n][l + 1];
    for (size_t i = 0; i < n; ++i) {
        scanf("%s", s[i]);
    }
    qsort(s, n, l + 1, (void *)strcmp);
    for (size_t i = 0; i < n; ++i) {
        printf("%s", s[i]);
    }
    puts("");

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e+8;

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  int diff = INF, l = 0, r = 0;
  for(int i=0;i<n;i++){
      cin >> w[i];
      r += w[i];
  }
  for(int i=0;i<n;i++){
      l += w[i];
      r -= w[i];
      diff = min(diff, abs(l-r));
  }
  cout << diff << endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;

int main() {
	double a, b;
	int A = 0, B = 0, C = 0, D = 0;
	int bA = 0, bB = 0, bC = 0, bD = 0;
	while (std::cin >> a >> b) {
		if (a >= 1.1)A++;
		else if (a >= 0.6)B++;
		else if (a >= 0.2)C++;
		else D++;

		if (b >= 1.1)bA++;
		else if (b >= 0.6)bB++;
		else if (b >= 0.2)bC++;
		else bD++;
	}
	std::cout << A << " " << bA << std::endl;
	std::cout << B << " " << bB << std::endl;
	std::cout << C << " " << bC << std::endl;
	std::cout << D << " " << bD << std::endl;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1145148931919810;
int main(){
	ll n; cin >> n;
	ll edge[n][n];
	ll d[n][n];
	for(ll i = 0; i < n; ++i){
		for(ll j = 0; j < n; ++j){
			cin >> edge[i][j];
			d[i][j] = edge[i][j];
		}
	}
	for(ll k = 0; k < n; ++k)for(ll i = 0; i < n; ++i)for(ll j = 0; j < n; ++j) d[i][j] = min(d[i][k] + d[k][j], d[i][j]);
	ll ans = 0;
	for(ll i = 0; i < n; ++i){
		for(ll j = i + 1; j < n; ++j){
			if(edge[i][j] > d[i][j]){
				cout << "-1\n";
				return 0;
			}
			bool po = 1;
			for(ll k = 0; k < n; ++k){
				if(k == i || k == j) continue;
				if(d[i][k] + d[k][j] == edge[i][j]) po = 0;
			}
			ans += edge[i][j] * po;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1664
#ABC105-B
n = int(input())
divisor_list = []
divisor_length = 0
ans = 0
for i in range(1,n+1):
    divisor_list = []
    divisor_length = 0
    #odd,even判定
    if(i % 2 != 0):
        #約数をdivisor_listに追加していく
        for j in range(1,i+1):
            if (i % j == 0):
                divisor_length += 1
    if(divisor_length == 8):
        ans += 1
print(ans)

Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
count = 0

for i in range(0, n):
    minj = i
    for j in range(i+1, n):
        if a[j] < a[minj]:
            minj = j
    if i != minj:
        x = a[i]
        a[i] = a[minj]
        a[minj] = x
        count = count + 1

print(*a)
print(count)


Measured memory_bytes: 5600
#include <stdio.h>
int main(void)
{	
	int a[3],b,c,m;
	
	for(b=0;b<3;b++)scanf("%d",&a[b]);
	for(b=0;b<3;b++){
	for(c=b+1;c<3;c++){
	if(a[b]>a[c]){
		m=a[b];
		a[b]=a[c];
		a[c]=m;
	}
	}
	}
	printf("%d %d %d\n",a[0],a[1],a[2]);
	return 0;
	}


Measured memory_bytes: 2732
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

/*ソートの時に使う
int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}
    qsort (data,sizeof(data),sizeof(int),sort); 
*/

int main(void){
    int n;
    scanf("%d",&n);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    if (n%2==0){
        int i=n-1;
        while(i>0){
            printf("%d ",a[i]);
            i-=2;
        }
        printf("%d",a[0]);
        i=2;
        while (i<n-1){
            printf(" %d",a[i]);
            i+=2;
        }
    } else {
        int i=n-1;
        while (i>0){
            printf("%d ",a[i]);
            i-=2;
        }
        printf("%d",a[0]);
        i=1;
        while (i<n-1){
            printf(" %d",a[i]);
            i+=2;
        }
    }
    printf("\n");
	return 0 ;
}

Measured memory_bytes: 2816
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,q;
    cin>>n>>q;
    vector<tuple<ll,ll,ll>> L(n);
    rep(i,n) cin>>get<1>(L[i])>>get<2>(L[i])>>get<0>(L[i]);
    sort(all(L));
    vector<ll> ans(q,-1);
    // vector<ll> D(n*2,0);
    unordered_map<ll,ll> D;
    set<ll> s;
    rep(i,q){
        ll d;
        cin>>d;
        s.insert(d);
        D[d]=i;
    }
    rep(i,n){
        auto t=L[i];
        ll X=get<0>(t);
        ll S=get<1>(t);
        ll T=get<2>(t);
        auto it=s.lower_bound(S-X);
        while (it != s.end() && *it < T-X ) {
            ans[D[*it]]=X;
			s.erase(it++);
		}
    }
    rep(i,q) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 25800
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    string cad;
    while(cin>>n>>k){
        cin>>cad;
        for(int i=1;i<=n;i++){
            if(i==k)cout<<(char)tolower(cad[i-1]);
            else cout<<cad[i-1];
        }
        cout<<endl;
    }

    return 0;
 
}

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

const int INF = (int)1e9 + 1;

int main() {
	while (1) {
		int n;
		cin >> n;
		if (n == 0) break;

		int d[10][10];
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if (i == j) {
					d[i][j] = 0;
				}
				else {
					d[i][j] = INF;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			int a, b, c;
			cin >> a >> b >> c;
			d[a][b] = c;
			d[b][a] = c;
		}
		for (int k = 0; k < 10; k++) {
			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
		int ans = INF;
		int num = 0;
		for (int i = 0; i < 10; i++) {
			int sum = 0;
			for (int j = 0; j < 10; j++) {
				if (d[i][j] < INF) sum += d[i][j];
			}
			if (sum > 0 && ans > sum) {
				ans = sum;
				num = i;
			}
		}
		cout << num << " " << ans << endl;
	}
}


Measured memory_bytes: 3004
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main{
	
	static BufferedReader reader =
			new BufferedReader(new InputStreamReader(System.in));
	
	public static void main(String[] args)throws IOException{
		Main byakko = new Main();
		
		int n,count;
		String str;
		
		while((n = Integer.parseInt(reader.readLine())) != 0){
			BigDecimal bd = new BigDecimal(1);
			count = 0;
			for(int i = 1; i <= n; i++){
				BigDecimal x = new BigDecimal(i);
				bd = bd.multiply(x);
			}
			str = String.valueOf(bd);
			
			for(int i = 0; i < str.length(); i++){
				if(str.charAt(str.length() - i - 1) == '0'){
					count++;
				}
				else break;
			}
			System.out.println(count);
		}
		reader.close();
	}
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  ll ans = 0;
  ll n = s.size()-1;
  for (ll bit = 0; bit < 1<<n; ++bit) {
    ll ten = 1;
    ans += s[n]-'0';
    for (ll i = n-1; i >= 0; --i) {
      if (bit & (1<<i)) {
        ten = 1;
      } else {
        ten *= 10;
      }
      ans += (s[i]-'0') * ten;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define INF (int)(1e9+7)

int dp[41][410][410], n, Ma, Mb;
int a[41], b[41], c[41];

int dfs(int x, int A, int B) {
    int ret = INF;

    if (dp[x][A][B] != 0) return dp[x][A][B];

    if ((double)A == (double)B * ((double)Ma / (double)Mb)) {
        return c[x];
    }

    for (int i = x+1; i < n; ++i) {
        ret = std::min(ret, dfs(i, A+a[i], B+b[i]) + c[x]);
    }

    return dp[x][A][B] = ret;
}

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

    std::cin >> n >> Ma >> Mb;
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i] >> b[i] >> c[i];
    }

    int ans = INF;

    for (int i = 0; i < n; ++i) {
        ans = std::min(ans, dfs(i, a[i], b[i]));
    }

    if (ans != INF) std::cout << ans << std::endl;
    else std::cout << -1 << std::endl;

    return 0;
}


Measured memory_bytes: 8448
#include<stdio.h>
int main(void){
   int n, i, p;
   double m;
   m = 100;
   scanf("%d", &n);
   for(i = 0; i < n; i++){
      m = m + m * 0.05;
      p = m;
      if(m > p){
         p++;
         m = p;
      }
   }
   printf("%d\n", p * 1000);
   return 0;
}

Measured memory_bytes: 1740
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, K; cin >> N >> K;
	vector<ll>vec(N);
	rep(i, 0, N)cin >> vec[i];
	rep(i, K, N) {
		if (vec[i] > vec[i - K])cout << "Yes" << "\n";
		else cout << "No" << "\n";
	}

	return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int x=a[0],y=a[1];
    set<int> v;
    for(int i=1;i*i<=x;i++){
        if(x%i==0){
            v.insert(i);
            v.insert(x/i);
        }
    }
    for(int i=1;i*i<=y;i++){
        if(y%i==0){
            v.insert(i);
            v.insert(y/i);
        }
    }
    bool maki;
    auto m=v.size();
    auto i=v.end();
    for(int j=0;j<m;j++){
        i--;
        maki=false;
        for(int j=0;j<n;j++){
            if(a[j]%*i){
                if(maki){
                    j=n;
                }
                else{
                    maki=true;
                }
            }
            if(j==n-1){
                printf("%d\n", *i);
                return 0;
            }
        }
    }
    return 0;
}


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

int main() {
    int n, m; scanf("%d %d", &n, &m);
    vector<int> V;
    V.emplace_back(m);
    for(int i = 0, ret; i < n; ++i) {
        scanf("%d", &ret);
        V.emplace_back(ret);
    }
    sort(V.begin(), V.end());
    int gcd = V[1] - V[0];
    for(int i = 2; i <= n; ++i) gcd = __gcd(gcd, V[i] - V[i-1]);
    printf("%d\n", gcd);
}

Measured memory_bytes: 892