akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll n, m;
	cin >> n >> m;
	cout << abs((n - 2) * (m - 2)) << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    char a;
    cin >> a;
    if(a >= 'a'){
        cout << 'a' << endl;
    }else{
        cout << 'A' << endl;
    }
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
int c[100005][11];
int col[100005];
vector<int> g[100005];
int main()
{
	int n,m,q;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		--a;
		--b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	cin>>q;
	for(int i=0;i<q;i++)
	{
		int v,d;
		cin>>v>>d>>col[i+1];
		--v;
		c[v][d]=i+1;
	}
	for(int i=9;i>=0;i--)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<g[j].size();k++)
			{
				c[g[j][k]][i]=max(c[j][i+1],c[g[j][k]][i]);
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		int res=0;
		for(int j=0;j<11;j++)
		{
			res=max(c[i][j],res);
		}
		cout<<col[res]<<endl;
	}
	return 0;
}

Measured memory_bytes: 11128
import fractions as ma
import collections
n=int(input())
total=0

d=collections.defaultdict(int)

for a in range(1,n+1):
  for b in range(1,n+1):
    d[ma.gcd(a,b)]+=1
    
for a in range(1,n+1):
  for key in d.keys():
    total += ma.gcd(key,a)*d[key]
      
print(total)

Measured memory_bytes: 10580
from collections import defaultdict

N = int(input())
A = [-1]
for _ in range(N):
    A.append(int(input()))

def main():
    count = defaultdict(int)

    v = 1
    ans = 0
    while True:
        if count[v] != 0:
            return -1
        count[v] = 1
        v = A[v]
        ans += 1
        if v == 2:
            return ans

print(main())

Measured memory_bytes: 16628
#include <iostream>
#include <iomanip>
#include <map>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    ll n;
    cin >> n;
    map<ll, ll> mp;
    for (ll i = 2; i * i <= n; i++)
    {

        while (n % i == 0)
        {
            ++mp[i];
            n /= i;
        }
    }
    if (n != 1)
        mp[n] = 1;
    ll ans = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++)
    {
        ll i = 1;
        // cout << itr->first << " " << itr->second << endl;
        while (itr->second - i >= 0)
        {
            itr->second -= i;
            i++;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define FINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

string S;

bool check(string s) {
  if (s.size() % 2 == 1) return false;
  return s.substr(0,s.size()/2) == s.substr(s.size()/2);
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> S;
  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    string T = S.substr(0,i);
    if (check(T)) ans = i;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,k,t=0;
cin>>k>>a>>b;
for(int i=a;i<=b;i++){
  if(i%k==0)
    t=1;
}
  cout<<(t==1?"OK":"NG");

}

Measured memory_bytes: 3592
#include <stdio.h>

int main(void){
  int a, b;
  char c;
  scanf("%d %c %d", &a, &c, &b);
  if(c == '+'){
    printf("%d\n", a + b);
  }else{
    printf("%d\n", a - b);
  }
  return 0;
}

Measured memory_bytes: 128
class WeightedUnionFind():
    def __init__(self,n):
        self.n = n
        self.parents = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.weight = [0 for _ in range(n)]
    def find(self,x):
        root = x
        stack = [root]
        while self.parents[root] != root:
            root = self.parents[root]
            stack.append(root)
        while stack:
            s = stack.pop()
            self.weight[s] += self.weight[self.parents[s]]
        while self.parents[x] != root:
            parent = self.parents[x]
            self.parents[x] = root
            x = parent
        return root
    def unite(self,x,y,w):
        xroot = self.find(x)
        yroot = self.find(y)
        if xroot == yroot:
            return
        xrank = self.rank[xroot]
        yrank = self.rank[yroot]
        if xrank < yrank:
            self.parents[xroot] = yroot
            self.weight[xroot] = w-self.weight[x]+self.weight[y]
        else:
            self.parents[yroot] = xroot
            self.weight[yroot] = -w+self.weight[x]-self.weight[y]
            if xrank == yrank:
                self.rank[xroot] += 1
    def diff(self,x,y):
        return self.weight[x]-self.weight[y]

N,M = map(int,input().split())
uf = WeightedUnionFind(N)

for _ in range(M):
    l,r,d = map(int,input().split())
    if uf.find(l-1) == uf.find(r-1):
        if uf.diff(l-1,r-1) != d:
            print('No')
            break
    else:
        uf.unite(l-1,r-1,d)
else:
    print('Yes')

Measured memory_bytes: 10212
/*||>>>> Praveen Ojha <<<<>>>> 10 June 2019 <<<<>>>> 01:44:56 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf 1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int maxn=3000;
vi rw[maxn],cl[maxn];
int32_t main(){__
	int n,m;
	cin>>n>>m;
	char gg[n][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>gg[i][j];
			if(gg[i][j]=='#'){
				rw[i].push_back(j);
				cl[j].push_back(i);
			}
		}
	}
	int maxi=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(gg[i][j]=='.'){
				int ans=0;
				int ind=upper_bound(all(rw[i]),j)-rw[i].begin();
				int up=m,dw=0;
				if(ind<sz(rw[i]))
					up=rw[i][ind];
				ind=lower_bound(all(rw[i]),j)-rw[i].begin();
				if(ind>0)
				dw=rw[i][ind-1]+1;
				ans+=max(0LL,up-dw);
				up=n;
				dw=0;
				ind=(upper_bound(all(cl[j]),i)-cl[j].begin());
				if(ind<sz(cl[j]))
					up=cl[j][ind];
				ind=lower_bound(all(cl[j]),i)-cl[j].begin();
				if(ind>0)
					dw=cl[j][ind-1]+1;
				ans+=max(0LL,up-dw);
				ans--;
				maxi=max(ans,maxi);
			}
		}
	}
	cout<<maxi<<"\n";
return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<long> A(N), B(N);
	for (int i = 0; i < N; ++i) cin >> A[i] >> B[i];
	long ans = 0;
	for (int i = N - 1; i >= 0; --i) ans += (A[i] + B[i] + ans - 1) / B[i] * B[i] - A[i] - ans;
	cout << ans;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
int main(){
    string sd,t,ans(51,'z');
	cin>>sd>>t;
	if(sd.size()<t.size()){
		cout<<"UNRESTORABLE"<<endl;
		return 0;
	}
	for(int i=0;i<=sd.size()-t.size();i++){
		bool ok=true;
		string s=sd;
		for(int j=0;j<t.size();j++)
			if(s[i+j]=='?')
				s[i+j]=t[j];
			else if(s[i+j]!=t[j])
				ok=false;
		if(ok){
			for(int j=0;j<s.size();j++)
				if(s[j]=='?')
					s[j]='a';
			ans=min(s,ans);
		}
	}
	cout<<(ans==string(51,'z')?"UNRESTORABLE":ans)<<endl;
}


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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair

ll A, B, N;

int main() {
    cin >> A >> B >> N;
    PRINT((A * min(N, B-1)) / B);
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define mx 1000002
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int32_t main() {	
	string s;
	cin>>s;
	cout<<((s[2]==s[3] && s[4]==s[5])?("Yes"):"No");
}	

Measured memory_bytes: 256
# Align
""" Tenka1 Programmer Beginner Contest C """

test = False
A = []

N = int(input())
for _ in range(N):
    A.append(int(input()))


def answer(n, l):
    """中心が最小"""
    x = 0
    y = 0

    if n == 2:
        return abs(l[0] - l[1])

    if n%2 == 1: # nが奇数の時
        l.sort()
        for i in range(n//2):
            x += 2 * l[-(i+1)]
            x -= 2 * l[i]
        x -= l[n//2]
        x += l[n//2 -1]

        l.sort(reverse=True)
        for i in range(n//2):
            y += 2 * l[-(i+1)]
            y -= 2 * l[i]
        y -= l[n//2]
        y += l[n//2 -1]

        if test:
            print('x =', x)
            print('y =', y)
        return max(x, -y)

    # nが偶数の時
    l.sort()
    for i in range(n//2 -1):
        x += 2 * l[-(i+1)]
        x -= 2 * l[i]
    x += l[n//2]
    x -= l[n//2 -1]

    return x


def main():
    """main"""
    print(answer(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7516
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n],b[n],c[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        cin >> b[i];
    }
    c[0] = 0;
    for(int i=1; i<n; i++){
        cin >> c[i];
    }
    
    int sum = 0;
    int last = -1;
    for(int i=0; i<n; i++){
        sum += b[a[i]-1];
        //cout << "sum:" << sum << endl;
        if(last+1 == a[i]-1){
            sum += c[a[i]-1];
            //cout << "sum(add):" << sum << endl;
        }
        last = a[i]-1;
    }
    cout << sum << endl; 
    return 0;
}

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

int main(){
  int N,maxcount=-1,P=0;
  cin >> N;
  for(int i=0;i<N;i++){
    int A=i+1,count=0;
    while(A%2==0){
      count++;
      A/=2;
    }
    if(maxcount<count){
      maxcount=count;
      P=i+1;
    }
  }
  cout << P << endl;
}
      

Measured memory_bytes: 3652
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

int n; 
long long ans = 0;
vector<long long>a, b;

int main() {
	cin >> n;
	a.resize(n);
	b.resize(n);
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i];
	for (int i = n - 1; i >= 0; i--) {
		ans += (b[i] - (a[i] + ans) % b[i]) % b[i];
	}
	cout << ans << endl;
	//cin >> n;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

struct S
{
    int id;
    int ac, time, rank;
    int check[11], wa[11];
    S(){
        ac = time = rank = 0;
        rep(i, 11) check[i] = wa[i] = 0;
    }
    bool operator < (const S& s) const {
        if(ac != s.ac) return ac > s.ac;
        if(time != s.time) return time < s.time;
        return id > s.id;
    }
    bool operator > (const S& s) const{
        return s < *this;
    }
    bool operator == (const S& s) const{
        return (!(*this < s)) && (!(s < *this));
    }
    bool operator != (const S& s) const {
        return !(*this == s);
    }
    void add(int prob, int judge, int t) {
        if(check[prob] != 0) return;
        if(judge == 0) {
            ac++;
            check[prob]=1;
            time += t + wa[prob] * 20;
        }
        else {
            wa[prob]++;
        }
    }
};

int main(){
    int m, t, p, r;
    while(cin >> m >> t >> p >> r) {
        if(m == 0 && t == 0 && p == 0 && r == 0) break;
        vector<S> s(t);
        rep(i, t) s[i].id = i+1;
        rep(i, r) {
            int a, b, c, d;
            cin >> a >> b >> c >> d;
            b--;
            s[b].add(c, d, a);
        }
        sort(all(s));
        cout << s[0].id;
        REP(i, 1, t) {
            if(s[i].ac == s[i-1].ac && s[i].time == s[i-1].time) cout << "=";
            else cout << ",";
            cout << s[i].id;
        }
        cout << endl;
        // rep(i, t) {
        //     cout << s[i].id << " " << s[i].ac << " " << s[i].time << endl;
        // }
    }

    return 0;
}


Measured memory_bytes: 3076
N=int(input())
A= list(map(int,input().split()))
kabu=0
kane=1000
kabukin=0
for a in range(N-1):
    if A[a]<A[a+1] and kane>A[a]:
        #if kabukin<A[a]*kabu:
            kabu=int(kane/A[a])
            kabukin=kabu*A[a]
            kane=kane-kabu*A[a]
    elif A[a]>A[a+1] and kabu>=1:
        kane=kane+kabu*A[a]
        kabu=0

if kabu>0:
    kane+=kabu*A[-1]
print(kane)

Measured memory_bytes: 61936
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N;
string s;
char a[2] = { 'S', 'W' };


int state(char x, char y){
	if((x == 'S' && y == 'o') || (x == 'W' && y == 'x')) return 0;
	return 1;
}


string judge(char x, char y){
	string res = { x, y };
	rep(i, 1, N-1)
		if(state(res[i], s[i]) == 0) res.pb(res[i-1]);
		else res.pb(a[res[i-1]=='S']);
	if(state(res[0], s[0]) == 0 && res[N-1] != res[1]) return "!";
	else if(state(res[0], s[0]) == 1 && res[N-1] == res[1]) return "!";
	rep(i, 1, N-1)
		if(state(res[i], s[i]) == 0 && res[i-1] != res[i+1]) return "!";
		else if(state(res[i], s[i]) == 1 && res[i-1] == res[i+1]) return "!";
	if(state(res[N-1], s[N-1]) == 0 && res[N-2] != res[0]) return "!";
	else if(state(res[N-1], s[N-1]) == 1 && res[N-2] == res[0]) return "!";
	return res;
}


string solve(){
	char x[2] = { 'S', 'W' };
	rep(i, 0, 2)
		rep(j, 0, 2)
			if(judge(x[i], x[j]) != "!") return judge(x[i], x[j]);
	return "-1";
}


signed main(){
	cin >> N;
	cin >> s;

	cout << solve() << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;

ll x[500005], y[500005];
ll z[500005], w[500005];


ll i,n;
bool visited[500005];

vector <ll> G[500005];


void dfs(ll v){
	visited[v] = true;
	ll nv = G[v][0];
	if(visited[nv])return;
	dfs(nv);
}

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> x[i] >> y[i];
		z[i] = x[i];
		w[i] = y[i];
	}
	sort(w,w+n);
	sort(z,z+n);
	for(int i=0;i<n-1;i++){
		if(w[i] == w[i+1] || z[i] == z[i+1]){
			cout << -1 << endl;
			return 0;
		}
	}

	for(int i=0;i<n;i++){
		G[y[i]].push_back(x[i]);
	}
	ll cnt = 0;
	for(int i=1;i<=n;i++){
		if(!visited[i]){
			dfs(i);
			cnt++;
		}
	}
	cout << n - cnt << endl;

}


Measured memory_bytes: 21216
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long int ll;
const ll mod=1e9+7;
ll f[2006];
int main()
{
	ios;
	f[0]=1;
	for(int i=3;i<=2000;++i)
	for(int j=3;j<=i;++j)
	{
		f[i]=(f[i]+f[i-j])%mod;
	}
	int s;
	cin>>s;
	cout<<f[s]<<'\n';
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int max(int a,int b){
	return (a>b?a:b);
}
int main(){
	int n,w;
	cin>>n>>w;
	int wt,val;
	vector<long long int> dp(w+1,0);
	for(int j=0;j<n;j++){
		cin>>wt>>val;
		for(int i=w-wt;i>=0;i--){
			dp[i+wt]=max(dp[i+wt],dp[i]+val);
		}
	}
	long long int max=0;
	for(int i=0;i<=w;i++)if(max<dp[i])max=dp[i];
	cout<<max;

}

Measured memory_bytes: 1024
n, m = [int(x) for x in input().split()]
lr = [[int(x) for x in input().split()] for _ in range(m)]

lr.sort(key = lambda x : x[1])
ans = 0
rm = 0 # 最初のループで必ずif文がFalseになる値
for i in range(m):
    if lr[i][0] <= rm: # 取り除いた橋でカバー可能
        continue
    rm = lr[i][1] - 1  # 取り除く橋の番号
    ans += 1

print(ans)

Measured memory_bytes: 22816
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iterator>
#include <utility>
#define		fast			ios::sync_with_stdio(false);cin.tie(0);cout.tie(NULL);
#define		rep(i,n)		for(int i = 1; i<=n; i++)
#define		all(p)			p.begin(),p.end()
#define		mem(ar,val)		memset(ar, val, sizeof(ar))
#define		sz(c)			(int)c.size()
#define		pb(x)			push_back(x)
#define		mkp(x,y)		make_pair(x,y)
#define 	deb			cout<<"hehehe\n"
#define		ff			first
#define		ss			second
#define 	pf 			printf
#define 	sf 			scanf
#define		ll			long long
#define		pii			pair<int, int>
#define 	pll			pair<ll, ll>
#define 	vll			vector<long long>
#define 	vi			vector<int>
#define		nl			"\n"
#define		pnl			printf("\n");
#define		S(a)			scanf("%lld",&a)
#define		SS(a,b)			scanf("%lld %lld",&a,&b)
#define		SSS(a,b,c)			scanf("%lld %lld %lld",&a,&b,&c)
#define		P(a)			printf("%lld\n",a)
#define		PP(a,b)			printf("%lld %lld\n",a,b)
#define 	total_bit(a)		__builtin_popcount(a)
#define 	UNIQUE(a)		sort(all(a)); a.erase(unique(all(a)), a.end())
#define		FI			freopen("input.txt", "r", stdin);
#define 	FO			freopen("output.txt", "w", stdout);
using namespace std;
const double pi = acos(-1.0);
const int INF = 0x7f7f7f7f;
const int M = 1e9 + 7;
const int N = 1e6+7;
void solve()
{
	int n,k;
	cin>>n>>k;
	vi ar(n);
	for(int i = 0; i<n; i++)
		cin>>ar[i];
	sort(all(ar));
	ll ans = 0;
	for(int i = 0; i<k; i++) ans+= ar[i];
	cout<<ans<<nl;
}
int main()
{
//	ll t;
//	S(t);
//	while(t--)
//	{
		solve();
//	}
	return 0;
}


Measured memory_bytes: 3632
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
ans = [0]*(10**4+1)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            res = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if res <= 10**4:
                ans[res] += 1


for i in range(n):
    print(ans[i+1])

Measured memory_bytes: 69528
N = int(input())

import sys
if N == 0:
    print(0)
    sys.exit()

ans = ""
i = 1
while abs(N) > 0:
    if N%2 == 1:
        ans = "1" + ans
        N -= 1
        N //= -2
    else:
        ans = "0" + ans
        N //= -2

print(ans)

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

using namespace std;

namespace {

#define VERA(i, a, b)for(auto i=(ll)(a);i<(ll)(b);++i)
#define ANDY(i, a, b)for(auto i=(ll)(a);i>(ll)(b);--i)

typedef long long ll;
typedef double dd;

template <class T> inline ll Size(const T& x) { return x.size(); }

bool Solve(ll test_num) {
  (void) test_num;
  ll n;
  if (not(cin >> n))return false;
  vector<ll> aa(n), bb(n);
  VERA(i, 0, n)cin >> aa[i];
  VERA(i, 0, n)cin >> bb[i];
  const ll sum_a = accumulate(aa.begin(), aa.end(), ll(0));
  const ll sum_b = accumulate(bb.begin(), bb.end(), ll(0));
  if (sum_a > sum_b) {
    cout << "No\n";
    return true;
  }
  const ll ops = sum_b - sum_a;
  ll one = 0, two = 0;
  VERA(i, 0, n) {
    if (aa[i] > bb[i])
      one += aa[i] - bb[i];
    else {
      two += (bb[i] - aa[i]) / 2 + (bb[i] - aa[i]) % 2;
      one += (bb[i] - aa[i]) % 2;
    }
  }
//  Pln(one, two, ops);
  if (max(one, two) <= ops and (ops - one) == 2 * (ops - two))
    cout << "Yes\n";
  else
    cout << "No\n";
  return true;
}

void Init() {
}

}

int main() {
#ifdef AZN
  const auto start_time = chrono::system_clock::now();
  freopen("../input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand(1223);
  Init();
  ll test = 1;
  while (true)
    if (not Solve(test++))
      break;
#ifdef AZN
  cerr << "Took: " << ((chrono::system_clock::now() - start_time).count() /
                       static_cast<double>(chrono::system_clock::period::den)) << " s" << endl;
#endif
  return 0;
}


Measured memory_bytes: 384
// 1_abc128_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, p;
    cin >> a >> p;
    p += 3 * a;
    cout << p / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n;
int32_t main(){
CODE_START;
cin>>n;
ll s=0;
for(ll i=1;i<=n;i++)
{
    if(i%3!=0&&i%5!=0){
        s=s+i;
    }
}
cout<<s<<endl;
}


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

int main()
{
    string S;

    cin >> S;
    for(int i = 0; i < 8; i++) {
        int sum = S[0] - '0';
        for(int j = 0; j < 3; j++) {
            if((i >> j) & 1) sum += S[j + 1] - '0';
            else sum -= S[j + 1] - '0';
        }
        if(sum == 7) {
            cout << S[0];
            for(int j = 0; j < 3; j++) {
                if((i >> j) & 1) cout << "+";
                else cout << "-";
                cout << S[j + 1];
            }
            cout << "=7" << endl;
            break;
        }
    }

    return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;


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

	ll N,M;
	cin >> N >> M;
	map<ll,vector<ll>> m;
	vector<ll> P(M),Y(M); 
	rep(i,M){
		cin >> P[i] >> Y[i];
		m[P[i]].push_back(Y[i]);
	}

	map<ll,ll> juni;
	for(auto p:m){
		sort(p.second.begin(),p.second.end());
		rep(i,p.second.size()){
			juni[p.second[i]] = i;
			//cout << p.second[i] << endl;
		}
	}

	rep(i,M){
		printf("%06ld%06ld\n",P[i],juni[Y[i]]+1);
	}
	
	return 0;
}

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


namespace AtCoderPractice
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] NK  = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int N = NK[0];
            int K = NK[1];
            int[] d = new int[K];
            List<int[]> A = new List<int[]>();

            for(var i =0; i< K; i++)
            {
                d[i] = int.Parse(Console.ReadLine());
                int[] tmp = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                A.Add(tmp);
            }

            List<int> nonDis = new List<int>();
           
            for (var i =0; i<K; i++)
            {
                for(var j =0;j<d[i]; j++)
                {
                    nonDis.Add(A[i][j]);
                }
            }
            IEnumerable<int> Dis = nonDis.Distinct();
            Console.WriteLine(N - Dis.Count()) ;
            
        }
    }
}


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

using namespace std;

int main()

{

    int l,r,d,ans,m;

    ans=0;

    cin>>l>>r>>d;

    m=d;

    while(d<=r)

    {

        if(d>=l)

            ans++;

        d+=m;

    }

    cout<<ans<<endl;

    return 0;

}


Measured memory_bytes: 3624
// ~/BAU/ACM-ICPC/Teams/Rampage/Abukhadijah
// ~/sudo apt-get verdict Accpeted
// ~/Remember,remember the 6th of March
#include <functional>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<complex>
#include <numeric>
#include <string>
#include<iostream>
#include <fstream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
using namespace std;
const double PI = acos(-1.0);
const double  EPS = 1e-11;
typedef long long ll;
typedef unsigned long long ull;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
void fast()
{
	std::ios_base::sync_with_stdio(0);
}
bool bs[10000009];
void sev()
{
	bs[0] = bs[1] = 1;
	for (int i = 4; i <= 10000008; i += 2)
		bs[i] = 1;
	for (int i = 3; i*i <= 10000008; i += 2)
	{
		if (bs[i] == 1)continue;
		for (int j = i * i; j <= 10000008; j += (i + i))
			bs[j] = 1;
	}
}
void goldbach_conjecture(int n)
{
	for (int i = 2; i < 10000009; i++)
	{
		if (!bs[i] && !bs[n - i])
		{
			printf("%d %d\n", i, n - i);
			break;
		}
	}
}
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d)
	{
		cout << "Yes\n";
		return 0;
	}
	if (abs(a - b) <= d && abs(b - c) <= d)
	{
		cout << "Yes\n";
		return 0;
	}
	cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s;
    cin >> s;
    ll k;
    cin >> k;
    rep(i, 0, (int)s.size()) {
        if (s[i] != '1') {
            if (k < i + 1) {
                cout << 1 << endl;
                return 0;
            } else {
                cout << s[i] << endl;
                return 0;
            }
        }
    }
    cout << 1 << endl;
    return 0;
}


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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  string s;
  cin >> N >> s;

  int r = 0, b = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'R') {
      r++;
    } else {
      b++;
    }
  }

  if (r > b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

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

    for (int i = 0; i < s.size(); i++) {
        cout << (s[i] == ',' ? ' ' : s[i]);
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

LL n,k,ans = 0;

int main(){
	cin >> n >> k;
	while(n){
		ans ++;
		n /= k;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

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

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,q;
    cin>>n;
    ll ans = 0;
    map<int,ll> mp;
    REP(i,n){
        int a;
        cin>>a;
        mp[a]++;
        ans += a;
    }

    cin>>q;
    REP(i,q){
        ll b,c;
        cin>>b>>c;

        ll cnt = mp[b];
        mp[b] = 0;
        mp[c] += cnt;

        ans += (c-b) * cnt;

        cout << ans << endl;
    }

    
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    string S;
    cin >> S;

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

    if(S[0] == S[1] && S[2] == S[3] && S[1] != S[2])
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
import sys
def main():
    input=sys.stdin.readline
    N,K=map(int,input().split())
    H=tuple(map(int,input().split()))
    if N-1<=K:
        print(H[N-1]-H[0])
        return
    inf=10**9+7
    dp=[inf]*N
    dp[0]=0

    for i,h in enumerate(H[1:]):
        m=inf
        for j in range(max(0,i-K+1), i+1):
            m=min(m, dp[j]+abs(h-H[j]))
        dp[i+1]=m
    print(dp[N-1])

if __name__=="__main__":
    main()

Measured memory_bytes: 55644
# coding: utf-8

s = input().rstrip()

default = ["0", "1"]

ans = len(s)
for i in default:
    current = i
    cnt = 0
    for j in s:
        if j == current:
            cnt += 1
        if current == "1":
            current = "0"
        else:
            current = "1"
    ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	P a[5];
	REP(i, 5) {
		cin >> a[i].second;
		a[i].first = a[i].second % 10;
	}
	sort(a, a + 5);
	int res = 0;
	int j = 0;
	while (!a[j].first) j++;
	REP(i, 5) {
		res += a[i].second;
		if (i != j && a[i].first) res += 10 - a[i].first;
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
if(s=="Sunny"){
  cout<<"Cloudy"<<endl;
}

if(s=="Cloudy"){
  cout<<"Rainy"<<endl;
}

if(s=="Rainy"){
  cout<<"Sunny"<<endl;
}
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final int n = sc.nextInt();
    final List<Integer> list = new ArrayList<>();
    int a = sc.nextInt();
    int b = sc.nextInt();

    if(a * n >= b){
        System.out.println(b);
    }else{
        System.out.println(a * n);
    }

    

    



    
  

    


    


    

    
    
    



    





}
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define int long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define precise(i) fixed << setprecision(10) << i
#define f(i,a,b) for(int i=a;i<b;i++)

#define endl '\n'
#define debug cout<<endl;cout<<"*********************"<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;


#define all(a) a.begin(),a.end()
#define show(a) for(auto xyz:a)cout<<xyz<<" ";
#define maxEl(a) *max_element(a)
#define minEl(a) *min_element(a) 
#define LB lower_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS >= OUR VALUE 
#define UB upper_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS > OUR VALUE 

#define acc accumulate
#define F first
#define S second

#define MAXN 200050
#define INF 1e12

void solve(){
	int n;
	cin>>n;
	n=n%10;
	if(n==3)cout<<"bon";
	else if(n==0||n==1||n==6||n==8)cout<<"pon";
	else cout<<"hon";
}
signed main(){
    fastio
	int T=1;
//	cin>>T;
	while(T--){
		solve();
	}
}

Measured memory_bytes: 3612
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;

int main(){
    ll n,m;
    ll mod=1000000007;
    cin>>n>>m;
    vector<int>a(m);
    rep(i,m)cin>>a[i];
    vector<ll>dp(n+1,1);
    rep(i,m)dp[a[i]-1]=0;
    if(dp[0]==0&&dp[1]==0){cout<<"0";return 0;}
    for(int i=1;i<n;i++){
        if(i==1&&dp[0]==1&&dp[i]!=0){dp[i]=2;continue;}
        if(i==1&&dp[0]==0&&dp[i]!=0){dp[i]=1;continue;}
        if(dp[i]!=0)dp[i]=(dp[i-1]+dp[i-2])%mod;}
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 3824
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a,b,c,s;
  cin >> a >> b >> c;
  s += a.front()+'A'-'a';
  s += b.front()+'A'-'a';
  s += c.front()+'A'-'a';
  cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int cnt(ll x) {
	int res = 0;
	while (x) {
		res++; x /= (ll)10;
	}
	return res;
}
int main() {
	ll n; cin >> n;
	int out = 11;
	for (ll i = 1; i < 100001; i++) {
		if (n%i != 0)continue;
		int nex = max(cnt(i), cnt(n / i));
		out = min(out, nex);
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int 
#define ar array
#define pb push_back
//hash base 177013


int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//for(ll t=0;t<testcase;t++)
	{
		 int x;
		 cin>>x;
		 if(x>=30)
		 {
			 cout<<"Yes\n";
		 }
		 else
		 {
			 cout<<"No\n";
		 }
							
	}
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  
  long long d = c - a - b;
  if (d > 0 && 4*a*b < d*d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;



int main(){
  int n; cin>>n;
  int a[30],b[30],c[30];

  for(int i=0;i<n;i++)
  cin>>a[i];
  for(int i=0;i<n;i++)
  cin>>b[i];
  for(int i=0;i<n-1;i++)
  cin>>c[i];

  int ans=b[a[0]-1];

  for(int i=1; i<n;i++){
      if(a[i]-a[i-1]==1){
        ans+= c[a[i-1]-1];
        ans+=b[a[i]-1];
      }
      else{
      ans+=b[a[i]-1];
  }


  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Sum of Two Integers
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  printf("%d\n", (n - 1) / 2);
  return 0;
}


Measured memory_bytes: 256
import decimal,math
from collections import Counter,defaultdict
from fractions import gcd
from bisect import bisect_right,bisect_left
decimal.getcontext().prec = 100
import sys
sys.setrecursionlimit(1000000)

n,m = map(int,raw_input().split())
mat=[]
mod=10**9+7
for i in range(n):
	p=raw_input()
	mat.append(p)
dp = [[0]*m for i in range(n)]
dp[0][0]=1
for j in range(1,m):
	if(mat[0][j]=='.'):
		dp[0][j]=dp[0][j-1]
for i in range(1,n):
	if(mat[i][0]=='.'):
		dp[i][0]=dp[i-1][0]
for i in range(1,n):
	for j in range(1,m):
		if(mat[i][j]=="."):
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod
print (dp[-1][-1])%mod					


Measured memory_bytes: 38248
#include <stdio.h>
#define N 100
int main(){

  
  
  int n,A[N][N],i,j,u,v,k;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=0;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&v);
    for(j=0;j<v;j++){
      
      if(v!=0){
	scanf("%d",&k);
    
	A[u-1][k-1]=1;}
      

    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      
      if(j==n-1) printf("%d\n",A[i][j]);
      else printf("%d ",A[i][j]);
    }
  }
  
  return 0;
}



Measured memory_bytes: 2104