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

int main() {
  int A, B;
  cin >> A >> B;
  
  if (A == B) {
    cout << "Draw" << endl;
  }
  else if (A == 1) {
    cout << "Alice" << endl;
  }
  else if (B == 1) {
    cout << "Bob" << endl;  
  }
  else if (A > B) {
    cout << "Alice" << endl;
  }
    else {
    cout << "Bob" << endl;
  }
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
if a > b:
    print(0)
elif n == 1:
    if a == b:
        print(1)
    else:
        print(0)
elif n == 2:
    print(1)
else:
    # min = a*n +b-a max = b*n + a -b までを全て取れる。
    print(1 + (b - a) * (n - 2))


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

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

    int A, B, X;
    cin >> A >> B >> X;

    if((X - A < 0) || (A > X) || (A + B < X)){
        cout << "NO" << "\n";
    }
    else{
        cout << "YES" << "\n";
    }

    return 0;
}


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

int main(void){
    int x,y;
    
    while(true){
        cin >> x;
        cin >> y;
        if(x == 0 && y == 0){
            break;
        }
        if(x < y){
            cout << x << " " << y << endl;
        }
        else{
            cout << y << " " << x << endl;
        }
    
    }
}


Measured memory_bytes: 3076
package main

import (
	"fmt"
)

func max(x, y int) int {
	var res int
	if x > y {
		res = x
	} else {
		res = y
	}
	return res
}

func main() {
	var A, B, ans int
	fmt.Scan(&A, &B)

	ans += max(A, B)

	if A == max(A, B) {
		A -= 1
	} else {
		B -= 1
	}

	ans += max(A, B)

	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>a>>b;
    if(b%a==0)Cout(a+b);
    else Cout(b-a);
    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  double border = (double)accumulate(a.begin(), a.end(), 0) / (double)(4 * m);
  //cout << border << endl;
  int cnt = 0;
  rep(i, n) {
    if (a[i] >= border) {
      cnt += 1;
    }
  }

  if (cnt >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
void solve(){
    int n;
    cin >> n;
    cout << (n >= 30 ? "Yes" : "No") << endl;
}
main(){
    ios_base::sync_with_stdio(0);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define all(v) v.begin(), v.end() // sort(all(array))
#define INF 1000000000
#define mod 1000000007
using namespace std;
using ll = long long;
using vi = vector<int>; //vi array(要素数, 初期値)
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>; //vvi table(行数, vi(列数, 初期値))
using vvc = vector<vc>;
using vvs = vector<vs>;
using vvb = vector<vb>;

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double dist = sqrt(a*a + b*b - 2*a*b*cos(2*acos(-1)/720 * (60*h+m)-2*acos(-1)/60*m));
    cout << fixed << setprecision(15) << dist << endl;
}

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

int N,K;
int par[100010];
vector<int> G[100010];
int ans = 0;

int DFS(int v)
{
    int d = 0;
    for(int i = 0; i < G[v].size(); i++)
        d = max(DFS(G[v][i]),d);
        
    if(d == K - 1 && par[v] != 1 && v != 1)
    {
        ans++;
        return 0;
    }
    return d + 1;
}

int main()
{
    scanf("%d%d",&N,&K);
    for(int i = 1; i <= N; i++)
    {
        int a;
        scanf("%d",&a);
        par[i] = a;
        if(i == 1)continue;
        G[a].push_back(i);
    }

    DFS(1);

    printf("%d\n",ans + (par[1] != 1));
    return 0;
}


Measured memory_bytes: 12288
import java.util.*;
import java.io.*;
 
public class Main {
	
		
	
	public static void main(String args []) {
		InputReader obj = new InputReader(System.in);
		
		int a=obj.nextInt();
		if(a>=1&&a<10) {
			System.out.println(a);
		}
		else if(a>=10 && a<100) {
			System.out.println("9");
		}
		else if(a>=100 && a<1000) {
			int count=9+a-100+1;
			System.out.println(count);
		}
		else if(a>=1000&&a<10000) {
			System.out.println("909");
		}
		else if(a>=10000 && a<100000) {
			int cou=909+a-10000+1;
			System.out.println(cou);
		}
		else if(a==100000) {
			System.out.println("90909");
		}
	}
	public static class InputReader {
	    public BufferedReader reader;
	    public StringTokenizer tokenizer;
 
	    public InputReader(InputStream stream) {
	        reader = new BufferedReader(new InputStreamReader(stream), 32768);
	        tokenizer = null;
	    }
 
	    public String next() {
	        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }
 
	    public int nextInt() {
	        return Integer.parseInt(next());
	    }
 
	    public long nextLong() {
	        return Long.parseLong(next());
	    }
	    
 
	}
}

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

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

using namespace std;

int main () {
	int a, b, c; cin >> a >> b >> c;

	if (a % (b + c) == 0) cout << "Yes" << '\n';
	else if (b % (a + c) == 0) cout << "Yes" << '\n';
	else if (c % (a + b) == 0) cout << "Yes" << '\n';
	else cout << "No" << '\n';

	return 0;

}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[100010],b[100010];
int main() {
	ll ans=0;
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	for(int i=n-1;i>=0;i--){
		ll now=a[i]+ans;
		if(now%b[i]==0){
			continue;
		}
		ans+=(now+b[i]-1)/b[i]*b[i]-now;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  string w[3]={"Sunny", "Cloudy", "Rainy"};
  string r;cin>>r;
  for(int i=0;i<3;i++){
    if(r.compare(w[i])==0){
      cout<<w[(i+1)%3]<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int a,b;
    a=2;
    b=2;
    if(a>=2 && a<=100 && b>=2 && b<=100) {
        cin>>a>>b;
        if(a>=2 && a<=100 && b>=2&& b<=100){
        int area;
        area=(a-1)*(b-1);
        cout<<area;
        }
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))

SORTED = sorted(X)
med1 = SORTED[N//2 - 1]
med2 = SORTED[N//2]
# print(med1, med2)

for xi in X:
    if xi <= med1:
        print(med2)
    else:
        print(med1)

Measured memory_bytes: 25472
#include <stdio.h>

int main(int argc, char **argv) {
  int i, s, n;
  int mem[1000001];

  while (scanf("%d", &s) != EOF) {
    for (i = 0; i < 1000001; i++) {
      mem[i] = 0;
    }

    mem[s] = 1;
    for (i = 1, n = s;;) {
      if (n %2 == 0 ) {
        n /= 2;
      } else {
        n = n * 3 + 1;
      }
      i++;
      if (mem[n] == 1) {
        break;
      }
      mem[n] = 1;
    }
    printf("%d\n", i);
  }

  return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int A, B, T;
    cin >> A >> B >> T;
    double a = T + 0.5;
    int b = a/A;
    int ans = b*B;

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	IOS;
	int n;
	cin>>n;
	int mn=M;
	int ans=0;
	for(int i=0;i<n;i++){
		int x; cin>>x;
		if(x<=mn){
			ans++;
			mn=min(mn,x);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
if(n%2==0){
    cout<<n<<endl;
}
else{
    cout<<2*n<<endl;
}
//system("pause");
return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

func main() {
	n := readi()
	s := readString()

	eLen := 0
	for i := 0; i < n; i++ {
		if string(s[i]) == "E" {
			eLen++
		}
	}

	ans := INF
	w := 0
	e := 0
	for i := 0; i < n; i++ {
		if string(s[i]) == "W" {
			ans = min(ans, w+(eLen-e))
			w++
		} else {
			e++
			ans = min(ans, w+(eLen-e))
		}
	}

	fmt.Println(ans)
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int k, n;
    cin >> k >> n;
    vint a(n);
    rep(i, n) cin >> a[i];

    vint d;
    rep(i, n-1) {
        d.push_back(a[i+1] - a[i]);
    }
    d.push_back(k-a[n-1]+a[0]);
    sort(all(d));

    ll ans = 0;
    rep(i, n-1) ans += d[i];

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

Measured memory_bytes: 2168
from collections import namedtuple


def BubbleSort(C, N):
    for i in range(N):
        for j in range(N-1, i, -1):
            if C[j].value < C[j-1].value:
                C[j], C[j-1] = C[j-1], C[j]


def SelectionSort(C, N):
    for i in range(N):
        minj = i
        for j in range(i, N):
            if C[j].value < C[minj].value:
                minj = j
        C[i], C[minj] = C[minj], C[i]


Card = namedtuple('Card', 'mark value')
n = int(input())
a = [Card(i[0], int(i[1])) for i in input().split()]
b = a[:]

BubbleSort(a, n)
SelectionSort(b, n)

print(" ".join([i.mark + str(i.value) for i in a]))
print("Stable")
print(" ".join([i.mark + str(i.value) for i in b]))
print("Stable" if a == b else "Not stable")

Measured memory_bytes: 8212
#include "bits/stdc++.h"

using namespace std;
 
const long long inf = 1e18;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define rfr(i,n,a) for (int i=n;i>=a;i--)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define endl "\n"
typedef vector<int> VI;
typedef vector<ll> VL;

ll n,m,k;
ll dp[100001];
int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	VI v(n);
	for (auto &x:v)
		cin >> x;
	dp[0] = 0;
	dp[1] = abs(v[1]-v[0]);
	for (int i = 2;i < n;i++) {
		dp[i] = min(dp[i-1] + abs(v[i]-v[i-1]),dp[i-2] + abs(v[i] - v[i-2]) );
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>

int main(void)
{
  int x, y;

  while(scanf("%d %d", &x, &y) != EOF)
  {
    if(x == 0 && y == 0)
    {
      break;
    }
    else
    {
      if(x <= y)
      {
        printf("%d %d\n", x, y);
      }

      else
      {
        printf("%d %d\n", y, x);
      }
    }
  }

  return 0;
}



Measured memory_bytes: 1924
#include <bits/stdc++.h>
#define ll long long int
#define MOD1        1000000007
#define MOD2        998244353
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

ll k, n;
vector<ll> h;
void solve()
{
    cin >> k >> n;
    h.resize(n);
    for(auto &i: h)
        cin >> i;
    ll ans = k - h[n-1] + h[0];
    for(int i = 1; i < n; i++)
        ans = max(ans, h[i] - h[i-1]);
    cout << k-ans;
}


int main()
{
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif

    ll t = 1;
    //cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 1792
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  rep(i, n) cin >> a[i];
  ans = LINF;
  rep(i, 101) {
    cnt = 0;
    rep(j, n) { cnt += (a[j] - i) * (a[j] - i); }
    ans = min(ans, cnt);
  }
  Cout(ans);
  return 0;
}

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

int main(){

int n,k;
cin >> n >> k;
int a[n+1]={0};
rep(i,k){
    int di;
    cin >> di;
    rep(j,di){
        int g;
        cin >> g;
        a[g]++;
    }
}

int ans=0;
for(int i=1; i<=n; i++){
    if(a[i]==0) ans++;
}

cout << ans << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
#define For(x,s,y) for (x=s;x<=y;x++)
int main()
{
	int n,x,i,j,k,ans;
	while(1){
		scanf("%d%d",&n,&x);
		if (n==0&&x==0)break;
		ans=0;
		For (i,1,n) For (j,i+1,n) For (k,j+1,n) if(i+j+k==x) ans++;
		printf("%d\n",ans);
	}
	return 0;
}

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

int main()
{
	string s;
	cin >> s;
	int v[4];
	for (int i = 0; i < 4; ++i) {
		v[i] = s[i] - '0';
	}

	string stemp;
	stemp.resize(9);
	stemp[0] = s[0];
	stemp[2] = s[1];
	stemp[4] = s[2];
	stemp[6] = s[3];
	stemp[7] = '=';
	stemp[8] = '7';

	int e = 1 << 3;
	for (int i = 0; i < e; ++i) {
		int temp = i;
		string sr = stemp;
		int sum = v[0];
		for (int j = 1; j < 4; ++j) {
			if (temp & 1) {
				sum += v[j];
				sr[j * 2 - 1] = '+';
			}
			else {
				sum -= v[j];
				sr[j * 2 - 1] = '-';
			}
			temp >>= 1;
		}
		if (sum == 7) {
			cout << sr << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
m = (n + 1) / 2 - 1
x = gets.split.map(&:to_i)
y = x.each_with_index.sort{|a, b| a[0] <=> b[0] }
z = []
y.each_with_index do |i, j|
  z[i[1]] = j
end

n.times do |i|
  puts y[z[i] <= m ? m + 1 : m][0]
end



Measured memory_bytes: 35612
import sys

# S = input()
# N, M = map(int, input().split())
# As = [int(input()) for _ in range(N)]
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    print(solve())


def solve():
    K, N, = map(int, input().split())

    As = list(map(int, input().split()))

    pre = 0
    for i, a in enumerate(As):
        As[i] = a - pre
        pre = a

    As[0] = As[0] + (K - sum(As))

    return sum(As) - max(As)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26420
#include <stdio.h>
#include <math.h> 
int main(){
    int i,n,t;
    while(scanf("%d",&n)!=0){
        if(n==0)break;
        long int data[5100]={0};
        double max=0,sum=0;
        for(i=0;i<n;i++){
            scanf("%ld",&data[i]);
            if(i==0){
                max=data[i];
            }
        }
        max = -10000000;
        for(i=0;i<n;i++){
            sum=0;
            for(t=i;t<n;t++){
                sum+=data[t];
                if(sum>max)max=sum;
            }
        }
        printf("%.0lf\n",max);
    }
    return 0;
}

Measured memory_bytes: 680
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n;  cin >> n;
    string p, q;
    rep(i, n){
        int P;  cin >> P;
        p += to_string(P);
    }   
    rep(i, n){
        int Q;  cin >> Q;
        q += to_string(Q);
    }
    string tmp;
    rep(i, n)   tmp += to_string(i+1);
    int a, b;
    int i = 1;
    do{
        if(tmp == p)  a = i;
        if(tmp == q)  b = i;
        i++;
    }while(next_permutation(tmp.begin(), tmp.end()));
    cout << abs(a-b) << endl;
}


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

int main() {
    int n;
    cin >> n;
    long long int a[n], l[n+1] = {0}, r[n+1] = {0};
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        l[i+1] = l[i] + a[i];
    }
    for(int i = n-1; i >= 0; --i) r[i] = r[i+1] + a[i];
    long long int ans = 200000000000000;
    for(int i = 1; i < n; ++i) ans = min(ans, abs(l[i] - r[i]));
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i=(a); i<(n); ++i)
#define rrep(i,a,n) for(ll i=(a); i>(n); --i)
#define erep(i,a,n) for(ll i=(a); i<=(n); ++i)
#define rerep(i,a,n) for(ll i=(a); i>=(n); --i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int) x.size())
#define print (X) cout << (X) << endl
#define _ << " " <<
static const int INF = 1e+9+7;
ll n,m,l;
str s,t;
int A[100000];

int main(){

  cin >> n;
  rep(i,0,n) cin >> A[i];
  sort(A,A+n);
  map<int,int> res;
  vi vc;
  rep(i,0,n-1){
    int t = abs(A[i]-(A[n-1]-A[i]));
    vc.pb(t);
    res[t] = A[i];
  }

  sort(all(vc));
  int min_vc = vc[0];
  
  cout << A[n-1] _ res[min_vc] << endl; 

  return 0;
}





Measured memory_bytes: 5752
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long X, K, D;

int main() {
	cin >> X >> K >> D;
	if ((1LL << 60) / K <= D || abs(X) <= D * K) {
		long long V = abs(X) / D;
		if (V % 2 == K % 2) cout << abs(X) % D << endl;
		else cout << abs(D - abs(X) % D) << endl;
	}
	else {
		cout << abs(X) - K * D << endl;
	}
	return 0;
}

Measured memory_bytes: 3660
const M=1000000007;
var
	N,i,a,b:Longint;
	c,dp,ans:Array[1..200000]of int64;
	fac,invfac:Array[0..199999]of int64;
	V,nxt:Array[1..399998]of Longint;
	beg:Array[1..200000]of Longint;
function power(a,b:int64):int64;
begin
	if b=0 then power:=1 else if b mod 2=0 then power:=power(a*a mod M,b div 2)else power:=power(a*a mod M,b div 2)*a mod M;
end;
function dfs1(u,p:Longint):int64;
var
	id:Longint;
	ret:int64;
begin
	ret:=1;
	c[u]:=1;
	id:=beg[u];
	while id<>0 do begin
		if V[id]<>p then begin
			ret:=ret*dfs1(V[id],u)mod M;
			ret:=ret*invfac[c[V[id]]]mod M;
			inc(c[u],c[V[id]]);
		end;
		id:=nxt[id];
	end;
	dp[u]:=ret;
	dfs1:=ret*fac[c[u]-1]mod M;
end;
procedure dfs2(u,p:Longint;pr:int64);
var id:Longint;
begin
	ans[u]:=dp[u]*pr mod M*invfac[N-c[u]]mod M;
	id:=beg[u];
	while id<>0 do begin
		if V[id]<>p then begin
			dfs2(V[id],u,ans[u]*c[V[id]]mod M*power(dp[V[id]],M-2)mod M*fac[N-c[V[id]]-1]mod M);
		end;
		id:=nxt[id];
	end;
end;
begin
	read(N);
	fac[0]:=1;
	for i:=1 to N-1 do fac[i]:=fac[i-1]*i mod M;
	invfac[N-1]:=power(fac[N-1],M-2);
	for i:=N-2 downto 0 do invfac[i]:=invfac[i+1]*(i+1)mod M;
	for i:=1 to N-1 do begin
		read(a,b);
		V[i*2-1]:=b;
		nxt[i*2-1]:=beg[a];
		beg[a]:=i*2-1;
		V[i*2]:=a;
		nxt[i*2]:=beg[b];
		beg[b]:=i*2;
	end;
	dfs1(1,0);
	dfs2(1,0,1);
	for i:=1 to N do writeln(ans[i]*fac[N-1]mod M);
end.


Measured memory_bytes: 13824
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int n  ;
    cin >> n ;
    int a[n] ;
    for(int i = 0; i < n ; i++){
        cin >> a[i] ;
    }

    sort(a,a+n) ;
    cout << a[n-1] -a[0]  << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MAX 1000000001
using ll=long long;

int main(){
    int a[5],m=0,sum=0;
    rep(i,5){
        cin>>a[i];
        sum+=(a[i]+9)/10*10;
        int sub=(a[i]+9)/10*10-a[i];
        m=max(m,sub);
    }
    cout<<(sum-m)<<endl;
}

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

int main () {
  int a, b, k;
  cin >> a >> b >> k;
  
  int x = 0, ans = 1;
  for (int i = min(a,b); i >= 2; i--) {
    if (a%i==0 && b%i==0) {
      x ++;
    }
    if (x == k) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());

	ll res = a[n-1] - a[0];
	for (int i = 1; i < n/2; ++i) {
		res += a[n-i] - a[i];
		res += a[n-i-1] - a[i-1];
	}
	if(n & 1)
		res += max(a[n/2+1] - a[n/2], a[n/2] - a[n/2-1]);
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 3728
<?php
  list($n, $a, $b, $c) = explode(" ", trim(fgets(STDIN)));

  $s = [];
  for($i=0; $i<$n; $i++){
    list($s[]) = explode(" ", trim(fgets(STDIN)));
  }

  $ans = [];
  for($i=0; $i<$n; $i++){
    if($s[$i] == "AB"){
      if($a > $b){
        $a--;
        $b++;
        $ans[] = "B";
      }
      else if($b > $a){
        $b--;
        $a++;
        $ans[] = "A";
      }
      else{
        if($i == $n-1 || $s[$i] == $s[$i+1]){
          $a++;
          $b--;
          $ans[] = "A";
        }else{
          if($s[$i+1] == "BC"){
            $a--;
            $b++;
            $ans[] = "B";
          }else{
            $a++;
            $b--;
            $ans[] = "A";
          }
        }
      }
    }
    else if($s[$i] == "BC"){
      if($b > $c){
        $b--;
        $c++;
        $ans[] = "C";
      }
      else if($c > $b){
        $c--;
        $b++;
        $ans[] = "B";
      }
      else{
        if($i == $n-1 || $s[$i] == $s[$i+1]){
          $b--;
          $c++;
          $ans[] = "C";
        }else{
          if($s[$i+1] == "AC"){
            $b--;
            $c++;
            $ans[] = "C";
          }else{
            $c--;
            $b++;
            $ans[] = "B";
          }
        }
      }
    }
    else if($s[$i] == "AC"){
      if($a > $c){
        $a--;
        $c++;
        $ans[] = "C";
      }
      else if($c > $a){
        $c--;
        $a++;
        $ans[] = "A";
      }
      
      else{
        if($i == $n-1 || $s[$i] == $s[$i+1]){
          $a--;
          $c++;
          $ans[] = "C";
        }else{
          if($s[$i+1] == "BC"){
            $a--;
            $c++;
            $ans[] = "C";
          }else{
            $c--;
            $a++;
            $ans[] = "A";
          }
        }
      }
      
    }
    
    if($a < 0 || $b < 0 || $c < 0){
      echo "No";
      exit;
    }
  }

  echo "Yes".PHP_EOL;

  for($i=0; $i<$n; $i++){
    echo $ans[$i].PHP_EOL;
  }
  

Measured memory_bytes: 26632
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;

int main(){
    string S;
    cin >> S;
    for(int i=0;i<S.length();i+=2) cout << S[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//素因数分解をする関数.
map<long long int, int> prime_factorization(long long int a)
{
	map<long long int, int>ans;
	for (long long i = 2; i*i <= a; ++i) {
		while (a%i == 0) {
			ans[i]++;
			a /= i;
		}
	}
	if (a != 1)ans[a]++;
	return ans;
}

//最大公約数を返す関数.
long long int gcd(long long int x, long long int y){
    if (x < y) swap(x,y);
    while (y > 0){
        long long int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main()
{
	int n;
	cin >> n;
	set<int> a;
	rep(i, n){
		int b;
		cin >> b;
		a.insert(b);
	}
	if (a.size() % 2 == 0){
		cout << a.size() - 1 << endl;
	} else {
		cout << a.size() << endl;
	}

	return 0;
}




Measured memory_bytes: 8136
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int m = in.nextInt();
        int s[] = new int[m];
        int c[] = new int[m];
        int ans[] = new int[n];
        Arrays.fill(ans,-1);
        int f = 0;
        for(int i=0;i<m;i++){
            s[i] = in.nextInt();
            c[i] = in.nextInt();
            if(ans[s[i]-1]!=-1 && ans[s[i]-1]!=c[i]) f=1;
            else ans[s[i]-1] = c[i];
        }
        if(f==1) {out.println(-1);return;}
        if(n==1){
            if(ans[0]==-1) ans[0]=0;
        }else if(n==2){
            if(ans[0]==-1) ans[0]=1;
            else if(ans[0]==0) f=1;
            if(ans[1]==-1) ans[1]=0;
        }else{
            if(ans[0]==-1) ans[0]=1;
            else if(ans[0]==0) f=1;
            if(ans[1]==-1) ans[1]=0;
            if(ans[2]==-1) ans[2]=0;
        }
        if(f==1) {out.println(-1);return;}
        for(int i:ans) out.print(i);
        out.println();
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 23252
#include <utility>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>

using namespace std;

int c;
int a[100][100];
int times = 0;
vector<pair<int,int> > v;

vector<int> search(int node)
{
    vector<int> r;
    for(int i = 0;i<c;i++)
    {
        if(a[node][i] == 1)
            r.push_back(i);
    }
    return r;
}

int deep(int node)
{
    if(v[node].first == 0)
    {
        v[node].first = ++times;
        vector<int> r = search(node);
        for(int i = 0;i<r.size();i++)
        {
            deep(r[i]);
            
        }
        v[node].second = ++times;
    }
    else
        return -1;

    return 1;
}

int main() {

    cin >> c;
    for(int i= 0;i<c;i++)
        for(int j = 0;j<c;j++)
            a[i][j] = 0;
    v = vector<pair<int,int> >(c,{0,0});
    for(int i = 0; i<c;i++)
    {
        int rem[2];
        cin >> rem[0] >> rem[1];
        for(int j = 0;j<rem[1];j++)
        {
            int rem11;
            cin >> rem11;
            a[i][rem11-1] = 1;
        }
    }//cin fin
    for(int i = 0;i<c;i++)
    {
        if(v[i].first == 0)
            deep(i);
    }
    
    for(int i = 0; i<c;i++)
    {
        cout << i+1 << " " << v[i].first << " " << v[i].second << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3172
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
t = [0] * (N + 1)
vis = set()
res = 0
for i in range(M):
  p, s = input().split()
  p = int(p)
  if s == "WA": t[p] += 1
  else:
    if p in vis: continue
    res += t[p]
    vis.add(p)
print(len(vis), res)

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

int main() {
  long long int a, b, c, k;
  cin >> a >> b >> c >> k;
  if(k % 2 == 1) {
    cout << (a - b) * -1 << "\n";
  } else {
    cout << a - b << "\n";
  }
}

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

int main() {
  int N, K, a = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++){
    if (a <= K)
      a *= 2;
    else
      a += K;
  }
  cout << a << endl;
}

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

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


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var A = new int[N];
		for (var i = 0; i < N; i++) A[i] = F;
		Array.Sort(A);
		var coeff = new List<int>();
		if (N % 2 == 0)
		{
			for (var i = 0; i < N / 2 - 1; i++) coeff.Add(-2);
			coeff.Add(-1);
			coeff.Add(1);
			for (var i = 0; i < N / 2 - 1; i++) coeff.Add(2);
		}
		else
		{
			for (var i = 0; i < (N - 1) / 2; i++) coeff.Add(-2);
			coeff.Add(1);
			coeff.Add(1);
			for (var i = 0; i < (N - 3) / 2; i++) coeff.Add(2);
		}
		var ans = 0L;
		for (var i = 0; i < N; i++) ans += coeff[i] * A[i];
		var ans2 = 0L;
		for (var i = 0; i < N; i++) ans2 -= coeff[N - i - 1] * A[i];
		WriteLine(Max(ans, ans2));
	}
}


Measured memory_bytes: 17316
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t,ci,ti,ans=1e9;
    scanf("%d%d",&n,&t);
    while(n--)
    {
        scanf("%d%d",&ci,&ti);
        if(ti<=t) ans=min(ans,ci);
    }
    if(ans==1e9) printf("TLE\n");
    else printf("%d\n",ans);

}


Measured memory_bytes: 256
#ifdef _MSC_VER
#  define _CRT_SECURE_NO_WARNINGS
#  define _USE_MATH_DEFINES
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double;
using u32 = unsigned int; using u64 = unsigned long long int; using str = string;
template <typename T> using vec = vector<T>; void in() { }
template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); }
template <typename T> void out(T &&x) { cout << x << "\n"; }
template <typename T, typename...TS> void out(T &&x, TS &&...xs) { cout << x << " "; out(move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t x; cin >> x; return x; }()
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) ((abs(x) & 1) == 0)
#define odd(x) ((abs(x) & 1) == 1)
#define bit(x, i) (((x) >> i) & 1)
#define append emplace_back
#define bisect_left lower_bound
#define bisect_right upper_bound
#define bound(a, x, b) (a <= x && x <= b)
const i64 MOD = 1000000007ll;
const f64 EPS = 1e-10;

deque<i32> q;

void solve() {
    indef(i32, n);
    times(n, ai) {
        indef(i32, a);
        if ((n&1) == (ai&1))
            q.push_back(a);
        else
            q.push_front(a);
    }
    while (q.size()-1) {
        cout << q.front() << " ";
        q.pop_front();
    } cout << q.front() << endl;
}

i32 main()
{
    ios::sync_with_stdio(false);

#ifdef _MSC_VER
    /**
    ifstream fin("input.txt"); cin.rdbuf(fin.rdbuf()); assert(fin);
    ofstream fout("output.txt"); cout.rdbuf(fout.rdbuf()); assert(fout);
    /**/
#endif

    cout << fixed << setprecision(9);
    solve();

    return 0;
}

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

typedef long long ll;

ll X;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  cin >> X;
  cout << 360 / gcd(360, X) << endl;
  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	double A,B;
	double P,Q,R;

	scanf("%lf %lf",&A,&B);
	scanf("%lf %lf %lf",&P,&Q,&R);

	printf("%.10lf\n",B+(P*B-Q*max(0.0,B-A))/(R+Q));

	return 0;
}



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

template<typename T> class Dijkstra {
public:
  struct edge {
    int to; T cost;
  };
  int V;
  vector<vector<edge>> G;
  vector<T> dist;
  vector<int> pre;
  using pti = pair<T,int>;
  Dijkstra(int n) : V(n), G(V), dist(V, numeric_limits<T>::max()), pre(V) {}
  void add(int u, int v, T cost) {
    G.at(u).push_back((edge) {v, cost});
    G.at(v).push_back((edge) {u, cost});
  }
  void solve(int s) {
    priority_queue<pti, vector<pti>, greater<pti>> Q;
    dist.at(s) = 0;
    Q.push(pti(0, s));
    while (!Q.empty()) {
      pti p = Q.top();
      Q.pop();
      int v = p.second;
      if (dist.at(v) < p.first) continue;
      for (auto &w : G.at(v)) {
        if (dist.at(w.to) > dist.at(v) + w.cost) {
          dist.at(w.to) = dist.at(v) + w.cost;
          pre.at(w.to) = v;
          Q.push(pti(dist.at(w.to), w.to));
        }
      }
    }
  }
  vector<int> route(int from, int to) {
    vector<int> res;
    while (true) {
      res.push_back(to);
      if (to == from) break;
      to = pre.at(to);
    }
    reverse(res.begin(), res.end());
    return res;
  }
};

int N;
vector<vector<int>> G;
int cnt;
void dfs(int pre, int v, int ng) {
  cnt++;
  for (auto next : G.at(v)) {
    if (next == pre) continue;
    if (next == ng) continue;
    dfs(v, next, ng);
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> N;
  G.resize(N);
  Dijkstra<int> D(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    D.add(a, b, 1);
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  D.solve(0);
  auto res = D.route(0, N - 1);
  int r = res.size();
  int f = res.at(r - r / 2 - 1);
  int s = res.at(r - r / 2);
  dfs(-1, 0, s);
  int F = cnt;
  cnt = 0;
  dfs(-1, N - 1, f);
  int S = cnt;
  cout << ((F > S) ? "Fennec" : "Snuke") << "\n";
}

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

bool ispalidrome(int x)
{
    int temp, digit, rev = 0;
    temp = x;
    while (temp > 0)
    {
        digit = temp % 10;
        rev = (rev * 10) + digit;
        temp /= 10;
    }
    return x == rev;
    
}

int main()
{
    int a, b, count = 0;
    cin >> a >> b;
    for (int i = a; i <= b; i++)
    {
        if (ispalidrome(i))
            count++;
    }
    cout << count;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

vector<vl> g;
vl c, ans;
ll in = 0;

void dfs(ll i, ll p) {
  for(auto v : g[i])
    if(v != p) dfs(v, i);
  ans[i] = c[in];
  in++;
}

int main() {
  ll n;
  cin >> n;
  g.resize(n);
  rep(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  c.resize(n);
  rep(i, n) cin >> c[i];
  sort(all(c));
  ans.resize(n);
  dfs(0, -1);
  cout << accumulate(c.begin(), c.end() - 1, 0LL) << endl;
  rep(i, n) cout << ans[i] << ' ';
  cout << endl;
}

Measured memory_bytes: 4404
n,m = map(int,input().split())
if n==0 or n ==1:
    if m == 0 or m == 1:
         a = 0
    else:
        a = m*(m-1) / 2
else:
    if m == 0 or m ==1:
        a = n*(n-1) / 2
    else:
        a = (n*(n-1) + m*(m-1)) / 2
print(int(a))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
constexpr ll MOD = 1e9+7;

int pw(int base, int exp) {
	int res = 1;
	while (exp) {
		if (exp & 1) res = (ll)base * res % MOD;
		exp >>= 1;
		base = (ll)base * base % MOD;
	}
	return res;
}

int inv(int x) { return pw(x, MOD - 2); }

int dv[1001], nCr[1001][1001], dp[1001][1001];

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

	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	for (int i = 0; i <= N; ++i) {
		nCr[i][0] = nCr[i][i] = 1;
		for (int j = 1; j < i; ++j) nCr[i][j] = (nCr[i - 1][j - 1] + nCr[i - 1][j]) % MOD;
	}
	for (int i = 1; i <= N; ++i) dv[i] = inv(i);
	dp[A - 1][0] = 1;
	for (int i = A; i <= B; ++i) {
		for (int j = 0; j <= N; ++j) {
			if (dp[i - 1][j]) {
				dp[i][j] = (dp[i - 1][j] + dp[i][j]) % MOD;
				ll cnt = 1;
				for (int k = 0; k <= D && j + k * i <= N; ++k) {
					if (k >= C) dp[i][j + k * i] = (cnt * dp[i - 1][j] + dp[i][j + k * i]) % MOD;
					cnt = ((cnt * nCr[N - j - k * i][i]) % MOD) * dv[k + 1] % MOD;
				}
			}
		}
	}
	cout << dp[B][N] << '\n';
}

Measured memory_bytes: 8064
import math

n, m = map(int, input().split())
a = math.factorial(n)
b = math.factorial(m)
if n == m:
    print(a * b * 2 % 1000000007)

elif abs(n - m) == 1:
    print(a * b % 1000000007)
else:
    print(0)

Measured memory_bytes: 5188
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9;
using v = vector<int>;

int main(){
	int n;
	cin >>n;
  
	auto a = v(n,0);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
  
	int c=0;
	bool f = true;
	while(f){
		for(auto &i:a){
          	if(i%2){
               f= false;
			}else{
				i /=2;
			}
		}
      	if(f)c++;
		else break;
	}
	
	cout << c;
}


Measured memory_bytes: 256