akhauriyash/Code-Regression huggingface dataset:
import sys
import queue


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7


def main():
    N = int(input())
    s = input()
    Animal = ["WW", "WS", "SS", "SW"]
    for i in range(1, N - 1):
        if s[i] == "o":
            for j in range(4):
                if Animal[j][-1] == "S":
                    Animal[j] = Animal[j] + Animal[j][-2]
                else:
                    if Animal[j][-2] == "S":
                        Animal[j] = Animal[j] + "W"
                    else:
                        Animal[j] = Animal[j] + "S"
        else:
            for j in range(4):
                if Animal[j][-1] == "S":
                    if Animal[j][-2] == "S":
                        Animal[j] = Animal[j] + "W"
                    else:
                        Animal[j] = Animal[j] + "S"
                else:
                    Animal[j] = Animal[j] + Animal[j][-2]
    for i in range(4):
        animal = Animal[i]
        if s[-1] + s[0] == "xo":
            for a in ["WWWS", "WSSS", "SWSW", "SSWW"]:
                if animal[-2:] + animal[:2] == a:
                    print(animal)
                    return
            else:
                continue

        elif s[-1] + s[0] == "xx":
            for a in ["WWWW", "WSSW", "SWSS", "SSWS"]:
                if animal[-2:] + animal[:2] == a:
                    print(animal)
                    return
                else:
                    continue

        elif s[-1] + s[0] == "ox":
            for a in ["WWSS", "WSWS", "SSSW", "SWWW"]:
                if animal[-2:] + animal[:2] == a:
                    print(animal)
                    return
        elif s[-1] + s[0] == "oo":
            for a in ["WWSW", "WSWW", "SSSS", "SWWS"]:
                if animal[-2:] + animal[:2] == a:
                    print(animal)
                    return
                else:
                    continue
    print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 4880
#include<stdio.h>
int main(void){

	int n,i,j,team[100];
	int a,b,c,d,jun[100];

	scanf("%d",&n);
	for(i=0;i<n;i++){
		team[i]=0;
		jun[i]=1;
	}
	int game=n*(n-1)/2;
	for(i=0;i<game;i++){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		if(c>d) team[a-1]+=3;
		else if(c==d){
			team[a-1]+=1; team[b-1]+=1;
		}else team[b-1]+=3;
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(team[i]<team[j]) jun[i]++;
		}
		printf("%d\n",jun[i]);
	}

	return 0;
}

Measured memory_bytes: 600
l = input().split()
H = int(l[0])
W = int(l[1])

S = []

for i in range(H):
    S.append(input().split()[0])

# print(H, W, S)

for i in range(1, H - 1):
    for j in range(1, W - 1):
        s = S[i][j]
        if s == '.':
            continue
        if S[i][j - 1] == '#':
            continue
        if S[i][j + 1] == '#':
            continue
        if S[i - 1][j] == '#':
            continue
        if S[i + 1][j] == '#':
            continue
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 38768
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector<int> A(1<<(N+1));
	int num = 1<<N;
	for(int i = 0;i<num;++i){
		cin >> A[num+i];
	}
	for(int i=num-1;i>=1;--i){
		int L = i<<1;
		int R = (i<<1)+1;
		if( A[L] == A[R] ){//どちらかの硬度
			A[i] = A[L];
		}else{
			A[i] = max(A[L],A[R])-min(A[L],A[R]);
		}
	}
	int ans = A[1];
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define int long long
#define maxn 300005
#define inf 2000000000000000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
const double PI = acos(-1);
using namespace std;

string s; int n;
int a[maxn],ans=0;
int d[maxn],d2[maxn];
main(){
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("inp.txt","r",stdin); //freopen("out.txt","w",stdout);
	//freopen(".inp","r",stdin); freopen(".out","w",stdout);
	cin>>s; n=s.size()+1; s='?'+s; s+='0'; int i,j,k;
	a[0]=0;
	for (i=1;i<=n;i++){
		a[i]=a[i-1]*10+s[i]-48; a[i]%=2019;
		for (j=0;j<2019;j++) d2[j]=0;
		for (j=0;j<2019;j++){
			k=j*10+s[i]-48; k%=2019;
			d2[k]+=d[j];
		} 
		d2[s[i]-48]++;
		for (j=0;j<2019;j++) d[j]=d2[j];
	}
	for (i=0;i<2019;i++){
		ans+=d[i]*(d[i]-1)/2;
	}
	cout<<ans;
}

Measured memory_bytes: 5324
def CalAbs(a, b):
    sol=a-b
    if sol<0:
        sol=sol*(-1)
    return sol
    
input_line = input().split(" ")
N=int(input_line[0])
K=int(input_line[1])

sol=10**18+1
N=N%K+K
i=0
count=0
while i<=10:
    if sol>N:
        sol=N
    N=CalAbs(N,K)
    i=i+1
print(sol)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    string number;
    cin >> number ;
    
      if(number.at(0)=='7'||number.at(1)=='7'||number.at(2)=='7'){
          cout<<"Yes"<< endl;          
      }
      else{
          cout<<"No"<< endl;
      }
}

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

using namespace std;

const int INF = numeric_limits<int>::max();
const int MAXN = 2e5+ 5;
const int MOD = 1e9 + 7;
const double res = 1e-9;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define int int64_t

signed main() {
#if(DEBUG_LEVEL > 0)
    freopen("../input.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#endif
    string s, t;
    cin >> s >> t;
    map <int, vector <int>> was;
    for (int i = 0; i < s.size(); ++i) {
        was[s[i]].emplace_back(i);
    }
    int ans = 1;
    int last = -1;
    for (auto u : t) {
        if(was.count(u) == 0) {
            cout << "-1";
            return 0;
        }
        auto it = upper_bound(was[u].begin(), was[u].end(), last);
        if(it == was[u].end()) {
            ans += s.size();
            it = was[u].begin();
        }
        last = *it;
    }
    ans += last;
    cout << ans;
    return 0;
}

Measured memory_bytes: 1728
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1LL << 40;

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

ll N, K;

int main()
{
    cin >> N >> K;
    vector<vector<ll>> S(N);
    rep(i, 0, N)
    {
        ll t, d;
        cin >> t >> d;
        t--;
        S[t].push_back(d);
    }
    for (auto &v : S)
    {
        sort(v.begin(), v.end(), greater<ll>());
        if (v.empty())
            v.push_back(-INF);
    }

    sort(S.begin(), S.end(), [&](vector<ll> a, vector<ll> b) {
        return a[0] > b[0];
    });

    ll cur = 0;
    priority_queue<ll> que;
    for (int i = 0; i < K; i++)
    {
        cur += S[i][0];
        for (int j = 1; j < S[i].size(); j++)
        {
            que.push(S[i][j]);
        }
    }
    for (int i = K; i < N; i++)
    {
        for (int j = 0; j < S[i].size(); j++)
        {
            que.push(S[i][j]);
        }
    }
    ll res = cur + K * K;
    for (ll i = K - 1; i >= 1; i--)
    {
        ll v = S[i][0];
        ll w = que.top();
        if (w > v)
        {
            cur += w;
            cur -= v;
            que.pop();
            que.push(v);
        }
        chmax(res, cur + i * i);
    }
    cout << res << endl;
}


Measured memory_bytes: 8696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Stack;


/**
 *
 * @author
 *
 *
 *
 */

public class Main {

    public static final char BACKSPACE = 'B';

	public String find(String string) {
        Stack<Character> stack = new Stack<>();

        char[] chars  = string.toCharArray();

        for (char c : chars ) {
            if ( c == BACKSPACE ) {
                if  ( ! stack.isEmpty()) {
                    stack.pop();
                }
            } else {
                stack.push(c);
            }
        }

        StringBuilder builder = new StringBuilder();
        while ( ! stack.isEmpty()  ) {
            builder.append(stack.pop());
        }

        return builder.reverse().toString();
    }

    public static void main(String[] args) throws IOException {
        MyScanner scanner = new MyScanner();
        PrintStream out = System.out;

        Main main = new Main();

        String string = scanner.next();

        out.println(main.find(string));

        scanner.reader.close();
        out.close();
    }

    // -----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader reader;

        public MyScanner() {
            this.reader = new BufferedReader(new InputStreamReader(System.in));
        }

        public void close() throws IOException {
            this.reader.close();
        }

        int nextInt() {
            return Integer.parseInt(this.next());
        }

        long nextLong() {
            return Long.parseLong(this.next());
        }

        double nextDouble() {
            return Double.parseDouble(this.next());
        }

        String next() {
            String str = "";
            try {
                str = this.reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        String[] nextStringArray() {
            String[] str = null;
            try {
                str = this.reader.readLine().trim().split(" ");
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int[] nextIntArray() {
            String[] data  = nextStringArray();
            int[] a  = new int[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Integer.parseInt(data[i]);
            }

            return a;
        }

        Integer[] nextIntegerArray() {
            String[] data  = nextStringArray();
            Integer[] a  = new Integer[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Integer.parseInt(data[i]);
            }

            return a;
        }

        long[] nextLongArray() {
            String[] data  = nextStringArray();
            long[] a  = new long[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Long.parseLong(data[i]);
            }

            return a;
        }
    }
}



Measured memory_bytes: 7636
#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(){
    int n;
    cin>>n;
    rep(i,n+1){if((int)(i*1.08)==n){cout<<i;return 0;}}
    cout<<":(";return 0;
}

Measured memory_bytes: 3236
from heapq import heappush, heappop

N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))

res = True
res_cnt = 0

h = []
for i in range(N):
    if B_list[i] > A_list[i]:
        heappush(h, (-B_list[i], i))
    elif B_list[i] < A_list[i]:
        res = False

while len(h) > 0 and res:
    _, i = heappop(h)
    a = B_list[(i - 1) % N]
    c = B_list[(i + 1) % N]

    if B_list[i] > max(a, c):
        k1 = (B_list[i] - A_list[i]) // (a + c)
        k2 = (B_list[i] - max(a, c)) // (a + c)
        k = min(k1, k2+1)
        if k == 0:
            res = False
        res_cnt += k
        B_list[i] -= k * (a + c)
        if B_list[i] > A_list[i]:
            heappush(h, (-B_list[i], i))
    else:
        res = False

if __name__ == "__main__":
    if res:
        print(res_cnt)
    else:
        print(-1)


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

typedef long long ll;

const int maxN = 3010, mod = 1e9 + 7;
int N;
string s;
ll dp[maxN][maxN];

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

    cin >> N >> s;
    dp[1][1] = 1;
    for (int i = 2; i <= N; i++) {
        ll pref[i];
        pref[0] = dp[i - 1][0];
        for (int j = 1; j < i; j++) {
            pref[j] = (pref[j - 1] + dp[i - 1][j]) % mod;
        }
        for (int j = 1; j <= i; j++) {
            int l, r;
            if (s[i - 2] == '<') {
                l = j, r = i - 1;
            } else {
                l = 1, r = j - 1;
            }
            dp[i][j] = (pref[r] - pref[l - 1] + mod) % mod;
        }
    }
    ll answer = 0;
    for (int i = 1; i <= N; i++) {
        answer = (answer + dp[N][i]) % mod;
    }
    cout << answer;

    return 0;
}

Measured memory_bytes: 49824
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
using namespace std;
int main(){
    int n,T;
    int ans=10000;
    cin>>n>>T;
    rep(i,n){
      int c,t;
      cin>>c>>t;
      if(t<=T) ans=min(ans,c);
    }
    if (ans==10000) cout<<"TLE"<<endl;
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(K: int, X: int):
    return [NO, YES][500*K >= X]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    print(f'{solve(K, X)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 75188
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, m;

const int MAX_V = 300100;

vector<int> G[MAX_V];
int color[MAX_V];
//頂点を1と-1で塗っていく
bool dfs(int v, int c) {
	color[v] = c;//vをcで塗る
	for (int i = 0; i < G[v].size(); i++) {
		//隣接している頂点が同じ色ならfalse
		if (color[G[v][i]] == c)return false;
		//隣接している頂点がまだ塗られてないなら-cで塗る
		if (color[G[v][i]] == 0 && !dfs(G[v][i], -c))return false;
	}
	//全ての頂点が塗れたらtrue
	return true;
}

int main() {
	cin >> n >> m;
	int ll;
	REP(i, n) {
		int k;
		cin >> k;
		REP(j, k) {
			int l;
			cin >> l;
			ll = l;
			G[i].emplace_back(101010 + l);
			G[101010 + l].emplace_back(i);
		}
	}

	dfs(101010 + ll, 1);
	
	REP(i, n) {
		if (color[i] != -1) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 11392
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);
string a,b;
int main(){ _;
  cin>>a>>b;
  if(a.length() > b.length()){
    cout<<"GREATER"<<endl;
    return 0;
  }else if (a.length() < b.length()){
    cout<<"LESS"<<endl;
    return 0;
  }    
  
  int i=0;
  while(a[i]!='\0' && b[i]!='\0'){
    if(a[i]>b[i]){
      cout<<"GREATER"<<endl;
      return 0;
    }
    else if (a[i]<b[i]){
      cout<<"LESS"<<endl;
      return 0;
    }
    i++;
  }

  cout<<"EQUAL"<<endl;
      

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define pll pair <ll,ll>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<=(ll)n;i++)
#define rep(i,x,y) for(ll i=(ll)x;i<=(ll)y;i++)
#define reprev(i,n) for(ll i=(ll)n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

// FOR DEBUGGING
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", ";
	else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

const int mod = 1e9+7;
const long double pi = acos(-1);
const ll INF = 1e15;

ll power(ll x, ll y){
	x %= mod;
	ll ans = 1;
	while(y){
		if(y&1) ans = (ans*x)%mod;
		y /= 2;
		x = (x*x)%mod;
	}
	return ans;
}

void solve(){

	int n;
	cin >> n;
	ll sum = 0;
	vector <ll> a(n);
	vector <int> cnt(100001,0);
	rep0(i,n){
		cin >> a[i];
		cnt[a[i]]++;
		sum += a[i];
	}

	int q;
	cin >> q;
	while(q--){
		ll b, c;
		cin >> b >> c;
		sum -= b*cnt[b];
		sum += c*cnt[b];
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout << sum << "\n";
	}

	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 4504
n = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)
res = 1
flag0 = False
if 0 in a_list:
  res = 0
else:
  for i in range(n):
    res = a_list[i]*res
    if res > 1000000000000000000:
      res = -1
      break

print(res)

Measured memory_bytes: 84740
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	
	string t;
	cin >> t;
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

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

    double dice = 1.0 / n;

    double prob = 0.0;

    for (int i = 1; i <= n; i++) {
        if (i < k) {
            int cnt = 0;
            for (int j = 0;; j++) {
                if ((i << j) < k) {
                    cnt++;
                } else {
                    break;
                }
            }
            prob += dice * pow(0.5, 1.0 * cnt);
        } else {
            prob += dice;
        }
    }
    printf("%.11lf\n", prob);
}

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

int main()
{
        long long max;
        vector<long> pn;
        bool npn[1000001];
        npn[0] = npn[1] = true;


        while(cin >> max){
                for(long j=2;j<=999999;j++) npn[j] = false;
                for(long i=2;i<=max;i++){
                        if(npn[i]) continue;
                        pn.push_back(i);
                        for(long j=i*1;j<=max;j+=i)npn[j] = true;
                }

                cout << pn.size() << "\n";
                pn.clear();
        }

        return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x,int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/


int main()
{
	int N, M;
	pair<int, int> R[100005];
	int temp;
	cin >> N >> M;
	for (int i = 0; i < M; i++)
	{
		cin >> temp;
		R[i].first = temp - 1;
		cin >> temp;
		R[i].second = temp - 1;
	}
	sort(R, R + M);
	R[M].first = 1000000;
	R[M].second = 1000000;
	
	int ans = 0;
	int up = 0;
	int last = 1000000;

	for (int i = 0; i < N; i++)
	{
		while (R[up].first == i)
		{
			last = min(last, R[up].second);
			up++;
		}

		if (i == last - 1)
		{
			ans++;
			last = 1000000;
			if (up == M) break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
package main

import (
  "fmt"
  "math"
)

func main() {
  var n, a int
  min := math.MaxInt64
  fmt.Scan(&n)
  for i := 0; i < 5; i++ {
    fmt.Scan(&a)
    if a < min {
      min = a
    }
  }
  fmt.Println((n+min-1)/min + 4)
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
using namespace std;
int len;
char s[105];
int main()
{
	scanf("%s",s+1);
	len=strlen(s+1);
	for(int i=1;i<=len;i++){
		if(i%2&&s[i]!='R'&&s[i]!='U'&&s[i]!='D'){
			printf("No");
			return 0;
		}
		if(!(i%2)&&s[i]!='L'&&s[i]!='U'&&s[i]!='D'){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
k, n = map(int, input().split())
l = list(map(int, input().split()))
m = []
for i in range(n- 1):
    m.append(l[i + 1] - l[i])
m.append(k - l[n - 1] + l[0])
m.sort()
print(sum(m) - m[n - 1])

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll color1 = 0;
    ll color2 = 0;
    ll color3 = 0;
    ll count = 1;
    rep(i,N){
        if (color1 == A[i] && color2 == A[i] && color3 == A[i]){
            color1++;
            count = (count * 3) % 1000000007;
        }
        else if (color1 == A[i] && color2 == A[i]){
            color1++;
            count = (count * 2) % 1000000007;
        }
        else if (color2 == A[i] && color3 == A[i]){
            color2++;
            count = (count * 2) % 1000000007;
        }
        else if (color1 == A[i]) color1++;
        else if (color2 == A[i]) color2++;
        else if (color3 == A[i]) color3++;
        else{
            count = 0;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3988
<?php /*atcoder.php*/

$t = new temp();

$t->stdin();

unset($t);

class temp{
	public function stdin(){
		$line1 = explode(" ", fgets(STDIN));
		$line2 = explode(" ", fgets(STDIN));
		$line3 = explode(" ", fgets(STDIN));

		$f = true;

		$con1 = $line1[0] - $line1[1];
		$con2 = $line2[0] - $line2[1];
		$con3 = $line3[0] - $line3[1];
		
		if($con1 != $con2 || 
			$con1 != $con3 || 
			$con2 != $con3){
			$f = false;
		}

		$con1 = $line1[1] - $line1[2];
		$con2 = $line2[1] - $line2[2];
		$con3 = $line3[1] - $line3[2];
		
		if($con1 != $con2 || 
			$con1 != $con3 || 
			$con2 != $con3){
			$f = false;
		}
		
		$con1 = $line1[0] - $line2[0];
		$con2 = $line1[1] - $line2[1];
		$con3 = $line1[2] - $line2[2];
		
		if($con1 != $con2 || 
			$con1 != $con3 || 
			$con2 != $con3){
			$f = false;
		}

		$con1 = $line2[0] - $line3[0];
		$con2 = $line2[1] - $line3[1];
		$con3 = $line2[2] - $line3[2];
		
		if($con1 != $con2 || 
			$con1 != $con3 || 
			$con2 != $con3){
			$f = false;
		}
		
		if($f){
			echo "Yes";
		}else{
			echo "No";
		}

	}
	
}

?>


Measured memory_bytes: 3828
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	int n,m,a;
	while(cin >> n >> m >>a && n!=0 && m!=0 && a!=0)
	{
		int ans[100]={};
		REP(i,100){ans[i]=i;}
		
		int h[1000]	={};
		int p[1000]	={};
		int q[1000]	={};
		
		REP(i,m){cin >> h[i] >> p[i] >> q[i];}
		
		REP(i,1001)
		{
			REP(j,m)
			{
				if(h[j]==i)
				{
					swap(ans[p[j]-1],ans[q[j]-1]);
				}
			}
		}
		
		cout << ans[a-1]+1 << endl;
	}
	return 0;
}

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

int main() {
	int N;					// 頂点数
	cin >> N;
	vector<vector<int>> to(N), cost(N);		// グラフ

	for (int i = 0; i < N-1; i++)	{
		// sからtへの辺を張る
		int s, t, w;
		cin >> s >> t >> w;
		s--;
		t--;
		to[s].push_back(t);  cost[s].push_back(w);
		to[t].push_back(s);	 cost[t].push_back(w);  // 無向グラフなので、両方向の辺を張る
	}

	vector<int> ans(N, -1);		// 頂点の色 塗る前:-1, 白:0, 黒:1
	queue<int> q;

	ans[0] = 0;
	q.push(0);

	while (!q.empty())	{
		int v = q.front();
		q.pop();
		for (int i = 0; i < to[v].size(); i++)	{
			int u = to[v][i];
			int w = cost[v][i];
			if (ans[u] != -1)	continue;
			ans[u] = (ans[v] + w) % 2;
			q.push(u);
		}
	}

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

	return 0;
}


Measured memory_bytes: 14552
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  int result=1;
  int min=p[0];
  for(int i=1;i<n;i++){
    if(min>p[i]){
      result++;
    }
    UpdateMin(min,p[i]);
  }
  cout<<result<<endl;


  return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
// #include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> // Общий файл. 
#include <ext/pb_ds/tree_policy.hpp> // Содержит класс tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define PI 3.14159265
#define int long long

typedef
tree<
  int,
  null_type,
  less<int>,
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;





main(){


	std::ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	int n; cin >> n;

	string s; cin >> s;

	set <int> m[26];

	for(int i = 0; i < n; i++){
		m[s[i] - 'a'].insert(i);
	}

	int q; cin >> q;


	int index, l, r, cnt, type; char c;
	for(int i = 0; i < q; i++){
		cin >> type;
		if(type == 1){
			cin >> index >> c; index--;

			if(c != s[index]){
				m[s[index] - 'a'].erase(index);
				m[c - 'a'].insert(index);
				s[index] = c;
			}
		}else{
			cin >> l >> r; l--, r--;

			cnt = 0;
			for(int j = 0; j < 26; j++){
				auto it = m[j].lower_bound(l);
				auto jt = m[j].upper_bound(r);

				if(it != jt) cnt++;

				// if(it == m[j].end() and jt == m[j].end()){
				// 	//
				// }else if(jt == m[j].end()){
				// 	cnt += m[j].order_of_key(n) - m[j].order_of_key(*it);
				// }else{
				// 	cnt += m[j].order_of_key(*jt) - m[j].order_of_key(*it);
				// }
			}

			cout << cnt << endl;
		}
	}
	
	
	
	
	return 0;
}

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

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  
  int sum = 0;
  
  if (a + b > c * 2) {
    if (x >= y) {
      for (int i = 0; i < y; i++) {
        sum += c * 2;
      }
      if (a > c * 2) {
        sum += c * 2 * (x - y);
      }
      else if (a <= c * 2) {
        sum += a * (x - y);
      }
    }
    else if (y > x) {
      for (int i = 0; i < x; i++) {
        sum += c * 2;
      }
      if (b > c * 2) {
        sum += c * 2 * (y - x);
      }
      else if (b <= c * 2) {
        sum += b * (y - x);
      }
    }
  }
  
  else if (a + b <= c * 2) {
    sum = a * x + b * y;
  }
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from itertools import product

def main():
  input = sys.stdin.readline
  N, A, B, C = map(int, input().split())
  L = [int(input()) for _ in range(N)]
  ans = float('inf')
  for s in product(range(4), repeat=N):
    X = [0, 0, 0, 0]
    Y = [0, 0, 0, 0]
    for i in range(len(L)):
      X[s[i]] += L[i]
      Y[s[i]] += 1
    if Y[0]*Y[1]*Y[2] == 0:
      continue
    elongate = abs(X[0] - A) + abs(X[1] - B) + abs(X[2] - C)
    connect = (sum(Y[:3]) - 3) * 10
    ans = min(ans, elongate+connect)
  
  print(ans)
  

if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
let f a b c d = [abs (a-b) <= d; abs (b-c) <= d; abs (c-a)<= d];;
let f2 [b1;b2;b3] = if b3 then "Yes" else (if b2 && b1 then "Yes" else "No");;
let () = Scanf.scanf "%d %d %d %d" f
|> f2 |> Printf.printf "%s\n"

Measured memory_bytes: 384
use proconio::{input, fastout};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! { n: usize, }
    let mut aa: HashMap<u32, u64> = HashMap::new();
    for _ in 0..n {
        input! { a: u32, }
        let count = aa.entry(a).or_insert(0);
        *count += 1;
    }
    let mut ans = 0;
    for (k, v) in &aa {
        ans += *k as u64 * v;
    }

    input! { q: usize, }
    for _ in 0..q {
        input! { b: u32, c: u32, }
        let bc: u64;
        match aa.remove(&b) {
            None => {
                bc = 0;
            },
            Some(v) => {
                bc = v;
                ans -= b as u64 * bc;
            },
        }
        let count = aa.entry(c).or_insert(0);
        *count += bc;
        ans += c as u64 * bc;
        println!("{}", ans);
    }
}


Measured memory_bytes: 7168
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MON 1000000007
#define INF (1LL<<60)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

Int dist[108][108];
Int n, m, x, y, w;
int main(){
  cin >> n >> m;
  for(Int i = 0;i < n;i++)
    for(Int j = 0;j < n;j++)
      dist[i][j] = INF;
  for(Int i = 0;i < m;i++){
    cin >> x >> y >> w;
    dist[x][y] =  w;
  }
  for(Int i = 0;i < n;i++)
    for(Int j = 0;j < n;j++)
      for(Int k = 0;k < n;k++)
	if(dist[j][i] != INF && dist[i][k] != INF)
	  dist[j][k] = min(dist[j][i] + dist[i][k], dist[j][k]);

  for(Int i = 0;i < n;i++){
    if(dist[i][i] < 0){
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
    dist[i][i] = 0;
  }

  for(Int i = 0;i < n;i++){
    for(Int j = 0;j < n;j++){
      if(j)cout << " ";
      if(dist[i][j] == INF)cout << "INF";
      else cout << dist[i][j];

    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3196
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        String s = in.next();
        out.println(
                s.charAt(0) >= 'a' ? "a" : "A"
        );
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


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

using namespace std;

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int x;
  cin>>x;
  if(x<1200)
    cout<<"ABC\n";
  else
    cout<<"ARC\n";
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
import java.lang.Math;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.close();

        int M = 0;
        for(int i = 1;i<=N;i++){
            for(int j = 1;j<=N;j++){
                // M = M + gcd(i,j);
                for(int k = 1;k<=N;k++){
                    M = M + gcd(i,gcd(j,k));
                }
            }
        }
        System.out.print(M);
    }

    public static int gcd(int a,int b){
        int c = a;
        a = Math.min(a,b);
        b = Math.max(c,b);

        while(b%a != 0){
            c = a;
            a = b%a;
            b = c;
        }
        return a;
    }
}

Measured memory_bytes: 35680
import java.util.*;
import javax.lang.model.util.ElementScanner6;
//import java.lang.Math;

public class Main {

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

        // 入力
        int n = sc.nextInt();
        int m = sc.nextInt();
        //String s = sc.next();

        // 処理
        int out = n;
        for(int i = 0; i < m; i++){
            out -= sc.nextInt();
        }
        if (out < 0) out = -1;

        // 出力
        System.out.println(out);
    }
}

Measured memory_bytes: 46280
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn dfs(n: usize, m: u8, v: Vec<u8>) -> String {
    let l = v.len();
    if l == n {
        return v.iter().map(|&i| i as char).collect::<String>() + "\n";
    }

    let mut ans = "".to_string();
    for i in 97..m+1 {
        let mut v2 = v.clone();
        v2.push(i);
        ans = ans + &dfs(n, m, v2);
    }
    let mut v2 = v.clone();
    v2.push(m+1);
    ans = ans + &dfs(n, m+1, v2);

    return ans;
}

fn main() {
    let n = read1::<usize>();

    println!("{}", dfs(n, 97u8, vec![97u8]));
}

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

int main(){
  while(1){
    int n,m; //個数 n、最大金額 m
    cin >> n >> m;
    if(n==0&&m==0) break;

    int a[n];
    for(int i=0; i<n; i++) cin >> a[i]; //品物の価格

    int ans = -1;
    for(int i=0; i<n; i++){
      for(int j=i+1; j<n; j++){
        if(a[i] + a[j] <= m){
          ans = max(ans, a[i] + a[j]);
        }
      }
    }
    if(ans == -1) cout << "NONE" << endl;
    else cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3108
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	char S[4];

	for (int i = 0; i < 4; i++){
		cin >> S[i];
	}

	sort(S, S + 4);

	if (S[0] == S[1] && S[0] != S[2] && S[2] == S[3]){
		cout << "Yes" << endl;
	}

	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

#define INF 100000000

using namespace std;

int main()
{
	int h, w;
	int c[10][10];
	int a, ans=0;
	int d[10];
	int n[10];

	for(int i=0; i<10; i++){
		n[i]=0;
	}

	scanf("%d %d", &h, &w);

	for(int i=0; i<10; i++){
		for(int j=0; j<10; j++){
			scanf("%d", &c[i][j]);
		}
	}
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			scanf("%d", &a);
			for(int k=0; k<10; k++){
				if(a==k){
					n[k]++;
				}
			}
		}
	}

	d[0]=INF;
	d[1]=0;
	for(int i=2; i<10; i++){
		d[i]=INF;
	}

	for(int k=0; k<9; k++){
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(d[i]+c[j][i]<d[j]){
					d[j]=d[i]+c[j][i];
				}
			}
		}
	}

	for(int k=0; k<10; k++){
		ans=ans+d[k]*n[k];
	}

	printf("%d\n", ans);

	return 0;

}

Measured memory_bytes: 128
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion

int dp[50][500][500];

int main()
{
	int n, ma, mb; cin >> n >> ma >> mb;
	int INF = 1e4;
	vector<int> a(n), b(n), c(n);
	rep(i, n)cin >> a[i] >> b[i] >> c[i];
	rep(i, 50)rep(j, 450)rep(k, 450)dp[i][j][k] = INF;
	dp[0][0][0] = 0;
	rep(i, n)rep(j, 405)rep(k, 405)
	{
		chmin(dp[i + 1][j][k], dp[i][j][k]);
		chmin(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
	}
	int res = INF;
	rep(i, n + 1)rep(j, 405)rep(k, 405)
	{
		if (i*j*k == 0)continue;
		if (j*mb == k * ma)chmin(res, dp[i][j][k]);
	}
	if (res == INF)cout << -1 << endl;
	else cout << res << endl;
}

Measured memory_bytes: 48768
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = 1e9 + 7;

int n, a[1000009], cnt[1000009];

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

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	bool ok = true;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		int tmp = a[i];
		for (int i = 2; i * i <= tmp; i++) {
			if (tmp % i == 0) {
				if (cnt[i]) ok = false;
				cnt[i]++;
				while (tmp % i == 0) tmp /= i;
			}
		}
		if (tmp > 1) {
			if (cnt[tmp]) ok = false;
			cnt[tmp]++;
		}
	}
	if (ok) cout << "pairwise coprime" << E;
	else {
		int cur = a[0];
		for (int i = 1; i < n; i++) {
			cur = gcd(cur, a[i]);
			if (cur == 1) break;
		}
		if (cur == 1) cout << "setwise coprime" << E;
		else cout << "not coprime" << E;
	}
	//system("pause");
	return 0;
}

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

using namespace std;

bool isStraight(vector<int> v, int s) {
	for (int i = 1; i < v.size(); ++i) {
		if (v[(s+i)%v.size()] != (v[(s+i-1+v.size())%v.size()]+1)%13) {
			return false;
		}
	}
	return true;
}
bool isStraight(vector<int> v) {
	return isStraight(v, 0) || (v[0] == 0 && isStraight(v, 1));
}
int main() {
	vector<int> a(5);
	while ( scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4]) != EOF ) {
		for (int i = 0; i < a.size(); ++i) {
			--a[i];
		}
		sort(a.begin(), a.end());
		vector<int> v(1, 1);
		int prev = a[0];
		for (int i = 1; i < a.size(); ++i) {
			if (prev == a[i]) {
				++v[v.size()-1];
			}
			else {
				v.push_back(1);
				prev = a[i];
			}
		}
		sort(v.begin(), v.end(), greater<int>());
		if (v[0] >= 4) {
			cout << "four card" << endl;
		}
		else if (v.size() >= 2 && v[0] >= 3 && v[1] >= 2) {
			cout << "full house" << endl;
		}
		else if ( isStraight(a) ) {
			cout << "straight" << endl;
		}
		else if (v[0] >= 3) {
			cout << "three card" << endl;
		}
		else if (v.size() >= 2 && v[1] >= 2) {
			cout << "two pair" << endl;
		}
		else if (v[0] >= 2) {
			cout << "one pair" << endl;
		}
		else {
			cout << "null" << endl;
		}
		
	}
}

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

t = list(input())
s = list(input())

del(t[-1])
del(s[-1])


for _ in range(len(t)):
    temp = t[-1]

    for i in range(len(t)-1):
        t[-1 - i] = t[-2 - i]
    t[0] = temp

    if t == s:
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 3064