akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
 
public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    
    int days = 0;
    
     switch (s){
      case "SAT": days += 1; break;
      case "FRI": days += 2; break; 
      case "THU": days += 3; break;
      case "WED": days += 4; break;
      case "TUE": days += 5; break;        
      case "MON": days += 6; break;    
      case "SUN": days += 7; break;   
    }
    
    System.out.println(days);
  }
}

Measured memory_bytes: 23892
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

void solve(){
  int n;
  cin >> n;
  int ans = n;
  int mx = 0;
  while (n){
    int x = n;
    int c = 0;
    while (x % 2 == 0){
      x /= 2;
      c++;
    }
    if (c > mx){
      mx = c;
      ans = n;
    }
    n--;
  }
  cout << ans;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
322123


n - 1
0 ... (n-1) [res ... res] S - (n-1) ... S


 */

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

using namespace std;
typedef long long ll;
#define rep(i,n) for( int i=0; i<n; ++i )

int main(){
  int n;
  std::cin >> n;
  vector<int> d(n);
  rep(i,n){
    cin >> d[i];
  }
  ll cnt = 0;
  sort( d.begin(), d.end() );
  for( int a=0; a<n-2; a++ ){
    auto t = d.begin();
    for( int b=a+1; b<n-1; ++b ){
      t = lower_bound( t, d.end(), d[a]+d[b] );
      if ( t == d.end() ){
        cnt += n - b - 1;
      } else {
        cnt += max( t - d.begin() - b - 1, 0l );
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll n,k,sum=0;scanf("%lld%lld",&n,&k);
	if(k==0)
	{
		printf("%lld\n",n*n);
		return 0;
	}
	for(int b=k+1;b<=n;b++)
	{
		int a=n%b;
		sum+=a-k>=0? a-k+1:0;
		sum+=n/b*(b-k);
	}
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 256
import java.awt.print.Printable;
import java.util.Scanner;
import javax.sound.midi.SysexMessage;
  
public class Main{      
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int w = sc.nextInt();
        int amidaArray[] = new int[n+1];

        for(int i=1;i<=n;i++){
            amidaArray[i] = i;
        }
        for(int i=0;i<w;i++){
            String str = sc.next();
            String[] strs = str.split(",");

            int a = Integer.parseInt(strs[0]);
            int b = Integer.parseInt(strs[1]);

            int temp = amidaArray[a];

            amidaArray[a]=amidaArray[b];

            amidaArray[b]=temp;
        }
        for(int i=1;i<=n;i++){
            System.out.println(amidaArray[i]);
        }
    }   
}


Measured memory_bytes: 26092
#include <iostream>
#include <string>

using namespace std;

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

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

    int cnt = 0;
    rep(i, 0, 1000)
    {
        int tmp[3] = { i/100, (i/10)%10, i%10 };
        int idx = 0;
        rep(j, 0, n)
        {
            if ((tmp[idx] + '0') == s[j]) ++idx;
            if (idx == 3) break;
        }
        if (idx == 3) ++cnt;
    }
    cout << cnt << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;



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

	ll N;
	cin >> N;

	vector<ll> a(N);
	rep(i, N) cin >> a[i];

	vector<ll> b(N);
	rep(i, N) cin >> b[i];

	ll x = 0LL, y = 0LL;
	rep(i, N){
		x += max(a[i] - b[i], 0LL);
		y += max((b[i] - a[i])/2, 0LL);
	}

	if(x <= y){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define  ll  long long
#define  pii pair<ll,ll>
#define  pll pair<ll , ll>
#define  debug cout << "this far" << endl;
#define  For(i, n) for(int i = 0; i < (n); ++i)
#define  lsb(x) ((x) & (-x))
#define  PI acos(-1)
#define  line cout << endl;
#define  getbit(n, i) (((n) & (1LL << (i))) != 0)
#define  resetbit(n, i) ((n) & (~(1LL << (i))))
#define  setbit(n, i) ((n) | (1LL << (i)))
#define  togglebit(n, i) ((n) ^ (1LL << (i)))
#define  gap " "
#define printall(container) for(auto val  : container) cout << val << gap ; line ; 
using namespace std;
const int N = 2e5 + 10;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    int arr[n];
    for (int i = 0; i < n; ++i) cin >> arr[i];
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if (arr[i] == arr[j]) continue ;
                for (int k = j + 1; k < n; ++k) {
                    if (arr[k] == arr[i] || arr[k] == arr[j]) continue;
                    if (arr[i] + arr[j] > arr[k]
                        && arr[i] + arr[k] > arr[j] && arr[j] + arr[k] > arr[i]) {
                        ++ ans;
                    }
                }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define F first
#define S second
#define um map <ll,ll>
#define rep(i,z,n)  for(int i=z;i<n;i++)
#define repi(i,z,n) for(int i=z;i<=n;i++)
#define repn(i,z,n) for(int i=n-1;i>=z;i--)
#define vec vector<ll>
#define vecp vector<pair<ll,ll>>
#define pi (double)3.14159265358979323846
#define ld long double
#define all(z) z.begin(),z.end()

ll power(ll a, ll b, ll m) { ll ans = 1; a = a % m; if (a == 0) return 0; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; }
ll modInverse(ll a, ll m) {return power(a, m - 2, m);}
ll binpow(ll a, ll b) {ll res = 1; while (b > 0) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll binlog2(ll n) {ll logValue = -1; while (n) {logValue++; n >>= 1;} return logValue;}
void print(vec a) {rep(i, 0, a.size())cout << a[i] << " "; cout << endl;}
const ll mod = 1e9 + 7;
const ll N = 3e3 + 5;
const ll inf = 2e18;
double a[N];
vector<vector<double>> dp(N, vector<double>(N, -1));;
ll n, m;

double recur(ll i, ll h) {
    if (i > n) {
        if (h > n / 2)
            return 1;
        else
            return 0;
    }
    if (dp[i][h] != -1)
        return dp[i][h];
    double l = 0, r = 0;

    l = a[i] * recur(i + 1, h + 1);
    r = (1 - a[i]) * recur(i + 1, h);
    // cout << l << " " << r << endl;

    return dp[i][h] = (l + r);

}

void solve() {
    cin >> n;
    repi(i, 1, n)
    cin >> a[i];

    double ans = recur(1, 0);
    cout << fixed << setprecision(10) << ans << endl;
}








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

    speed;
    int test = 1;
    // cin >> test;
    while (test--) {
        // cout << "Case #" << t1 << ": ";
        solve();
    }
    return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPR(i,n) for(int (i)=(n-1);(i)>=0;i--)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);i++)
#define FORR(i,m,n) for(int (i)=(m-1);(i)>=(n);i--)
#define PRINT(x) {cout<<(x)<<"\n";}

int main(){
    string s = "753";
    char x;
    cin >> x;
    if (s.find(x) != string::npos) PRINT("YES")
    else PRINT("NO")
}

Measured memory_bytes: 256
package main

import(
    "bufio"
    "fmt"
    "os"
)

var r=bufio.NewReader(os.Stdin)

func main(){
    var x,h,m,s int
    fmt.Fscan(r, &x)
    
    h=x/60/60
    m=(x-h*60*60)/60
    s=x-h*60*60-m*60
    fmt.Printf("%d:%d:%d\n",h,m,s)
}


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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

    int n, t;
    cin >> n >> t;
    vt<pii> a(n);
    for (pii &i : a) cin >> i.fi >> i.se;
    sort(all(a));

    vt<int> dp(t);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = t - 1; j >= 0; j--) {
            int res = dp[j] + a[i].se;
            if (j + a[i].fi < t) {
                int &x = dp[j + a[i].fi];
                x = max(x, res);
            }
            ans = max(ans, res);
        }
    }

    cout << ans;
}


Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
 
using namespace std;
 
const int N = 200000 + 10;
 
vector<int> v[N];
int ans[N];
int n,m;
queue<int> q;

void bfs()
{
	q.push(1);
	ans[1] = 1;
	while(!q.empty())
	{
		int a = q.front();
		q.pop();
		for(int i=0; i<v[a].size(); i++)
		{
			int b = v[a][i];
			if(!ans[b])
			{
				ans[b] = a;
//				cout<<b<<' '<<a<<endl;
				q.push(b);
			}
		}
	}
} 
 
 
int main()
{
	cin>>n>>m;
	for(int i=0; i<m; i++) 
	{
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}	
	bfs();
	for(int i=2; i<=n; i++)
	{
		if(!ans[i]) 
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	for(int i=2; i<=n; i++) cout<<ans[i]<<endl;
	return 0;
} 

Measured memory_bytes: 12424
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=200050;
ll lsm[N],rsm[N];
int main()
{
	int n,i,L;
	scanf("%i %i",&L,&n);
	vector<int> a(n+1);
	for(i=1;i<=n;i++) scanf("%i",&a[i]);
	for(i=1;i<=n;i++) lsm[i]=lsm[i-1]+a[i]*2,rsm[i]=rsm[i-1]+(L-a[i])*2;
	ll ans=max(a[n],L-a[1]);
	for(int cen=1;cen<=n;cen++)
	{
		int l=cen-1;
		int r=n-cen;
		if(l<=r)
		{
			//Same
			ll lf=lsm[cen-1];
			ll rf=rsm[cen+l]-rsm[cen];
			ans=max(ans,lf+rf+max(a[cen],L-a[cen]));
			//MoreL
			if(l>0)
			{
				rf=rsm[cen+l-1]-rsm[cen];
				ans=max(ans,lf+rf+L-a[cen]);
			}
			//MoreR
			if(l<r)
			{
				rf=rsm[cen+l+1]-rsm[cen];
				ans=max(ans,lf+rf+a[cen]);
			}
		}
		else
		{
			//Same
			ll lf=lsm[cen-1]-lsm[cen-r-1];
			ll rf=rsm[n]-rsm[cen];
			ans=max(ans,lf+rf+max(a[cen],L-a[cen]));
			//MoreL
			if(l>r)
			{
				lf=lsm[cen-1]-lsm[cen-r-2];
				ans=max(ans,lf+rf+L-a[cen]);
			}
			//MoreR
			if(r>0)
			{
				lf=lsm[cen-1]-lsm[cen-r];
				ans=max(ans,lf+rf+a[cen]);
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4096
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

check_A = [0]
check_B = [0]

for a in range(N):
    check_A.append(check_A[a] + A[a])

for b in range(M):
    check_B.append(check_B[b] + B[b])

ans = 0
j = M

for i in range(N+1):
    if check_A[i] > K:
        break
    while check_B[j] > K - check_A[i]:
        j -= 1
    ans = max(ans, i+j)

print(ans)

Measured memory_bytes: 47648
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        pair<int, int> ret(-1, -1);
        for(int i=0; i<n; ++i){
            int p, d1, d2;
            cin >> p >> d1 >> d2;
            ret = max(ret, make_pair(d1 + d2, p));
        }
        cout << ret.second << ' ' << ret.first << endl;
    }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
ll N;
char s[101010];
int as[256];
ll tp[101010];
ll i,j, an;
ll ans;
int main(){
    scanf("%lld%s", &N, s);
    tp[0] = 1;
    fornum(i,0,N){
        tp[i + 1] = (tp[i] * 2) % MOD;
    }
    fornum(i,0,N){
        ll a = 1;
        fornum(j,'a','z'+1){
            if(s[i]==j)
                continue;
            a = (a * (as[j] + 1)) % MOD;
        }
        ans =(ans+a) %MOD;
        as[s[i]]++;
        //printf("%lld,%lld\n", i, ans);
    }
    printf("%lld", ans);

    return 0;
}

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

using namespace std;

int h[111111];
long d[111111];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%d", h + i);
	d[1] = abs(h[0] - h[1]);
	for (int i = 2; i < n; i++)
		d[i] = min(d[i - 2] + abs(h[i - 2] - h[i]), d[i - 1] + abs(h[i - 1] - h[i]));
	cout << d[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define NIL -1
#define MAX 100000

struct Node{int parent, left, right;};
Node T[MAX];
int n,D[MAX],H[MAX];

void depth(int u,int d){
    if(u==NIL) return;
    D[u]=d;
    depth(T[u].left, d+1);
    depth(T[u].right,d+1);
}

//?????°??§??????????±????????????????
int height(int u){
    int hl=0,hr=0;
    if(T[u].left!=NIL) hl=height(T[u].left) + 1;
    if(T[u].right!=NIL) hr=height(T[u].right) + 1;
    
    return H[u] = (hl > hr ? hl : hr);
}

int GetSibling(int u){
    int _p = T[u].parent;
    if(_p==NIL) return NIL;
    if(T[_p].left!=u && T[_p].left!=NIL) return T[_p].left;
    if(T[_p].right!=u && T[_p].right!=NIL) return T[_p].right;
    return NIL;
}

void print(int u){
    cout << "node " << u <<": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "sibling = " << GetSibling(u) << ", ";
    int deg=0;
    if(T[u].left!=NIL) deg++;
    if(T[u].right!=NIL) deg++;
    cout << "degree = " << deg << ", ";
    cout << "depth = " << D[u] << ", ";
    cout << "height = " << H[u] << ", ";
    if(T[u].parent == NIL) cout << "root";
    else if(T[u].left == NIL && T[u].right == NIL) cout << "leaf";
    else cout << "internal node";
    cout << endl;
}

int main(){
    int v,l,r,root=0;
    cin >> n;
    rep(i, n) T[i].parent = NIL;
    rep(i, n){
        cin >> v >> l >> r;
        T[v].left = l;
        T[v].right = r;
        if(l != NIL) T[l].parent = v;
        if(r != NIL) T[r].parent =v;
    }
    rep(i, n) {
        if(T[i].parent == NIL) root=i;
    }
    depth(root, 0);
    height(root);
    
    rep(i, n) print(i);
    return 0;
}

Measured memory_bytes: 3048
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int[] a = new int[n + 1];

    for (int i = 1; i <= n; i++) {
      a[i] = sc.nextInt();
    }

    int m = 0;
    List<Integer> turnOn = new ArrayList<>();
    int[] b = new int[n + 1];
    for (int i = n; 1 <= i; i--) {
      int val = a[i];
      for (int j = 2 * i; j <= n; j += i) {
        val += b[j];
      }
      b[i] = val % 2;
      if (b[i] == 1) {
        m++;
        turnOn.add(i);
      }
    }

    os.println(m);
    if (m > 0) {
      os.println(turnOn.stream().map(String::valueOf).collect(Collectors.joining(" ")));
    }
  }
}

Measured memory_bytes: 71268
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
    char a [10];
    scanf("%s",a);
    if(a[1]==a[2]&&(a[1]==a[0]||a[1]==a[3])) 
    printf("Yes");
    else 
    printf("No");
    return 0;
}


Measured memory_bytes: 256
// finish date: 2018/02/18

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N;
    cin >> N;
    vi p(N);
    rep(i, N) cin >> p[i];
    int ans=0;
    rep(i,N){
        if(i==N-1&&p[i]==i+1) ans++;
        else if(p[i]==i+1){
            swap(p[i],p[i+1]);
            ans++;
        }
    }
    cout<<ans<<endl;


    return 0;
}




Measured memory_bytes: 640
N, Y = map(int, input().split())
flag = False
for x in range(N + 1):
    for y in range(0, N - x + 1):
        if 10000 * x + 5000 * y + 1000 * (N - x - y) == Y:
            print(x, y, N - x - y)
            flag = True
            exit()
if (not flag): print("-1 -1 -1")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int main() {
    int N; cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    int amax = -100, amin = 100;
    rep(i, N) {
        if (a[i] > amax) amax = a[i];
        if (a[i] < amin) amin = a[i];
    }

    int ans = INT_INF;
    for (int i = amin; i <= amax; i++) {
        int tmp = 0;
        for (int j = 0; j < N; j++) {
            tmp += (a[j] - i) * (a[j] - i);
        }
        if (tmp < ans) ans = tmp;
    }
    cout << ans << endl;
}


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

int main(){
  int A,B,C,D;cin >> A >> B >> C >> D;
  int Tak = (C-1) / B + 1,Aok = (A-1) / D + 1;
  if(Tak<=Aok){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  string s, t;
  int a, b;
  cin >> s >> t;
  cin >> a >> b;
  string u;
  cin >> u;
  if(u == s){
    a -= 1;
  }else{
    b -= 1;
  }
  cout << a << " " << b << endl;;
}


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

class Program
{
    static void Main()
    {
        while (true)
        {
            string dajkldjkldas = Console.ReadLine();
            if (dajkldjkldas == null) { break; }
            int x = 0, y = 0;
            string[] a = dajkldjkldas.Split();
            string[] b = Console.ReadLine().Split();
            for (int i = 0; i < 4; i++)
            {
                if (a[i] == b[i])
                {
                    x++;
                }
                for (int k = 0; k < 4; k++)
                {
                    if (a[i] == b[k]) { y++; }
                }
            }
            Console.WriteLine(x + " " + (y - x));
        }

    }
}

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    scanf("%d",&N);
    
    int A[N],counter=0;
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    for(int i=0;i<N;i++){
        for(int j=N-1;j>=i+1;j--){
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                counter++;
            }
        }
    }
    for(int i=0;i<N;i++){
        printf("%d",A[i]);
        if(!(i==N-1))
        printf(" ");
    }
    printf("\n");
    printf("%d\n",counter);
    
    return 0;
}



Measured memory_bytes: 3188
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(long long L, long long R) {
        auto calc = [&](long long x) {
            if (x < 0) {
                return 0LL;
            }

            int r = x % 4;
            if (r == 0) {
                return x;
            } else if (r == 1) {
                return 1LL;
            } else if (r == 2) {
                return x + 1;
            } else if (r == 3) {
                return 0LL;
            }
            assert(0);
            return 0LL;
        };

        return calc(L - 1) ^ calc(R);
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    long long a, b;
    cin >> a >> b;
    Solution sol;
    cout << sol.solve(a, b) << "\n";

    return 0;
}

Measured memory_bytes: 384
// Problem: F - Range Set Query
// Contest: AtCoder - AtCoder Beginner Contest 174
// URL: https://atcoder.jp/contests/abc174/tasks/abc174_f
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define y2 y1919810
//#define int long long
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define range(i, s, t) for (int i = s; i <= (int)t; i++)
#define RESET(x) memset((x), 0, sizeof(x))
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
const int N = 500050;
int cnt[N], ans, a[N];
void move(int pos, int sign) {
  if (sign) {
    if (++cnt[a[pos]] == 1) ++ans;
  } else {
    if (--cnt[a[pos]] == 0) --ans;
  }
}
int n, Q;
struct Query {
  int l, r, id;
} q[N];
int answer[N];
void solve() {
  scanf("%d%d", &n, &Q);
  rep(i, n) cin >> a[i];
  int BL = 1000;
  rep(i, Q) {
    int l, r;
    scanf("%d%d", &l, &r);
    --l;
    q[i] = {l, r, i};
  }
  sort(q, q + Q, [BL](const Query& a, const Query& b) {
    int al = a.l / BL, bl = b.l / BL;
    return (al != bl) ? al < bl : a.r < b.r;
  });
  int l = 0, r = 0;
  rep(i, Q) {
    while (l > q[i].l) move(--l, true);
    while (r < q[i].r) move(r++, true);
    while (l < q[i].l) move(l++, false);
    while (r > q[i].r) move(--r, false);
    answer[q[i].id] = ans;
  }
  rep(i, Q) printf("%d\n", answer[i]);
}
signed main() {
  int T = 1;
  // cin >> T;
  while (T--) solve();
  return 0;
}


Measured memory_bytes: 15412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

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

using namespace std;

bool prime[10000000];
void Eratosthenes(int n)
{
    rep(i,n) prime[i] = true;
    prime[1] = false;

    REP(i,2,(int)sqrt(n))
    {
        if(prime[i])
        {
            for(int j=0;i*(j+2)<n;j++)
            {
                prime[i*(j+2)] = 0;
            }
        }
    }
}

int main()
{
    Eratosthenes(10000000);
    int n;
    while(cin >> n && n)
    {
        int ans = 0;
        REP(i,n+1,2*n+1) {
            if(prime[i]) ans++;
        }
        
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    for (int i = 0; i < n; i++) {
        string t;
        cin >> t;
        mp[t]++;
    }
    int mx = 0;
    for (auto i : mp) {
        mx = max(mx, i.second);
    }
    for (auto i : mp) {
        if (i.second == mx) {
            cout << i.first << "\n";
        }
    }
    return 0;
}

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

int main(){
    /*input*/
    int n,k;	cin >> n >> k;
    /*calculatoin*/
    int ans=1;
    rep(i, n){
	ans = min(2*ans, ans+k);
    }
    /*output*/
    cout << ans << endl;
}



Measured memory_bytes: 256
n,a,b,c,d = map(int,input().split())
for p in range(n-1):
    q = n - 1 - p
    b_min = p * c - q * d
    b_max = p * d - q * c
    if b_min <= b - a <= b_max:
        print('YES')
        exit()
print('NO')


Measured memory_bytes: 2940
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
     int r=n%1000;
      if(r==0)
      {
        System.out.println(r);
      }
      else
      {
         System.out.println(1000-r);
      }
  }
}

Measured memory_bytes: 35656
def main():
    import heapq
    n = int(input())
    a = list(map(int, input().split()))
    for i in range(n-1):
        if a[i] >= a[i+1]:
            break
    else:
        print(1)
        return

    h = []
    heapq.heapify(h)
    kind = 1
    length = 0
    d = dict()
    for i in a:
        if length >= i:
            while h:
                hh = -heapq.heappop(h)
                if hh > i:
                    d.pop(hh)
                else:
                    heapq.heappush(h, -hh)
                    break
            for j in range(i, 0, -1):
                if j not in d:
                    d[j] = 2
                    heapq.heappush(h, -j)
                    kind = max(kind, 2)
                    while h:
                        hh = -heapq.heappop(h)
                        if hh > j:
                            d.pop(hh)
                        else:
                            heapq.heappush(h, -hh)
                            break
                    break
                else:
                    if d[j] < kind:
                        d[j] += 1
                        while h:
                            hh = -heapq.heappop(h)
                            if hh > j:
                                d.pop(hh)
                            else:
                                heapq.heappush(h, -hh)
                                break
                        break
            else:
                d[i] += 1
                kind += 1
        length = i

    def value(kind):
        length = 0
        d = dict()
        for i in a:
            if length >= i:
                del_list = []
                for j in d:
                    if j > i:
                        del_list.append(j)
                for j in del_list:
                    d.pop(j)
                for j in range(i, 0, -1):
                    if j not in d:
                        d[j] = 2
                        break
                    else:
                        if d[j] < kind:
                            d[j] += 1
                            break
                        else:
                            d.pop(j)
                else:
                    return False
            length = i
        return True

    def b_search(ok, ng, value):
        while abs(ok-ng) > 1:
            mid = (ok+ng)//2
            if value(mid):
                ok = mid
            else:
                ng = mid
        return ok

    print(b_search(kind, max(1, kind-30), value))


main()


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

int main() {
    long long l, r;
    cin >> l >> r;

    int mod = 2019;

    if (r - l > mod) {
        cout << 0 << endl;
        return 0;
    }

    long long ans = mod;
    for (int i = l; i < r; i++) {
        for (int j = i+1; j <= r; j++) {
            ans = min(ans, 1LL * i * j % mod);
        }
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
import scala.io.StdIn

object Main {
  def main(args:Array[String]):Unit = {
    val in = StdIn.readLine().split(" ").map(s => s.toInt)

    if (in(0) < in(1) && in(1) < in(2)) {
      println("Yes")
    } else {
      println("No")
    }
  }
}

Measured memory_bytes: 43820
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;


int main()
{
	int n; cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) cin >> p[i];
	int cnt = 0;

	for (int i = 0; i < n; i++)
	{
		if (i + 1 != p[i]) cnt++;
	}

	if (cnt >= 3) cout << "NO";
	else cout << "YES";
}

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

int dp[100001];
int solve(int height[],int i,int n)
{
    if(dp[i]!=-1)
    {
        return dp[i];
    }
    if(i==n-1)
    {
        return dp[i]= 0; 
    }
    
    if(i+2>n-1)
    {
         return dp[i]= abs(height[i+1]-height[i])+solve(height,i+1,n);
    }
    
    return dp[i]= min((abs(height[i+1]-height[i])+solve(height,i+1,n)),(abs(height[i]-height[i+2])+solve(height,i+2,n)));
}
int main() {
    
    // For fast i/o
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    
    int tc,n,i,k,q,m;
    
cin>>n;

int height[n];
memset(dp,-1,sizeof(dp));

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


cout<<solve(height,0,n)<<endl;
	
	
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)
// 最大公約数(ユークリッドの互除法)
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
const int MAX_N = 200000;
int main() {
	int N, X; cin >> N >> X;
	int x[MAX_N];
	rep(i, N) cin >> x[i];
	int ans = max(X-x[0], x[0]-X);
	rep(i, N) {
		int tmp = max(X-x[i], x[i]-X);
		ans = gcd(ans, tmp);
	}
	cout << ans << endl;
}

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

int main()
{
    vector<int> moun(10);
    vector<int>::iterator it=moun.begin();
    while(it!=moun.end())
    {
        cin>>*it;
        it++;
    }
    it=moun.begin();
    sort(moun.begin(),moun.end(),greater<int>());
    while(it!=moun.begin()+3)
    {
        cout<<*it<<endl;
        it++;
    }
}

Measured memory_bytes: 1212
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	vector<string> v = {"ABC", "ARC"};
	string s; cin >> s;

	cout << ((s == v[0]) ? v[1] : v[0]);

	return 0;
}

Measured memory_bytes: 3564
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> L = new ArrayList<Integer>();
		
		for(int i=0;i<N;i++) {
			L.add(sc.nextInt());
		}
		
		Collections.sort(L);
		//小さい順に並んでいる。
		
		
		//三角形ができない組み合わせを数える。
		long count=0;
		long count_memo=0;
		
		int sh =0;
		int mi =0;
		int sum=0;
		for(int i=0;i<N-2;i++) {
			sh=L.get(i);
			for(int j=i+1;j<N-1;j++) {
				mi=L.get(j);
				sum = sh + mi;
				int k=L.size();
				count_memo=count;
				while(sum<=L.get(k-1)) {
					count++;
					k--;
				}
				if(count_memo==count) {
					break;
				}
			}
		}
		
		//組み合わせの総数　
		long total = ((long)(N*(N-1)))*(N-2)/(3*2); 
		
		long ans = total-count;
		
		System.out.println(ans);
	}
}


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

int main() {
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++) cin >> x.at(i);

	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += x.at(i);
	}
	int min_cand1 = sum/n, min_cand2 = sum/n + 1;
	int power1 = 0, power2 = 0;
	for (int i = 0; i < n; i++) {
		power1 += (min_cand1 - x.at(i))*(min_cand1 - x.at(i));
		power2 += (min_cand2 - x.at(i))*(min_cand2 - x.at(i));
	}
	cout << min(power1, power2) << endl;
}


Measured memory_bytes: 256
def rootT(x, cnt):
  cnt += 1
  if x == T[x]:
    return x, cnt
  x = T[x]
  return rootT(x, cnt)

N, M = list(map(int, input().split()))
ab = []
for i in range(M):
  ab.append(list(map(int, input().split())))

Ans = 0
# それぞれの辺を除いたときに
for i in range(M):
  L = ab[:i] + ab[i + 1:]
  
  # 連結かどうか調べる
  T = [i for i in range(N + 1)]
  for j in L:
    # 根っこを取得
    a = rootT(j[0], 0)
    b = rootT(j[1], 0)
    # 異なっていたら
    if a[0] != b[0]:
      # 短いほうをくっつける
      if a[1] > b[1]:
        T[b[0]] = a[0]
      else:
        T[a[0]] = b[0]

  flag = False
  t = rootT(T[1], 0)[0]
  for j in range(2, N + 1):
    if rootT(T[j], 0)[0] != t:
      flag = True
      break
  if flag:
    Ans += 1

print(Ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x


using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
const long long MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

int main() {
    int n;cin>>n;
    vector<ll> a(n+1);
    for(auto i = 1; i<=n;i++){
        cin>>a[i];
    }
    sort(all(a));
    
    /// ある重さ以上なら問題ない。二分探索で求める。
    
    int l = 1;
    int r = n;
    int m = (l+r)/2;
    
    while(l<r){
        m = (l+r)/2;
        ll w = a[m];
        bool flag = false;
        
        for(auto i = m-1;i>=1;i--){
            w+=a[i];
        }
        
        for(auto i = m+1; i<=n;i++){
            
            if(a[i]> 2*w) {flag = true;}
            else{
                w+=a[i];
            }
            
        }
        
        
        if(flag){
            l=m+1;
        }else{
            r=m;
        }
        
    }
    
    cout<<n-r + 1<<endl;
    
    return 0;
}




Measured memory_bytes: 1024
N,X,M = map(int,input().split())
#全体ループを見る配列
t_loop = [X]
#初回ループを見る配列
f_loop = [X]
#出現回数を見る辞書
memo = {X:1}
#2回目以降のループを見る配列
s_loop = []
while True:
    new_val = t_loop[-1]**2%M
    t_loop.append(new_val)
    if new_val not in memo:
        memo[new_val] = 1
        f_loop.append(new_val)
    else:
        memo[new_val] += 1
        if memo[new_val] == 3:
            break
        else:
            s_loop.append(new_val)

ans = 0
if N <= len(f_loop):
    ans += sum(f_loop[:N])
else:
    ans += sum(f_loop)
    shou = (N-len(f_loop))//len(s_loop)
    amari = (N-len(f_loop))%len(s_loop)
    ans += shou*sum(s_loop)
    ans += sum(s_loop[:amari])
    
print(ans)

Measured memory_bytes: 86068
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

int main() {
    int N,M;

    cin >> N >> M;

    vector<pair<pair<string,long long>, int>> V;

    for(int i = 0; i < M; i++){
        string p;
        long long y;

        cin >> p >> y;

        while(p.size() != 6){
            p = '0' + p;
        }

        V.push_back(make_pair(make_pair(p,y), i));
    }

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

    int n = 1;
    string I = V[0].first.first;
    vector<pair<int, string>> ID;

    for(int i = 0; i < M; i++){
        string id;

        if(V[i].first.first != I){
            n = 1;
            I = V[i].first.first;
        }

        string D = to_string(n);

        while(D.size() != 6){
            D = '0' + D;
        }

        id = I + D;

        ID.push_back(make_pair(V[i].second, id));
        n++;
    }

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

    for(int i = 0; i < M; i++){
        cout << ID[i].second << endl;
    }

    return 0;
}


Measured memory_bytes: 16944
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node {
  struct node *l;
  struct node *r;
  struct node *p;
  int key;
};

typedef struct node * Node;
Node root;

void insert(int k) {
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
  while(x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->l;
    }
    else {
      x = x->r;
    }
  }
  z->p = y;
  if(y == NIL) {
    root = z;
  }
  else {
    if(z-> key < y->key) {
      y->l = z;
    }
    else {
      y->r = z;
    }
  }
}

void in(Node u) {
  if(u->l != NIL) {
	  in(u->l);
	}
	printf(" %d", u->key);
	if(u->r != NIL) {
	  in(u->r);
	}
}

void pre(Node u) {
  printf(" %d",u->key);
	if(u != NIL) {
	  if(u->l != NIL) pre(u->l);
		if(u->r != NIL) pre(u->r);
	}
}

int main() {
  
  int n, i, x;
  char s[20];
  scanf("%d",&n);
  for(i = 0; i < n; i++) {
    scanf("%s",s);
    
    if(s[0] =='i') {
      scanf("%d",&x);
      insert(x);
      
    } else if(s[0] == 'p') {
      in(root);
      printf("\n");
      pre(root);
      printf("\n");
    }
  }
  
  return 0;
}

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

int main() {
  long int x,a;
  cin>>x;
  a=x%11;
  x=x-a;
  x=(x/11)*2;
  if(a==0) x=x;
  else if(a<=6) x+=1;
  else x+=2;
  cout<<x<<endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"log"
)

func main() {
	var a, b int
	if _, err := fmt.Scan(&a, &b); err != nil {
		log.Fatal(err)
	}
	if a%2 == 1 && b%2 == 1 {
		fmt.Println("Odd")
	} else {
		fmt.Println("Even")
	}
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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


int main(void){

	int a; cin >> a;
	string s; cin >> s;
	if(a >= 3200) cout << s << endl;
	else cout << "red" << endl;


	return 0;

}


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

#define LL long long


int main()
{
    int N, a[111111], ans = 0;
    memset(a, 0, sizeof(a));
    cin >> N;
    for (int x = 1; x * x <= N; x ++){
        int x2 = x * x;
        for (int y = 1; x2 + y * y <= N; y ++){
            int y2 = y * y;
            for (int z = 1; x2 + y2 + z * z <= N; z ++){
                int z2 = z * z;
                int sum = x2 + y2 + z2 + x * y + x * z + y * z;
                if (sum <= N){
                    a[sum] ++;
                }
            }
        }
    }
    for (int i = 1; i <= N; i ++){
        cout << a[i] << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 4128
#include <iostream>
#include <sstream>
#include <string>

using namespace std;

int main(){

   string s;
   int alph[26] = {0};
   int f_en = 0;

   for(;getline(cin, s);){
      for(int i = 0; i < s.length(); i++){
         if('A' <= s[i] && s[i] <= 'Z'){
            alph[s[i] - 'A']++;
         }
         else if('a' <= s[i] && s[i] <= 'z'){
            alph[s[i] - 'a']++;
         }
      }

      if(f_en){
         break;
      }
   }

   for(int i = 0; i < 26; i++){
      cout << (char)('a' + i) << " : " << alph[i] << endl;
   }

   return 0;
}


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

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

  int b, f, r, v;
  // b:棟(0~3の4つ)
  // f:階(3階まで)
  // r:番目(10部屋まで)
  // v:入居した人数

  int room[4][3][10] = {
    {
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    },
    {
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    },
    {
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    },
    {
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    }
  };

  //入力
  for(int i=0;i<n;i++){
    cin >> b >> f >> r >>v;

    room[b-1][f-1][r-1] += v;
  }

  //出力
  for(int j=0;j<4;j++){
    for(int k=0;k<3;k++){
      for(int l=0;l<10;l++){
        cout << " " << room[j][k][l];
      }
      cout << endl;
    }
    if(j!=3){
      cout << "####################" << endl;
    }
  }
}



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

using namespace std;
typedef long long ll;
int main(){
	int N;
	cin >> N;
	vector<ll> A(N, 0);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}


	ll h = 0;
	ll sum = 0;
	for (int i = 0; i < N; i++)
	{
		if (h > A[i]) {
			sum += h - A[i];
		} else {
			h = A[i];
		}
	}
	

	cout << sum << endl;



	
}



Measured memory_bytes: 4832
K = int(input())
def gcd(x, y):
  a, b = x, y
  while b != 0:
    a, b = b, a % b
  return a
gcds = [[0 for j in range(K)] for i in range(K)]
for i in range(K):
  for j in range(K):
    gcds[i][j] = gcd(i+1, j+1)
S = 0
for i in range(K):
  for j in range(K):
    for k in range(K):
      S += gcds[gcds[j][k]-1][i]
print(S)

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

using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define UNIQUE(o) (o).erase(unique(sort(all((o)))))

typedef long long ll;
const int M = 200;
int p[M];

int main() {
  int m, l, u;
  while(1) {
    scanf("%d%d%d ", &m, &l, &u);
    if (!m) break;
    REP(i,m) scanf("%d ", p+i);
    int res = 0, g = 0;
    FOR(n, l, u+1) {
      if (p[n-1] - p[n] >= g) {
        g = p[n-1] - p[n];
        res = n;
      }
    }
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 3152
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int BIG = 1e+18+3;
int mod = 1e+9+7;

signed main()
{
    IOS;
    
    int n; cin>>n;

    int h[n+1];

    repa(i,1,n) cin>>h[i];

    int cost[n+1] = {0};

    cost[1] = 0;
    cost[2] = abs(h[2]-h[1]);

    repa(i,3,n)
        cost[i] = min( abs(h[i]-h[i-1])+cost[i-1], abs(h[i]-h[i-2]) + cost[i-2] );   

    cout<< cost[n] <<endl;
}

Measured memory_bytes: 1792