akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>      // std::setprecision
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FENWICK(k) (k&-k)
#define FOREACH(i,t) for (auto i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define LL long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}};
const int fxx[8][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int rogi[4][2] = { {1,1}, {1,-1}, {-1,1}, {-1,-1} };

double n;

void dane() {
	cin>>n;
	cout<<((n-2)*180)<<endl;
}   


int main() {
	IOS
	// int t;
	// cin>>t;
	// F(i,0,t)
	    dane();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;
int x,y,z;
int ans;

int main(){
  cin >> x >> y >> z;
  x -= y+2*z;
  ans ++;
  ans += x/(y+z);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    string s;
    cin >> s;
    map<char, int> m;
    for (int i = 0; i < s.size(); ++i) {
        m[s[i]]++;
    }
    bool ok = true;
    if (m.size() == 2) {
        for (auto &p : m) {
            if (p.second != 2) {
                ok = false;
            }
        }
    } else {
        ok = false;
    }
    if (ok)
        cout << "Yes"
             << "\n";
    else
        cout << "No"
             << "\n";
    return 0;
}

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

// 隣接リストを用いた深さ優先探索（再帰ver.） O(|V|+|E|)
int n;
vector<int> G[100000], color(100000);
/*
* main関数からこれらを削除すること
* 隣接リストGの頂点数と訪問状態colorの要素数はnの最大値を整数で入力すること
*/

void dfs(int u) {
  color[u] = 1; // GRAY
  for(int i = 0; i < G[u].size(); i++){
    int v = G[u][i];
    if(color[v] == 0) dfs(v);
  }
  color[u] = 2; // BLACK
}

int main() {
// 無向(有向)グラフの隣接リスト
  int m, u, v, w;
  cin >> n >> m;
  
  for(int i = 0; i < m; i++){
    cin >> u >> v >> w;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u); // 有向グラフではこの行をコメントアウト
  }
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(color[i] == 0){
      dfs(i);
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 10752
use std::str::FromStr;
use std::io::stdin;

fn main() {
    let (n, r) = {
        let vec: Vec<i32> = read_vec();
        (vec[0], vec[1])
    };
    println!("{}", if n < 10 { 100 * (10 - n) + r } else { r });
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().split_whitespace().
        map(|x| x.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long int
#define ull long long int
#define float long double
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ALL(a) a.begin(),a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout<<" x is "<<x<<"\n"
using namespace std;

//inline size_t key( int a,int b,int c,int d) {return a*b*c*d-7707;}
//unordered_map<size_t,bool >vismap;


/*int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */  // 2 Direction
/*int dx[] = {1,0} , dy[] = {0,1};     */  // 4 Direction
/* int dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction
/*
struct myClass{

    int sum;
    int x;
    int y;

    bool operator < (myClass t) const{
        return sum<t.sum;
    }

};
 */
/*
ll fast_expo(ll a,ll b,ll m){
	if(b==0){
		return 1;
	}
	else{
		ll x=fast_expo(a,b/2,m);
		x*=x;
		x%=m;
		if(b%2==0){
			return x;
		}
		else{
			return (x*a)%m;
		}
	}
}

ll inverse(ll a,ll m){
	return fast_expo(a,m-2,m);
}
*/

/*

void prime_precomputation(vector<ll> &primes,int n){
	vector<int> v(n+10,0);
	v[0]=1;v[1]=1;
	for(int i=2;i*i<=n;i++){
		if(v[i]==0){
			for(int j=2*i;j<=n;j+=i){
				v[j]=1;
			}
		}
	}


}

*/

/*
void FTdfs(int src,vector<vector<int> > &adj, vector<int > & vis,stack<int> &Ftime){
	vis[src]=1;
	for(int i=0;i<adj[src].size();i++){
		int x=adj[src][i];
		if(vis[x]==0){
			FTdfs(x,adj,vis,Ftime);
		}
	}
	Ftime.push(src);
}

void dfs(int src,vector<vector<int> > &adj,vector<int> &vis ,int sc){
	vis[src]=1;
	um[src]=sc;
	scc[sc].pb(src);
	for(int  i=0;i<adj[src].size();i++){
		int x=adj[src][i];
		if(vis[x]==0){
			dfs(x,adj,vis,sc);
		}
	}
}

*/

/*

vector<pair<int,int> > compress(vector<int> &v){
	sort(v.begin(),v.end());
	int n=v.size();
	int cnt=0;
	vector<pair<int,int> > ret;
	for (int i=0;i<n;i++){
		if (i>0&&ar[i]!=ar[i-1]){
			ret.push_back(make_pair(ar[i-1],cnt));
			cnt=0;
		}
		cnt++;
	}
	ret.push_back(make_pair(ar[n-1],cnt));
	return ret;
}






*/

int main(){
	 fast
    cout<<fixed;
    cout<<setprecision(10);
    int q;
   // cin>>q;
    q=1;
    while(q--){
     ll n;
      cin>>n;
      vector<ll> v(n);
      for(int i=0;i<n;i++){
        cin>>v[i];
      }
      sort(ALL(v));
      cout<<v[n-1]-v[0];


    }
	return 0;
}


Measured memory_bytes: 256
#include <atcoder/segtree>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int op(int a, int b) { return max(a, b); }
int e() { return -1L; }

int V;
bool f(int a) { return a < V; }

int main(void) {
  ios::sync_with_stdio(false);
  int N, Q;
  cin >> N >> Q;
  vector<int> A(N);
  rep(i, N) { cin >> A[i]; }
  atcoder::segtree<int, op, e> seg(A);

  rep(i, Q) {
    int T;
    cin >> T;
    if (T == 1) {
      int X;
      int V;
      cin >> X >> V;
      X--;
      seg.set(X, V);
    } else if (T == 2) {
      int L, R;
      cin >> L >> R;
      L--;
      int answer = seg.prod(L, R);
      cout << answer << endl;
    } else {
      int X;
      cin >> X >> V;
      X--;
      int answer = seg.max_right<f>(X) + 1;
      cout << answer << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 6176
#include<bits/stdc++.h>
using namespace std; 
#define For(i , j , k) for (register int i = (j) , i##_end_ = (k) ; i <= i##_end_ ; ++ i) 
#define Mod (1000000007)
typedef long long LL; int _ , __; char c_; inline int read() { for (_ = 0 , __ = 1 , c_ = getchar() ; !isdigit(c_) ; c_ = getchar()) if (c_ == '-') __ = -1; for ( ; isdigit(c_) ; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48); return _ * __; } const int maxn = 1000010; int n, dp[maxn], Ans, pre[maxn]; inline void mod(int &x) { if (x >= Mod) x -= Mod; } int main() { n = read(); dp[0] = 1; pre[0] = 1; Ans = (LL)(n - 1) * (LL)(n - 1) % Mod; For(i, 1, n - 1) { dp[i]  = dp[i - 1] + (i - 3 >= 0 ? pre[i - 3] : 0); mod(dp[i]); pre[i] = pre[i - 1] + dp[i]; mod(pre[i]); if (i < n - 1) Ans += (LL)dp[i] * (LL)(n - 1) % Mod * (LL)(n - 1) % Mod, mod(Ans); else Ans += (LL)dp[i] * (LL)(n - 1) % Mod, mod(Ans); } For(i, 0, n - 2) { int x = i + 3, y = i + n + 1, z; if (x <= n) z = y - n + 1; else z = y - x + 1; dp[n] += (LL)dp[i] * z % Mod, mod(dp[n]); } dp[n] += dp[n - 1]; mod(dp[n]); Ans += dp[n]; mod(Ans); printf("%d\n", Ans); return 0; }

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

int main(void) {
int h, w; cin >> h >> w;
vector<string> ss(h);
for(int i=0; i<h; ++i) cin >> ss[i];
for(int i=0; i<h; ++i) cout << ss[i] << endl << ss[i] << endl;
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int H = reader.nextInt();
		int W = reader.nextInt();
		int[][] arr = new int[H][W];
		int[] Hbom = new int[H * W];
		int[] Wbom = new int[H * W];
		int count = -1;
		for (int i = 0; i < H; i++) {
			String str = reader.next();
			for (int j = 0; j < W; j++) {
				char ch = str.charAt(j);
				if (ch == '#') {
					arr[i][j] = -1;
					count++;
					Hbom[count] = i;
					Wbom[count] = j;
				} else {
					arr[i][j] = 0;
				}
			}
		}
		for (int i = 0; i <= count; i++) {
			int height = Hbom[i];
			int width = Wbom[i];
			if (height > 0) {
				if (width > 0) {
					add(arr, height-1, width-1);
				}
				add(arr, height-1, width);
				if (width < W-1) {
					add(arr, height-1, width+1);
				}
			}
			if (width > 0) {
				add(arr, height, width-1);
			}
			if (width < W-1) {
				add(arr, height, width+1);
			}
			if (height < H-1) {
				if (width > 0) {
					add(arr, height+1, width-1);
				}
				add(arr, height+1, width);
				if (width < W-1) {
					add(arr, height+1, width+1);
				}

			}
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (arr[i][j] == -1)  {
					System.out.print('#');
				} else {
					System.out.print(arr[i][j]);
				}
			}
			System.out.println();
		}
		reader.close();
	}
	public static void add(int[][] arr, int height, int width) {
		if (arr[height][width] != -1) {
			arr[height][width]++;
		}
	}
}





Measured memory_bytes: 23124
/*                                                                                 
	Author :- Gaurang_Kothiya
	
	Quote :- " Practice makes a man perfect. "		
*/  
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  
 
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ld long double
#define f(i,x,n) for(auto i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(auto i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
const ll inf= 1e9;
const ll inf64= 1e18;
const ll MOD= 1e9 +7;



void Solve()
{
	ll n;
	cin>>n;
	ll a[n];
	ll res;
	f(i,0,n-1)
	{
		cin>>a[i];
		if(i==0) res=a[i];
		else res = res ^ a[i];
	}
	f(i,0,n-1)
	{
		cout<< (res^a[i]) <<" ";
	}
} 
 
signed main() 
{
	speed		
	
	
	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
	
	return 0;
} 

Measured memory_bytes: 5208
using System;
using System.Collections.Generic;

namespace ABC133_A
{
    class Program
    {
        static void Main(string[] args) {
            
            string[] input = Console.ReadLine().Split();
            long n = long.Parse(input[0]);
            long a = long.Parse(input[1]);
            long b = long.Parse(input[2]);
            if (a * n > b)
                Console.WriteLine(b);
            else
                Console.WriteLine(a * n);

            return;

            List<long> list = new List<long>();
            for(long i = 0; i < n; i++) {
                list.Add(long.Parse(input[i]));
            }

            long ans = 0;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
a,b,c,d,e,f = map(int,input().split())
w = []
s = []
i = 0
while 100*a*i <= f:
  j = 0
  while 100*a*i + 100*b*j <= f:
    w.append(100*a*i+100*b*j)
    j += 1
  i += 1
i = 0
while c*i <= f:
  j = 0
  while c*i + d*j <= f:
    s.append(c*i+d*j)
    j += 1
  i += 1
mx = -1
mxw = 0
mxs = 0
for wi in w:
  for si in s:
    if wi + si <= f and 100*si <= wi*e:
      if si > mx*wi:
        mx = si/wi
        mxw = wi
        mxs = si
print(mxs+mxw,mxs)
        
      
  

Measured memory_bytes: 84676
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S, T;
    cin >> S >> T;
    bool flag = true;
    rep(i, S.size()) {
        if (S[i] != T[i]) flag = false;
    }

    if (flag) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 998244353;
ll N;
ll dp[301][100100];
ll dp2[301][100100];
vector<ll> a;
ll ans = 0;
ll asum;

ll beki(ll a, ll b) {
    if(b == 0) return 1;
    ll ret = beki(a, b / 2);
    ret = ret * ret % mod;
    if(b & 1) ret = ret * a % mod;
    return ret;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    a.resize(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    dp[0][0] = 1;
    dp2[0][0] = 1;
    for(int i = 0; i < N; i++) {
        asum += a[i];
        for(ll before = 0; before <= 9e4; before++) {
            dp[i+1][before] += dp[i][before];
            dp[i+1][before] %= mod;
            dp[i+1][before+a[i]] += dp[i][before];
            dp[i+1][before+a[i]] %= mod;
            dp2[i+1][before] += dp2[i][before] * 2;
            dp2[i+1][before] %= mod;
            dp2[i+1][before+a[i]] += dp2[i][before];
            dp2[i+1][before+a[i]] %= mod;
        }
    }
    /*
    for(int i = 0; i <= asum; i++) {
        cerr << i << " " << dp[N][i] << " " << dp2[N][i] << endl;
    }
    */
    ans = beki(3, N);
    cerr << ans << endl;
    ll tmp = beki(2, N);
    for(int i = (asum + 1) / 2; i <= asum; i++) {
        tmp += dp2[N][i];
    }
    tmp %= mod;
    cerr << 3 * tmp << endl;
    ans -= 3 * tmp;
    ans %= mod;
    ans += mod;
    ans %= mod;
    tmp = 0;
    tmp = 3;
    if(asum % 2 == 0) {
        tmp += 3 * dp[N][asum / 2];
    }
    tmp += 3 * beki(2, N);
    if(asum % 2 == 0) {
        tmp += 3 * dp[N][asum / 2];
    }
    ans += tmp;
    cerr << tmp << endl;
    tmp = 0;
    tmp = 3;
    if(asum % 2 == 0) {
        tmp += 3 * dp[N][asum / 2];
    }
    ans -= tmp;
    ans %= mod;
    ans += mod;
    ans %= mod;
    cerr << tmp << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 470016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n; cin >> n;
    vector<int> v(n+1);
    for(int i = 1; i <= n; i++)
        cin >> v[i];

    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(v[i] != i)
            cnt++;
    }
    cout << (cnt <= 2 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(ll i=m ; i<=n ; i++)
#define clr(v, val) memset(v,val,sizeof(v))
#define endl '\n'
#define pb push_back
#define pff push_front
#define re return
const int N = 3e4 + 5;
const ll mod = ll(1e9) + 7;
using namespace std;
ll fact[N], inv[N];

ll fp(ll base, ll exp) {
    if (exp == 0)
        re 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    re ans;
}

void calcFacAndInv(ll n) {
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++) {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r) {
    re ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

int main() {
    IO;
    calcFacAndInv(N);
    ll n, k;
    cin >> n >> k;
    forr(i, 1, k) {
        ll ans = 0;
        if (n - k + 1 >= i) {
            ans = (ncr(n - k + 1, i) % mod) * (ncr(k - 1, i - 1) % mod);
            ans %= mod;
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 768
#include<iostream>
#include<string.h>
using namespace std;

int main(){

  string str;

  cin >> str;
  for(int i=0;str[i+1]!='\0';i++){
    if(str[i]=='A' && str[i+1]=='C'){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
   
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int k,t;
    cin >> k >> t;
    vector<int>a(t);
    rep(i,t)cin >> a[i];
    sort(all(a));
    reverse(all(a));
    int ans = max(0,a[0]-1-(k-a[0]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys
import itertools


def solve(X: int):
    for a in range(-118, 119):
        for b in range(-119, 118):
            if a**5-b**5 == X:
                print(f'{a} {b}')
                return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63904
#include<iostream>
using namespace std;
 
int main(){
    int a, b;

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

    return 0;		 
}



Measured memory_bytes: 3104
#include<stdio.h>

int main(){
  int n;
  long a[100000],cnt=0;
  scanf("%d",&n);
  scanf("%ld",&a[0]);
  cnt+=a[0]/2;
  a[0]%=2;
  for(int i=1;i<n;i++){
    scanf("%ld",&a[i]);
    if(a[i-1]&&a[i]){
      cnt++;
      a[i-1]--;
      a[i]--;
    }
    cnt+=a[i]/2;
    a[i]%=2;
  }
  printf("%ld\n",cnt);
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define taskname "abc42_b"
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    int n; cin >> n;
    int a = n / 100, b = n % 100;
    if (a && b && a <= 12 && b <= 12) cout << "AMBIGUOUS";
    else if (a && a <= 12) cout << "MMYY";
    else if (b && b <= 12) cout << "YYMM";
    else cout << "NA";
}


Measured memory_bytes: 3588
s=input()
if s[0]==s[1] and s[1]!=s[2] and s[2]==s[3]:
    print("Yes")
elif s[0]==s[3] and s[0]!=s[1] and s[1]==s[2]:
    print("Yes")
elif s[0]==s[2] and s[1]!=s[2] and s[1]==s[3]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    int table[4]={0};
    while(1){
        int a,b,c;
        cin >> a >> b >> c;
        if(a>b&&a>c){
            if(a>=b+c)   break;
            if(a*a==b*b+c*c)  table[1]++;
            else if(a*a<b*b+c*c)  table[2]++;
            else    table[3]++;  
        }
        else if(b>a&&b>c){
            if(b>=a+c)   break;
            if(b*b==a*a+c*c)  table[1]++;
            else if(b*b<a*a+c*c)  table[2]++;
            else    table[3]++; 
        }
        else{
            if(c>=a+b)   break;
            if(c*c==b*b+a*a)  table[1]++;
            else if(c*c<b*b+a*a)  table[2]++;
            else    table[3]++; 
        }
        table[0]++;
    }
    cout << table[0] << " " << table[1] << " " << table[2] << " " << table[3] << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

int main(void){
  int N,K;
  cin>>N>>K;
  long x[N]; 
  for(int i=0;i<N;i++){
    cin>>x[i];
  }
  long ans=1000000000;
  for(int i=0;i<=N-K;i++){
     ans=min(ans,x[i+K-1]-x[i]+abs(x[i]));
     ans=min(ans,x[i+K-1]-x[i]+abs(x[i+K-1]));
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
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 = 100000; 

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

   string s = to_string(a);
   string t = to_string(b);
   for(int i = 1; i < b; i++){
       s += to_string(a);
   }

    for(int i = 1; i < a; i++){
        t += to_string(b);
    }

    if(s < t){
        cout << s << endl;
    }else{
        cout << t << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from sys import stdin

N = int(stdin.readline().rstrip())
V = [int(x) for x in stdin.readline().rstrip().split()]
C = [int(x) for x in stdin.readline().rstrip().split()]

max_profits = 0
for i in range(N):
   profit = (V[i] - C[i]) 
   if profit > 0 :
        max_profits = max_profits + profit

print(max_profits)

exit(0)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;


ll fn(ll H) {
	if (H == 1) return 1;
	else return 1 + 2 * fn(H/2);
}

int main() {
	ll H;
	cin >> H;
	cout << fn(H) << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll f(ll x, int c, int d) {
	ll res = x;
	res -= x / c;
	res -= x / d;
	res += x / lcm(c, d);
	return res;
}
int main() {
	ll a, b;
	int c, d;
	cin >> a >> b >> c >> d;
	ll ans = f(b, c, d) - f(a - 1, c, d);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  cin >> n;
  int na=0,is=0;
  string nak[100];
  string iso[100];
  for(int i=0;i<n;i++){
    cin >> iso[i];
  }
  for(int i=0;i<n;i++){
    cin >> nak[i];
  }
  int po=0;
  //han
  for(int i=0;i<n;i++){
    //
    if(iso[i]=="tameru"){
      if(is < 5)is++;
      po=0;
    }
    //
    else if(iso[i]=="kougekida"){
      if(is==0){
	if(nak[i]=="kougekida"&&na==0){
	  if(i==n-1)cout << "Hikiwake-kun" << endl;
	  continue;
	}
	else{
	  cout << "Nakajima-kun" << endl;
	  break;
	}
      }
      else po=1;
    }
    //
    else if(iso[i]=="mamoru"){
      po=2;
    }

    //////
    //////
    if(nak[i]=="tameru"){
      if(na<5)na++;
      if(po==1){
	cout << "Isono-kun" << endl;
	break;
      }
    }
    //
    else if(nak[i]=="kougekida"){
      if(na==0&&po!=-1){
	cout <<  "Isono-kun" << endl;
	break;
      }
      if(po==1){
	if(na>is)cout << "Nakajima-kun" << endl;
	else if(na<is) cout <<  "Isono-kun" << endl;
	else{
	  is=0;
	  na=0;
	  continue;
	}
	break;
      }
      else if(po==2){
	if(na==5){
	  cout << "Nakajima-kun" << endl;
	  break;
	}
	na=0;
      }
      else{
	cout << "Nakajima-kun" << endl;
	break;
      }
    }
    else if(nak[i]=="mamoru"){
      if(is==5){
	cout <<  "Isono-kun" << endl;
	break;
      }
    }
    if(po==1)is=0;
    if(i==n-1)cout << "Hikiwake-kun" << endl;
  }
  
  return 0;
}

      

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

int kaijo(int nb)
{
	int sum = 1;
	while (nb > 0)
	{
		sum *= nb;
		nb--;
	}
	return (sum);
}

int main(void)
{
	int N;
	scanf("%d", &N);
	int P[N];
	int Q[N];
	int total = kaijo(N);
	int i,j,ans1 = 0,ans2 = 0;
	i = 0;
	while (i < N)
		scanf("%d", &P[i++]);
	i = 0;
	while (i < N)
		scanf("%d", &Q[i++]);
	i = 0;
	int k,p,q;
	while (i < N)
	{
		j = 0;
		p = 0;
		q = 0;
		k = i;
		while (j < k)
		{
			if (P[j] < P[i])
				p++;
			if (Q[j] < Q[i])
				q++;
			j++;
		}
		ans1 += kaijo(N - (i + 1)) * (P[i] - 1 - p);
		ans2 += kaijo(N - (i + 1)) * (Q[i] - 1 - q);
		i++;
	}
	ans1++;
	ans2++;
	printf("%d\n", abs(ans1 - ans2));
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;


typedef pair <char, int> CARD;
typedef vector <CARD> CARDS;
const int SIZE = 9;

CARDS C;

void init() {
    C = CARDS(SIZE);
}

void input() {
    for ( int i = 0; i < SIZE; ++ i ) {
        cin >> C[i].second;
    }
    for ( int i = 0; i < SIZE; ++ i ) {
        cin >> C[i].first;
    }
}

bool check( CARDS C ) {
    sort( C.begin(), C.end() );
    for ( int i = 0; i < 3; ++ i ) {
        for ( int j = 0; j < 3; ++ j ) {
            if ( C[i].first != C[j].first ) return false;
        }
    }
    bool flag = true;
    for ( int i = 0; i < 3; ++ i ) {
        for ( int j = 0; j < 3; ++ j ) {
            if ( C[i].second != C[j].second ) flag = false;
        }
    }
    if ( flag ) return true;
    for ( int i = 0; i+1 < 3; ++ i ) {
        if ( C[i].second + 1 != C[i+1].second ) return false;
    }
    return true;
}

int solve() {
    sort( C.begin(), C.end() );
    do {
        bool flag = true;
        flag &= check( CARDS( C.begin(), C.begin()+3 ) );
        flag &= check( CARDS( C.begin()+3, C.begin()+6 ) );
        flag &= check( CARDS( C.begin()+6, C.begin()+9 ) );
        if ( flag ) return 1;
    } while( next_permutation( C.begin(), C.end() ) );
    return 0;
}

int main() {
    int tests;
    cin >> tests;
    for ( int i = 0; i < tests; ++ i ) {
        init();
        input();
        cout << solve() << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
import heapq

N, K = map(int, input().split())
sushi = []

for _ in range(N):
    t, d = map(int, input().split())
    sushi.append((t, d))
sushi = sorted(sushi, key=lambda x: -x[1])

d_sushi = []  # 捨てる候補の寿司
heapq.heapify(d_sushi)  # リストaのheap化

fp = 0
tp = set()

for i in range(K):
    fp += sushi[i][1]
    if sushi[i][0] in tp:
        heapq.heappush(d_sushi, sushi[i][1])
    else:
        tp.add(sushi[i][0])
ans = fp+len(tp)**2

if N == K:
    print(ans)
    exit()

j = K
while d_sushi and len(tp) <= N:
    while sushi[j][0] in tp:
        j += 1
        if j == N:
            print(ans)
            exit()
    fp = fp-heapq.heappop(d_sushi)+sushi[j][1]
    tp.add(sushi[j][0])
    ans = max(ans, fp+len(tp)**2)

print(ans)


Measured memory_bytes: 22236
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int a, b, c; cin >> a >> b >> c;
  if(a+b == c || a+c == b || b+c== a){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  system("pause");
}

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

int main(){
    int N;
    cin >> N;
    double ans = 0;
    for ( int i = 0; i < N; i++){
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") ans += x;
        else ans += 380000.0 * x;
    }
    cout << ans << endl;
}

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

// 標準入力から改行かスペースまで読み取り、数字として返す
int get_num() {
    // 10文字+区切り文字までしか受け付けられない
    char s[11];
    int i, n;
    for (i = 0; i < sizeof(s); i++) {
        s[i] = getchar();
        if (s[i] == ' ' || s[i] == '\n') {
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}

int main(void) {
    int i, n, x;
    int m[1001];
    int count;
    
    int min_i, min_m;
    
    n = get_num();
    x = get_num();

    for (i = 0; i < n; i++) {
        m[i] = get_num();
    }
//    printf("n = %d\n", n);
//    printf("x = %d\n", x);
//    for (i = 0; i < n; i++) {
//        printf("m[%d] = %d\n", i, m[i]);
//    }

    min_i = 0;
    min_m = m[0];
    
    for (i = 0; i < n; i++) {
        if (m[i] < min_m) {
            min_m = m[i];
            min_i = i;
        }
        x -= m[i];
    }
    count = n;
    count += x / min_m;
    
    printf("%d\n", count);
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int w,h;
int dh[4]={1,0,-1,0},dw[4]={0,1,0,-1},d[900],inf=1e8;
bool iswall[59][30];
void bfs(int s){
	queue<int> que;
	que.push(s);
	rep(i,w*h) d[i]=inf;
	d[s]=0;
	while(!que.empty()){
		int q=que.front();
		que.pop();
		int hh=q/w,ww=q%w;
		rep(i,4){
			int nh=hh+dh[i],nw=ww+dw[i];
			if(0<=nh && nh<h && 0<=nw && nw<w && d[nh*w+nw]==inf){
				if(i==0 && iswall[2*nh-1][nw]) continue;
				if(i==1 && iswall[2*nh][nw-1]) continue;
				if(i==2 && iswall[2*nh+1][nw]) continue;
				if(i==3 && iswall[2*nh][nw]) continue;
				que.push(nh*w+nw);
				d[nh*w+nw]=d[q]+1;
			}
		}
	}
}
int main(){
	while(true){
		cin >> w >> h;
		if(w==0) break;
		rep(i,h-1){
			rep(j,w-1) cin >> iswall[i*2][j];
			rep(j,w) cin >> iswall[i*2+1][j];
		}
		rep(j,w-1) cin >> iswall[h*2-2][j];
		bfs(0);
		if(d[w*h-1]==inf) d[w*h-1]=-1;
		cout << d[w*h-1]+1 << endl;
	}
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long double ll;
typedef pair <int,int> P;

ll a,b;
ll h,m;

int main(){
  ll pi = M_PI;
  cout << setprecision(20) << fixed;
  cin >> a >> b >> h >> m;
  ll p = a*sin(2.0*pi/12.0 *(h+m/60.0)) - b*sin(2.0*pi/60.0 * m);
  ll q = a*cos(2.0*pi/12.0 *(h+m/60.0)) - b*cos(2.0*pi/60.0 * m);
  //cout << p << endl;
  //cout << q << endl;
  cout << sqrt(p*p + q*q) << endl;

  return 0;
}


Measured memory_bytes: 4172
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

int N;
int a[200100];
int x;

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

  cin>>N>>x;
  for(int i=0;i<N;i++) cin>>a[i];

  ll res=0;
  for(int i=1;i<N;i++) {
    if (a[i-1] + a[i] > x) {
      int d = a[i-1]+a[i]-x;
      res += d;
      if (d <= a[i])
        a[i] -= d;
      else
        a[i-1] -= d-a[i], a[i] = 0;
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 640
n, x = map(int, input().split())
l = list(map(int, input().split()))

d = [0]*(n+1)
for i in range(n):
    d[i+1] = d[i] + l[i]
    
ans = 0
for j in range(n+1):
    if d[j] <= x:
        ans += 1
    else:
        break

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli N, D, A;
pll XH[200000] = {};


int main(void) {

	lli t = 0;
	lli ans = 0;
	queue<pll> q;

	cin >> N >> D >> A;
	for (int i = 0; i < N; i++) {
		cin >> XH[i].first >> XH[i].second;
	}

	sort(XH, XH + N);

	for (int i = 0; i < N; i++) {


		while (!q.empty() && q.front().first < XH[i].first) {
			t -= q.front().second;
			q.pop();
		}

		const lli count = ((XH[i].second - t * A) + A - 1) / A;
		if (count >= 0) {
			t += count;
			ans += count;
			q.push(pll(XH[i].first + 2 * D, count));
		}
	}

	COUT(ans);

	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N; cin >> N;
    vll L(N);
    for(int i=0; i<N; i++){
        cin >> L[i];
    }
    sort(L.begin(),L.end(),greater<ll>());
    ll c = 0;
    for(int i=0; i<N-2; i++){
        for(int j=i+1; j<N-1; j++){
            for(int k=j+1; k<N; k++){
                if(L[i] < L[j] + L[k]){
                    c++;
                }else{
                    break;
                }
            }
        }
    }
    cout << c;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define FOR(i, a, n) for(int i=a; i<n; i++)
#define RFOR(i, a, n) for(int i=n-1; i>=a; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)

int main()
{
	int x, y, s;
	while (cin >> x >> y >> s, x||y||s) {
		int max_v = 0;
		FOR(i, 1, s) {
			FOR(j, 1, s) {
				int val = i*(100 + x) / 100 + j*(100 + x) / 100;
				if (val == s) {
					max_v = max(max_v, i * (100 + y) / 100 + j * (100 + y) / 100);
				}
				if (val > s) break;
			}
		}

		cout << max_v << endl;
	}
	return 0;
}

Measured memory_bytes: 3036
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let r = get!();
    
    if r < 1200 {
    	println!("ABC");
    } else if r < 2800 {
    	println!("ARC");
    } else {
    	println!("AGC");
    }
    
    
}

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

int main(){
    int N ;
    cin >> N;
    vector<int> A(N-1);
    vector<int> buka(200000);
    for (int i = 0; i < N-1; i++)
    {
        cin >> A[i] ;
        buka[A[i]-1]++ ;
    }
    
    for (int i = 0; i < N; i++)
    {
        cout << buka[i] <<endl ;
    }
    
    

    return 0 ;
}

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

long long getKey(const string &s){
  long long res = 0;

  for(int i = 0; i < s.size(); i++){
    res *= 10;

    switch(s[i]){
    case 'A': res += 1; break;
    case 'C': res += 2; break;
    case 'G': res += 3; break;
    case 'T': res += 4; break;
    }
  }

  return res;
}

/*
int getKey(const string &s){
  int res = 0;
  for(int i = 0; i < s.size(); i++){
    res *= 5;
    switch(s[i]){
      case 'A': res += 1; break;
      case 'C': res += 2; break;
      case 'G': res += 3; break;
      case 'T': res += 4; break;
    }
  }
  return res;
}
*/

int main(){
  set<long long> s;
  int n;
  cin >> n;

  for(int i = 0; i < n; i++){
    string op;
    string str;
    cin >> op >> str;

    if(op == "insert"){
      s.insert(getKey(str));
    }
    else if(s.find(getKey(str)) != s.end()){
      cout << "yes" << endl;
    }
    else{
      cout << "no" << endl;
    }
  }
}



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

class Program {
    static void Main(string[] args) {
        var s = Console.ReadLine().Split(' ');
        string A = s[0];
        string B = s[1];

        Console.WriteLine(B + A);


    }
}

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

using namespace std;

const int MOD = 998244353;

typedef long long ll;

int mul(ll a, int b){
    return (a * b) % MOD;
}

void smul(int &a, int b){
    a = mul(a, b);
}

int main(){
    string s;
    int n;cin >> n >> s;
    map<char, int> mp;
    mp['R'] = 0;
    mp['G'] = 1;
    mp['B'] = 2;
    int cnt[3] = {}, ans=1;
    for(int i=1 ; i<=n ; i++)
        smul(ans, i);
    for(auto c : s){
        while(cnt[0] && cnt[1] && cnt[2]){
            cnt[0] --;
            cnt[1] --;
            cnt[2] --;
        }
        int cur = mp[c];
        int prv = (cur+2)%3;
        int nxt = (cur+1)%3;
        if(cnt[prv] && cnt[nxt])
            smul(ans, min(cnt[prv], cnt[nxt]));
        else if(cnt[prv]-cnt[cur] > 0)
            smul(ans, cnt[prv] - cnt[cur]);
        else if(cnt[nxt]-cnt[cur] > 0)
            smul(ans, cnt[nxt] - cnt[cur]);
        cnt[cur] ++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 900
s = input() 
if s[0]=="R":
  if s[1]=="R":
    if s[2]=="R":
      print(3) 
    else:
      print(2)
  else:
    print(1) 
else:
  if s[1]=="R":
    if s[2]=="R":
      print(2) 
    else:
      print(1)
  else:
    if s[2]=="R":
      print(1) 
    else:
      print(0) 
    

Measured memory_bytes: 9104
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());

  vector<bool> f(1000001, true);
  int res = 0;
  rep(i,n) {
    if(i != n-1) {
      if(a[i] != a[i+1] && f[a[i]]) res++;
    }
    else if(f[a[i]]) res++;

    if(f[a[i]]) {
      int x = a[i];
      while(1) {
	f[x] = false;
	if(x + a[i] > 1000000) break;
	x += a[i];
      }
    }    
  }

    
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 4308
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    string s,t;
    
    cin>>s>>t;
    
    int ans=t.size();
    
    for(int start=0;start<=s.size()-t.size();start++){
        int diff=0;
        for(int i=0;i<t.size();i++){
            if(t[i]!=s[start+i]){
                diff++;
            }
        }
        ans=min(ans,diff);
    }
    cout<<ans<<endl;
}


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

int main()
{
	int a[10],k;
	for(int i=0;i<5;i++){
		cin>>a[i];
	}
	int sum = 0 , mi = 1000;
	for(int i=0;i<5;i++){
		int s = a[i]%10;
		if(s<mi&&s!=0){
			mi = s ;
		}
		if((a[i]/10)==0){
			sum +=10;
			continue;
		}
		if(s!=0){
			sum = sum + a[i]/10*10 + 10;
		}else {
			sum += a[i];
		}
		//cout<<sum<<endl;
	}
	if(mi==1000) cout<<sum<<endl; 
	else cout<<sum-10 + mi<<endl; 
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int maxn = 1e5;
int n, l, a[maxn];

int main(void) {
  scanf("%d%d", &n, &l);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < n - 1; ++i) {
    if (a[i] + a[i + 1] >= l) {
      puts("Possible");
      for (int j = 0; j < i; ++j) {
        printf("%d ", j + 1);
      }
      for (int j = n - 2; j >= i; --j) {
        printf("%d ", j + 1);
      }
      puts("");
      return 0;
    }
  }
  puts("Impossible");
  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
template<class T>inline int cmp(vector<T>&v,T &a){
	return lower_bound(all(v),a)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int f(int x){
	int res=0;
	rep(i,50){
		int j=x>>(i+1);j--;
		int cnt=(1ll<<i)*j;
		if(x>>i&1)cnt+=x%(1ll<<i)+1;
		if(cnt%2)res+=1ll<<i;
	}
	return res;
}
signed main(){
	int A,B;cin>>A>>B;
	cout<<(f(B)^f(A-1))<<"\n";
}


Measured memory_bytes: 3600
k = int(input())
ans = [str(i) for i in range(1, 10)]
tmp = [str(i) for i in range(1, 10)]
cnt = 10
if k<=9:
    print(k)
else:
    while cnt<=k:
        ap = []
        for t in tmp:
            if t[-1]=='0':
                ap.append(t+'0')
                ap.append(t+'1')
            elif t[-1]=='9':
                ap.append(t+'8')
                ap.append(t+'9')
            else:
                l = int(t[-1])
                ap.append(t+str(l-1))
                ap.append(t+str(l))
                ap.append(t+str(l+1))
        cnt += len(ap)
        tmp = ap
    print(tmp[k-cnt])

Measured memory_bytes: 15636
#include <iostream>
#include <vector>
using namespace std;
typedef long long int ll;

int main()
{
    ll N,K,Q;
    cin>>N>>K>>Q;
    vector<ll> pt(N,K-Q);
    int num;
    for(int i=0;i<Q;i++)
    {
        cin>>num;
        pt[num-1]++;
    }
    for(int i=0;i<N;i++)
    {
        if(pt[i]<=0)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }


}

Measured memory_bytes: 1408
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  private Scanner sc = new Scanner(System.in);

  private void run() {
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int M = Integer.parseInt(sc.next());
    
    int[] as = new int[A];
    int minA = 99999999;
    for (int i = 0; i < A; i++) {
      as[i] = Integer.parseInt(sc.next());
      minA = Math.min(minA, as[i]);
    }

    int[] bs = new int[B];
    int minB = 99999999;
    for (int i = 0; i < B; i++) {
      bs[i] = Integer.parseInt(sc.next());
      minB = Math.min(minB, bs[i]);
    }

    int minAplusB = minA + minB;
    int minPrice = minA + minB;

    for (int i = 0; i < M; i++) {
      int fridgeIdx = Integer.parseInt(sc.next()) - 1;
      int microwaveIdx = Integer.parseInt(sc.next()) - 1;
      int discountPrice = Integer.parseInt(sc.next());
      minPrice = Math.min(minPrice, as[fridgeIdx] + bs[microwaveIdx] - discountPrice);
    }

    System.out.println(minPrice);
  }
}


Measured memory_bytes: 67912
#include <iostream>
#include <map>

using Key = std::string;

int main(void) {
    int q;
    std::cin >> q;

    std::multimap<Key, int> my_multi_map{};
    using Iterator = decltype(my_multi_map)::iterator;
    for (int i = 0; i < q; ++i) {
        int kind;
        std::cin >> kind;

        Key key;
        int x;
        std::pair<Iterator, Iterator> range;
        switch (kind) {
            case 0:
                std::cin >> key >> x;
                my_multi_map.insert(std::pair<Key, int>(key, x));
                break;
            case 1:
                std::cin >> key;
                range = my_multi_map.equal_range(key);
                for (Iterator iter = range.first; iter != range.second;
                     ++iter) {
                    std::cout << iter->second << std::endl;
                }
                break;
            case 2:
                std::cin >> key;
                my_multi_map.erase(key);
                break;
            case 3:
                Key left, right;
                std::cin >> left >> right;
                for (auto iter = my_multi_map.lower_bound(left);
                     iter != my_multi_map.upper_bound(right); ++iter) {
                    std::cout << iter->first << ' ' << iter->second
                              << std::endl;
                }
        }
    }
}


Measured memory_bytes: 24816
#include <bits/stdc++.h>
using namespace std;
int main(){
  	int P, Q, R, i , a[3];
		cin >> P >> Q >> R;
  		a[0]=P+Q;
		a[1]=Q+R;
		a[2]=R+P;
		int min = a[0];
		for(i=1; i<3; i++){
			if(a[i]<=min){
				min = a[i];
			}
			}
  
   cout << min <<endl;
}


Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp
ans = 0
1000.times do |i|
    str = sprintf("%03d", i)
    i1 = s.index(str[0])
    if i1
        i2 = s[(i1 + 1)..-1].index(str[1])
        if i2
            i3 = s[(i1 + i2 + 2)..-1].index(str[2])
            if i3
                ans += 1
            end
        end
    end
end
puts ans


Measured memory_bytes: 1788