akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t = 1;
    int n;
    while(cin >>n, n!=0)
    {
        if(t == 0)
        {
            cout << endl;
        }
        else
        {
        }
        
        t = 0;
        
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int e, f, g, h;
        
        int k = (n/10) % 5;
        if(k > a)
        {
            n = n + (5-k)*10;
        }
        else
        {
            e = ((a-k)/5)*5+k;
            if(e == 0)
            {
            }
            else
            {
                cout << "10 " << e << endl;
            }
            
            n = n - 10*e;
        }
        
        int l = (n/50+2000000) % 2;
        if(l > b)
        {
            n = n + (2-l)*50;
        }
        else
        {
            f = ((b-l)/2)*2+l;
            if(f == 0)
            {
            }
            else
            {
                cout << "50 " << f << endl;
            }
            
            n = n - 50*f;
        }
        
        int m = (n/100+2000000) % 5;
        if(m > c)
        {
            n = n + (5-m)*100;
        }
        else
        {
            g = ((c-m)/5)*5+m;
            if(g == 0)
            {
            }
            else
            {
                cout << "100 " << g << endl;
            }
            
            n = n - 100*g;
        }
        
        if((n+2000000) % 500 != 0)
        {
            h = (n/500)+1;
            cout << "500 " << h << endl;
        }
        else if(n <= 0)
        {
        }
        else
        {
            h = n/500;
            cout << "500 " << h << endl;
        }
    
        
        
        
    }




}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1010;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
ll gcd(ll x, ll y)
{
  if(y == 0) return x;
  return gcd(y, x%y);
}
int main()
{
	int n;
	cin>>n;
	vector<ll> v(n);
	rep(i, 0, n)cin>>v[i];
	rep(i, 0, n-1) v[i+1] = gcd(v[i], v[i+1]);
	cout<<v[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  unsigned long long A;
  string B;
  cin >> A >> B;
  int b = (B[0] - '0') * 100 + (B[2] - '0') * 10 + (B[3] - '0') * 1;
  //cout << b << endl;
  ll ans = A * b;
  cout << (ans / 100) << endl;

  return 0;
}


Measured memory_bytes: 3620
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, P, *ABC = map(int, read().split())
    edge = [0] * M
    for i, (a, b, c) in enumerate(zip(*[iter(ABC)] * 3)):
        edge[i] = (a - 1, b - 1, -(c - P))

    dist = [INF] * N
    dist[0] = 0

    for _ in range(N - 1):
        for a, b, c in edge:
            if dist[a] != INF and dist[b] > dist[a] + c:
                dist[b] = dist[a] + c

    updated = [False] * N
    for _ in range(N):
        for a, b, c in edge:
            if dist[b] != INF and dist[b] > dist[a] + c:
                updated[b] = True
            if updated[a]:
                updated[b] = True

    if updated[N - 1]:
        print(-1)
    else:
        print(max(0, -dist[N - 1]))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 74456
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> vv;

int abs(int a){
  if(a>0) return a;
  return -a;
}

int main(){
  ll n,m;
  cin >> n >> m;
  if (n > m) swap(n,m);
  if(n == 1){
    if(m == 1) cout << 1 << endl;
    if(m == 2) cout << 0 << endl;
    if(m > 2) cout << m-2 << endl;
  }
  if(n == 2){
    if(m == 2) cout << 0 << endl;
    if(m > 2) cout << 0 << endl;
  }
  if(n > 2) cout << (n-2)*(m-2) << endl;
}

Measured memory_bytes: 256
def main():
  element_num = int(input())
  elements = [int(s) for s in input().split()]
  swap_count = 0

  for i in range(0, element_num - 1):
    min_val = elements[i + 1]
    min_index = i + 1
    for j in range(i + 1, element_num):
      if elements[j] < min_val:
        min_val = elements[j]
        min_index = j
    if elements[i] > elements[min_index]:
      elements[i], elements[min_index] = elements[min_index], elements[i]
      swap_count += 1

  print(' '.join(list(map(str, elements))))
  print(swap_count)

  return 0


if __name__ == '__main__':
  main()

Measured memory_bytes: 7740
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ABC089C - March
  // N人の名前がそれぞれSで与えられる。以下の条件に当てはまる3人を選ぶ
  // 名前がMARCHのいずれかで始まる
  // 同じ文字から始まる人がいない
  // 選び方は何通りあるか。Sは全て英大文字
  // 5個の配列で管理
  // M:12, A:0, R:17, C:2, H:7
  // MARCHの選び方は5C3＝10通り。全て列挙して全部足す(良い方法が思い付かない)
  int N; cin >> N;
  vector<string> S(N);
  REP(i, N) cin >> S[i];
  vector<ll> cnt(5, 0);
  REP(i, N){
    if(S[i][0] - 'A' == 12) cnt[0]++; //M
    if(S[i][0] - 'A' == 0) cnt[1]++;  //A
    if(S[i][0] - 'A' == 17) cnt[2]++; //R
    if(S[i][0] - 'A' == 2) cnt[3]++;  //C
    if(S[i][0] - 'A' == 7) cnt[4]++;  //H
  }
  ll ans = 0;
  ans += cnt[0] * cnt[1] * cnt[2];
  ans += cnt[0] * cnt[1] * cnt[3];
  ans += cnt[0] * cnt[1] * cnt[4];
  ans += cnt[0] * cnt[2] * cnt[3];
  ans += cnt[0] * cnt[2] * cnt[4];
  ans += cnt[0] * cnt[3] * cnt[4];
  ans += cnt[1] * cnt[2] * cnt[3];
  ans += cnt[1] * cnt[2] * cnt[4];
  ans += cnt[1] * cnt[3] * cnt[4];
  ans += cnt[2] * cnt[3] * cnt[4];
  cout << ans << endl;
}

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

const int INF = 1e9;

int main() {
  string s;
  cin>>s;
  int n = s.length();
  int ans = 753;
  for (int i=0; i<n-2; i++) {
    int v = 100*(s[i]-'0') + 10*(s[i+1]-'0') + s[i+2] - '0';
    ans = min(abs(v - 753), ans);
  }
  cout<<ans<<endl;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int B[2000011] = {};
unordered_set<int> S;
map<int,int> T;

int main(){

    rep(i,2000011 ) {
        S.insert(i+1);
    }

    int N;
    cin >> N;
    vector<int> A;
    
    rep(i,N) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());

    rep(i,N) {
        if (B[A[i]]==1) {
            B[A[i]]++;
        }
        if (S.count(A[i])) {
            B[A[i]] = 1;
            int tmp = A[i];
            for (int j = 1; j<INF; j++) {
                if (j*tmp>2000000) {
                    break;
                }
                else if (S.count(tmp*j)){
                    S.erase(tmp*j);
                    if (j>1) B[tmp*j] = 2;
                }
            }
        }
    }
    int ans = 0;
    rep(i,2000000) {
        if (B[i+1]==1) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 92128
# include <stdio.h>
# include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 1e5+3;

int a[maxn], d[maxn], c[maxn], b[maxn], tmp[maxn];
LL n, m, k, t;

void qmod()
{
    while(k)
    {
        if(k&1)
        {
            for(int i=1; i<=n; ++i) tmp[i] = b[c[i]];
            for(int i=1; i<=n; ++i) b[i] = tmp[i];
        }
        k >>= 1;
        for(int i=1; i<=n; ++i) tmp[i] = c[c[i]];
        for(int i=1; i<=n; ++i) c[i] = tmp[i];
    }
}

int main()
{
    scanf("%lld",&n);
    for(int i=1; i<=n; ++i)
    {
        scanf("%d",&a[i]);
        d[i] = a[i]-a[i-1];
        tmp[i] = b[i] = c[i] = i;
    }
    scanf("%lld%lld",&m,&k);
    for(int i=1; i<=m; ++i)
    {
        scanf("%d",&t);
        swap(c[t], c[t+1]);
    }
    qmod();
    LL ans = 0;
    for(int i=1; i<=n; ++i)
    {
        ans += (LL)d[b[i]];
        printf("%lld.0\n",ans);
    }
    return 0;
}


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

int main()
{
	int A,B,C,X,Y;
	ll ans=0;
	cin >> A >> B >> C >> X >> Y;
	if (A+B>2*C)
	{
		ans+=2*C*min(X,Y);
		if (X>Y)
		{
			if (A>C*2) ans+=C*2*(X-min(X,Y));
			else ans+=A*(X-min(X,Y));
		}
		else
		{
			if (B>C*2) ans+=C*2*(Y-min(X,Y));
			else ans+=B*(Y-min(X,Y));
		}
	}
	else
	{
		ans=A*X+B*Y;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
ls = []
now = 0
simekiri = 0
flag = 0
for i in range(N):
    a,b = map(int,input().split())
    ls.append([b,a])
ls.sort()
for i in range(len(ls)):
    simekiri = ls[i][0]
    now += ls[i][1]
    if now > simekiri:
        print("No")
        flag += 1
        break
if flag == 0:
    print("Yes")


Measured memory_bytes: 35624
using System;
using System.Linq;
using System.Collections.Generic;

public class Prime{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
         
        var primeFactors = PrimeFactors(n);
        //primeFactors.Dump();
         
        string output = primeFactors.Count() == 0 
                        ? n.ToString() 
                        : string.Join(" ", primeFactors.Select (f => f.ToString()).ToArray()); //AOJ??¨
                        //:string.Join(" ", primeFactors);
        Console.WriteLine("{0}: {1}", n, output);
    }
     
    public static IEnumerable<int> PrimeFactors(int n)
    {
        int i = 2;
        int tmp = n;
         
        while (i <= n)
        {
            if(n % i == 0){
                n /= i;
                yield return i;
            }else{
                i++;
            }
             
            if(i > Math.Sqrt(tmp)){
                i = int.MaxValue; //???????????????
                yield return n;
            }
        }
    }
}

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

int main(){
  int N,M;
  cin >>N>>M;
  int X[M];
  for(int i=0;i<M;i++){
    cin>>X[i];
  }
  sort(X,X+M);
  int D[M-1];
  for(int i=0;i<M-1;i++){
    D[i]=X[i+1]-X[i];
  }
  sort(D,D+M-1);
  int ans=0;
  for(int i=0;i<M-N;i++){
    ans+=D[i];
  }
  cout<<ans<<endl;
    
  return 0;
}


Measured memory_bytes: 4316
#include <iostream>
	#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
	#define rep(x,to) rep2(x,0,to)
	using namespace std;
	int main(){
		int x, y;
		while(cin >> x >> y && (x||y) ) {
			int b[15][15] = {};
			rep(i,y) {
				rep(j,x) {
					cin >> b[i][j];
				}
			}
			int ret[20][20] = {};
			rep(i,x) {
				if(b[0][i] == 0) {
					ret[0][i+1] = 1;
				}
			}
			rep2(i,1,y) {
				rep(j,x) {
					if(b[i][j] == 0) {
						ret[i][j+1] += ret[i-1][j] + ret[i-1][j+1] + ret[i-1][j+2];
						rep2(k,-1,2) {
							if(b[i-1][j+k] == 2) ret[i][j+1] -= ret[i-1][j+k+1];
						}
					} else if(b[i][j] == 2) {	
						if(b[i-1][j] == 0) ret[i][j+1] += ret[i-1][j+1];
						if(y <= i+2 || b[i+2][j] != 1) ret[i+2][j+1] += ret[i][j+1];
					}
				}
			}
			int ans = 0;
			rep2(i,y-1,y+2) {
				rep(j,x) {
					if(y <= i || b[i][j] != 2) ans += ret[i][j+1];
				}
			}
			cout << ans << endl;
		}
	}

Measured memory_bytes: 1164
# Surrounded Nodes
import sys
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
N = int(input())
G = [[] for i in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
S = -1
for i in range(1, N+1):
    if len(G[i]) == 1:
        S = i
        break
visited = [False for i in range(N+1)]
parent = [-1 for i in range(N+1)]
count = [1 for i in range(N+1)]

ans = N*pow(2, N-1, mod)


def dfs(node):
    visited[node] = True
    for child in G[node]:
        if visited[child] == False:
            parent[child] = node
            dfs(child)
    for child in G[node]:
        if child != parent[node]:
            count[node] += count[child]


powers = [1 for i in range(2*10**5+1)]
for i in range(1, 2*10**5+1):
    powers[i] = powers[i-1]*2 % mod

dfs(S)

ans = 0
for i in range(1, N+1):
    if len(G[i]) > 1:
        ans += powers[N-1]
        for x in G[i]:
            if x != parent[i]:
                ans -= powers[count[x]]
        ans -= powers[N-count[i]]
        ans += len(G[i]) - 1
        ans %= mod
D = pow(2, N, mod)
print(ans*pow(D, mod-2, mod) % mod)

Measured memory_bytes: 213384
#include <bits/stdc++.h>
#define int int64_t
#define F first
#define S second
#define pb push_back
#define fo(i, n) for(int i = 0; i < n;  i ++)
using namespace std;

int32_t main(){
  int n; cin >> n;
  for(int i = sqrt(n); i >= 1; i --){
    if(n % i == 0){
      cout << i + n / i - 2;
      return 0;
    }
  }
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main()
{
    string s;
    cin >> s;
    string line = "";
    string part;
    string sfind;
    int max = 0;
    int ans = 0;
    s = s.substr(0, s.length()-1);
    for(lli i=0; i<s.length()-1; i++){
        part += s[i];
        sfind = s.substr(part.length(), part.length());
        if(part!=sfind) continue; 
        if(max<part.length())  
            max = part.length();
        sfind = "";
    }
    cout << max*2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
     
     
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;

ll arr[100100];
     
int main(){
  ll N;

  cin >> N;

#ifdef DEBUG
  cout << "N=" << N << endl;
#endif

  for(ll i = 0; i < N; ++i){
    cin >> arr[i];
  }

  ll x1 = 0;
  for(ll i = 0; i < N; ++i){
    if( i % 2 == 0) {
      x1 += arr[i]*2;
    } else {
      x1 -= arr[i]*2;
    }
  }

  x1 /= 2;
  
  cout << x1 << " ";
  ll tmp = x1;
  for(ll i = 0; i < N-1; ++i){
    tmp = arr[i]*2 - tmp;
    if(i < N-2){
      cout << tmp << " ";
    } else {
      cout << tmp << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 2048
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: ident) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let (n, r): (usize, usize) = parse!(it, 2);
    if n > 10 {
        println!("{}", r);
    } else {
        println!("{}", r + (10 - n) * 100);
    }
}


Measured memory_bytes: 4352
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public int x { get; set; }
    public int y { get; set; }
    public int h { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var ps = new List<P>();
        var ps0 = new List<P>();
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var x = int.Parse(line[0]);
            var y = int.Parse(line[1]);
            var h = int.Parse(line[2]);
            if (h > 0) ps.Add(new P { x = x, y = y, h = h });
            else ps0.Add(new P { x = x, y = y, h = h });
        }
        for (int i = 0; i <= 100; i++)
            for (int j = 0; j <= 100; j++)
            {
                var t = ps[0].h + Math.Abs(ps[0].x - i) + Math.Abs(ps[0].y - j);
                var ok = true;
                for (int k = 1; k < ps.Count(); k++)
                {
                    var t2 = ps[k].h + Math.Abs(ps[k].x - i) + Math.Abs(ps[k].y - j);
                    if (t != t2) { ok = false; goto next; }
                }
                if (ok)
                {
                    var ok2 = true;
                    foreach (var x in ps0)
                        if (t > Math.Abs(x.x - i) + Math.Abs(x.y - j) ){ ok2 = false; break; }
                    if (ok2) { Console.WriteLine("{0} {1} {2}", i,j,t); goto end; }
                }
                next:;
            }
        end:;
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;
#define MOD 1000000007LL

ll N, X;
vll length(51);
vll pnum(51);

ll func(ll lv, ll x){
  if(x == length.at(lv)) return pnum.at(lv);
  ll xx;
  if(x <= length.at(lv)/2){
    xx = x;
    if(xx == 1) return 0;
    return func(lv-1, xx-1);
  }
  else{
    xx = length.at(lv) - x;
    if(xx == 1) return pnum.at(lv);
    return pnum.at(lv) - func(lv-1, xx-1);
  }
}

int main(){
  cin >> N >> X;
  length.at(0) = 1LL;
  pnum.at(0) = 1LL;
  for(int i = 1; i <= N; i++){
    length.at(i) = 2LL * length.at(i-1) + 3LL;
    pnum.at(i) = 2LL * pnum.at(i-1) + 1LL;
  }
  cout << func(N, X) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        foreach(var s in Enumerable.Range(0, int.Parse(ReadLine().Split(' ')[1])).Select(i => ReadLine().Split(' ')).Select((x, i) => (i, p: int.Parse(x[0]), y: int.Parse(x[1]))).OrderBy(x => x.y).GroupBy(x => x.p).SelectMany(g => g.Select((x, j) => (x.i, s: x.p.ToString("D6") + (j + 1).ToString("D6")))).OrderBy(x => x.i).Select(x => x.s))
            WriteLine(s);
    }
}


Measured memory_bytes: 64324
from collections import deque

def bfs(graph, N, start):
    visited = [0] * N
    visited[start] = 1
    que = deque([start])
    while que:
        node = que.popleft()
        for n in graph[node]:
            if not visited[n]:
                visited[n] = node + 1
                que.append(n)
    return visited


## ----main
N, M = list(map(int,input().split()))
graph = [[] for _ in range(N)]

for _ in range(M):
    a,b = list(map(int,input().split()))
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

visited = bfs(graph,N,0)

if all(visited[1:]):
    print("Yes")
    print(*visited[1:], sep="\n")
else:
    print("No")

Measured memory_bytes: 39024
#include <stdio.h>

int main() {
    
    int A, B, N;
    char s[100001];
    int a,b,i;
    
    scanf("%d %d %d\n", &N, &A, &B);
    scanf("%s\n", s);
    
    a = 0;
    b = 0;
    
    for (i = 0; i < N; i++) {
        if (s[i] == 'a') {
            if (a + b < A + B) {
                printf("Yes\n");
                a++;
            } else {
                printf("No\n");
            }
            
        } else if (s[i] == 'b') {
            if (a + b < A + B && b < B) {
                printf("Yes\n");
                b++;
            } else {
                printf("No\n");
            }
            
        } else {
            printf("No\n");
        }
    }
    
    return 0;
    
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
  int N,M;
  int A;
  scanf("%d %d",&N,&M);
  for(int i=1;i<=M;i++){
    scanf("%d",&A);
    N-=A;
    if(N<0){
      N=-1;
      break;
    }
  }
  printf("%d\n",N);
  return 0;
}


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


int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    int n;
    while (scanf("%d", &n) == 1) {
        int a, b, c, d;
        scanf("%d%d%d%d", &a, &b, &c, &d);

        n--;
        bool ok = 0;
        for (int cntNeg = 0; cntNeg <= n; cntNeg++) {
            ll mn = a - 1LL * cntNeg * d + 1LL * (n - cntNeg) * c;
            ll mx = a - 1LL * cntNeg * c + 1LL * (n - cntNeg) * d;
            if (mn <= b && b <= mx) ok = 1;
        }
        string ans = ok ? "YES" : "NO";
        printf("%s\n", ans.c_str());
    }

#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, l;
    cin >> n >> l;
    string str[110] = {};
    for (int i = 0; i < n; i++)
    {
        cin >> str[i];
    }
    sort(str, str + n);
    for (int i = 1; i < n; i++)
    {
        str[0] += str[i];
    }
    cout << str[0] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int a,b;
    cin >> a >> b;
    cout << MAX(a+b,a-b,a*b) << endl;
}

Measured memory_bytes: 256
n = gets.to_i

counts = Array.new(n + 1)
counts[0] = 0
counts[1] = 1
available = [1]
max_six = 1
max_nine = 1
(1..n).each do |num|
  new_six = max_six * 6
  if new_six <= num
    available << new_six
    max_six = new_six
  end

  new_nine = max_nine * 9
  if new_nine <= num
    available << new_nine
    max_nine = new_nine
  end

  counts[num] = available.map { |a| counts[num - a] }.min + 1
end

puts counts[n]

Measured memory_bytes: 2812
#include <iostream>
    #include <algorithm>
     
    using namespace std;
     
    int main() {
    	int mx = 0, u;
      int n; cin >> n;
      while(n--){
        cin >> u;
        mx = __gcd(mx, u);
      }
      
      cout << mx;
      return 0;
    }

Measured memory_bytes: 256
n = int(input())
d = sorted(list(map(int,input().split())))
m = int(input())
t = sorted(list(map(int,input().split())))
didx = 0
tidx = 0
while tidx < m and didx < n:
    if d[didx] == t[tidx]:
        didx += 1; tidx += 1
    elif d[didx] < t[tidx]:
        didx += 1
    else:
        print("NO")
        break
else:
    if tidx == m:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 35164
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <functional>
#include <cstring>
#include <set>
using namespace std;

typedef long long ll;
#define MAX 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)

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

	rep(i, s.size()) {
		if (s[i] == 'a')continue;
		if ('z' - s[i] < K) {
			K -= ('z' - s[i] + 1);
			s[i] = 'a';
		}
	}
	for (int i = 0; i < K;) {
		if (s[s.size() - 1] == 'z') {
			s[s.size() - 1] = 'a';
			K--;
			break;
		}
		else s[s.size() - 1]++;
		K--;
	}
	if (K > 0)s[s.size() - 1] += (K % 26);

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		int max, midle, min;
		
		while(a < 1 || a > 10000 || b < 1 || b > 10000 || c < 1 || c > 10000) {
			a = stdIn.nextInt();
			b = stdIn.nextInt();
			c = stdIn.nextInt();
			
		}
		
		if(a < b && a < c) {
			min = a;
			if(b < c) {
				midle = b;
				max = c;
			}else {
				midle = c;
				max = b;
			}
		}else if(b < c) {
			min = b;
			if( a < c) {
				midle = a;
				max = c;
			}else {
				midle = c;
				max = a;
			}
		}else {
			min = c;
			if( a < b) {
				midle = a;
				max = b;
			}else {
				midle = b;
				max = a;
			}
		}
		
		System.out.println(min + " " + midle + " " + max);
		
	}
}


Measured memory_bytes: 26152
/*
 * 黒板に N 個の正の整数 A1,…,AN が書かれています．
 * 
 * すぬけ君は，黒板に書かれている整数がすべて偶数であるとき，次の操作を行うことができます．
 * 
 *     黒板に書かれている整数すべてを，2 で割ったものに置き換える．
 * 
 * すぬけ君は最大で何回操作を行うことができるかを求めてください．
 */

import java.util.Scanner;
    public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            int n = Integer.parseInt(sc.next());
            int min = 0;
            int temp = 0;
            
            int x = Integer.parseInt(sc.next());
        	
        	while(x%2==0){
        		temp++;
        		x = x/2;
        	}
        	min = temp;
            
            for(int i=1; i<n; i++){
            	x = Integer.parseInt(sc.next());
            	temp = 0;
            	
            	while(x%2==0){
            		temp++;
            		x = x/2;
            	}
            	if(min>temp){
            		min = temp;
            	}
            }
            // 出力
            System.out.println(min);
            
            sc.close();
        }
    }
	

Measured memory_bytes: 23764
# -*- coding: utf-8 -*-

def countSort(A, m):
    count = [0]*(m+1)
    n = len(A)
    B = [0]*2000001
    j = 0
    for i in range(n):
        count[A[i]] += 1
    for i in range(1, m):
        count[i] += count[i-1]
    for i in range(n-1, -1, -1):
        j = count[A[i]]
        B[j] = A[i]
        count[A[i]] = j-1
    for i in range(n):
        A[i] = B[i+1]
    return A

n = int(raw_input())
A = map(int, raw_input().split())
B = countSort(A, 10000)
print " ".join(map(str, B))

Measured memory_bytes: 241100
import sys
input = sys.stdin.readline

N = int(input())
H = [int(item) for item in input().split()]

cand = []
cand += [H[0], H[0] - 1]
for i in range(1, N):
    new_cand = []
    for c in cand:
        if c <= H[i] - 1:
            new_cand += [H[i], H[i] - 1]
        elif c == H[i]:
            new_cand += [H[i]]
    cand = list(set(new_cand))
    if len(cand) == 0:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 14252
n,m = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]
red = [0] * (n+1)
red[1] = 1
ball = [1] * (n+1)
for x,y in xy:
    ball[x] -= 1
    ball[y] += 1
    if red[x] == 1:
        red[y] = 1
        if ball[x] == 0: red[x] = 0
print(sum(red))

Measured memory_bytes: 28756
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N, K = NMI()
    LR = list(sorted([NLI() for _ in range(K)]))
    
    dp = [0 for _ in range(N)]
    dp[0] = 1
    
    cumsum = [0 for _ in range(N+1)]
    cumsum[0] = 0
    cumsum[1] = 1
    
    for n in range(1,N):
        for k in range(K):
            r = n-LR[k][0]
            l = n-LR[k][1]
            if r < 0:
                continue
            else:
                l = max(0,l)
            dp[n] += cumsum[r+1]-cumsum[l]
        dp[n] = dp[n]%MOD2
        cumsum[n+1] = (dp[n] + cumsum[n])%MOD2
    print(dp[-1])
if __name__ == '__main__':
    main()

Measured memory_bytes: 100512
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Cake123 | diff Cake123.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Cake123.cpp && ./a.out

/*
 
 4/7/2019
 
 20:19-21:05 give up
 
 4/8/2019
 
 14:45- read editorials
 
 There are three solutions
  1. Make `K` largest from A and B as A'. make K largest from A' and C
  2. If f(A[i],B[j],C[k]) is taken, keep adding next candidate to priority queue
   - f(A[i+1],B[j],C[k]), f(A[i],B[j+1],C[k]) and f(A[i],B[j].C[k+1]) are next candidate
  3. Brute-force + edge pruning
 
 http://drken1215.hatenablog.com/entry/2019/04/07/001000
 
 */

const int MAX_N=1e3+1;
LL A[3][MAX_N];
int K,N[3];

void solve() {
  REP(c,3) sort(A[c],A[c]+N[c]),reverse(A[c],A[c]+N[c]);
  vector<LL> X;
  REP(i,N[0])REP(j,N[1]) {
    X.emplace_back(A[0][i]+A[1][j]);
  }
  sort(ALL(X)),reverse(ALL(X));
  vector<LL> Y;
  REP(i,min(N[0]*N[1],K))REP(j,N[2]) {
    Y.push_back(X[i]+A[2][j]);
  }
  sort(ALL(Y)),reverse(ALL(Y));
  REP(i,K) cout<<Y[i]<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  REP(i,3) cin>>N[i];
  cin>>K;
  REP(i,3)REP(j,N[i]) cin>>A[i][j];
  solve();
  
  return 0;
}


Measured memory_bytes: 43236
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
#include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;
	using BigNum = std::vector<double>;

	class InputData {
	public:
		void getInput(void);
		void skipInput(void);
		Str getStr(void);
		Num getNum(void);
		BigNum getBigNum(void);
	private:
		Str str;
		Num num;
		BigNum bNum;
	};
	Str AtCoder::InputData::getStr(void) {
		return this->str;
	}
	Num AtCoder::InputData::getNum(void) {
		return this->num;
	}
	BigNum AtCoder::InputData::getBigNum(void) {
		return this->bNum;
	}
	void AtCoder::InputData::skipInput(void) {
		std::string buf = "";
		std::getline(std::cin, buf);
	}
	void AtCoder::InputData::getInput(void) {
		this->str.clear();
		this->num.clear();
		this->bNum.clear();

		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				this->str.push_back(row);
				this->num.push_back(std::atoi(row.c_str()));
				this->bNum.push_back(std::atof(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		this->str.push_back(row);
		this->num.push_back(std::atoi(row.c_str()));
		this->bNum.push_back(std::atof(row.c_str()));
	}

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
	void rsort(std::vector<double>* vec) {
		std::sort(vec->begin(), vec->end(), std::greater<double>());
	}
}

int main(void) {
	AtCoder::InputData* data = new AtCoder::InputData();
	data->getInput();
	AtCoder::Num num = data->getNum();

	int k = num[1];

	data->getInput();
	AtCoder::BigNum bnum = data->getBigNum();

	AtCoder::rsort(&bnum);

	AtCoder::Ans* ans = new AtCoder::Ans();

	for (double val : bnum) {
		if (0 == k) {
			ans->increment(val);
		} else {
			k--;
			continue;
		}
	}

	ans->showResult();

	delete(ans);
	delete(data);

	return 0;
}


Measured memory_bytes: 13932
/*I wanna be the very best, like no one ever was...*/

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define ll long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int main() {
    io;
    // freopen("in","r",stdin); 
    // freopen("out","w",stdout);
  string s;
  cin>>s;
  map<char, int> mp;
  for(auto i : s){
      mp[i]++;

  }

  for(auto i : mp){
      if(i.second%2==1){
          cout<<"No"<<endl;
          return 0;
      }
  }

  cout<<"Yes";

 
 
 
    
 
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("03", "unroll-loops")
//#pragma GCC target("avx2")

#include <bits/stdc++.h>

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR(i,n) for(i=0;i<n;i++)
#define FORn(i,j,n) for(i=j;i<n;i++)
#define pb push_back
#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define vprint(v) for(auto t:v)cout<<t<<" "
#define endl "\n"

using namespace std;

typedef long long int lli;
typedef long int li;
typedef vector<lli> vli; 
typedef vector<int> vi; 
typedef vector<string> vs; 


const lli mod=1000000007;
const lli limit=1000000;


void fc(lli &x)
    {
        bool neg=false;
        register char c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

int main() {

    fast()
    lli n,q,t;
    lli temp,temp1,temp2,temp3;
    lli i,j,k,a,b;
    cin>>k;
    temp=100;
    i=0;
    while(temp<k){
        i++;
        temp+=floor(0.01*temp);
    }
    //cout<<pow(1.01,3)<<endl;
    cout<<i;
 
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n;
  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    mp[s]--;
  }
  int ans = 0;
  for (auto &v : mp) {
    ans = max(ans, v.second);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#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> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
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;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    a=1;
    while(1){
        if(a*a>n)break;
        ans=max(ans,a*a);
        a++;
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <vector>

using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n%2==1){
        cout<<"No";
        return 0;
    }
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[i+n/2]) {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

void turn(int *DICE,char com);

int main(void){
int i,j,q,top,front;
int DICE1[6],DICE2[6];
char com[105];
for(i=0;i<6;i++){scanf("%d",&DICE1[i]);}
for(i=0;i<6;i++){scanf("%d",&DICE2[i]);}
top=DICE1[0];front=DICE1[1];
i=0;
strcpy(com,"SSSSESSSS");
while(DICE2[1]!=front){
	if(com[i]=='\0'){printf("No\n");return 0;}
	turn(&DICE2[0],com[i]);
	i++;
	}
i=0;
strcpy(com,"EEEE");
while(DICE2[0]!=top){
	if(com[i]=='\0'){printf("No\n");return 0;}
	turn(&DICE2[0],com[i]);
	i++;
	}
for(i=2;i<6;i++){
	if(DICE1[i]!=DICE2[i]){printf("No\n");return 0;}
	}
printf("Yes\n");
return 0;
}

void turn(int *DICE,char com){
int temp;
switch(com){
	case 'N':
		temp     =*DICE;
		*DICE    =*(DICE+1);
		*(DICE+1)=*(DICE+5);
		*(DICE+5)=*(DICE+4);
		*(DICE+4)=temp;
		break;
	case 'S':
		temp     =*DICE;
		*DICE    =*(DICE+4);
		*(DICE+4)=*(DICE+5);
		*(DICE+5)=*(DICE+1);
		*(DICE+1)=temp;
		break;
	case 'E':
		temp     =*DICE;
		*DICE    =*(DICE+3);
		*(DICE+3)=*(DICE+5);
		*(DICE+5)=*(DICE+2);
		*(DICE+2)=temp;
		break;
	case 'W':
		temp     =*DICE;
		*DICE    =*(DICE+2);
		*(DICE+2)=*(DICE+5);
		*(DICE+5)=*(DICE+3);
		*(DICE+3)=temp;
		break;
	}
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] input = new int[3];

        for (int i = 0; i < 3; i++) {
            input[i] = sc.nextInt();
        }

        Arrays.sort(input);

        System.out.println((input[1] - input[0]) + (input[2] - input[1]));
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
const int MOD = 1000000007;

template <typename T>
void __dump__(std::ostream &os, const T &first) {
    os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
    os << first << ", ";
    __dump__(os, rest...);
}
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __dump__(os, __VA_ARGS__);                        \
        std::cerr << os.str() << std::endl;               \
    } while (0)

ll modpow(ll x, ll y) {
    if (y == 0) return 1;
    ll res = modpow(x, y / 2);
    return res * res % MOD * (y & 1 ? x : 1) % MOD;
}

ll modinv(ll x, ll m) { return modpow(x, m - 2); }

ll fact(ll n) {
    return n ? n * fact(n - 1) % MOD : 1;
}

int main() {
    ll a, b;
    while (cin >> a >> b && a) {
        if (a > b) swap(a, b);
        ll ans;
        if (b - a == 1) {
            ans = fact(b) * fact(a) % MOD;
        } else if (b - a == 0) {
            ans = fact(b) * fact(a) % MOD * 2 % MOD;
        } else {
            ans = 0;
        }
        cout << ans << endl;
    }
}


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

using namespace std;

int main() {

	int n,q;
	cin >> n >> q;

	vector < priority_queue<int>> qq(n );
	for (int i = 0; i < q; i++) {
		int a, b;
		cin >> a >> b;

		if (a == 0) {
			int c;
			cin >> c;
			qq[b].push(c);
		}
		else if (a == 1) {
			if (!qq[b].empty()) {
				cout << qq[b].top() << endl;
			}
		}
		else if (a == 2) {
			if (!qq[b].empty()) {
				qq[b].pop();
			}
		}
	}

}


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

#define ll long long
#define vec vector<ll>
#define sortv(a); sort(a.begin(), a.end());
#define rev(a); reverse(a.begin(), a.end());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)
#define printarray(a) FOR(Q,0,(int)(a).size()) cout<<(a)[Q]<<" "; cout<<'\n';

ll MOD = 1000000007;
ll INF = 1LL << 60;

/*****************************************************************************/
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s;cin>>s;
	int n=(int)s.length();
	int x,y;cin>>x>>y;
	vec hor;
	vec ver;
	bool flat=1;
	int cnt=0;
	bool minused=false;
	FOR(i,0,n) {
		if (s[i]=='F') {
			cnt++;
		}else{
			if (flat) {
				if (!minused) {
					x-=cnt;
					minused=true;
				} else {
					hor.push_back(cnt);
				}
			}else{
				ver.push_back(cnt);
			}
			cnt=0;
			flat^=1;
		}
	}
	if(cnt>0) {
		if (flat) {
			if (!minused) {
				x-=cnt;
				minused=true;
			} else {
				hor.push_back(cnt);
			}
		}else{
			ver.push_back(cnt);
		}	
	}

	sortv(hor);rev(hor);
	sortv(ver);rev(ver);

	int h=0;
	FOR(i,0,(int)hor.size()) {
		if (h>x) {
			h-=hor[i];
		} else {
			h+=hor[i];
		}
	}
	int v=0;
	FOR(i,0,(int)ver.size()) {
		if (v>y) {
			v-=ver[i];
		} else {
			v+=ver[i];
		}
	}

	// printarray(hor);
	// printarray(ver);
	// cout<<h<<" "<<v<<endl;

	if (h==x&&v==y) {
		cout<<"Yes";
	} else {
		cout<<"No";
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = ~(1 << 31);

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

    int n;
    cin >> n;
    int a;
    set<int> set;
    rep(i, n){
        cin >> a;
        if(set.find(a) == set.end()){
            set.insert(a);
        }else{
            set.erase(a);
        }
    }
    cout << set.size() << endl;
    
    return 0;
}

Measured memory_bytes: 4992
use std::io::{stdout, Write};

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    let out = stdout();
    let mut out = out.lock();

    input!{
        k: i32,
    };

    let mut ans: i32 = 0;
    for a in 1..(k+1) {
        for b in 1..(k+1) {
            for c in 1..(k+1) {
                ans += gcd(a as usize, gcd(b as usize, c as usize)) as i32;
            }
        }
    }

    writeln!(out, "{}", ans).unwrap()
}

Measured memory_bytes: 2152