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

ll solve() {
    ll N;
    cin >> N;
    ll ans = 0, c = 0, h, hc = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> h;
        if ( h <= hc ) {
            c++;
        } else {
            c = 0;
        }
        if ( ans < c ) ans = c;
        hc = h;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main(){
  int N, i;
  string S;
  scanf("%d", &N);
  cin >> S;
  for(i = 0; i < S.size(); i++){
    S[i] = 'A' + (S[i] - 'A' + N) % 26;
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
     char a , b , c ;
    string c1,c2,c3 ;
    cin >> c1 >> c2 >> c3 ;
    a = c1[0];
    b = c2[1];
    c = c3[2];
    cout << a << b << c << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int solve(vector<vector<bool>>& map, int k, int state) {
	int ans = 0;

	int nb = 0;
	FOR_LT(i, 0, 10) {
		if (state & (1 << i)) nb++;
	}
	nb++;

	vector<int> ss(nb);
	vector<int> cb(nb);

	FOR_LT(x, 0, map[0].size()) {
		FOR_LT(i, 0, nb) {
			cb[i] = 0;
		}

		int ci = 0;
		FOR_LT(y, 0, map.size()) {
			if (map[y][x]) cb[ci]++;

			if (state & (1 << y)) {
				ci++;
			}
		}

		bool hasb = false;
		FOR_LT(b, 0, nb) {
			if (cb[b] > k) {
				return INT_MAX;
			}
			if (ss[b] + cb[b] > k) {
				hasb = true;
				break;
			}
		}

		if (hasb) {
			ans++;
			FOR_LT(b, 0, nb) {
				ss[b] = 0;
			}
		}
		FOR_LT(b, 0, nb) {
			ss[b] += cb[b];
		}
	}

	return ans + nb - 1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int h, w, k; cin >> h >> w >> k;
	vector<vector<bool>> map(h, vector<bool>(w));
	FOR_LT(y, 0, h) {
		FOR_LT(x, 0, w) {
			char c; cin >> c;
			map[y][x] = ('1' == c);
		}
	}

	int ans = INT_MAX;
	FOR_LT(s, 0, 1 << (h - 1)) {
		int ca = solve(map, k, s);
		ans = min(ca, ans);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n,a[101],ans;
int main(void){
    cin>>n;
    for(int i=1;i<n;i++){
        cin>>a[i];
    }
    a[0]=a[1];
    a[n]=a[n-1];
    for(int i=0;i<n;i++){
        ans+=min(a[i],a[i+1]);
    }
    cout<<ans<<endl;
}


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

using namespace std;

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << max(0, h2 * 60 + m2 - h1 * 60 - m1 - k) << '\n';
    return 0;
}



Measured memory_bytes: 3652
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
int cmp3(T lhs, T rhs) { return (lhs == rhs) ? 0 : (lhs > rhs) ? 1 : -1; }

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

int main() {
  // cout << fixed << setprecision(10);

  string S, T;
  cin >> S >> T;
  cout << (S == (T.substr(0, T.size()-1)) ? "Yes":"No") << endl;
  return 0;
}


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

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var n = int.Parse(inputs[0]);
            var m = int.Parse(inputs[1]);

            var list = new List<int>() { n + m, n - m, n * m };
            Console.WriteLine(list.Max());
        }
    }
}


Measured memory_bytes: 28160
import java.util.Scanner;

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

    int[] origin = new int[3];
    origin[0] = sin.nextInt();
    origin[1] = sin.nextInt();
    origin[2] = sin.nextInt();

    for( int i = 0, exch; i < origin.length -1; i++) {
      for( int j = 1; j < origin.length - i; j++)
      if( origin[j-1] > origin[j] ) {
        exch = origin[j-1];
        origin[j-1] = origin[j];
        origin[j] = exch;
      }
    }

    System.out.println(origin[0] + " " + origin[1] + " " + origin[2]);
    sin.close();
  }
}


Measured memory_bytes: 26260
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll N, M, X;

void dfs(ll &ans, vl &buy, vvl CA, ll ind){
  if(ind == N){
    ll cost = 0;
    vl q(M, 0);
    rep(i, N){
      if(buy[i] == 0) continue;
      cost += CA[i][0];

      rep2(j, 1, M + 1){
	q[j - 1] += CA[i][j];
      }
    }

    rep(i, M){
      if(q[i] < X) return;
    }

    ans = min(ans, cost);
    
    return;
  }

  rep(i, 2){
    buy.push_back(i);
    dfs(ans, buy, CA, ind + 1);
    buy.pop_back();
  }

  return;
}

int main(){
  cin >> N >> M >> X;
  vvl CA(N, vl(M + 1));
  rep(i, N){
    rep(j, M + 1) cin >> CA[i][j];
  }

  ll ans = (ll)pow(10, 15);
  vl buy;

  dfs(ans, buy, CA, 0);

  if(ans <= (ll)pow(10, 14))
    cout << ans << endl;
  else
    cout << -1 << endl;
  
  return 0;
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLineIntSpilit();
            
            Console.WriteLine(Math.Ceiling((1.0*n[0])/n[1]));
            ReadLine();
        }

        /// <summary>
        /// コンビネーション
        /// </summary>
        /// <param name="n"></param>
        /// <param name="m"></param>
        /// <returns></returns>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

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

int main() {
  int n,k,x,y,ans;

  cin >> n >> k >> x >> y;

  if(k>n) {
    ans = n*x;
  } else {
    ans = k*x+(n-k)*y;
  }
  
  cout << ans << endl;

}

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

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

  if(a>b){
    cout << "a > b" << endl;
  }else if(a<b){
    cout <<  "a < b" << endl;
  }else{
    cout << "a == b" <<endl;
  }

  return 0;
}



Measured memory_bytes: 3084
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int m = stdIn.nextInt();
			int n = stdIn.nextInt();
			if(m == 0 && n == 0) {
				break;
			}
			
			boolean[] isLive = new boolean[m];
			for(int i = 0; i < m; i++) {
				isLive[i] = true;
			}
			String[] say = new String[n];
			for(int i = 0; i < n; i++) {
				say[i] = stdIn.next();
			}
			int deadC = 0;
			int now = 0;
			for(int i = 1; i <= n; i++) {
				boolean isFizz = i%3==0;
				boolean isBuzz = i%5==0;
				boolean isFizzBuzz = false;
				if(isFizz && isBuzz) {
					isFizzBuzz = true;
					isFizz = false;
					isBuzz = false;
				}
				while(true) {
					if(isLive[now]) {
						break;
					}
					now++;
					if(now >= m) now = 0;
				}
				if(deadC == m - 1) {
					break;
				}
				if(isFizzBuzz&&!say[i-1].equals("FizzBuzz")) {
					isLive[now] = false;
					deadC++;
					continue;
				}
				else if(isFizz&&!say[i-1].equals("Fizz")) {
					isLive[now] = false;
					deadC++;
					continue;
				}
				else if(isBuzz&&!say[i-1].equals("Buzz")) {
					isLive[now] = false;
					
					deadC++;
					continue;
				}
				else if(!isFizzBuzz&&!isBuzz&&!isFizz&&!say[i-1].equals(String.valueOf(i))) {
					isLive[now] = false;
					deadC++;
					continue;
				}
				now++;
				if(now >= m) {
					now = 0;
				}
			}
			boolean isFirst = true;
			for(int i = 0; i < m; i++) {
				if(isLive[i] && isFirst) {
					System.out.print((i+1));
					isFirst = false;
				}
				else if(isLive[i]) {
					System.out.print(" " + (i+1));
				}
			}
			System.out.println();
		}
	}
	

}

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

 int main()
 {
     int n,i,j,k,c;
     cin>>n;
     int ara[n];

     for(i=0;i<n;i++){
        cin>>ara[i];
     }
     c = ara[0];
     k = 1;;
     for(i=1;i<n;i++){
       if(ara[i]<=c){
        k++;
        c = ara[i];
       }
    }

     cout<<k<<endl;

     return 0;
 }


Measured memory_bytes: 3940
/**
 * Created by hiramekun at 20:53 on 2019-11-23.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) {
        cin >> s[i];
    }
    vector<vector<ll>> ans(h, vector<ll>(w));
    vector<bool> hasS(h);
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '#') {
                hasS[i] = true;
                break;
            }
        }
    }

    ll now = 1;
    rep(i, h) {
        if (hasS[i]) {
            bool has = false;
            rep(j, w) {
                if (s[i][j] == '#') {
                    if (has) now++;
                    ans[i][j] = now;
                    has = true;
                } else {
                    ans[i][j] = now;
                }
            }
            now++;
        }
    }
    rep(i, h) {
        rep(j, w) {
            if (i > 0 && hasS[i] && !hasS[i - 1]) {
                ll now = i - 1;
                while (now >= 0 && ans[now][0] == 0) {
                    rep(l, w) {
                        ans[now][l] = ans[i][l];
                    }
                    now--;
                }
            }
            if (i < h - 1 && hasS[i] && !hasS[i + 1]) {
                ll now = i + 1;
                while (now < h && ans[now][0] == 0) {
                    rep(l, w) {
                        ans[now][l] = ans[i][l];
                    }
                    now++;
                }
            }
        }
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
char in[9][5]={
  {'.',',','!','?',' '},
  {'a','b','c'},
  {'d','e','f'},
  {'g','h','i'},
  {'j','k','l'},
  {'m','n','o'},
  {'p','q','r','s'},
  {'t','u','v'},
  {'w','x','y','z'},
};
int in1[9]={5,3,3,3,3,3,4,3,4};
int main(){
  int n;
  cin>>n;
  rep(j,n){
    string s;
    cin>>s;
    int i=0;
    while(i!=s.size()){
      int co=0;
      while(s[i]!='0'){
	co++;
	i++;
      }
      //cout<<co<<endl;
      if(co)cout<<in[s[i-1]-'0'-1][(co-1)%in1[s[i-1]-'0'-1]];
      i++;
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> H(N);
  rep(i, N)
  {
    cin >> H[i];
  }
  int ans = 0;
  int mm = 0;
  for (int i = 0; i < N; i++)
  {
    mm = max(mm, H[i]);
    if (mm == H[i])
    {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<set>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[1000000];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	ll s=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		s+=a[i];
	}
	ll k=0;
	ll mi=1e16;
	for(int i=0;i<n-1;i++){
		k+=a[i];
		if(abs(s-2*k)<=mi){
			mi=abs(s-2*k);
		}
	}
	cout<<mi<<endl;
return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>

int main(void){
	int a[3];
	int B=4000;
	scanf("%d",a);
	scanf("%d",a+1);
	scanf("%d",a+2);
	
	
	int x = abs(a[1] - a[0]);
		x += abs(a[2] - a[0]);
	if( x < B){
		B = x;
	}
	int y = abs(a[0] - a[2]);
		y += abs(a[1] - a[2]);
	if( y < B){
		B = y;
	}
	int z = abs(a[0] - a[1]);
		z += abs(a[2] - a[1]);
	if( z < B){
		B = z;
	}
	printf("%d\n",B);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから
ll n,k;
vector<ll>a;
#define int64_t ll
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
bool C(ll mid,ll x){
  if(x%mid)return false;
  vector<ll>p(n);
  rep(i,n){
    p[i]=a[i]%mid;
  }
  sort(p.begin(),p.end());
  ll sum=0,sum2=0;
  int pos=0;
  while(pos<n&&p[pos]+sum<=k){
    sum+=p[pos++];
  }
  for(int i=pos;i<n;++i){
    sum2+=p[i];
  }
  return sum2<=k;
}

void solve(){
  cin>>n>>k;
  a.resize(n);
  ll sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  ll ans=0;
  vector<ll>v=divisor(sum);
  vector<ll>p(n);
  rep(j,v.size()){
    rep(i,n){
      p[i]=a[i]%v[j];
    }
    sort(p.begin(),p.end());
    ll sum=0,sum2=0;
    int pos=0;
    while(pos<n&&p[pos]+sum<=k){
      sum+=p[pos++];
    }
    for(int i=pos;i<n;++i){
      sum2+=v[j]-p[i];
    }
    if(sum2<=k){
      chmax(ans,v[j]);
    }
  }
  cout<<ans<<endl;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(sorted(map(int, input().split())))
# N = 10
# A = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]
# A = sorted(A)
# print(A)

total = 0
cnt = 0
for i in range(3 * N - 2, 0, -2):
    cnt += 1
    total += A[i]

    if cnt == N:
        break
print(total)


Measured memory_bytes: 39492
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int a[3];
    REP(i,3)cin>>a[i];
    sort(a,a+3);
    cout<<a[2]-a[0]<<endl;
}

Measured memory_bytes: 256
using System;

class Program
{
    class DICE {
        public int top = 0;
        int right = 0;
        int left = 0;
        int front = 0;
        int back = 0;
        int bottom = 0;

        public DICE(string[] no) {
            top = int.Parse(no[0]);
            back = int.Parse(no[1]);
            right = int.Parse(no[2]);
            left = int.Parse(no[3]);
            front = int.Parse(no[4]);
            bottom = int.Parse(no[5]);
        }

        public void Move(string mv) {
            for (int i = 0; i < mv.Length; i++) {
                string ch = mv.Substring(i, 1);
                if (ch == "N") {
                    MOVE_N();
                }
                else if (ch == "E") {
                    MOVE_E();
                }
                else if (ch == "W") {
                    MOVE_W();
                }
                else if (ch == "S") {
                    MOVE_S();
                }
            }
        }

        private void MOVE_N() {
            int wk = top;
            top = back;
            back = bottom;
            bottom = front;
            front = wk;
        }

        private void MOVE_E() {
            int wk = top;
            top = left;
            left = bottom;
            bottom = right;
            right = wk;
        }

        private void MOVE_W() {
            int wk = top;
            top = right;
            right = bottom;
            bottom = left;
            left = wk;
        }

        private void MOVE_S() {
            int wk = top;
            top = front;
            front = bottom;
            bottom = back;
            back = wk;
        }
    }

    static void Main(string[] args) {
        string[] x = Console.ReadLine().Split(' ');
        string mv = Console.ReadLine();

        DICE d = new DICE(x);
        d.Move(mv);
        Console.WriteLine(d.top);
    }
}


Measured memory_bytes: 19976
#include <iostream>

using namespace std;
int n,mn,a,c;
int main()
{
    cin>>n;
    mn=n+1;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        if(a<mn)
        {
            mn=a;
            c++;
        }
    }
    cout<<c;
    return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    ll n, m, f[100005] = {1};
    cin >> n >> m;
    if (n > m) swap(n, m);
    for (int i = 1; i <= 100000; i++) f[i] = f[i - 1] * i % mod;
    if (n == m) cout << f[n] * f[n] * 2 % mod;
    else if (n + 1 == m) cout << f[n] * f[n + 1] % mod;
    else cout << 0;
}


Measured memory_bytes: 1024
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 n = N;
    int fN = 0;
    
    while(n > 0){
      fN += n % 10; //1の位を取得
      n /= 10;  //1桁ずらす  	
    }
    if(N % fN == 0) System.out.println("Yes");
    else System.out.println("No");   
  }
}




Measured memory_bytes: 21972
s = input()
valid = True
for i in range(len(s)):
    if i % 2 == 1:
        if not (s[i] in ['L', 'U', 'D']):
            valid = False
            break
    else:
        if not (s[i] in ['R', 'U', 'D']):
            valid = False
            break
if valid:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll a,b;cin>>a>>b;
	if((a+b)%2==0){
		cout<<(a+b)/2<<endl;
	}else{
		cout<<"IMPOSSIBLE"<<endl;
	}































	
}

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

int main(){
  int H,W;cin>>H>>W;
  int N;cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++) cin>>a[i];
  vector<vector<int> > fields(H,vector<int>(W));
  int i=0,j=0;
  for(int k=0;k<N;k++){
    int h=0;
    while(true){
      if(h==a[k]) break;
      fields[i][j]=k+1;
      j++;
      if(j==W){
        i++;
        if(i==H) break;
        j=0;
      }
      h++;
    }
  }
  for(int i=0;i<H;i++){
    if(i&1){
      for(auto it=fields[i].begin();it!=fields[i].end();it++){
        cout<<*it<<((it==fields[i].end()-1)?'\n':' ');
      }
    }else{
      for(auto it=fields[i].rbegin();it!=fields[i].rend();it++){
        cout<<*it<<((it==fields[i].rend()-1)?'\n':' ');
      }
    }
  }
  return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	
	int A, B;
	int Answer;
	cin >> A >> B;
	
	if ((0 < A) && (A < 10) && (0 < B) && (B < 10)) {
		
		Answer = A * B;
		
	} else {
		Answer = -1;
	}
	
	cout << Answer << endl;
	
	return 0;
	
}

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

string s;
int k, cnt;
set <string> sub;

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> s >> k;
	for(int i = 0; i < s.length(); ++i) {
		for(int j = min(k, (int)s.length()); j > 0; --j) {
			sub.insert(s.substr(i, j));
		}
	}
	cnt = 0;
	for(auto it:sub) {
		if (cnt == k-1) {
			cout << it;
			break;
		}
		++cnt;
		// cout << '#' << ' ' << cnt << '\n';
		// cout << it << '\n';
	}
}

Measured memory_bytes: 4820
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
vector<int>g[110000];
int N;
int bfs[110000];
int chk(int a){
	for(int i=0;i<N;i++){
		bfs[i]=0;
	}
	queue<int>Q;
	if(a!=0){
		Q.push(0);
		bfs[0]=1;

	}else{
		Q.push(1);
		bfs[1]=1;
	}
	while(Q.size()){
		int at=Q.front();Q.pop();
		for(int i=0;i<g[at].size();i++){
			if(g[at][i]!=a&&bfs[g[at][i]]==0){
				bfs[g[at][i]]=1;
				Q.push(g[at][i]);
			}
		}
	}
	int cnt=0;
	for(int i=0;i<N;i++)cnt+=bfs[i];
	if(cnt==N-1)return 0;
	else return 1;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);N=a;
	for(int i=0;i<b;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(q);
		g[q].push_back(p);
	}
	int cnt=0;
	vector<int>t;
	for(int i=0;i<a;i++){
		if(g[i].size()%2){
			printf("No\n");return 0;
		}

		if(g[i].size()==4){
			cnt++;
			t.push_back(i);
		}
	}
	for(int i=0;i<a;i++){
		if(g[i].size()>=6){
			printf("Yes\n");return 0;
		}
	}
	if(cnt<2){
		printf("No\n");return 0;
	}
	if(cnt>=3){
		printf("Yes\n");return 0;
	}
	if(chk(t[0])&&chk(t[1])){
		printf("Yes\n");return 0;
	}printf("No\n");return 0;
}

Measured memory_bytes: 6272
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  while(n!=0){
    int i;
    double s[1000]={},sum=0,a=0;
    for(i=0;i<n;i++){
      cin >> s[i];
      sum+=s[i];
    }
    for(i=0;i<n;i++){
      a+=((sum/n)-s[i])*((sum/n)-s[i])/n;
    }
    printf("%.5f\n",sqrt(a));
    cin >> n;
  }
  
  return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=1ll*x*x%p)if(k&1)res=1ll*res*x%p;return res;}
const int maxn=2e5+5,inf=1e9+10;
int n;
int tag[maxn<<2],mini[maxn<<2][2];
int pos[maxn];
set<int>used;
void U(int x){
	rep(i,0,1)mini[x][i]=min(mini[ls][i],mini[rs][i]);
}
void B(int x,int l,int r){
	mini[x][0]=mini[x][1]=inf;
	if(l==r){
		read(mini[x][l&1]);
		pos[mini[x][l&1]]=l;
		return;
	}
	B(ls,l,mid);B(rs,mid+1,r);
	U(x);
}
void R(int x){
	tag[x]^=1;
	swap(mini[x][0],mini[x][1]);
}
void PD(int x){
	if(!tag[x])return;
	R(ls);R(rs);tag[x]^=1;
}
void R(int x,int l,int r,int ll,int rr){
	if(ll>rr)return;
	if(l==ll&&r==rr){
		R(x);
		return;
	}
	PD(x);
	if(rr<=mid)R(ls,l,mid,ll,rr);
	else if(ll>mid)R(rs,mid+1,r,ll,rr);
	else R(ls,l,mid,ll,mid),R(rs,mid+1,r,mid+1,rr);
	U(x);
}
void M(int x,int l,int r,int pos){
	if(l==r){
		mini[x][0]=mini[x][1]=inf;
		return;
	}
	PD(x);
	if(pos<=mid)M(ls,l,mid,pos);
	else M(rs,mid+1,r,pos);
	U(x);
}
int Q(int x,int l,int r,int ll,int rr,int i){
	if(l==ll&&r==rr)return mini[x][i];
	PD(x);
	if(rr<=mid)return Q(ls,l,mid,ll,rr,i);
	else if(ll>mid)return Q(rs,mid+1,r,ll,rr,i);
	else return min(Q(ls,l,mid,ll,mid,i),Q(rs,mid+1,r,mid+1,rr,i));
}
int main(){
	read(n);
	B(1,1,n);
	used.insert(n+1);
	rep(i,1,n/2){
		int minv=Q(1,1,n,1,n,1),now=pos[minv];
		int r=*used.lower_bound(now)-1;
		int secv=Q(1,1,n,now+1,r,0),nxt=pos[secv];
		R(1,1,n,now+1,nxt-1);
		M(1,1,n,now);
		M(1,1,n,nxt);
		printf("%d %d ",minv,secv);
		used.insert(now);
		used.insert(nxt);
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

#define INF 1e15

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll a(n);
    rep(i,n) cin>>a[i];
    vector<map<ll,ll> > dp(n+1);
    dp[0][0] = 0;
    dp[1][0] = 0, dp[1][1] = a[0];
    FOR(i,2,n)rep(j,3){
        int k=i/2+j-1;
        if (!dp[i-1].count(k)) dp[i-1][k] = -INF;
        if (!dp[i-2].count(k-1)) dp[i-2][k-1] = -INF;
        dp[i][k] = max(dp[i-1][k], dp[i-2][k-1]+a[i-1]);
    }
    cout<<dp[n][n/2]<<"\n";
    return 0;
}


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

int main() {
  int N, D;
  cin >> N >> D;
  vector<vector<int> > x(N, vector<int>(D));

  for(int i=0;i<N;i++) {
    for(int j=0;j<D;j++) {
      cin >> x[i][j];
    }
  }

  int combi = 0;

  for(int i=0;i<N;i++) {
    for(int j=i+1;j<N;j++) {
      int total = 0;
      for(int k=0;k<D;k++) {
        total += pow(x[i][k] - x[j][k], 2);
      }

      if(sqrt(total) == floor(sqrt(total))) {
        combi++;
      }
    }
  }

  cout << combi << endl;

  return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

int MOD=1e9+7;
ll INF=1e18;

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

int d[110][110];

void warshall_floyd(int n){
	for(int k=0; k<n; k++){
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
                d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
			}
		}
	}
}

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

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i == j) d[i][j]=0;
            else d[i][j]=MOD;
        }
    }

    vector<int> a(m+10), b(m+10), c(m+10);
    for(int i=0; i<m; i++){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--, b[i]--;
        d[a[i]][b[i]]=c[i];
        d[b[i]][a[i]]=c[i];
    }

    warshall_floyd(n);

    int ans=0;
    for(int i=0; i<m; i++){
        if(d[a[i]][b[i]] < c[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

vector<int> a(mx,-1), p(mx,0);

int main(){
  int n;
  cin >> n;
  rep(i,n-1){
    cin >> a[i+1];
    a[i+1]--;
    p[a[i+1]]++;
  }
  rep(i,n){
    cout << p[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4656
#include <cstdio>
#include <algorithm>

using namespace std;

const int NMAX = 1e5;
int n;
int b[NMAX + 5];
int dp[(1 << 15)];

int main(){
	
	scanf("%d",&n);
	
	for(int i = 1;i < n;i++){
		int x,y,z;
		scanf("%d %d %d",&x,&y,&z);
		x++;
		y++;
		b[x] ^= z;
		b[y] ^= z;
	}
	
	int ans = n;
	int mask = 0;
	
	
	for(int i = 1;i <= n;i++){
		if(b[i] == 0){
			ans--;
		}
		else if((mask >> (b[i] - 1)) & 1){
			mask ^= (1 << (b[i] - 1));
			ans--;
		}
		else{
			mask ^= (1 << (b[i] - 1));
		}
	}
		
	dp[0] = 0;
	
	for(int i = 1;i <= mask;i++){
		dp[i] = -(1 << 28);
		for(int j = i;j;j = (j - 1) & i){
			int xo = 0;
			
			for(int b = 0;b < 15;b++){
				if((j >> b) & 1){
					xo ^= (b + 1);///cause i subtracted 1 before to make them in [0,15) range
				}
			}
			
			if(xo == 0){
				dp[i] = max(dp[i],1 + dp[i ^ j]);
			}
		}
	}
	
	ans -= dp[mask];
	
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
 
using namespace std;

int i,j,k;
 
int max(int a, int b)
{
    if(a>b) return a;
    else return b;
}
 
int min(int a,int b)
{
    if(a<b) return a;
    else return b;
}

int fast_power(int a,int b)
{
    int res=1;
    while(b>0)
    {
        if(b%2==0)
        {
            b/=2;
            a=(a*a)%mod;
        }
        else
        {
             b/=2;
             res=(res*a)%mod;
            a=(a*a)%mod;
        }
    }
    return res;
}

signed main()
{
    IOS;
    int n,m,i,sum=0,num,d;
    cin>>n>>m;
    vi v(n);
    for(i=0;i<n;i++)
    {
        cin>>v[i];
        sum+=v[i];
    }
    sort(v.begin(),v.end());
    d=4*m;
    if(sum%d==0) num=sum/d;
    else num=sum/d+1;
    int flag=0;
    for(i=n-m;i<n;i++)
    {
        if(v[i]<num)
        {
            flag=1;
            break;
        }
    }
    if(flag==1) cout<<"No";
    else cout<<"Yes";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
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; }


int main(){
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    vector<vector<int> > x(n), y(n);
    rep(i, n){
        cin >> a[i];
        rep(j, a[i]){
            int X, Y;
            cin >> X >> Y;
            X--;
            x[i].push_back(X);
            y[i].push_back(Y);
        }
    }
    rep(bit, 1<<n){
        bitset<16> tmp(bit);
        if((int)tmp.count() < ans) continue;
        bool ok = true;
        rep(i, n) {
            // 正直な人
            if(tmp.test(i)){
                rep(j, a[i]) {
                    // x[i][j]は正直者だと正直者が言っているのに実際には正直者ではない
                    if(tmp.test(x[i][j]) && y[i][j] == 0) {
                        ok = false;
                        break;
                    }
                    if(!tmp.test(x[i][j]) && y[i][j] == 1) {
                        ok = false;
                        break;
                    }
                }
            }
        }
        if(ok) chmax(ans, (int)tmp.count());
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;

int main(){
    int N,L;cin>>N>>L;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    REP(i,N-1){
        if(a[i]+a[i+1]>=L){
            cout<<"Possible"<<endl;
            REP(k,i){
                cout<<k+1<<endl;
            }
            for(int k=N-2;k>=i+1;--k){
                cout<<k+1<<endl;
            }
            cout<<i+1<<endl;
            return 0;
        }
    }
    cout<<"Impossible"<<endl;
}


Measured memory_bytes: 1280
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());
		String[] tokens = in.readLine().split(" ");
		int[] A = new int[N];
		for (int i = 0; i < N; ++i) {
			A[i] = Integer.parseInt(tokens[i]);
		}
		Arrays.sort(A);
		double sum = 0.0;
		for (int i = N - 1; i >= 0; --i) {
			sum += 1.0 / (double) (A[i]);
		}
		sum = 1.0 / sum;
		System.out.println(sum);

	}
}


Measured memory_bytes: 22228
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vs W(n);
  VIN(W)
  bool test1 = true;
  REP(i,n){
    REP(j,n){
      if(i==j) continue;
      if(W[i]==W[j]) test1 = false;
    }
  }
  bool test2 = true;
  REP(i,n-1){
    if(W[i][W[i].size()-1] != W[i+1][0]) test2 = false;
  }
  Yes(test1 && test2);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 10000

int main(){
  unsigned short *A, *B;

  int C[N+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0; i <= N; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= N; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }


signed main(void){
  string s;cin >> s;
  if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) cout << "Yes" << endl;
  else if(s[0]==s[2]&&s[1]==s[3]&&s[1]!=s[2]) cout << "Yes" << endl;
  else if(s[0]==s[3]&&s[2]==s[1]&&s[1]!=s[0]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/


signed main(){
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  vi cnt(100'001);
  rep(i,n)cnt[a[i]]++;

  int kab=0;
  rep(i,cnt.size()) if(cnt[i]>1) kab+=cnt[i]-1;
  
  int ans;
  if(kab%2==0){
    ans=n-kab;
  }else{
    ans=n-kab-1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int s[200010];
int f[200010];
vector<int>v;
typedef long long ll;
int main()
{
    ll n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>s[i];
    }
    int tmp=1;
    int cnt=0;
    int ans,flag=0;
    while(1)
    {
        if(f[tmp]==2){break;}
        else if(f[tmp]==1){
            v.push_back(tmp);
            f[tmp]=2;
            tmp=s[tmp];
        }else if(f[tmp]==0){
            f[tmp]=1;
            ans=s[tmp];
            tmp=s[tmp];
            cnt++;
            if(k==cnt){
                flag=1;break;
            }
        }
    }
    if(flag==1){cout<<ans<<endl;return 0;}
    k=k-(cnt-v.size());
    int xxx=(k)%v.size();
    cout<<v[xxx];
}


Measured memory_bytes: 5388
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
a = [LIST() for i in range(m)]
c = [0]*(n+1)

for i in range(m):
        if a[i][0] == 1 or a[i][0] == n or a[i][1] == 1 or a[i][1] == n:
                c[a[i][0]] += 1
                c[a[i][1]] += 1

for i in range(2, n):
        if c[i] >= 2:
                print("POSSIBLE")
                exit()

print("IMPOSSIBLE")

Measured memory_bytes: 47872
n, k = map(int, input().split())
ps = list(map(lambda n: (int(n)+1)/2, input().split()))

mx = sum(ps[:k])
sm = sum(ps[:k])
for i in range(k, n):
  sm += ps[i] - ps[i-k]
  if sm > mx:
    mx = sm
print(mx)

Measured memory_bytes: 23148
#include<stdio.h>
int main(void)
{
    int h,m,s,a,S;
    scanf("%d",&S);
    h=S/3600;
    a=S-(h*3600);
    m=a/60;
    s=a-(m*60);
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 592
from collections import Counter
n = int(input())
cnt = Counter(map(int, input().split()))
q = int(input())
Asum = sum(k*v for k, v in cnt.items())
for _ in range(q):
    b, c = map(int, input().split())
    cnt[c] += cnt[b]
    Asum += c*cnt[b]-b*cnt[b]
    cnt[b] = 0
    print(Asum)


Measured memory_bytes: 22208
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt(); //お札の枚数 2*10^3
		int y = stdIn.nextInt(); //金額 2*10^7
		
		
		//boolean flag = false; //実際にその金額になるか
		
		
		for(int i = 0; i <= n; i++) {
			for(int j = 0; j <= n - i; j++) {
				int k = n - i - j; //1000円札の枚数
				
				if(i*10000 + j*5000 + k*1000 == y) {
					System.out.println(i+" "+j+" "+k);
					return;
				}
				
				
			}
		}
		
		System.out.println(-1+" "+-1+" "+-1);
		
		
		
	}

}


Measured memory_bytes: 23124