akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int, int>P;

int s[1000], d[1000], t[1000][1000], y[1000];
P p[100001];
int main() {
	int n, m, h, k;
	while (scanf("%d%d%d%d", &n, &m, &h, &k), n) {
		rep(i, n)scanf("%d", &s[i]), d[i] = t[0][i] = i;
		rep(i, m) {
			int a, b; scanf("%d%d", &a, &b); p[i] = P(b, a);
		}
		sort(p, p + m);
		int u = 0;
		for (int i = 1; i < h; i++) {
			while (p[u].first == i)swap(d[p[u].second - 1], d[p[u].second]), u++;
			rep(j, n)t[i][j] = d[j];
		}
		rep(i, n)y[d[i]] = i;
		int Min = 0; rep(i, n)if (d[i] < k)Min += s[i];
		rep(i, m) {
			int c = p[i].first - 1, e = p[i].second;
			int a = y[t[c][e - 1]], b = y[t[c][e]];
			swap(d[a], d[b]);
			int sum = 0;
			rep(i, n)if (d[i] < k)sum += s[i];
			Min = min(Min, sum);
			swap(d[a], d[b]);
		}
		printf("%d\n", Min);
	}
}

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

int main(void) {
	char sA[100], sB[100], sC[100];
	scanf("%s", &sA);
	scanf("%s", &sB);
	scanf("%s", &sC);
	int lenA = strlen(sA), lenB = strlen(sB), lenC = strlen(sC);
	int a = 1, b=0, c = 0;
	char next = sA[0];

	while (1)
	{
		if (next == 'a') {
			if (lenA == a) {
				printf("A");
				return 0;
			}
			next = sA[a];
			++a;
		}
		else if (next == 'b') {
			if (lenB == b) {
				printf("B");
				return 0;
			}
			next = sB[b];
			++b;
		}
		else
		{
			if (lenC == c) {
				printf("C");
				return  0;
			}
			next = sC[c];
			++c;
		}
	}


	return 0;
}

Measured memory_bytes: 128
#%%
s = list(input())
ans = 0
l_count, r_count = 0, 0
l, r = 0, 0
last = ''


for i in range(len(s)):
    if last == '>' and s[i] == '<':
        if l >= r:
            ans += l + r - r_count
        else:
            ans += l + r - l_count
        l_count = 0
        r_count = 1
        l = 0
        r = 1
    else:
        if s[i] == '>':
            l_count += 1
            l += l_count
        else:
            r_count += 1
            r += r_count
    last = s[i]
    #print(i, ans)

if l >= r:
    ans += l + r - r_count
else:
    ans += l + r - l_count

print(ans)

#%%


Measured memory_bytes: 7964
from operator import mul
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")

MOD = 998244353
class Combination(object):
    def __init__(self, N, MOD):
        self.fac = [0] * (N + 1)
        self.inv = [0] * (N + 1)
        self.finv = [0] * (N + 1)
        self.fac[0] = 1
        self.finv[0] = 1
        if N > 0:
            self.fac[1] = 1
            self.inv[1] = 1
            self.finv[1] = 1
 
        # 前計算
        for i in range(2, N + 1):
            self.fac[i] = self.fac[i - 1] * i % MOD
            self.inv[i] = self.inv[MOD % i] * (MOD - (MOD // i)) % MOD
            self.finv[i] = self.finv[i - 1] * self.inv[i] % MOD
 
    def com(self, N, k):
        return (self.fac[N] * self.finv[k] * self.finv[N - k]) % MOD


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

    Com = Combination(N-1, MOD)
    ans = 0
    for k in range(K+1):
        ans += M * pow(M-1, N-k-1, MOD) * Com.com(N-1, k)
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 77968
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
typedef pair<int,int>pii;
#define fi first
#define se second
const int MN=1e6+5;
int n,lt[MN],rt[MN],a[MN],b[MN];
char S[MN];
pii A[MN],B[MN];
int main(){
	scanf("%d",&n);
	for(reg int i=1;i<=n;i++){
		scanf("%s",S+rt[i-1]+1);
		lt[i]=rt[i-1]+1;rt[i]=strlen(S+lt[i])+lt[i]-1;
	}
	reg int tot1=0,tot2=0;
	for(reg int i=1;i<=n;i++){
		reg int tot=0;
		for(reg int j=lt[i];j<=rt[i];j++){
			tot+=(S[j]=='('?1:-1);
			a[i]=min(a[i],tot);
		}
		a[i]=-a[i];b[i]=tot+a[i];
		if(a[i]<=b[i])A[++tot1]=make_pair(a[i],b[i]);
		else B[++tot2]=make_pair(a[i],b[i]);
	}
	sort(A+1,A+1+tot1,[](pii a,pii b){
		return a.fi<b.fi;
	});
	reg int res=0;
	for(reg int i=1;i<=tot1;i++){
		if(res<A[i].fi)return 0*puts("No");
		res+=A[i].se-A[i].fi;
	}
	sort(B+1,B+1+tot2,[](pii a,pii b){
		return a.se>b.se;
	});
	for(reg int i=1;i<=tot2;i++){
		if(res<B[i].fi)return 0*puts("No");
		res+=B[i].se-B[i].fi;
	}
	if(res)puts("No");
	else puts("Yes");
	return 0;
}

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

void Main(){
    
}

int main() {
	int w,h,x,y,r;cin>>w>>h>>x>>y>>r;
	if(x+r<=w&&x-r>=0&&y+r<=h&&y-r>=0){
		puts("Yes");
	}
	else puts("No");
}


Measured memory_bytes: 3084
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000007
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

bool is_prime(ll N)
{
    if (N <= 1)
        return false;
    for (ll i = 2; i * i <= N; ++i)
    {
        if (N % i == 0)
            return false;
    }
    return true;
}

int main(void)
{
    int n = 101000;
    vector<ll> cusum(n, 0);
    for (ll i = 1; i < n; i++)
        cusum[i] = cusum[i - 1] + ((1 & i) && is_prime(i) && is_prime((i + 1) / 2));
    ll q;
    cin >> q;
    vector<int> l(q), r(q);
    rep(i, 0, q) cin >> l[i] >> r[i];
    rep(i, 0, q)
    {
        cout << cusum[r[i]] - cusum[l[i] - 1] << endl;
    }
    return 0;
}

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

int main(){
    int S;
    cin >> S;
    int D = S % 10,C = S % 100 /10,B = S % 1000 / 100,A = S / 1000;
    int ans = 0;
    if(A+B+C+D == 7){
        cout << A << '+' << B<<'+' << C << '+' << D << '=' << 7;
        return 0;
    }
    if(A+B+C-D == 7){
        cout << A << '+' << B<< '+' << C << '-' << D << '=' << 7;
        return 0;
    }
    if(A+B-C-D == 7){
        cout << A << '+' << B<< '-' << C << '-' << D << '=' << 7;
        return 0;
    }
    if(A+B-C+D == 7){
        cout << A << '+' << B <<'-' << C << '+' << D << '=' << 7;
        return 0;
    }
    if(A-B+C+D == 7){
        cout << A << '-' << B <<'+' << C << '+' << D << '=' << 7;
        return 0;
    }
    if(A-B+C-D == 7){
        cout << A << '-' << B <<'+' << C << '-' << D << '=' << 7;
        return 0;
    }
    if(A-B-C-D == 7){
        cout << A << '-' << B <<'-' << C << '-' << D << '=' << 7;
        return 0;
    }
    if(A-B-C+D == 7){
        cout << A << '-' << B <<'-' << C << '+' << D << '=' << 7;
        return 0;
    }
    cout << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a_b = [list(map(int, input().split())) for _ in range(n)]
c_d = [list(map(int, input().split())) for _ in range(m)]
ans = []
for i in range(n):
    ans_sub = []
    for j in range(m):
        ans_sub.append(abs(a_b[i][0]-c_d[j][0]) + abs(a_b[i][1]-c_d[j][1]))
    ans.append(ans_sub.index(min(ans_sub)) + 1)
for i in range(n):
    print(ans[i])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
using namespace std;

typedef long long ll;

const ll INF = (ll)(1e+18);
int N;
ll sum1, sum3;
vector<int> a1, a2, a3;
vector<ll> max_a1, min_a3;
priority_queue<int, vector<int>, greater<int> > aq1;
priority_queue<int> aq3;

int main(void) {
	cin >> N;
	a1.resize(N);
	a2.resize(N);
	a3.resize(N);
	sum1 = 0LL;
	for (int i = 0; i < N; ++i) {
		cin >> a1[i];
		sum1 += a1[i];
		aq1.push(a1[i]);
	}
	for (int i = 0; i < N; ++i)
		cin >> a2[i];
	sum3 = 0LL;
	for (int i = 0; i < N; ++i) {
		cin >> a3[i];
		sum3 += a3[i];
		aq3.push(a3[i]);
	}
	max_a1.resize(N + 1);
	max_a1[0] = sum1;
	for (int i = 0; i < N; ++i) {
		int top = aq1.top();
		if (a2[i] > top) {
			aq1.pop();
			sum1 = sum1 - top + a2[i];
			aq1.push(a2[i]);
		}
		max_a1[i + 1] = sum1;
	}
	min_a3.resize(N + 1);
	min_a3[0] = sum3;
	for (int i = N - 1; i >= 0; --i) {
		int top = aq3.top();
		if (a2[i] < top) {
			aq3.pop();
			sum3 = sum3 - top + a2[i];
			aq3.push(a2[i]);
		}
		min_a3[N - i] = sum3;
	}
	ll ans = -INF;
	for (int i = 0; i <= N; ++i) {
		if (max_a1[i] - min_a3[N - i] > ans)
			ans = max_a1[i] - min_a3[N - i];
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3960
n = int(input())

countA = 0
countW = 0
countT = 0
countR = 0
for i in range(n):
  a = input()
  if a == "AC":
    countA += 1
  elif a == "WA":
    countW += 1
  elif a == "TLE":
    countT += 1
  elif a == "RE":
    countR += 1

print("AC x " + str(countA))
print("WA x " + str(countW))
print("TLE x " + str(countT))
print("RE x " + str(countR))
    

Measured memory_bytes: 9048
n = int(input())
d = {}
for i in range(n):
    s = input()
    try:
        d[s] += 1
    except:
        d[s] = 1
m = int(input())
for i in range(m):
    s = input()
    try:
        d[s] -= 1
    except:
        d[s] = -1
ans = 0
for v in d.values():
    ans = max(ans, v)
print(ans)

Measured memory_bytes: 3064
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {s: String};

    let mut count = 0;
    for si in s.chars() {
        if si == '+' {
            count += 1;
        } else {
            count -= 1;
        }
    }

    println!("{}", count)
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a,b;
    cin>>n;
    for (int i=0;i<n;i++) {
        cin>>a>>b;
        if (a<b) {
            for (int j=a;j<b+1;j++) {
                if (j==b) {
                    cout<<j<<endl;
                } else {
                    cout<<j<<" ";
                }
            }
        } else {    //a>b
            if (a<=5&&b<=5) {
                for (int k=a;k>=b;k--) {
                    if (k==b) {
                        cout<<k<<endl;
                    } else {
                        cout<<k<<" ";
                    }
                }
            } else if (b<=5) {
                for (int l=a;l<=9;l++) {
                    cout<<l<<" ";
                }
                for (int m=5;m>=b;m--) {
                    if (m==b) {
                        cout<<m<<endl;
                    } else {
                        cout<<m<<" ";
                    }
                }
            } else {
                for (int p=a;p<=9;p++) {
                    cout<<p<<" ";
                }
                for (int q=5;q>=0;q--) {
                    cout<<q<<" ";
                }
                for (int r=1;r<=b;r++) {
                    if (r==b) {
                        cout<<r<<endl;
                    } else {
                        cout<<r<<" ";
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;}
int main() {

  int N,a=1,b=1,no=0; cin>>N;
  vector<int> A(N),B(N);
  for(int i=0; i<N; i++){
    cin>>A.at(i);}
    for(int i=0; i<N; i++){
    cin>>B.at(i);}
  
no=A.at(0);
for(int i=0; i<N; i++){
  a+=(facctorialMethod(N-i-1) * (no-1));
  A.erase(A.begin());
  no=1;
  for(int j=0; j<N-i-1;j++){
    if(A.at(0)>A.at(j)){no++;}}}
  //cout<<a<<endl;}
no=B.at(0);
for(int i=0; i<N; i++){
  b+=(facctorialMethod(N-i-1) * (no-1));
  B.erase(B.begin());
  no=1;
  for(int j=0; j<N-i-1;j++){
    if(B.at(0)>B.at(j)){no++;}}
 // cout<<b<<endl;}
 // cout<<b<<endl;
 // cout<<a<<endl;
} cout<<max(a,b)-min(a,b)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100001
vector<int> G[N];
vector<ll> a[N], b[N];
ll f[N], len[N], m;
ll s1[N], s2[N] = {0, 1};
void dfs1(int x) {
    G[x].erase(remove(G[x].begin(), G[x].end(), f[x]), G[x].end());
    len[x] = G[x].size() - 1;
    a[x].resize(len[x] + 1), b[x].resize(len[x] + 1);
    ll sa = 1, sb = 1;
    for (int i = 1; i <= len[x]; i++) {
        f[G[x][i]] = x;
        dfs1(G[x][i]);
        a[x][i] = sa = sa * (s1[G[x][i]] + 1) % m;
    }
    for (int i = len[x]; i; i--) b[x][i] = sb = sb * (s1[G[x][i]] + 1) % m;
    s1[x] = sa;
}
void dfs2(int x) {
    for (int i = 1; i <= len[x]; i++) {
        s2[G[x][i]] = s2[x];
        if (i > 1) s2[G[x][i]] = s2[G[x][i]] * a[x][i - 1] % m;
        if (i < len[x]) s2[G[x][i]] = s2[G[x][i]] * b[x][i + 1] % m;
        s2[G[x][i]]++;
        dfs2(G[x][i]);
    }
}
int main() {
    int n;
    scanf("%d%lld", &n, &m);
    for (int i = 1; i <= n; i++) G[i].push_back(-1);
    for (int i = 1, x, y; i < n; i++) {
        scanf("%d%d", &x, &y);
        G[x].push_back(y), G[y].push_back(x);
    }
    dfs1(1), dfs2(1);
    for (int i = 1; i <= n; i++) printf("%lld\n", s1[i] * s2[i] % m);
    return 0;
}


Measured memory_bytes: 26240
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

int dp[2001][2001][2];
int a[2001];
int N;

using namespace std;

int rec(int idx, int enemy, int turn) {
	if (dp[idx][enemy][turn] >= 0) {
		return dp[idx][enemy][turn];
	}
	if (idx == N - 1) {
		int ret = dp[idx][enemy][turn] = abs(a[enemy] - a[N]);
		return ret;
	}

	int ret = 0;
	if (turn) {
		ret = INT_MAX;
	}

	for (int i = idx; i < N - 1; i++) {
		int tmp = rec(i + 1, i + 1, (turn + 1) % 2);
		if (turn) {
			ret = min(ret, tmp);
		} else {
			ret = max(ret, tmp);
		}
	}
	if (turn) {
		ret = min(ret, abs(a[enemy] - a[N]));
	} else {
		ret = max(ret, abs(a[enemy] - a[N]));
	}
	return dp[idx][enemy][turn] = ret;
}

int main() {
	int n, z, w;
	cin >> n >> z >> w;
	N = n;
	a[0] = w;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		a[i + 1] = tmp;
	}
	for (int i = 0; i < 2001; i++) {
		for (int j = 0; j < 2001; j++) {
			dp[i][j][0] = -1;
			dp[i][j][1] = -1;
		}
	}
	int ret = rec(0, 0, 0);
	cout << ret << endl;
	return 0;
}

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

// main.cpp

constexpr std::int_fast64_t f(const std::int_fast64_t x, const std::int_fast64_t y) {
  return x > 0 ? f(x / 10, y * 10 + (x % 10)) : y;
}
constexpr std::int_fast64_t f(const std::int_fast64_t x) {
  return f(x, 0);
}

int main() {
  std::int_fast64_t A, B;
  std::cin >> A >> B;

  std::int_fast64_t answer = 0;
  for (std::int_fast64_t i = A; i <= B; ++i) {
    if (i == f(i)) ++answer;
  }

  std::cout << answer << std::endl;
  return 0;
}

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

typedef pair<int,int> ii;
#define F first
#define S second
#define mp(x,y) make_pair(x,y)


/* start */

char g[10][10], l[10], c[10];

signed main(){
   IOS;
   int n, m, k;
   cin >> n >> m >> k;
   for(int i = 0; i < n; i++) {
      for(int j = 0; j < m; j++) {
         cin >> g[i][j];
      }
   }
   vector<ii> v;
   for(int i = 0; i < n; i++) {
      v.push_back(ii(i, 0));
   }
   for(int i = 0; i < m; i++) {
      v.push_back(ii(i, 1));
   }
   int ans = 0;
   for(int it = 0; it < 1ll<<(n + m); it++) {
      char copy[10][10];
      for(int i = 0; i < n; i++) {
         for(int j = 0; j < m; j++) {
            copy[i][j] = g[i][j];
         }
      }
      for(int i = 0; i < n + m; i++) {
         if(1<<i & it) {
            if(v[i].S == 0) {
               for(int j = 0; j < m; j++) {
                  copy[v[i].F][j] = 'r';
               }
            }
            else {
               for(int j = 0; j < n; j++) {
                  copy[j][v[i].F] = 'r';
               }
            }
         }
      }
      int tmp = 0;
      for(int i = 0; i < n; i++) {
         for(int j = 0; j < m; j++) {
            if(copy[i][j] == '#') tmp++;
         }
      }
      if(tmp == k) ans++;
   }
   cout << ans << "\n";
}

Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int lli;
int main(){
	lli n;
  cin >> n;
  lli arr[5];
  // reading into array
  for (int i = 0; i< 5; i++)
    cin >> arr[i];
  // getting the minimum most element
  lli mini = *min_element(arr, arr+5);
  (n%mini == 0)? cout << n/mini + 4 <<'\n' : cout << n/mini +5 << '\n';

	return 0;
}

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

int main(void) {
    int loop;
    //???????????°??\???
    scanf("%d",&loop);
    int i,scoreA=0,scoreB=0;
    for(i=0;i<loop;i++){
        char word[202],playerA[101],playerB[101];
        //fgets(word,sizeof(word),stdin);
        //playerA=strtok(word," ");
        //playerB=strtok(NULL," ");
        int j;
        scanf("%s %s",&playerA,&playerB);
        for(j=0;j<strlen(playerA);j++){
            if(playerA[j]>playerB[j]){
                scoreA+=3;
                break;
            }else if(playerA[j]<playerB[j]){
                scoreB+=3;
                break;
            }
            if(j==strlen(playerA)-1){
                if(strlen(playerA)>strlen(playerB))scoreA+=3;
                else if(strlen(playerA)<strlen(playerB))scoreB+=3;
            }
        }

        if(strcmp(playerA,playerB)==0){
            scoreA++;
            scoreB++;
        }
        //printf("%d:%s %d:%s %d\n",scoreA,playerA,scoreB,playerB,i);

    }
    printf("%d %d\n",scoreA,scoreB);

	return 0;
}

Measured memory_bytes: 604
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll h, w;
    cin >> h >> w;
    if(h == 1 || w == 1){
        cout << 1 << '\n';
    }else{
        cout << (h * w + 1) / 2 << '\n';
    }
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
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;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S;
    cin >> S;
    int n = S.length();
    ll ans = 0;
    REP(i, n-1){
        if(S[i] != S[i+1]) ans++;
    }
    pr(ans);
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    if (A > 9 || B > 9) {
      System.out.println(-1);
      return;
    }
    System.out.println(A * B);

  }
}


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

int main() {
    map<int, int> m;
    for (int i = 0; i < 3; i++) {
        int n;
        cin >> n;
        m[n]++;
    }
    cout << (m.size() == 2 ? "Yes" : "No") << endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> oprt(100*N,N);
  oprt.at(0) = 0;
  for(int i=0; i<=N; i++){
    oprt.at(i+1) = min(oprt.at(i+1), oprt.at(i)+1);
    for(int j=6; i+j<=N; j*=6){
      oprt.at(i+j) = min(oprt.at(i+j), oprt.at(i)+1);
      for(int k=9; i+k<=N; k*=9){
        oprt.at(i+k) = min(oprt.at(i+k), oprt.at(i)+1);
        oprt.at(i+j+k) = min(oprt.at(i+j+k), oprt.at(i+j)+1);
      }
    }
  }
  cout << oprt.at(N);
  return 0;
}

Measured memory_bytes: 42252
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
// #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;


int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  vector<string> ans(n);
  queue<string> q;

  rep(i,n){
    cin >> s[i];
  } 
  sort(s.begin(),s.end());
  int mx = 0;
  int tmp = 0;
  vector<int> v(n,0);
  for(int i = 1; i < n; i++){
    if(s[i] == s[i-1]){
      v.at(i) = v.at(i-1)+1;
      tmp +=1;
      mx = max(mx,tmp);
    } 
    else{
      tmp = 0;
      v.at(i) = 0;
    }
  }
  rep(i,n){
    if(v.at(i) == mx){
      q.push(s.at(i));
    }
  }
  int ss = q.size();
  rep(i,ss){
    cout << q.front()<< endl; q.pop();
  }


}


Measured memory_bytes: 18304
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <pi, int>
#define vi vector <int>
#define int ll
const ll mod = 1000000007;
int n, a[200020], cnt[200020], ans;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>a[i];
        cnt[a[i]]++;
    }
    for(int i=1; i<=n; i++) ans+=cnt[i]*(cnt[i]-1)/2;
    for(int i=1; i<=n; i++) cout<<ans-cnt[a[i]]+1<<" ";
}


Measured memory_bytes: 4736
//author : Yogi79

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

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int n;
   string s;
   cin>>n;
   cin>>s;

   if(n<3200)
   	cout<<"red";
   else
   	cout<<s;
}

Measured memory_bytes: 256
import Control.Arrow
import Control.Monad
import Data.Bits
import qualified Data.ByteString.Char8 as BC
import Data.Char
import Data.List
import Data.Maybe

main :: IO ()
main = do
  n <- getInt
  print . minimum $ [sum (baseConvert 6 x) + sum (baseConvert 9 (n - x)) | x <- [0..n]]

getInt :: IO Int
getInt = readLn

baseConvert :: Int -> Int -> [Int] -- O(log n)
baseConvert b = unfoldr (\n -> if n == 0 then Nothing else Just (n `mod` b, n `div` b))


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
    b[a[i]-1]++;
  }
  sort(b.begin(),b.end(),greater<int>());
  int sum=0;
  for(int i=0;i<k;i++){
    sum+=b[i];
  }
  cout << n-sum << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N; cin >> N;
  vector<ll> A(N, 0);
  rep(i, N) cin >> A[i];
  map<ll,ll> MP;
  ll ans = 0;
  rep(i, N){
    ans += MP[i-A[i]];
    MP[A[i]+i]++;
  }
  cout<<ans<<endl;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

int N,K;
VI a, dp;

int rec(int n){
    if(dp[n] != -1) return dp[n];
    if(n == 0) return dp[n] = 0;
    if(n < 0) return 1;
    int res = 0;
    REP(i,N){
        if(rec(n-a[i]) == 0) res = 1;
    }
    return dp[n] = res;
}

int main(void){
    cin >> N >> K;
    a.assign(N,0); REP(i,N) cin >> a[i];
    dp.assign(2*K,0); REP(i,2*K) dp[i] = -1;

    REP(i,K){
        if(dp[i] == -1) dp[i] = 0;
        REP(j,N){
            if(dp[i] == 0) dp[i+a[j]] = 1;
            else if(dp[i+a[j]] != 1) dp[i+a[j]] = 0;
        }
    }
    string ans;
    if(dp[K] == 1) ans = "First";
    else ans = "Second";
    cout << ans << en;
    return 0;
}

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

int main(){ 
  int n;
  cin>>n; 
  vector<int> d(n); 
  for(int i=0;i<n;i++){ 
    cin>>d[i]; 
  } 
  int sum=0; 
  for(int i=0;i<n;i++){ 
    for(int j=i+1;j<n;j++){ 
      sum+=d[i]*d[j]; 
    } 
  } 
  cout<<sum;

  return 0; 
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int R;
  cin >> R;
  if(R < 1200){
    cout << "ABC" << endl;
  } else if(R < 2800){
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine();
        HashSet<char> charHash = new HashSet<char>();
        bool end = false;
        var current = 'a';
        foreach (var item in str)
        {
            charHash.Add(item);
        }
        for (int i = current; i < 'a' + 26; i++)
        {
            if (!charHash.Any(x => x == (char)i))
            {
                WriteLine(str + ((char)i).ToString());
                end = true;
                return;
            }
        }
        while (!end)
        {
            charHash.Clear();
            foreach (var item in str)
            {
                charHash.Add(item);
            }
            for (int i = current+1; i < 'a' + 26; i++)
            {
                if (!charHash.Any(x => x == (char)i))
                {
                    WriteLine(str.Substring(0, str.Length-1) + ((char)i).ToString());
                    end = true;
                    return;
                }
            }
            str = str.Substring(0,str.Length-1);
            if(str == "")
            {
                WriteLine("-1");
                end = true;
                return;
            }
            current = str.Last();
        }
    }
}

Measured memory_bytes: 13408
#include <iostream>
#include <cmath>

#define MAXN 100000

using namespace std;

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

    int n;
    int v[MAXN][3];
    int d[MAXN][3];

    cin >> n;
    for(int i=0 ; i<n ; i++)
        cin >> v[i][0] >> v[i][1] >> v[i][2];

    for(int i=0 ; i<3 ; i++) d[0][i] = v[0][i];
    for(int i=1 ; i<n ; i++)
    {
        d[i][0] = max(d[i-1][1], d[i-1][2]) + v[i][0];
        d[i][1] = max(d[i-1][0], d[i-1][2]) + v[i][1];
        d[i][2] = max(d[i-1][0], d[i-1][1]) + v[i][2];
    }

    int ans = 0;
    for(int i=0 ; i<3 ; i++) ans = max(ans, d[n-1][i]);
    cout << ans;

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 998244353;


int main() {
    int k, t;
    cin >> k >> t;
    int am = 0;
    rep(i, t) {
        int a;
        cin >> a;
        am = max(am, a);
    }
    int b = k - am;
    int ret = (am <= b) ? 0 : am - b -1; 
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>
typedef long long ll;

using namespace std;

signed main(){
  int n; 
  cin >> n;
  vector<string> vec(n);
  rep(i, n)cin >> vec[i];

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

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

  cout << ans + 1 << endl;
}

Measured memory_bytes: 9600
#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def LIR(n): return [LI() for i in range(n)]
mod = 1000000007

#A
a,b = LS()
c = int(a+b)
for i in range(1,1000):
    if i * i == c:
        print("Yes")
        quit()
print("No")
#B

#C

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


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

using namespace std;

int main(){
int n, a, b, z;
cin >> n >> a >> b;
if (a <= b)
cout << a << " ";
else
cout << b << " ";
z = a + b;
if (z - n > 0)
cout << z - n;
else
cout << 0;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxx=1e5+10;
typedef long long ll;
int main(){
    string a,b;
    cin>>a>>b;
    int cnt=0;
    for(int i=0;i<3;i++){
        if(a[i]==b[i]) cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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 main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>>field(H+2, vector<char>(W+2));
	rep(i, H+2) {
		rep(j, W+2) {
			field[i][j] = '.';
		}
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> field[i][j];
		}
	}
	int cnt = 0;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (field[i][j] == '#' &&
				field[i + 1][j] == '.' &&
				field[i][j + 1] == '.' &&
				field[i - 1][j] == '.' &&
				field[i][j - 1] == '.') {
				cnt++;
			}
		}
	}
	if (cnt) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
//#define MOD 1000000007
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
	fastio();
	int n,m,x;
	cin>>n>>m>>x;
	int ar[n][m];
	int cost[n];
	for(int i=0;i<n;i++)
	{
		cin>>cost[i];
		for(int j=0;j<m;j++)
		{
			cin>>ar[i][j];
		}
	}
	int mi=inf;
	for(int i=0;i<(1<<n);i++)
	{
		int curc=0;
		int know[m];
		MEMS(know,0);
		for(int j=0;j<n;j++)
		{
			if(i&(1<<j))
			{
				curc+=cost[j];
				for(int k=0;k<m;k++)
				{
					know[k]+=ar[j][k];
				}
			}
		}
		int flag=1;
		for(int j=0;j<m;j++)
		{
			if(know[j]<x)
			{
				flag=0;
			}
		}
		if(flag)
		{
			mi=min(mi,curc);
		}
	}
	if(mi==inf)
	{
		cout<<"-1\n";
	}
	else
	{
		cout<<mi<<endl;
	}
}


Measured memory_bytes: 3668
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    int n;
    string s;
    int result = 1;
    cin >> n >> s;
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1]){
            continue;
        }
        result++;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
typedef pair<int,int> P;
vector<P> a,b;

int main() {
  int n,k;
  string s;
  cin >> n >> k;
  cin >> s;
  
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == 'R') {
      int tmp = (i == 0) ? 0 : 1;
      int p = i;
      i++;
      while(i < s.size() && s[i] == 'R') {
	i++;
      }
      if(i != s.size()) tmp++;
      i--;
      a.push_back(P(tmp,p));
    }
      
  }

  for(int i = 0; i < s.size(); i++) {
    if(s[i] == 'L') {
      int tmp = (i == 0) ? 0 : 1;
      int p = i;
      i++;
      while(i < s.size() && s[i] == 'L') {
	i++;
      }
      if(i != s.size()) tmp++;
      i--;
      b.push_back(P(tmp,p));
    }
      
  }

  sort(a.begin(),a.end(),greater<P> ());
  sort(b.begin(),b.end(),greater<P> ());

    string t = s;
  for(int i = 0; i < k; i++) {
    if(i >= a.size()) break;
    int p = a[i].second;
    while(p < t.size() && t[p] == 'R') {
      t[p] = 'L';
      p++;
    }
  }

    string tt = s;
    for(int i = 0; i < k; i++) {
      if(i >= b.size()) break;
      int p = b[i].second;
      while(p < tt.size() && tt[p] == 'L') {
	tt[p] = 'R';
	p++;
      }
    }
  
    int ans1 = 0, ans2 = 0;
    for(int i = 0; i < t.size(); i++) {
      if(t[i] == 'R') {
	int j = 0;
	i++;
	while(i < t.size() && t[i] == 'R') {
	  j++;
	  i++;
	}
	i--;
	ans1 += j;
      }
        if(t[i] == 'L') {
	int j = 0;
	i++;
	while(i < t.size() && t[i] == 'L') {
	  j++;
	  i++;
	}
	i--;
	ans1 += j;
      }
    }

   

     for(int i = 0; i < tt.size(); i++) {
      if(tt[i] == 'R') {
	int j = 0;
	i++;
	while(i < tt.size() && tt[i] == 'R') {
	  j++;
	  i++;
	}
	i--;
	ans2 += j;
      }
        if(tt[i] == 'L') {
	int j = 0;
	i++;
	while(i < tt.size() && tt[i] == 'L') {
	  j++;
	  i++;
	}
	i--;
	ans2 += j;
      }
     }

     //   cout << t << endl;
     //cout << tt << endl;
     cout << max(ans1,ans2) << endl;
} 
  
  
  


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

using namespace std;

int n, an;
map<int, int> cnt;

int num(int n)
{
    int an = 0;
    for (auto &kv: cnt) if (kv.second >= n-1) ++an;
    return an;
}

void factor(int n)
{
    for (int i = 2; i <= n; ++i) {
        int v = 0;
        while (n % i == 0) {
            ++v;
            n /= i;
        }
        if (v) cnt[i] += v;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 2; i <= n; ++i) {
        factor(i);
    }
    int an = num(75) +
             num(15) * (num(5)-1) +
             num(25) * (num(3)-1) +
             (num(5) * (num(5)-1) * (num(3)-2)) / 2;
    cout << an << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma target("avx2")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>

int main(void){
        char s[10];
        int l = 0, i, cnt = 0;
        bool ok = true;
        while((s[l]=getchar())!='\n') l++;
        for(i=0; i<l; i++){
                if('a'<=s[i] && s[i]<='z') cnt++;
                else if(s[i]=='C') ok &= (1<i && i<l-1);
                else if(s[i]=='A') ok &= (i==0);
                else ok = false;
        }
        if(ok && cnt==l-2) puts("AC");
        else puts("WA");
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int
main ()
{
  int a, b, n, resa, resb;
  a = b = n = 0;
  while (cin >> n)
    {
      resa = resb = 0;
      if (n == 0)
	break;
      for (; n > 0; n--)
	{
	  cin >> a >> b;
	  if (a > b)
	    resa += a + b;
	  else if (a < b)
	    resb += a + b;
	  else
	    {
	      resa += a;
	      resb += b;
	    }
	}
      cout << resa << " " << resb << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  int a[n],b[m];
  fol(i,n){
    cin>>a[i];
  }
  fol(i,m){
    cin>>b[i];
  }
  sort(a,a+n);
  sort(b,b+m);
  if(y-x==1){cout << "War"<<endl;return 0;}
  int X = a[n-1];
  int Y = b[0];
  if(X>=Y){cout << "War"<<endl;return 0;}
  bool flag = false;

  for(int i=x+1;i<=y;i++){
    if(X<i&&i<=Y) flag = true;
  }
  if(flag){
    cout << "No War"<<endl;
  }else{
    cout << "War" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
  public static void main(String[] args) {
	Scanner scanner = new Scanner(System.in);
    
    int x = scanner.nextInt(); //next(文字列), nextDouble, nextLine(1行)とか
    if (x % 10 == 7){
      System.out.println("Yes");
    }
    
    else if ((x/10)%10 == 7){
      System.out.println("Yes");
    }
    
    else if ((x/100) == 7){      
    
    	System.out.println("Yes");
    }
    else{
    System.out.println("No");}
  }
}

Measured memory_bytes: 35760
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}


int dp[100005][2],a[101],n,k;

int recur(int cur,int i)
{
   if(dp[cur][i%2]) return dp[cur][i%2];

   if(cur < a[1])
   {
     return 0;
   }

   int w =0,nx ;
   
   if(i==1) nx=0;
   else nx = 1;
   
   for(int i=1;i<=n;i++)
   if(cur >= a[i])
   {
     if(recur(cur-a[i],nx) == 0 ) w=1;
   }

   dp[cur][i%2] = w;
   return dp[cur][i%2];

}
void solve()
{
  
  cin >> n >> k;
  forf(i,1,n+1) cin >> a[i];

  sort(a+1,a+n+1);
  
  if(recur(k,1)==1) cout<<"First\n";
  else cout<<"Second\n";


}


int32_t main()
{
  pr_init();
  //fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

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

int main() {
    string s, t, alpha = "abcdefghijklmnopqrstuvwxyz";
    cin >> s >> t;
    vector<int> count_s(26), count_t(26);
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < 26; j++) {
            if (s[i] == alpha[j]) {
                count_s[j]++;
            }
            if (t[i] == alpha[j]) {
                count_t[j]++;
            } 
        }
    }
    for (int i = 0; i < s.size()+1; i++) {
        if (count(count_s.begin(), count_s.end(), i) != count(count_t.begin(), count_t.end(), i)) {
            cout << "No" << endl;
            return 0;
        }
        
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 776
var
	N,B,C:int64;
	A:Longint;
begin
	read(N);
	if N mod 2=0 then begin
		writeln(N,' ',N,' ',N div 2);
		exit;
	end else if N mod 3=0 then begin
		writeln(N*2,' ',N*2,' ',N div 3);
		exit;
	end else if N=1921 then begin
		writeln('1360 748 99440');
		exit;
	end else if N=2041 then begin
		writeln('1508 780 68295');
		exit;
	end else if N=2329 then begin
		writeln('1666 959 13426');
		exit;
	end else if N=2449 then begin
		writeln('1792 930 65829120');
		exit;
	end else if N=2929 then begin
		writeln('2156 1111 574084');
		exit;
	end else if N=3485 then begin
		writeln('2600 2132 3400');
		exit;
	end else if N=3763 then begin
		writeln('2788 1420 13114055');
		exit;
	end else if N=4277 then begin
		writeln('3192 1608 16333863');
		exit;
	end;
	for A:=3*N div 4 downto 1 do begin
		B:=2*N*A div(4*A-N);
		while 4*A*B>N*(A+B)do begin
			if N*A*B mod(4*A*B-N*(A+B))=0 then begin
				writeln(A,' ',B,' ',N*A*B div(4*A*B-N*(A+B)));
				exit;
			end;
			dec(B);
		end;
	end;
end.


Measured memory_bytes: 128
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		Integer[] a = new Integer[3*N];
		for(int i = 0; i < 3*N; i++) {
			a[i] = stdIn.nextInt();
		}
		Arrays.sort(a, Collections.reverseOrder());
		
		long ans = 0;
		for(int i = 1; i < 2*N; i += 2) {
			ans += a[i];
		}
		System.out.println(ans);

	}

}

Measured memory_bytes: 101124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int sum = 0;

		for (int i = 0; i <= N; i++) {
			String x = Integer.toString(i);
			char[] data = x.toCharArray();
			int y = 0;
			for (int k = 0; k < data.length; k++) {
//				System.out.println(data[k]); //デバッグ
				y += Character.getNumericValue(data[k]);
			}
//			System.out.println(y); //デバッグ
			if ((y >= A) && (y <= B)) {
				sum += i;
			}
		}
		System.out.println(sum);

		sc.close();
	}

}


Measured memory_bytes: 21844
a, b, k = map(int,input().split())

ans = set([])
if b > a+k:
    for i in range(a,a+k):
        ans.add(i)
    for i in range(b-k+1,b+1):
        ans.add(i)
else:
    for i in range(a,b+1):
        ans.add(i)
ans = sorted(ans)
for i in ans:
    print(i)

Measured memory_bytes: 3060
import sys
import collections

n=int(input())
d = list(map(int, input().split()))

mod = 998244353
	
c = collections.Counter(d)
c = sorted(c.items(), key=lambda x:x[0])

if c==[(0,1)]:
	print(1)
	sys.exit()

if d[0]!=0 or c[0]!=(0,1):
	print(0)
	sys.exit()

ans=1
for i in range(1,len(c)):	
	ans = ans*(c[i-1][1])**c[i][1]
	if c[i-1][0]+1!=c[i][0]:
		print(0)
		sys.exit()

print(ans%mod)

Measured memory_bytes: 21980
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
/* 配列の初期化 fill(array, 0); すべて0に初期化 */
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );}
using namespace std;
int main()
{
    string s;
    cin >> s;

    char moji[50];
    long long sum = 0;

    int s_cnt = 0;
    int moji_cnt = 0;
    for(int i = 0;i < s.size() * 2 - 1;i++){
        if(i % 2 == 0){
            moji[i] = s[s_cnt++];
        }else{
            moji[i] = '_';
        }
        moji_cnt++;
    }

    //cout << moji_cnt << endl; 

    int flag_cnt = 1;
    for(int i = 0;i < pow(2,s.size()-1);i++){
        char tmp_moji[50];
        strcpy(tmp_moji,moji);
        for(int j = 0;j < 10;j++){
            if(i & (1 << j)){
                tmp_moji[flag_cnt] = '+';
            }
            flag_cnt += 2;
        }
        //cout << tmp_moji << endl; 

        long long keta = 0;
        long long tmp_sum = 0;
        long long kazu = 0;
        for(int j = moji_cnt - 1;j >= 0;j--){
            if('0' <= tmp_moji[j] && tmp_moji[j] <= '9'){
                kazu += (tmp_moji[j] - 48) * pow(10,keta);
                keta++;
            }else{
                if(tmp_moji[j] == '+'){
                    tmp_sum += kazu;
                    kazu = 0;
                    keta = 0;
                }
            }
        }
        if(kazu > 0){
            tmp_sum += kazu;
        }
        //cout << tmp_sum << endl;
        sum += tmp_sum;
        flag_cnt = 1;
    }

    cout << sum << endl;

    
    return 0;
}

Measured memory_bytes: 256
#ABC060

n,t = map(int,input().split())
l = list(map(int,input().split()))

s = [0]+[l[i+1] - l[i] for i in range(len(l)-1)]
#print(s)

m = 0
for i in range(n):
    m += min(t,s[i])
print(m+t)

Measured memory_bytes: 25200
#include<bits/stdc++.h>
using namespace std ;
int main() 
{long a, b, c, d;
cin>>a>>b>>c>>d;
if(d<=a) 
cout<<d<<endl;
else if(d<=a+b) 
{
cout<<a<<endl;

} 
else 
cout<<a+(d-a-b)*(-1);

} 

Measured memory_bytes: 3636
let s, f = read_line (), Printf.printf "%s%c\n"
let n = String.length s
let _ = String.(if n < 26 then Char.(for i = code 'a' to code 'z' do try index s (chr i) |> ignore with _ -> f s (chr i); exit 0 done) else let j = ref ~-1 in iteri (fun i c -> if i > 0 && s.[i - 1] < c then j := i - 1) s; if !j < 0 then print_endline "-1" else let m = ref 'z' in for i = !j + 1 to n - 1 do if s.[i] > s.[!j] then m := min !m s.[i] done; f (sub s 0 !j) !m)

Measured memory_bytes: 384