akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.Arrays;

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

		while(true){
			int a0 = sc.nextInt();
			int digits = sc.nextInt();
			if(a0==0&&digits==0) break;
			int[] num = new int[digits];
			int i = 0, k;

			ai[0] = a0;
			while(true){
				int max = 0, min = 0;
				int temp = ai[i];
				for(int j=0; j<digits; j++){
					num[j] = temp % 10;
					temp /= 10;
				}
				Arrays.sort(num);

				for(int j=0; j<digits; j++){
					max *= 10;
					min *= 10;
					min += num[j];
					max += num[digits-1-j];
				}
				ai[++i] = max - min;
				k = Check(ai, i);
				if(k!=-1){
					System.out.printf("%d %d %d\n", k, ai[i], i-k);
					break;
				}
			}
		}
	}
	
	static int Check(int[] ai, int i){
		for(int j=0; j<i; j++){
			if(ai[j]==ai[i]){
				return j;
			}
		}
		return -1;
	}
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;

    while (cin >> n)
    {
        int count = 0;
        rep(a, 10)
        {
            rep(b, 10)
            {
                rep(c, 10)
                {
                    rep(d, 10)
                    {
                        if (a + b + c + d == n)
                        {
                            count++;
                        }
                    }
                }
            }
        }
        OP(count)
    }
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

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

int N, M;

int L, a, b;
#define POW(x) ((x)*(x))

int main(void)
{
	cin >> N >> M;
	vector<pair<double, pair<double, double> > > colors;
	rep(i, N) {
		double l, a, b;
		cin >> l >> a >> b;
		colors.push_back(make_pair(l, make_pair(a, b)));
	}

	vector<int> s;
	rep(i, N-M) s.push_back(0);
	rep(i, M) s.push_back(1);
	double ans = 0;
	do {
		double buf = 0;
		rep(i, N) if (s[i]) {
			double l1, a1, b1;
			l1 = colors[i].first;
			a1 = colors[i].second.first;
			b1 = colors[i].second.second;
			REP(j, i+1, N) if (s[j]) {
				double l2, a2, b2;
				l2 = colors[j].first;
				a2 = colors[j].second.first;
				b2 = colors[j].second.second;
				buf += POW(l1-l2)+POW(a1-a2)+POW(b1-b2);
			}
		}
		ans = max(ans, buf);
	} while(next_permutation(ALL(s)));

	printf("%0.10lf\n", ans);
	return 0;
}

Measured memory_bytes: 1272
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 200100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,W;
    cin>>N>>W;
    //dp[i]:重さiで達成できる最大の価値
    int dp[d5];
    for(int i=0;i<d5;i++)dp[i]=-1;
    dp[0]=0;
    for(int i=0;i<N;i++){
        int w,v;
        cin>>w>>v;
        for(int i=W;i>=0;i--){
            if(dp[i]==-1)continue;
            else{
                dp[i+w]=max(dp[i+w],dp[i]+v);
            }
        }
    }
    int res=0;
    for(int i=0;i<=W;i++)res=max(res,dp[i]);
    cout<<res<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;

int main(){
	
	while(true){
		int N, A, B, C, X;
		cin >> N >> A >> B >> C >> X;
		
		if(N == 0){
			break;
		}
		
		int num[200];
		
		for(int i = 0; i < N; i++){
			cin >> num[i];
		}
		
		int counter = 0;
		int cur = X;
		int ans = -1;
		
		for(int loop = 0; loop <= 10000; loop++){
			if(num[counter] == cur){
				counter++;
			}
			cur = (A * cur + B) % C;
			if(counter == N){
				ans = loop;
				break;
			}
		}
		
		cout << ans << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3012
# 締切の早いものから順番に見ていくのが最適戦略
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
X = sorted(X, key=lambda x: x[1])  # B (締切の早い順にソート)

res = 0
for i in range(N):
    res += X[i][0]
    if res > X[i][1]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 55264
N=int(input())
A=[int(a) for a in input().split()]
B=[int(a) for a in input().split()]

ans=0
for i in range(N):
    sm=A[i]+A[i+1]
    rem=sm-B[i]
    if rem>0:
        A[i+1]=min(rem,A[i+1])
        ans+=B[i]
    else:
        A[i+1]=0
        ans+=sm

print(ans)
        

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

void solve(long long A, long long B)
{
    for (size_t i = 0; i < 10; i++)
    {
        long long price = 10 * B + i;

        if (floor(price * 0.08) == A && floor(price * 0.1) == B)
        {
            cout << price << endl;
            return;
        }
    }
    cout << -1 << endl;
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
# floyd_warshall
h,w = map(int,input().split())
l = [['#']*(w+2)]
for i in range(h):
    l.append(['#']+list(input())+['#'])
l.append(['#']*(w+2))

def id(x,y):
    return x*w+y

INF = 1<<29
dp = [[INF]*500 for _ in range(500)]
for i in range(500):
    dp[i][i] = 0


ans = 0
directions = [(1,0),(0,1),(-1,0),(0,-1)]

for i in range(1,h+1):
    for j in range(1,w+1):
        if l[i][j]=='#':
            continue
        for dir in directions:
            ni = i+dir[0]
            nj = j+dir[1]
            if l[ni][nj] == '#':
                continue
            dp[id(i-1,j-1)][id(ni-1,nj-1)] = 1
            dp[id(ni-1,nj-1)][id(i-1,j-1)] = 1

for k in range(h*w):
    for i in range(h*w):
        for j in range(h*w):
            dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j])

ans = 0
for si in range(h):
    for sj in range(w):
        if l[si+1][sj+1] == '#':
            continue
        for gi in range(h):
            for gj in range(w):
                if l[gi+1][gj+1] == '#':
                    continue
                ans = max(ans,dp[id(si,sj)][id(gi,gj)])
print(ans)

Measured memory_bytes: 70772
n,k = map(int,input().split())
val = (n-1)*(n-2)//2
if k > val:print(-1);exit()


print(n-1+val-k)

for i in range(2,n+1):
    print('1' + ' ' + str(i))

v = 2
w = 3
while k < val:
    val -= 1
    print(v, w)
    w += 1
    if w == n + 1:
        v += 1
        w = v + 1

Measured memory_bytes: 74352
import fractions # for python 3.4.3

N = int(input())
A = list(map(int, input().split()))

gcd_l = [0]
gcd_r = [0]
for i in range(N):
    gcd_l.append(fractions.gcd(gcd_l[i], A[i]))
    gcd_r.append(fractions.gcd(gcd_r[i], A[-(i+1)]))
    #print(gcd_l)
    #print(gcd_r)
gcd_r = gcd_r[::-1]

ans = []
for i in range(N):
    ans.append(fractions.gcd(gcd_l[i], gcd_r[i+1]))

print(max(ans))

Measured memory_bytes: 16152
import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    h_list = list(map(int, input().split()))
    l = -1
    r = -1
    result = 0
    while any((h > 0 for h in h_list)):
        for i,height in enumerate(h_list):
            if height > 0:
                if l == -1:
                    l = i
                if i == n-1:
                    r = i
                    break
            else:
                if l == -1:
                    continue
                elif r == -1:
                    r = i - 1
                    break

        if l == 0 and r == 0:
             h_list[0] = h_list[0] - 1
        else:
            for i in range(l,r+1):
                h_list[i] = h_list[i] - 1 
        l = -1
        r = -1
        result += 1
    print(result)
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N;
string S;

template <unsigned mod>
struct RollingHash {
  vector<unsigned> hashed, power;

  inline unsigned mul(unsigned a, unsigned b) const {
    unsigned long long x = (unsigned long long)a * b;
    unsigned xh = (unsigned)(x >> 32), xl = (unsigned)x, d, m;
    asm("divl %4; \n\t" : "=a"(d), "=d"(m) : "d"(xh), "a"(xl), "r"(mod));
    return m;
  }

  RollingHash(const string &s, unsigned base = 10007) {
    int sz = (int)s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
    power[0] = 1;
    for (int i = 0; i < sz; i++) {
      power[i + 1] = mul(power[i], base);
      hashed[i + 1] = mul(hashed[i], base) + s[i];
      if (hashed[i + 1] >= mod) hashed[i + 1] -= mod;
    }
  }

  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
    if (ret >= mod) ret -= mod;
    return ret;
  }

  unsigned connect(unsigned h1, int h2, int h2len) const {
    unsigned ret = mul(h1, power[h2len]) + h2;
    if (ret >= mod) ret -= mod;
    return ret;
  }

  int LCP(const RollingHash<mod> &b, int l1, int r1, int l2, int r2) {
    int len = min(r1 - l1, r2 - l2);
    int low = -1, high = len + 1;
    while (high - low > 1) {
      int mid = (low + high) / 2;
      if (get(l1, l1 + mid) == b.get(l2, l2 + mid))
        low = mid;
      else
        high = mid;
    }
    return (low);
  }
};

using RH = RollingHash<1000000007>;

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

  RH rh(S);

  auto tooSmall = [&rh](int l) {
    unordered_map<int, int> m;
    for (int i = 0; i + l <= N; ++i) {
      int h = rh.get(i, i + l);
      auto it = m.find(h);
      if (it == m.end()) {
        m[h] = i;
      } else {
        if ((*it).second + l <= i) return true;
      }
    }
    return false;
  };

  int l = 0, r = N / 2 + 1;
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (tooSmall(m)) {
      l = m;
    } else {
      r = m;
    }
  }

  cout << l << endl;
  return 0;
}


Measured memory_bytes: 596
#include <stdio.h>


int main (void){
	int n, x, N[3], i, j, k, a[1000], c, m = 1;//c:count
	scanf("%d %d", &n, &x);
	while(n != 0 || x != 0){
		c = 0;
		for(i = 1; i <= n - 2; i++){
			N[1] = i;
			for(j = i + 1; j <= n -1; j++){
				N[2] = j;
				for(k = j + 1; k <= n; k++){
					N[3] = k;
				
					if( N[1] + N[2] + N[3] == x){
						c++;
						}
			
				}
			}
		}
		a[m] = c;
		m++;
		scanf("%d %d", &n, &x);
	}
	for( i = 1; i < m; i++){
		printf("%d\n", a[i]);
	}
	return 0;
}

Measured memory_bytes: 1776
N = int(input())
H = list(map(int,input().split()))
flg = 0
ans = "Yes"

for i in range(N-1):
  if H[i]-H[i+1] > 1:
    ans = "No"
    break
  elif H[i]-H[i+1] == 1 and flg == 0:
    flg = 1
  elif H[i]-H[i+1] == 1 and flg == 1:
    ans = "No"
    break
  elif H[i]-H[i+1] == 0:
    continue
  else:
    flg = 0
    continue

print(ans)

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

int main()
{
ll h , w , k ;
cin >> h >> w >> k ;
vector<vector<ll>> v(h, vector<ll>(w,0) );
rep(i,h*w){
  char a ;
  cin >> a ;
  v[i/w][i%w]=a-'0';
}
rep(i,1LL<<(h-1)){
  ll an=0;
  ll ta=0;
  an+=__builtin_popcountll(i);
  vector<ll> a(an+1,0);

  rep(j,w){
    vector<ll> b(an+1,0);
    ll itr=0;

    rep(l,h){
      b[itr]+=v[l][j];
      if(i>>l&1LL)itr++;
    }

    bool ok=1;

    rep(l,an+1){
      if(a[l]+b[l]<=k)a[l]+=b[l];
      else ok=0;
    }

    if(ok==0){
      ta++;
      rep(l,an+1)a[l]=b[l];
    }
  }
  bool ook=1;
  for(auto r:a)if(r>k)ook=0;
  if(ook)ans=min(ans,an+ta);
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

int main() {
	double r;
	cin >> r;
	double pai = 3.141592653589;
	cout << fixed << setprecision(6);
	cout << r * r * pai << " " << 2 * r * pai;

	return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000007
ll c[1000000];
ll c1[1000000];
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result

    x = x % p; // Update x if it is more than or
               // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1ll)
            res = (res * x) % p;

        // y must be even now
        y = y >> 1ll; // y = y/2
        x = (x * x) % p;
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    c[0] = 1;
    for (ll i = 1; i <= 1000000; i++)
    {
        c[i] = c[i - 1] * i;
        c[i] %= MOD;
    }
    c1[0] = 1;
    for (ll i = 1; i <= 1000000; i++)
    {
        c1[i] = c1[i - 1] * power(i, MOD - 2ll, MOD);
        c1[i] %= MOD;
    }
    for (ll i = 0; i <= x; i++)
    {
        if ((x - i) % 2 == 0)
        {
            ll j = (x - i) / 2;
            if (y == 2 * i + j)
            {
                ans += ((c[i + j] * c1[i]) % MOD) * c1[j];
                ans %= MOD;
            }
        }
    }
    cout << ans % MOD << endl;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;

  string weeks[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

  for(int i = 0; i < 7; i++){
    if(weeks[i] == S){
      cout << 7 - i << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    int n;
    cin >> n;
    int mn = INF;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int val;
        cin >> val;
        if (val < mn) {
            mn = val;
            ans++;
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int n;
const int N = 100010;
vector<P> G[N];

vector<bool> seen(N);
vector<int> Color(N); // 1, 2

void dfs(int now, int pre, int cl){ // color
    Color[now] = cl;
    for(int i = 0; i < G[now].size(); i++){
        P p = G[now][i];
        int to = p.first;
        int cost = p.second;
        if(to == pre) continue;
        if(cost % 2 == 0) dfs(to, now, cl);
        else dfs(to, now, (cl == 1 ? 0 : 1));
    }
}

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

    cin >> n;
    for(int i = 0; i < n - 1; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }

    seen.reserve(n);
    Color.resize(n);

    dfs(0, -1, 0);

    for(int i = 0; i < n; i++){
        cout << Color[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 9216
#include <stdio.h>
int main()
{ 
    char W[11], Ti[30]; 
    int i, count=0; 
 
    scanf("%s", W); 
    while(1)
    { 
        scanf(" %s", Ti); 
        if(strcmp(Ti, "END_OF_TEXT") == 0)
        {
        break; 
        }
 
        for(i = 0; Ti[i] != '\0'; i++)
        { 
            Ti[i] = tolower(Ti[i]); 
        } 
         
        if(strcmp(Ti, W) == 0)
        { 
            count++; 
        } 
    } 
 
    printf("%d\n", count); 
    return 0; 
} 


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

typedef long long ll;
#define MOD = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class K, class V> void cout_v(map<K, V>& m)
{ for(auto it=m.begin();it!=m.end();it++)cout<<it->first<<":"<<it->second<<endl;}
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
template<class T> inline bool is_overlap(const T& a, const T& b, const T& p, const T& q)
{ return p <=b && a <= q; }
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    vector<int> L(N*2); cin >> L;

    int ans = 0;
    sort(ALL(L));
    rep(i, L.size()) {
        if (i%2==0)
            ans += L[i];
    }

    cout << ans << endl;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(ll i = (k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;
long long powm(long long a, long long b, long long mod=1000000007){
    if(b<0) b+=mod-1;
    if(b>0){
        if(b%2==1) return a*powm(a*a%mod,b/2)%mod;
        else return powm(a*a%mod,b/2)%mod;
    }else{
        return 1;
    }
}


void exptb(long long a, long long mod, vector<long long> &tb){
    tb[0]=1;
    for(long long i=1;i<tb.size();i++){
        tb[i]=tb[i-1]*a%mod;
    }
}
ll mod = 1e10;
int main(){
    string s,t;
    cin>>s>>t;
    int n = s.size(),ans=0;
    rep(i,n) if(s[i]!=t[i]) ans++;
    cout<<ans<<endl;
    return 0;
}

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


int main() {
  int X,Y,Z,a;
  cin >> X >> Y >> Z;
  a = X;
  X = Y;
  Y = a;
  
  a = X;
  X = Z;
  Z = a;
  
  cout << X << " ";
  cout << Y << " ";
  cout << Z << endl;
 
}
        

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n = ri()
s = rs()
print(s.count('ABC'))

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

#define int long long

int h, w;
vector<string> s;
vector< vector<bool> > done;
int ans = 0;

void dfs(int y, int x, int &black, int &white){
    done[y][x] = true;
    if(s[y][x] == '.'){
        ans += black;
        ++white;
    }else{
        ans += white;
        ++black;
    }
    rep(i, 4){
        int ny = y + dy4[i], nx = x + dx4[i];
        if(0 <= ny && ny < h && 0 <= nx && nx < w && !done[ny][nx] && s[y][x] != s[ny][nx]){
            dfs(ny, nx, black, white);
        }
    }
    return;
}

signed main(){
    cin >> h >> w;
    s.resize(h);
    rep(i, h){
        cin >> s[i];
    }
    done.resize(h);
    rep(i, h){
        done[i].resize(w, false);
    }
    rep(i, h){
        rep(j, w){
            if(!done[i][j] && s[i][j] == '#'){
                int black = 0, white = 0;
                dfs(i, j, black, white);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18048
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func binarySearch(_ inputArray: [Int], _ searchItem: Int) -> Int {
    if inputArray[inputArray.count - 1] < searchItem {
      return inputArray.count
    }
  
    var lowerIndex = 0
    var upperIndex = inputArray.count
    
    while true {
        let currentIndex = (lowerIndex + upperIndex) / 2
        
        if inputArray[currentIndex] == searchItem {
            return currentIndex
        }
        if lowerIndex == currentIndex {
            if inputArray[upperIndex] == searchItem {
                return upperIndex
            } else {
                return currentIndex
            }
        }
        
        if inputArray[currentIndex] > searchItem {
            upperIndex = currentIndex
        } else {
            lowerIndex = currentIndex
        }
    }
}

func main() {
    let line = readInts()
    // let n = line[0]
    // let m = line[1]
    let k = line[2]
    let a_tachi = readInts()
    let b_tachi = readInts()
    
    var a_acc: [Int] = [0]
    var b_acc: [Int] = [0]
    
    for i in 1...a_tachi.count {
        a_acc.append(a_acc[i - 1] + a_tachi[i - 1])
    }
    
    for j in 1...b_tachi.count {
        b_acc.append(b_acc[j - 1] + b_tachi[j - 1])
    }
    
    var ans = 0
    for j in 0...b_tachi.count {
        if b_acc[j] > k {
            break
        }
        let bookCount = j + binarySearch(a_acc, k - b_acc[j])
        if ans < bookCount {
            ans = bookCount
        }
    }
    
    print(ans)
}

main()


Measured memory_bytes: 26408
h,w = map(int,input().split())

def solve(tate,yoko):
    a_min = 100000000000
    if tate % 3 == 0 or yoko % 3 == 0:
        return 0
    for i in range(1,tate+1):
        s1 = i * yoko
        s2 = (tate - i) * (yoko // 2)
        s3 = (tate - i) * (yoko // 2 + yoko % 2)
        ans1 = max(s1,s2,s3) - min(s1,s2,s3)  
        
        t1 = i * yoko
        t2 = yoko * ((tate - i) // 2)
        t3 = yoko * ((tate - i) // 2 + (tate - i) % 2)
        ans2 = max(t1,t2,t3) - min(t1,t2,t3)
        
        ans = min(ans1,ans2)
        
        if a_min > ans :
            a_min = ans
    
    return a_min 
    
print(min(solve(h,w),solve(w,h)))

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

using namespace std;

int main()
{
  int l;
  cin >> l;
  float x = l * 1.0 / 3.0;
  cout << fixed << setprecision(10) << (float)pow(x, 3.0);

  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{int N ; int K;cin >> N >> K;
 char S[N]; cin >> S;
 
 if( S[K - 1] == 'A'){ S[K - 1] = 'a';}
 if( S[K - 1] == 'B'){ S[K - 1] = 'b';}
 if( S[K - 1] == 'C'){ S[K - 1] = 'c';}
 
 for( int i = 0; i < N; i++){
   cout << S[i];}
 
 return 0;
}

Measured memory_bytes: 256
// DP F

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

void dump(const vector<pair<int, int>>& a)
{
  for (auto v : a) {
    cerr << v.first << " " << v.second << endl;
  }
}

void dump(const vector<int>& a)
{
  for (auto v : a) {
    cerr << v << " ";
  }
  cerr << endl;
}


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

  vector<int> a(n, 0);
  rep(i, n) {
    ll b;
    cin >> b;
    a[b-1] += 1;
  }

  sort(a.begin(), a.end(), greater<int>());
  int i = 0;
  for (i = 0; i < n; i++) {
    if (a[i] == 0) {
      break;
    }
  }

  a.resize(i);

  sort(a.begin(), a.end());
  int changeNum = a.size() - k;
  int ans = 0;
  rep(j, changeNum) {
    ans += a[j];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main() {
    int f=0, s=0, t=0, n, i;

    for (i=0; i<10; i++){
        scanf("%d", &n);
        if(f<n){
            t = s;
            s = f;
            f = n;
        }else if(s<n){
            t = s;
            s = n;
        }else if(t<n){
            t = n;
        }
     }
     printf("%d\n%d\n%d\n", f, s, t);
     return 0;
}
   

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

int main() {
	long long int n;
	while (cin >> n, n) {
		long long int total = -n;
		for (long long int i = 1; i * i <= n; i++) {
			if (n % i == 0) {
				total += i + n / i;
				if (i == n / i) {
					total -= i;
				}
			}
		}
		if (total < n) {
			cout << "deficient number" << endl;;
		}
		else if (total > n) {
			cout << "abundant number" << endl;
		}
		else {
			cout << "perfect number" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll a1 = a * c;
  ll a2 = a * d;
  ll a3 = b * c;
  ll a4 = b * d;
  cout << max({a1, a2, a3, a4}) << endl;
  return 0;
}


Measured memory_bytes: 3632
///****In the name of ALLAH, most Gracious, most Compassionate****//

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

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

#define ALL(a) a.begin(), a.end()
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)

#define DBG(a) cerr<< "line "<<__LINE__ <<" : "<< #a <<" --> "<<(a)<<endl
#define NL cout<<endl

template < class T1,class T2>
ostream &operator <<(ostream &os,const pair < T1,T2 > &p)
{
    os<<"{"<<p.first<<","<<p.second<<"}";
    return os;
}

const int N=3e5+5;
const int oo=1e9+7;
ll val[102];
ll cnt[100][100];

pair <ll ,ll > inp()
{
    string s;
    cin>>s;
    ll a = 0;
    ll b= 1;
    bool paisi = 0;
    for(char c: s)
    {
        if(c=='.')
            paisi = 1;
        else
        {
            c-='0';
            a =a * 10 + c;
            if(paisi )
                b*=10;
        }
    }
    ll g= __gcd(a,b);
    a/=g;
    b/=g;
    return {a,b};
}

int32_t main()
{
    FastIO;
    int n;
    cin>>n;
    unordered_map<int ,int > idx;
    for(int i=0;i<100;i++)
    {
        int x = i/10;
        int y = i%10;

        val[i]= 1;
        while(x--)  val[i]*=2;
        while(y--)  val[i]*=5;

        idx[val[i]] = i;
//        cout<<val[i]<<" ";


    }
//    NL;

    for(int i=0;i<n;i++)
    {
        pair<ll,ll> x = inp();
//        DBG(x);

        ll a=x.first;
        ll b = x.second;

        assert(idx.find(b)!=idx.end());

        b=idx[b];
        for(int j=0;j<100;j++)
            if(a%val[j] == 0)
                cnt[b][j]++;
    }
    ll ans = 0;
    for(int i=0;i<100;i++)
    {
        for(int j=i+1;j<100;j++)
        {
            ans+=cnt[j][i] * cnt[i][j];

        }
        ans+= cnt[i][i] * (cnt[i][i] -1)/2;
    }
    cout<<ans<<"\n";

}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int h, w;
vector<string> g;

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

// return: 最大距離
int bfs(int start_y, int start_x) {
    mat dist(h, vec(w, INF));
    dist[start_y][start_x] = 0;

    queue<P> que;
    que.push(make_pair(start_y, start_x));

    while (!que.empty()) {
        auto pos = que.front();
        que.pop();

        rep(i, 4) {
            int ty = pos.first + dy[i];
            int tx = pos.second + dx[i];
            if (ty >= 0 && ty < h && tx >= 0 && tx < w) {
                if (g[ty][tx] == '.' && dist[ty][tx] == INF) {
                    dist[ty][tx] = dist[pos.first][pos.second] + 1;
                    que.push(make_pair(ty, tx));
                }
            }
        }
    }

    int res = -1;

    rep(i, h) rep(j, w) if (dist[i][j] != INF) res = max(res, dist[i][j]);

    return res;
}

int main() {
    cin >> h >> w;
    g.resize(h);
    rep(i, h) cin >> g[i];

    int res = -1;

    rep(i, h) rep(j, w) {
        if (g[i][j] == '.') {
            res = max(res, bfs(i, j));
        }
    }

    cout << res << endl;
    return 0;
}

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

int main() {
  double N,X;
  cin >> N ;

 X = floor(N/1.08);
 
 if(floor(X*1.08) == N){
cout << X << endl;
}else if(floor((X+1)*1.08) == N){
cout <<X+1 << endl;
}else{
  cout << ":(" << endl;
}
}


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

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("b.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n;
    cin >> n;

    vector<int> p(n);
    rep (i, n) cin >> p[i];

    int ans = 0;
    for (int i = 0; i < p.size() - 2; i++)
    {
        if ((p[i] < p[i+1] && p[i+1] < p[i+2])
            || (p[i] > p[i+1] && p[i+1] > p[i+2]))
        {
            ans++;
        }
    }

    cout << ans;

    return 0;
}


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

int gcd(int x, int y)
{
    if(x % y == 0)
    {
        return y;
    }
    int z = gcd(y, x % y);
    return z;
}

int main()
{
    int n, sum = 0;
    cin >> n;

    for(int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            int l = gcd(i, j);
            for (int k = 1; k <= n; k++)
            {
                sum += gcd(l, k);
            }
        }
    }
    cout << sum <<endl;
}

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

using namespace std;
const int MAX = 1e5+10;


int64_t A[MAX], B[MAX], v[MAX], x[MAX];
int main(){
    int N; cin >> N;
    int64_t C; cin >> C;
    for(int i=1;i<=N;i++){
        cin >> x[i] >> v[i];
        A[i] = A[i-1] + x[i-1] - x[i] + v[i];
    }
    x[N+1] = C;
    for(int i=N;i>=1;i--){
        B[i] = B[i+1] - x[i+1] + x[i] + v[i];
    }
    for(int i=2;i<=N;i++){
        A[i] = max(A[i], A[i-1]);
    }
    for(int i=N-1;i>=1;i--){
        B[i] = max(B[i], B[i+1]);
    }
    int64_t ans = 0;
    for(int i=1;i<=N;i++){
        ans = max(ans, max(A[i], B[i]));
        ans = max(ans, max(A[i] - x[i] + B[i+1], B[i] - (C-x[i]) + A[i-1]));
    }
    cout << ans << endl;
    return 0;
}

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

int main(int argc, const char * argv[]) {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    string t;

    cin >> s >> t;

    cout << t << s;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

void run (void) {
  i64 w, h, x, y;
  scanf ("%" SCNi64 "%" SCNi64 "%" SCNi64 "%" SCNi64, &w, &h, &x, &y);
  double ans = (double) w * h / 2;
  printf ("%.9f %" PRIi32 "\n", ans, 2 * x == w && 2 * y == h ? 1 : 0);
  return;
}

int main (void) {
  run();
  return 0;
}

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

typedef long double ldb;

const int maxn = 3001;

ldb p[maxn], dp[3001][3001];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(11);

    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> p[i];
    dp[1][1] = p[1];
    dp[0][1] = 1-p[1];
    for(int j = 2; j <= n; j++){
        dp[0][j] = dp[0][j-1]*(ldb)(1-p[j]);
        for(int i = 1; i <= n; i++)
            dp[i][j] = dp[i][j-1]*(ldb)(1-p[j])+dp[i-1][j-1]*(ldb)p[j];
    }

    ldb ans = 0;
    for(int i = n; i > n-i; i--)
        ans += dp[i][n];
    cout << ans;

    return 0;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

const int MAX_N = 200000;
int n;
ll k;
ll a[MAX_N];
ll f[MAX_N];

bool check(ll m) {
  ll c = 0;
  forn(i,n) {
    if (a[i] * f[i] > m) {
      c += a[i] - m / f[i];
    }
  }
  return c <= k;
}

int main()
{
  fastio();

  cin >> n >> k;
  forn(i,n) cin >> a[i];
  forn(i,n) cin >> f[i];

  sort(a,a+n,greater<ll>());
  sort(f,f+n);

  ll l = -1, r = TEN(12);
  while (r - l > 1) {
    ll m = (l + r) / 2;
    if (check(m)) {
      r = m;
    } else {
      l = m;
    }
  }

  cout << r << endl;

  return 0;
}


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

int N,total;

int main() {
    cin >>N;
    for(int i=1; i<=N; i++){
        for(int j=1; j<=N; j++){
            for(int k=1; k<=N; k++){
                total++;
                
            }
        }
    }
    cout<<total<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
    int n; cin >> n;
    bool f = 0;
    for (int i = 0; i <= n / 4; ++i)for (int j = 0; j <= n / 7; ++j) {
        if (4 * i + 7 * j == n) { f = 1; break; }
    }
    cout << (f ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <string>
#include <unordered_map>
using namespace std;
const int mod=1e9+7;
const int MXN=1e6+5;
string tab;
int n;
long long h1,hasz[MXN],x=41,pot[MXN],spec;
bool odw[MXN];
char lewo[MXN],prawo[MXN];
int skok[MXN],skokt[MXN];
unordered_map<long long,int>mapsko;
inline long long pot_szybkie(long long a,long long n){
    long long w=1;
    while(n>0){
        if (n%2==1)w=(w%mod*a)%mod;
        a%=mod;
        a=(a*a)%mod;
        n/=2;
    }
    return w%mod;
}
inline bool rek(int gleb,long long haszek,int pomoc,int ile,int pocz,int koncz){
    if(mapsko[haszek]==2){
        printf("TAK\n");
        exit(0);
    }
    if(mapsko[haszek]==1)return 0;
    if(ile==0||pomoc==1){
        if(gleb%2==0){
            mapsko[haszek]=2;
            printf("TAK\n");
            exit(0);
        }
        mapsko[haszek]=1;
        return 0;
    }
    int zl=0;
    int h=koncz;
    long long h2=0,h3=0;
    char ob=tab[n-1];
    while(skokt[h]>=0){
        if(odw[h]==0){
            //   printf("%c",tab[h]);
            prawo[h]=ob;
            ob=tab[h];
        }
        h=skokt[h];
    }
    //  printf("\n");
    ob=tab[0];
    h=pocz;
    while(skok[h]<n){
        if(odw[h]==0){
            lewo[h]=ob;
            ob=tab[h];
        }
        h=skok[h];
    }
    long long xd=1;
    int cos=0;
    h=koncz;
    while(skokt[h]>=0){
        if(odw[h]==0){
            h3=(h3+xd*(tab[h]-'a'+1))%mod;
            xd=(xd*x)%mod;
            cos++;
        }
        h=skokt[h];
    }
    bool ok=0;
    h=pocz;
    while(skok[h]<n){
        if(odw[h]==0){
            h2=(h2*x+(tab[h]-'a'+1))%mod;
            h3=h3-(tab[h]-'a'+1)*pot[--cos];
            while(h3<0)h3+=mod;
        }
        if(prawo[h]!=lewo[h]&&odw[h]==0){
            odw[h]=1;
            long long pom=(h2*pot_szybkie(x,mod-2)+h3)%mod;
            ok=1;
            int popek=skokt[h];
            int wpr=skok[h],wle=skokt[h];
            skok[popek]=wpr;
            skokt[wpr]=wle;
            rek(gleb+1,pom,0,ile-1,pocz,koncz);
            skok[popek]=h;
            skokt[wpr]=h;
            odw[h]=0;
        }
        h=skok[h];
    }
    if(ok==0)rek(gleb,haszek,1,ile,pocz,koncz);
    return 0;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>tab;
    n=tab.size();
    if(n<=2){
        printf("Second\n");
        return 0;
    }
    if(n%2==0){
        if(tab[0]==tab[n-1]){
            printf("First\n");
            return 0;
        }
        printf("Second\n");return 0;
    }
    if(n%2==1){
        if(tab[0]==tab[n-1]){
            printf("Second\n");
            return 0;
        }
        printf("First\n");return 0;
    }
    pot[0]=1;
    for(int i=0;i<n;i++){
        skok[i]=i+1;
    }
    for(int i=n-1;i>=0;i--){
        skokt[i]=i-1;
    }
    for(int i=1;i<=n;i++){
        pot[i]=(pot[i-1]*x)%mod;
    }
    for(int i=1;i<n-1;i++){
        h1=(h1*x+(tab[i]-'a'+1))%mod;
    }
    if(rek(1,h1,0,n-2,1,n-2)==1)printf("First\n");
    else printf("Second\n");
    return 0;
}
 

Measured memory_bytes: 512
def main():
  s=input()
  t=input()
  ls=len(s)
  lt=len(t)
  r=0
  if ls==lt:
    for i in range(ls):
      if s[i]==t[i]:
        r+=1
    print(lt-r)
    exit()
  st= [ [ 0 for y in range(ls ) ] for x in range( lt ) ]
  for si in range(ls):
    for ti in range(lt):
      if s[si]==t[ti]:
        st[ti][si]=1
  r=0
  for si in range(ls-lt):
    rt=0
    for ti in range(lt):
      rt+=st[ti][(si+ti)]
    if r<rt:
      r=rt
  print(lt-r)
main()

Measured memory_bytes: 14388
#include <iostream>
using namespace std;
enum {LE = -1, EQ = 0, GE = 1};
int A[100000 + 1];
int main() {
  int N; scanf("%d", &N);
  int total{1}, flag{EQ};
  if (N <= 2) {
    goto END;
  }
  scanf("%d", &A[0]);
  for (size_t i{1}; i < N; ++i) {
    scanf("%d", &A[i]);
    if (A[i] < A[i - 1]) {
      if (flag == GE) {
        ++total;
        flag = EQ;
        continue;
      }
      flag = LE;
    } else if (A[i] > A[i - 1]) {
      if (flag == LE) {
        ++total;
        flag =EQ;
        continue;
      }
      flag = GE;
    }
  }

  END:
  cout << total << "\n";
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int n,k;
    cin >> n >> k;
    cout  << k * powmod((k - 1), n - 1);
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<deque>
#include<array>


#define REP(i,a,b) for(int i = (a); i < b; ++i)
#define inf 1e9+10
#define MOD 1000000007

using ll = long long;
using ull = unsigned long long;
using namespace std;

inline ll modpow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

inline ll mod(ll val, ll m) {
	ll res = val % m;
	if (res < 0) res += m;
	return res;
}


int main() {
	int n;

	cin >> n;

	vector<pair<int, int>> d(n);

	REP(i, 0, n) {
		int a, b;
		cin >> a >> b;
		d[i].first = a;
		d[i].second = b;
	}

	int count = 0;

	REP(i, 0, n) {
		if (count == 3) {
			cout << "Yes";
			return 0;
		}
		else {
			if (d[i].first == d[i].second) {
				count++;
			}
			else {
				count = 0;
			}
		}
	}

	if (count == 3) {
		cout << "Yes";
		return 0;
	}

	cout << "No";

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

string s;

int main(){
  cin >> s;
  if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad" << endl;
  else cout << "Good" << endl;
}


Measured memory_bytes: 764
N = int(input())
a = list(map(int, input().split()))
a = sorted(a)

a1, a2, a3 = [], [], []
for i in range(N):
    a1.append(a[i])
    a3.append(a[-(2*i+1)])
    a2.append(a[-(2*i+2)])

print(sum(a2))

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int A, B, C, X;
	cin >>A >>B >>C >>X;
	int S=0;
	for (int i=0; i<=A; i++) {
		int XX=X-i*500;
		for (int j=0; j<=B; j++) {
			int XXX=XX-j*100;
			for (int k=0; k<=C; k++)
				if (0==XXX-k*50)
					S++;
		}
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int A,B,C; cin >> A >> B >> C;
    if(A+B>=C){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int         long long
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
using namespace std;

signed main(){
    tezz   
    
    int n;
    cin >> n;
    if(n%2==1){
        cout << 0 << endl;
        return 0;
    }
    int c=0;
    for(int i=1; i<35; i++){
        c+=(n/(int)pow(5,i))/10;
    }
    c+=n/10;
    cout << c << endl;
    
    return 0;
}   


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int N;
    cin >> N;
    vi X(N), Y(N);
    rep(i, N) {
        cin >> X[i] >> Y[i];
        if (abs(X[0] + Y[0]) % 2 != abs(X[i] + Y[i]) % 2) {
            cout << -1 << endl;
            return;
        }
    }

    vll D;
    for (int i = 32; i >= 0; --i) {
        D.push_back(1ll<<i);
    }
    if ((X[0] + Y[0]) % 2 == 0)D.push_back(1);
    cout << sz(D) << endl;
    rep(i, sz(D)) {
        cout << D[i] << (i != sz(D) - 1 ? ' ' : '\n');
    }
    
    rep(i, N) {
        ll x = X[i], y = Y[i];
        string s;
        each(d, D) {
            if (abs(x) >= abs(y)) {
                if (x <= 0) {
                    x += d;
                    s += 'L';
                } else {
                    x -= d;
                    s += 'R';
                }
            } else {
                if (y <= 0) {
                    y += d;
                    s += 'D';
                } else {
                    y -= d;
                    s += 'U';
                }
            }
        }
        assert(x == 0 && y == 0);
        cout << s << endl;
    }

}

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

Measured memory_bytes: 256