akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C4Adjacent solver = new C4Adjacent();
        solver.solve(1, in, out);
        out.close();
    }

    static class C4Adjacent {
        private static final String YES = "Yes";
        private static final String NO = "No";

        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            int[] a = in.ints(n);
            int x = 0, y = 0;
            for (int i = 0; i < n; i++) {
                if (a[i] % 4 == 0) {
                    x++;
                } else if (a[i] % 2 == 1) {
                    y++;
                }
            }
            if (y <= x || (y <= x + 1 && x + y == n)) {
                out.println(YES);
            } else {
                out.println(NO);
            }
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

        public int[] ints(int length) {
            return IntStream.range(0, length).map(x -> ints()).toArray();
        }

    }
}



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

using ll=long long;
using Graph=vector<vector<int>>;
using T3=pair<pair<int,int>,int>;
const int LOGN=22;
int main(){
    int n;
    cin>>n;
    Graph g(n);
    vector<int> p(n);
    p[0]=0;
    for(int i=0;i+1<n;i++){
        cin>>p[i+1];
        p[i+1]--;
        g[p[i+1]].push_back(i+1);
    }
    vector<vector<int>> dbl(LOGN,vector<int>(n));
    dbl[0]=p;
    for(int i=0;i+1<LOGN;i++){
        for(int j=0;j<n;j++){
            dbl[i+1][j]=dbl[i][dbl[i][j]];
        }
    }
    vector<int> dep(n);
    function<void(int,int)> setDep=[&](int v,int d){
        dep[v]=d;
        for(auto &to:g[v]) setDep(to,d+1);
    };
    setDep(0,0);
    auto LCA=[&](int l,int r){
        if(dep[l]<dep[r]) swap(l,r);
        int upper=dep[l]-dep[r];
        int iter=0;
        while(upper){
            if(upper&1) l=dbl[iter][l];
            upper/=2;
            iter++;
        }
        assert(dep[l]==dep[r]);
        if(l==r) return l;
        for(int i=LOGN-1;i>=0;i--){
            if(dbl[i][l]!=dbl[i][r]){
                l=dbl[i][l];
                r=dbl[i][r];
            }
        }
        return p[l];
    };

    priority_queue<T3,vector<T3>,greater<>> que;
    int t=0;
    auto insert=[&](int x){
        for(auto to:g[x]) que.push({{dep[to],t},to});
    };
    int v=0;
    insert(0);
    
    ll res=0;
    while(!que.empty()){
        int to=que.top().second;que.pop();
        int lca=LCA(v,to);
        int sc=dep[v]-dep[lca]+dep[to]-dep[lca];
        res+=sc;
        insert(to);
        v=to;
        t++;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 24072
# include <bits/stdc++.h>
# define rep(i, n) for (ll i = 0; i < (n); i++)
# define reps(i, n) for (ll i = 1; i <= (n); i++)
# define foreps(i, m, n) for (ll i = (m); i < (n); i++)
# define len(x) ((int)(x).size())
# define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
const long long mod = 1e9 + 7;
const long long inf = 1e18;

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

    ll cnt = 0;
    char t = S[0];
    reps(i, len(S) - 1) {
        if (t != S[i]) ++cnt;
        t = S[i];
    }
    cout << cnt << endl;
}

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

using namespace std ;

int a[200000] , n , R[200000] ;
bool cmp(int a , int b){
    return a > b ;
}
int main()
{
    scanf("%d" , &n ) ;

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

Measured memory_bytes: 640
#include <cstdio>
using namespace std;
int s[100005];
int n;
bool find (int x) {
	int l=0,r=n,mid;
	while (r-l>1) {
		mid=(l+r)>>1;
		if (s[mid]==x) return true;
		else if (s[mid]>x) r=mid;
		else l=mid+1;
	}
	if (s[l]==x&&l!=r) return true;
	return false;
}
int main () {
	int q,cnt=0;
	scanf ("%d",&n);
	for (int i=0;i<n;i++) {
		scanf ("%d",&s[i]);
	}
	scanf ("%d",&q);
	for (int i=0;i<q;i++) {
		int tmp;
		scanf ("%d",&tmp);
		if (find(tmp)) cnt++;
	}
	printf ("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 3124
#include <cstdio>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end
int main() {
    int  A,B,K;
    int answer;

    cin >> A>>B>>K;
//    vector<int> s();
//    vector<int> t();
    int i=0;
    answer = max(A,B);
    while(true){
        if(A%answer == 0 && B%answer == 0){
            i++;
            if(i==K) break;
        }
        answer--;
    }
    cout << answer <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iostream>
#include <utility>
 
using namespace std;
using ll = long long;
using ld = long double;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vb = vector<bool>;
using vs = vector<string>;

// # define int ll
#define REP(i,n)            for(int i=0;i<n;i++)
#define FOR(i,a,b)          for(int i=a;i<=b;i++)

ll n, k;

Vl h(100001);

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    REP(i,n) { cin >> h[i]; }
    Vl dp(n + 1, 1e18);
    dp[0] = 0;
    FOR(i, 1, n-1) {
        int start =  max(0,int(i-k));
        FOR(j, start, i-1) {
            dp[i] = min(dp[i], abs(h[i] - h[j]) + dp[j]);
        }
    }
    cout << dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <queue>
#include <cstring>
#include <set>
#include <list>
#include <map>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;

#define all(c) (c).begin(),(c).end()
#define forn(i, a, b) for(int i = a; i < b; i++)

#define pb push_back
#define mp make_pair

int main()
{
    char cc[300000];
    scanf("%s", cc);
    string s(cc);
    ll n = s.size();
    vll cnt(26,0);
    for(auto x : s) cnt[x-'a']++;
    ll ans = 1;
    ans += n*(n-1)/2;
    for(auto x : cnt) ans -= x*(x-1)/2;
    cout<<ans;
}



Measured memory_bytes: 640
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int n,x,ans = 0,i = 0;
    cin >> n;
    vector<int> v;
    while(i++ < n){
        cin >> x;
        if (x == i){
            ans--;
        }
        ans++;
        v.push_back(x);
    }
    if(ans <= 2){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] factors = new long[n+1];
        for (int i = 2; i <= n; i++) {
            int trg = i;
            int prime = 2;
            while (trg != 1) {
                if (trg % prime == 0) {
                    factors[prime]++;
                    trg /= prime;
                }
                else {
                    while (++prime<trg)
                        if (factors[prime] != 0)
                            break;
                }
            }
        }
        int mod = (int)1e9+7;
        long res = Arrays.stream(factors).reduce(1l, (a, b) -> (a*(b+1l)) % mod);
        System.out.println(res);
    }
}


Measured memory_bytes: 26708
#include<iostream>
using namespace std;
int main () {
  int N;
  cin >> N;
  int A[N];
  int res[N];
  double a[N][N];
  int tot = 0;
  int tot_1 = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    tot+=A[i];
    if (i%2==1) {
      tot_1+=2*A[i];
    }
  }
  
  res[0] = tot - tot_1;
  cout<<res[0]<<" ";
  for (int i = 1; i < N; i++) {
    res[i] = 2*A[i-1] - res[i-1];
    cout<<res[i]<<" "; 
  }
  
  return 0;
}
  


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

int main(){
  int n,m;
  long long k;
  cin >> n >> m >> k;
  vector<long long> a(n);
  vector<long long> b(m);
  vector<long long> ruib(m+1);
  ruib[0] = 0;

  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }

  for (int i = 0; i < m; i++)
  {
    cin >> b[i];
    ruib[i+1] = ruib[i] + b[i];
  }

  long long sum = 0;
  // int ni=0;
  // int mi=0;
  int ans = 0;
  // int ansi =  0;
  int cntb;

  for (int i = 0; i < n; i++)
  {
    if(i==0){
      cntb = upper_bound(ruib.begin(), ruib.end(), k) - ruib.begin()-1;
      ans = cntb;
    }



    sum += a[i];
    int tan = k-sum;
    cntb = upper_bound(ruib.begin(), ruib.end(), tan) - ruib.begin()-1;

    if(sum>k){
      ans = max(ans,i);
      break;      
    }

    if(sum==k){
      ans = max(ans,i+1);
      break;
    }

    // cout << "i=" << i << endl;
    // cout << "cntb=" <<  cntb << endl;

    // if(cntb < 0){
    // }
    ans = max(ans,i+1+cntb);    
  }
  cout << ans << endl;
}

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

int main(){
	int a[4], b[4], hit, blow, n1[10], n2[10];

	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
		hit = 0;
		blow = 0;
		for(int i=0 ; i<10 ; i++){
			n1[i] = 0;
			n2[i] = 0;
		}

		for(int i=0 ; i<4 ; i++){
			if(a[i]==b[i]) hit++;
			n1[ a[i] ] = 1;
			n2[ b[i] ] = 1;
		}
		for(int i=0 ; i<10 ; i++){
			if( n1[i]==n2[i] && n1[i]==1) blow++;
		}
		cout << hit << " " << blow-hit << endl;
	}
}

Measured memory_bytes: 0
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.util.stream.LongStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = in.nextInt();
            }
            for (int i = 0; i < M; i++) {
                Arrays.sort(A);
                A[N - 1] = A[N - 1] / 2;
                for (int j = N - 2; j >= 0 && A[j] >= A[N - 1] && ++i < M; j--) {
                    A[j] /= 2;
                }
            }
            long sum = Arrays.stream(A).mapToLong(n -> n).sum();
            out.println(sum);
        }

    }
}



Measured memory_bytes: 51760
using System;


namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            String str = Console.ReadLine();
            int n = int.Parse(str);
            for ( int i = 1; i <= n; i++ )
            {
                if ( i % 3 == 0 )
                {
                    Console.Write(" " + i);
                }
                else
                {
                    for ( int x = i; x >0; x /= 10)
                    {
                        if ( x % 10 == 3)
                        {
                            Console.Write(" " + i);
                            break;
                        }
                    }
                }
            }
            Console.Write("\n");
        }
    }
}

Measured memory_bytes: 9172
def partition(a, p, r)
  x = a[r]
  i = p - 1
  p.upto(r-1).each {|j|
    if a[j] <= x
      i += 1
      a[i], a[j] = a[j], a[i]
    end
  }
  a[i+1], a[r] = a[r], a[i+1]
  i+1
end

n = gets.to_i
a = gets.split.map(&:to_i)
q = partition(a, 0, n - 1)
puts a.map.with_index{|x,i| i == q ? "[#{x}]" : x.to_s}.join(" ")

Measured memory_bytes: 19396
H, W = map(int, input().split())
c = []
w = []
for i in range(10):
    c.append(list(map(int, input().split())))
for i in range(H):
    w.append(list(map(int, input().split())))
for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])
p = 0
for r in w:
    for n in r:
        if n == -1:
            pass
        else:
            p += c[n][1]
print(p)

Measured memory_bytes: 3316
#laczil
def solve():
    N = int(input())
    S = input()
 
    left_black = 0
    right_white = 0
    for i in range(N):
        if S[i] == '.':
            right_white += 1
 
    ans = left_black + right_white
    for i in range(N):
        if S[i] == '#':
            left_black += 1
        else:
            right_white -= 1
        ans = min(ans, left_black + right_white)
    print(ans)
 
if __name__ == '__main__':
    solve()

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

ll comb[51][51];
void pascal(ll n){
  for(ll i=0;i<=n;i++){
    for(ll j=0;j<=i;j++){
      if(j == 0 || j == i){
        comb[i][j] = 1;
      }else{
        comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]);
      }
    }
  }
}

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll v[n];
  for(ll i = 0;i < n; i++){
    cin >> v[i];
  }
  sort(v, v+n, greater<ll>());
  double av = 0.0;
  for(ll i = 0; i < a; i++){
    av += v[i];
  }
  av /= a;
  cout << fixed << setprecision(20) << av << endl;
  pascal(n);
  ll ans = 0;
  if(v[0] != v[a]){
    ll acnt = 0,bcnt = 0;
    for(ll i = 0; i < a; i++){
      if(v[a-1] == v[i]){
        acnt++;
      }
    }
    for(ll i = 0; i < n; i++){
      if(v[i] == v[a-1]){
        bcnt++;
      }
    }
    ans += comb[bcnt][acnt];
  }else{
    ll cnt = 0;
    for(ll i = 0; i < n; i++){
      if(v[i] == v[0]){
        cnt++;
      }
    }
    for(ll i = a; i <=min(cnt,b); i++ ){
      ans += comb[cnt][i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;
ll  LINF = 1e18;

int main(){
	ll n,l;cin >> n >> l;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	int ind = -1;
	rep(i,n-1) if(a[i]+a[i+1]>=l) ind = i;
	if(ind == -1) {
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << endl;
	ind++;
	for(int i = 1;i < ind;i++){
		cout << i << endl;
	}
	for(int i = n-1;i >= ind;i--) cout << i << endl;
	
} 


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

#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(),(a).rend())
#define ll long long
#define pb(a) push_back(a)

#define PRINTV(v) {for(ll deB=0; deB<(v).size(); deB++){cout << (v)[deB] << " ";}cout << endl;}

int main(){
	
	
	ll X,N;
	vector<ll> p(100,-1);
	cin >> X >> N;
	REP(i,N) cin >> p[i];
	if(N==0){
		cout << X << endl;
		return 0;
	}
	ll test = 0;
	while(true){
		ll ret = X - test;
		bool check = false;
		REP(i,N) if(ret==p[i]) check = true;
		if(!check){
			cout << ret << endl;
			return 0;
		}
		ret = X + test;
		check = false;
		REP(i,N) if(ret==p[i]) check = true;
		if(!check){
			cout << ret << endl;
			return 0;
		}
		test++;
	}
	
	return 0;
}

Measured memory_bytes: 3632
from math import ceil

N, K = map(int, input().split())

A = 1 / N
temp = N
count = 0
while True:
    if temp >= K:
        break
    temp *= 2
    count += 1

T = []
T.append(count)
C = 0

for i in reversed(range(1, N)):
    if i * (2 ** count) < K:
        count +=1
        T.append(count)
    else:
        T.append(count)

ans = 0
for i in T:
    ans += A * (0.5 ** i)
print(ans)

Measured memory_bytes: 3864
#include<cstdio>
const int MaxN=3010;
int N,K,B[MaxN][MaxN],W[MaxN][MaxN];
void add(int(*a)[MaxN],int x,int y){
	if(x<K*3&&y<K*3)a[x][y]++;
}
int get(int(*a)[MaxN],int x,int y){
	x%=K*2;y%=K*2;
	return a[x][y]-a[x][y+K]-a[x+K][y]+a[x+K][y+K];
}
void cmax(int&a,int b){b>a?a=b:1;}
int main(){
	scanf("%d%d",&N,&K);
	for(int i=0;i<N;i++){
		int x,y,(*a)[MaxN];char c[2];
		scanf("%d%d%s",&x,&y,c);
		x%=K*2;y%=K*2;
		a=*c=='B'?B:W;
		add(a,x,y);add(a,x,y+K*2);
		add(a,x+K*2,y);add(a,x+K*2,y+K*2);
	}
	for(int t=2;t--;)
		for(int i=K*3,(*a)[MaxN]=t?B:W;i--;)
			for(int j=K*3;j--;)a[i][j]+=a[i][j+1]+a[i+1][j]-a[i+1][j+1];
	int ans=0;
	for(int x=0;x<K*2;x++)
		for(int y=0;y<K*2;y++)cmax(ans,get(W,x,y)+get(B,x+K,y)+get(B,x,y+K)+get(W,x+K,y+K));
	printf("%d\n",ans);
}

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

vector<vector<int>> divisors_table(int n) {     // all
    vector<vector<int>> divisors(n + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j += i) divisors[j].emplace_back(i);;
    }
    return divisors;
}

int main() {
    int n; cin >> n;
    auto divisors = divisors_table(n);
    int cnt = 0;
    for (int i = 1; i <= n; i += 2) cnt += divisors[i].size() == 8;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# D

import sys
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n = int(input())
a = list(map(int, input().split()))
a.sort()
max_a = a[-1]
counter_a = Counter(a)

if n == 1:
    print(1)
    sys.exit()
    
if len(set(a)) == 1:
    print(0)
    sys.exit()

lis_prime = [False] * (max_a+1)
for a_ in a:
    lis_prime[a_] = True

primes = []
for i in range(len(lis_prime)):
    if lis_prime[i]:
        if counter_a[i]==1:
            primes.append(i)

        j = 2 * i
        while True:
            if j > max_a:
                break
            lis_prime[j] = False
            j += i

print(len(primes))


Measured memory_bytes: 147808
#include <stdio.h>	/*½èÍvÅ·B(Time Limit Exceeded)*/
					/*[NbhÌÝ@Æ¢¤ASYðg¢Ü·B*/
int main(){
	int a,b;
	int m,n;		/*ASYpÏ*/
	int k;			/*ð·pÏ*/
	int i;
	int GCD=1,LCM;	/*Ååöñ,Å¬ö{*/
	
	while(scanf("%d %d",&a,&b)!=EOF){
		if(b>a){	/*m>nÌ`Éµ½¢ÌÅ*/
			m=b;
			n=a;
		}else{
			m=a;
			n=b;
		}
		
		while(n!=0){	/*O.m>=nÆµ½Q	n==0ÉÈéÜÅ¨ÈÁ½çSÖ*/
			k=m%n;		/*P.mðnÅÁ½]èð*/
			m=n;		/*R.³ÌnðmÆµÄ(m>nÉÈéæI)AOÉßéB*/
			n=k;		/*Q.V½ÉnÆµA*/
		}
		/*S.mªÅåöñ*/
		GCD=m;							/*±ÌìÍ¢çÈ¢©àµêÈ¢¯ÇAª©èâ·­·é½ß*/
		LCM=a*(b/GCD);					/*Å¬ö{ÌvZ ()ðÂ¯éÌÍvZrÅint^ð´¦È¢½ß*/
		
		printf("%d %d\n",GCD,LCM);
	}
	
	return 0;
}

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

stack< int > st;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s;
    
    cin >> s;
    
    int n = s.length();
    
    int rmv = 0;
    
    for(int i = 0 ; i < n ; i++){
        if(st.empty()){
            st.push(i);        
        }else{
            if(s[st.top()] == s[i]){
                st.push(i);
            }else{
                rmv += 2;
                st.pop();
            }
        }
    }
    
    cout << rmv << endl;
    
	return 0;
}


Measured memory_bytes: 848
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  unsigned long m,a,r,c,h,sum;
  m=a=r=c=h=0;
  string s;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    if(s[0]=='M')m++;
    else if(s[0]=='A')a++;
    else if(s[0]=='R')r++;
    else if(s[0]=='C')c++;
    else if(s[0]=='H')h++;
  }
  sum=m*a*(r+c+h)+m*r*(c+h)+m*c*h+a*r*(c+h)+a*c*h+r*c*h;
  cout<<sum<<endl;
  return 0;
}

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

typedef long long ll;

ll md = 1000000007;

vector<ll> a;
vector<ll> x;

int main(int, char**) 
{
	ll a, b;
	std::cin >> a >> b;
	if (a < 10 && b < 10)
		cout << a * b << endl;
	else
		cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
    class Program
    {
        static void Main(string[] args)
        {
            var As = Console.ReadLine().ToCharArray().ToList();
            var Bs = Console.ReadLine().ToCharArray().ToList();
            var Cs = Console.ReadLine().ToCharArray().ToList();

            var turn = 'a';
            Func<char,List<char>, char> GetCard = (player, hands) =>
            {
                 if (!hands.Any())
                 {
                     Console.WriteLine(char.ToUpper(player));
                     return ' ';
                 }
                 var tmpTurn = hands[0];
                 hands.RemoveAt(0);
                 return tmpTurn;
            };

            while (true)
            {
                if (turn == 'a')
                    turn = GetCard(turn, As);
                else if (turn == 'b')
                    turn = GetCard(turn, Bs);
                else
                    turn = GetCard(turn, Cs);
                if (turn == ' ') break;
            }
        }
    }

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;
        if(a % 2 == 1){
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N =1000;

int lcs(string Xtw,string Ytw){
    int c[N+1][N+1];
    int m=Xtw.size();
    int n=Ytw.size();
    int maxl=0;
    Xtw=' '+Xtw;
    Ytw=' '+Ytw;
    for(int i=0;i<=m;i++)c[i][0]=0;
    for(int j=1;j<=n;j++)c[0][j]=0;

    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(Xtw[i]==Ytw[j]){
                c[i][j]=c[i-1][j-1]+1;
            }else{
                c[i][j]=max(c[i-1][j],c[i][j-1]);
            }
            maxl=max(maxl,c[i][j]);
        }
    }   

    return maxl;
}

int main(){
    string s1tw,s2tw;
    int n; cin>>n;
    for(int i=0;i<n;i++){
        cin>>s1tw>>s2tw;
        cout<<lcs(s1tw,s2tw)<<endl;
    }
    return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  rep(i,n) cin >> v[i];
  sort(v.begin(), v.end());
  rep(i,n - 1) {
    v[i + 1] = (v[i] + v[i + 1]) / 2;
  }
  cout << v[n - 1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  ll x;cin>>x;
  x-=6;
  ll ans=1;
  if(x<0){
    ;
  }else if(x%11==0)
    ans+=(x/11)*2;
  else if(x%11<=5){
    ans+=(x/11)*2+1;
  }else if(x%11>=6){
    ans+=(x/11)*2+2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
#define erase(s) s.erase(s.end()-1) //文字列sの末尾削除
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
string RLE(string s){
  ll n=s.size();
  char now='.';
  ll count=1;
  string press;
  loop(i,n){
    if(s[i]!=now){
      if(i){
        press+=now;
        press+=to_string(count);
      }
      now=s[i];
      count=1;
      continue;
    }
    else count++;
  }
  press+=now;
  press+=to_string(count);
  return press;
}
int main() {
  cout << fixed << setprecision(30);
  ll n,r;
  cin>>n>>r;
  if(n>=10)putout(r);
  else putout(r+100*(10-n));
}

Measured memory_bytes: 256
# include <cstdio>
# include <math.h>
# include <climits>
# include <vector>

using namespace std;

int main() {
  long int ppl;
  long int n;
  long int lo = LONG_MAX;
  scanf("%ld", &ppl);
  for (int i = 0; i < 5; ++i) {
    scanf("%ld", &n);
    if (n < lo) { lo = n; }
  }
  long int t = 5;
  if (lo < ppl) {
    ppl -= lo;
    t += (ppl / lo) + (ppl % lo > 0);
    //t += (ppl / lo);
  }
  printf("%ld", t);
  fflush(stdout);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n=0,color =0,color2 =0,cnt=1,sum =0;
  cin >> n;
  for(int i=0;i<n;i++)
    {
      
      cin >> color;
      if(color == color2)
	{
	  cnt++;
	  color2 = color;
      }
      else
	{
	  color2 = color;
	  sum += cnt /2 ;
	  cnt =1;
	}
      
    }
  sum += cnt /2;
  cout << sum << endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int n,s;

int dfs(int limit,int num,int res){
	if(num==n){
		if(res==s)
			return 1;
		else
			return 0;
	}
	int ans=0;
	for(int i=limit;i<10;++i){
		ans+=dfs(i+1,num+1,res+i);
	}
	return ans;
}

int main(){
	while(std::cin>>n>>s){
		if(n+s==0)
			break;
		std::cout<<dfs(0,0,0)<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 3008
N = int(input())
a = list(map(int, input().split()))
tmp = 1
cnt = 0
S = 0
a.sort()
a.append(0)
for i in range(N):
    if a[i] == a[i + 1]:
        tmp += 1
    else:
        if tmp > a[i]:
            cnt += tmp - a[i]
        elif tmp < a[i]:
            cnt += tmp
        tmp = 1
print(cnt)


Measured memory_bytes: 14692
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  ld a,b=3;
  cin >> a;
  a=a/b;
  cout << fixed << setprecision(10) << a*a*a << endl;
}


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

using namespace std;

int main() {
  vector<string> day = {"", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
  string in = "";
  cin >> in;
  for (int i=0; i<=7; i++) {
    if (in == day.at(i)) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


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

const int N = 100005, INF = int(2e9);

int n, a[3], d[N][3];

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%d%d%d", a, a + 1, a + 2);
        for(int j = 0; j < 3; j++) for(int k = 0; k < 3; k++) if(j != k)
            d[i][j] = max(d[i][j], d[i - 1][k] + a[j]);
    }
    printf("%d\n", *max_element(d[n], d[n] + 3));
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 a, b;
  cin >> a >> b;
  cout << max(i64(0), a - 2 * b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>

typedef unsigned long long LL;

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a+b == 15) {
		cout << "+" << endl;
	}
	else if (a * b == 15) {
		cout << "*" << endl;
	}
	else {
		cout << "x" << endl;
	}
}

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

const ll MOD = 1e9 + 7;

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  map<int, int> m;
  for (int i = 0; i < N; i++) {
    m[s[i] - 'a']++;
  }
  ll ans = 1;
  for (int i = 0; i < 26; i++) {
    ans *= m[i] + 1;
    ans %= MOD;
  }
  ans -= 1;
  while (ans < 0) ans += MOD;
  cout << ans << endl;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i = 0; i < N; i++) cin >> vec.at(i);
  sort(vec.begin(),vec.end(),greater<int>());
  for(int i = 0; i < min(N,K); i++){
    vec.at(i) = 0;
  }
  long long ans=0;
  for(int i = 0; i < N; i++){
    ans += vec.at(i);
  }
  cout << ans;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int h,w;char a[200][105];
	scanf("%d%d%*c",&h,&w);
	int i;
	for(i=0;i<h;i++)
		gets(a[i]);
	for(i=0;i<=w;i++)
	printf("#");printf("#\n");
	for(i=0;i<h;i++)
	{
	    printf("#");
		printf("%s",a[i]);
		printf("#\n");
	}
	for(i=0;i<=w;i++)
	printf("#");printf("#\n");
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
//#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010
#define md 1000000007//998244353

#define pb push_back
#define _vcppunko4(tuple) _getname4 tuple
#define _getname4(_1,_2,_3,_4,name,...) name
#define _getname3(_1,_2,_3,name,...) name
#define _trep2(tuple) _rep2 tuple
#define _trep3(tuple) _rep3 tuple
#define _trep4(tuple) _rep4 tuple
#define _rep1(n) for(lint i=0;i<n;++i)
#define _rep2(i,n) for(lint i=0;i<n;++i)
#define _rep3(i,a,b) for(lint i=a;i<b;++i)
#define _rep4(i,a,b,c) for(lint i=a;i<b;i+=c)
#define _trrep2(tuple) _rrep2 tuple
#define _trrep3(tuple) _rrep3 tuple
#define _trrep4(tuple) _rrep4 tuple
#define _rrep1(n) for(lint i=n-1;i>=0;--i)
#define _rrep2(i,n) for(lint i=n-1;i>=0;--i)
#define _rrep3(i,a,b) for(lint i=b-1;i>=a;--i)
#define _rrep4(i,a,b,c) for(lint i=a+(b-a-1)/c*c;i>=a;i-=c)
template<class T>
istream& operator>>(istream& is,vector<T>& vec);
template<class T,size_t size>
istream& operator>>(istream& is,array<T,size>& vec);
template<class T,class L>
istream& operator>>(istream& is,pair<T,L>& p);
template<class T>
ostream& operator<<(ostream& os,vector<T>& vec);
template<class T,class L>
ostream& operator<<(ostream& os,pair<T,L>& p);
template<class T>
istream& operator>>(istream& is,vector<T>& vec){ for(T& x: vec) is>>x;return is; }
template<class T,class L>
istream& operator>>(istream& is,pair<T,L>& p){ is>>p.first;is>>p.second;return is; }
//template<class T>
//ostream& operator<<(ostream& os,vector<T>& vec){ os<<vec[0];rep(i,1,vec.size())os<<' '<<vec[i];return os; }
//template<class T>
//ostream& operator<<(ostream& os,deque<T>& deq){ os<<deq[0];rep(i,1,deq.size())os<<' '<<deq[i];return os; }
template<class T,class L>
ostream& operator<<(ostream& os,pair<T,L>& p){ os<<p.first<<" "<<p.second;return os; }

inline void in(){}
template <class Head,class... Tail>
inline void in(Head&& head,Tail&&... tail){ cin>>head;in(move(tail)...); }
template <class T>
inline bool out(T t){ cout<<t<<'\n';return 0; }
inline bool out(){ cout<<'\n';return 0; }
template <class Head,class... Tail>
inline bool out(Head head,Tail... tail){ cout<<head<<' ';out(move(tail)...);return 0; }

#define rep(...) _vcppunko4((__VA_ARGS__,_trep4,_trep3,_trep2,_rep1))((__VA_ARGS__))
#define rrep(...) _vcppunko4((__VA_ARGS__,_trrep4,_trrep3,_trrep2,_trrep1))((__VA_ARGS__))
#define lin(...) lint __VA_ARGS__;in(__VA_ARGS__)
#define stin(...) string __VA_ARGS__;in(__VA_ARGS__)
#define vin(type,name,size) vector<type> name(size);in(name)
#define fi i.first
#define se i.second
#define YES(c) cout<<((c)?"YES\n":"NO\n")
#define Yes(c) cout<<((c)?"Yes\n":"No\n")

int main(){
	lin(n);
	vin(lint,a,n);
	rep(n)a[i]-=i+1;
	sort(all(a));
	lint b=a[n/2],ans=0;
	rep(n)ans+=abs(a[i]-b);
	cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;

    if(n>1 && n%2) {
        cout << "No" << endl;
        return 0;
    }

    vector<vector<ll>> v(n, vector<ll>(n));
    REP(i, n) v[i][i] = 2*n-1;
    REP(i, n-1) {
        ll st = i==0?0:(v[i][i-1])%(n-1);
        v[n-1][i] = st+1;
        (st += 1) %= n-1;
        FOR(j, i+1, n-1) {
            v[j][i] = st+1;
            (st += 1) %= n-1;
        }
    }
    REP(i, n-1) FOR(j, i+1, n) v[i][j] = 2*n-1 - v[j][i];

    cout << "Yes" << endl;
    REP(i, n) REP(j, n) cout << v[i][j] << (j==n-1?'\n':' ');
    cout << flush;

    return 0;
}



Measured memory_bytes: 4904
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

int vis[300];
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int a , b , c ,d;
	while(~scanf("%d %d %d %d",&a , &b , &c , &d)){
		memset(vis , 0 , sizeof(vis));
		int cnt = 0;
		for(int i = a ; i < b ; i++) vis[i]++;
		for(int i = c ; i < d ; i++) vis[i]++;
		for(int i = 0 ; i <= 100 ; i++)
			if(vis[i] == 2) cnt++;
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
typedef long long int64;
using namespace std;
inline int64 read(int f = 1, int64 x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5;
int n, m, a[N], f[N], s[N], top, vis[N];
int64 ans[N], k;
int main()
{
    n = read();
    for(int i = 1; i <= n; ++i) a[i] = read();
    for(int i = n; i; --i) a[i] -= a[i-1], f[i] = i;
    m = read(), k = read();
    for(int i = 1, p; i <= m; ++i) p = read(), swap(f[p], f[p+1]);
    for(int i = 1; i <= n; ++i, top = 0)
        if(!vis[i])
        {
            for(int j = i; !vis[j]; j = f[j]) vis[j] = 1, s[++top] = j;
            for(int j = 1; j <= top; ++j) ans[s[j]] = a[s[(j+k-1)%top+1]];
        }
    for(int i = 1; i <= n; ++i) printf("%lld\n", ans[i] += ans[i-1]);
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include<cmath>
using namespace std;
typedef unsigned long long ull;
int main() {
	ull q,h,s,d;
	int n;
	cin>>q>>h>>s>>d;
	cin>>n;
	q*=4;
	h*=2;
	q = min(q,h);
	q = min(q,s);
	if(2*q<=d)
		cout<<q*n;
	else
	{
		if(n%2==0)
			cout<<(n/2)*d;
		else
			cout<<((n-1)/2)*d + q;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set> 
#include<cmath>
using namespace std;
//long long p = 998244353;
long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) { pa[x] = y; }
}
int gcd(int x, int y) {
	if (x < y) { return gcd(y, x); }
	if (y == 0) { return x; }
	return gcd(y, x % y);
}
int solve(int x, int y) {
	int ans = rui(2, x) + rui(2, y) + p - 1;
	ans %= p;
	int g1 = gcd(x, y);
	ans += rui(2, g1) + p - 2;
	ans %= p;
	return ans;
}
int full;
vel pl(int diff, vel ans) {//最初の量ー＞今の量＊２
	ans[1] += diff; ans[3] += diff;
	if (ans[3] > full) {
		ans[2] -= (ans[3] - full);
		mmax(ans[2], ans[0]);
		mmin(ans[1], full);
		mmin(ans[3], full);
	}
	return ans;
}
vel mi(int diff, vel ans) {//最初の量ー＞今の量＊２
	ans[1] -= diff; ans[3] -= diff;
	if (ans[1] < 0) {
		ans[0] += -ans[1];
		int ze = 0;
		mmin(ans[0], ans[2]);
		mmax(ans[1], ze);
		mmax(ans[3], ze);
	}
	return ans;
}
int gt(vel ans, int x) {
	if (x < ans[0]) { return ans[1]; }
	if (ans[2] < x) { return ans[3]; }
	return ans[1] + (x - ans[0]);
}
signed main() {
	int k; cin >> full >> k;
	vvel ans(k + 1, vel(4));
	ans[0] = { 0,0,full,full };
	int now_time = 0;
	bool fl = true;
	vel r(k + 1, 0);
	rep(i, k) {
		int nex_time; cin >> nex_time;
		r[i + 1] = nex_time;
		int diff = nex_time - now_time;
		if (fl) {
			ans[i + 1] = mi(diff, ans[i]);
		}
		else {
			ans[i + 1] = pl(diff, ans[i]);
		}
		fl = !fl;
		now_time = nex_time;
	}
	int q; cin >> q;
	rep(i, q) {
		int t, a; cin >> t >> a;
		int x=upper_bound(r.begin(), r.end(), t)-r.begin();
		x--;
		int ret = gt(ans[x], a);
		if (x % 2 == 0) {
			ret -= (t - r[x]);
			int ze = 0;
			mmax(ret, ze);
		}
		else {
			ret += (t - r[x]);
			mmin(ret,full);
		}
		cout << ret << endl;
	}
	return 0;
}


Measured memory_bytes: 10240
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <list>
#include <math.h>
#include <map>
using namespace std;
#define REP(i, k, n) for(int i = k;i < n; i++)
#define rep(i, n) REP(i,0,n)
int dx[4] = {0,-1,1,0};
int dy[4] = {-1,0,0,1};
int main(void){
	int a,b;
	cin >> a >> b;
	cout << (a+b)%24 << endl;
}


Measured memory_bytes: 256
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber
// 14 06 2020

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);

// defines...
#define MP make_pair
#define PB push_back
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

int gcd(int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a*b/gcd(a, b));
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}


void bruce()
{
    //cout << "\nExpected answer:\n";
    //cout << "\nAnswer recieved:\n";
}

void task()
{
    //code here...

    int x, n, m=0, s=1000;
    cin >> x >> n;
    vi ara(n);
    if(n==0){
        cout << x << "\n";
        return;
    }

    for(int K=0; K<n; K++){
        cin >> ara[K];
        m = max(m, ara[K]);
        s = min(s, ara[K]);
    }

    int ans=1000, lol=-1;
    for(int K=s-1; K<=m+1; K++){
        if(find(ara.begin(), ara.end(), K)==ara.end()){
            if(abs(x-K)<ans){
                ans = abs(x-K);
                lol = K;
            }
        }
    }

    if(lol==-1) cout << min(x, n+1-x) << "\n";
    else cout << lol << "\n";
}

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

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

    task();

    return 0;
}

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

int main() {
	int a,b,tmp,r;
	int tmpa, tmpb;
	cin >> a >> b;

	tmpa = a;
	tmpb = b;

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

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

	double aa = tmpb / b;
	double ans=tmpa*aa;

	cout << (long long)ans << endl;
}

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

using namespace std;

#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5+1;

void setIO(string name)
{
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //setIO("");
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;


    return 0;
}


Measured memory_bytes: 896