akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	static ArrayList<Integer> list = new ArrayList<Integer>();
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		makePrimeList(50001);
		int[] listx = new int[50001];
		for(int i = 0; i < list.size(); i++) {
			for(int j = i; j < list.size(); j++) {
				int sum = list.get(i) + list.get(j);
				if(sum > 50000) break;
				listx[sum]++;
			}
		}
		while(true) {
			int n = (int)sc.nextLong();
			if(n == 0) break;
			
			
			out.println(listx[n]);
		}
		out.flush();
	}

	public static void makePrimeList(int n) {
		boolean[] isntPrime = new boolean[n];
		isntPrime[0] = isntPrime[1] = true;
		list.add(2);
		for(int i = 3; i < n; i+=2) {
			if(!isntPrime[i]) {
				list.add(i);
				for(int j = i+i; j < n; j+=i) {
					isntPrime[j] = true;
				}
			}
		}
	}
	
	
	
	
}
	
//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}

Measured memory_bytes: 24088
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n; cin >>n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >>a[i];
  }

  sort(a.begin(), a.end());
  a.push_back(0);

  int ret = 0;
  vector<bool> p(a[n-1], true);
  for (int i = 0; i < n; i++) {
    if (!p[a[i]]) continue;
    if (a[i]==a[i+1]) p[a[i]] = false;
    int t = 2;
    while (a[i]*t<=a[n-1]) {p[a[i]*t] = false; t++;}
  }

  for (int i = 0; i < n; i++) {
    if (p[a[i]]) ret++;
  }

  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 4812
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string s; cin >> s;
    int n = s.size() - 2;

    cout << s[0] << n << s[n+1] << endl;
}

Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)

if h % 3 == 0 || w % 3 == 0
    puts 0
else
    ans = [h, w]

    x = w / 3
    a, b = [h * x, h/2 * (w-x), (h+1)/2 * (w-x)].minmax
    ans << b - a

    x += 1
    a, b = [h * x, h/2 * (w-x), (h+1)/2 * (w-x)].minmax
    ans << b - a

    x = h / 3
    a, b = [w * x, w/2 * (h-x), (w+1)/2 * (h-x)].minmax
    ans << b - a

    x += 1
    a, b = [w * x, w/2 * (h-x), (w+1)/2 * (h-x)].minmax
    ans << b - a

    puts ans.min
end

Measured memory_bytes: 14128
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
//#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define izryt bool
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const llint mod=1000000007;
const llint gya=500000004;//mod modで2の逆元
const llint big=1e9;
const llint red=0xE869120;
const llint pro=1002001;

int main(void){
	int ans=0,i,j,n,m,q,a,b,c,d;
	string str;
	vector<vector<bool>> mat;
	vector<vector<int>> wa;//累積和
	vector<vector<int>> then;//累積和
	vector<vector<int>> yhen;//累積和
	cin>>n>>m>>q;
	wa.res(n+1);
	mat.res(n+1);
	then.res(n+1);
	yhen.res(n+1);
	wa[0].res(m+1);
	mat[0].res(m+1);
	then[0].res(m+1);
	yhen[0].res(m+1);
	for(i=1;i<=n;i++){
		wa[i].res(m+1);
		mat[i].res(m+1);
		then[i].res(m+1);
		yhen[i].res(m+1);
		cin>>str;
		for(j=1;j<=m;j++){
			if(str[j-1]=='1'){mat[i][j]=1;wa[i][j]=1;}
			if(mat[i][j]==1&&mat[i-1][j]==1){then[i][j]--;}
			if(mat[i][j]==1&&mat[i][j-1]==1){yhen[i][j]--;}
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			wa[i][j]+=wa[i][j-1];
			then[i][j]+=then[i][j-1];
			yhen[i][j]+=yhen[i][j-1];
		}
	}
	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			wa[j][i]+=wa[j-1][i];
			then[j][i]+=then[j-1][i];
			yhen[j][i]+=yhen[j-1][i];
		}
	}
	while(q--){
		ans=0;
		cin>>a>>b>>c>>d;
		a--;b--;
		ans+=wa[a][b]+wa[c][d]-wa[a][d]-wa[c][b];
		ans+=then[a+1][b]+then[c][d]-then[a+1][d]-then[c][b];
		ans+=yhen[a][b+1]+yhen[c][d]-yhen[a][d]-yhen[c][b+1];
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 50048
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
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;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int s;
cin >> s;
set<int> st;
st.insert(s);

auto f = [&](int c) {
    int res;
    if( c % 2 == 0) res = c / 2;
    else res = 3*c + 1;
    return res;
};

int ans = 1;

while(true) {
    s = f(s);
    st.insert(s);
    ans++;
    if(st.size() != ans) {
        cout << ans << endl;
        return 0;
    }
}

return 0;
}

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

int main() {
  int n,sum = 0;
  cin >> n;
  vector<int>a(n);
  rep(i,0,n){
    cin >> a[i];
    sum ^= a[i];
  }
  rep(i,0,n){
    int ans = sum ^ a[i];
    cout << ans;
    if(i != n-1) cout << " ";
    else cout << "" << endl;
  }
}

Measured memory_bytes: 3960
import java.util.Collections;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Scanner;

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

		while (true) {
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			int[] x_array = new int[n + 1];
			int[] y_array = new int[n + 1];
			
			x_array[0] = 0;
			y_array[0] = 0;
			
			for(int i = 1; i <= n; i++){
				x_array[i] = sc.nextInt();
				y_array[i] = sc.nextInt();
			}
			
			boolean[] visited = new boolean[n+1];
			
			int cur_place = 0;
			double sum_dist = 0;
			double cur_angle = Math.PI / 2;
			for(int run = 0; run < n; run++){
				visited[cur_place] = true;
				
				//System.out.println(cur_place);
				
				int next_place = -1;
				double min_angle = Math.PI * 2;
				double min_dist = 0;
				
				for(int next = 0; next < n + 1; next++){
					if(visited[next]){
						continue;
					}
					
					double d = Math.sqrt((x_array[cur_place] - x_array[next]) * (x_array[cur_place] - x_array[next]) +
							(y_array[cur_place] - y_array[next]) * (y_array[cur_place] - y_array[next]));
					double a = Math.atan2(y_array[next] - y_array[cur_place], x_array[next] - x_array[cur_place]);
					
					double diff_a = cur_angle - a;
					if(diff_a < 0){
						diff_a += Math.PI * 2;
					}
					
					if(min_angle >= diff_a){
						if(min_angle > diff_a){
							min_dist = d;
							min_angle = diff_a;
							next_place = next;
						}else if(min_dist > d){
							min_dist = d;
							next_place = next;
						}
					}
				}
				
				cur_angle = Math.atan2(y_array[next_place] - y_array[cur_place], x_array[next_place] - x_array[cur_place]);
				cur_place = next_place;
				sum_dist += min_dist;
			}
			
			
			System.out.printf("%.1f\n", sum_dist);
		}

	}

}

Measured memory_bytes: 22076
#include <cstdio>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

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

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

int main() {
    int  N;
    long double a=0;
    double x=0;
    string S;

    cin >> N;
    for(int i=0; i<N; i++){
        cin >> x >> S;
        if(S=="JPY"){
            a = a + (int)x;
        }else{
            a = a + 380000.0*x;
        }
    }
    cout << a <<endl;

    return 0;
}



Measured memory_bytes: 256
/*
[arc100] C - Linear Approximation
*/

#include <algorithm>
#include <iostream>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 200000;

int N;
int A[MAX_N];

ll solve() {
    int b[MAX_N];
    for (int i = 0; i < N; i++) {
        b[i] = A[i] - i + 1;
    }
    sort(b, b + N);

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += abs(b[i] - b[N / 2]);
    }
    return ans;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ALL(a) a.begin(),a.end()

int main(){
    int N, B, C, cnt = 0;
    string S;
    cin >> N;
    double A[N];
    for(int i = 0; i < N ; i++){
        double a; cin >> a;
        A[i] = a;
    }
    double ans = 0;
    for(int i = 0; i < N; i++){
        ans += 1/A[i];
    }
    


    cout << fixed << setprecision(10) <<  1 / ans << endl;
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;


int main() {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    if (n % 2 != 0) {
        cout << "No";
        return 0;
    }
    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[i + n / 2]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

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

int main(){
  ll i,j,k,H,W,f;
  cin>>H>>W;
  ll d[4]={1,-1,-2-W,W+2};
  vector<ll> map((H+2)*(W+2),0);
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#')map[i*(W+2)+j]=1;
    }
  }
  rep(i,H+2){
    rep(j,W+2){
      if(map[i*(W+2)+j]){
        f=1;
        rep(k,4){
          if(map[i*(W+2)+j+d[k]])f=0;
        }
        if(f){
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define push_back emplace_back
#define push emplace
#define insert emplace
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int p,q,r;
	cin>>p>>q>>r;
	//p=min(p,q+r);
	//q=min(q,p+r);
	//=min(r,p+q);
	cout<<min(p+q,min(p+r,q+r));
	return 0;

}

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

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

using namespace std;
using ll = long long;

void solve();

int main(void){
    int N, K;
    string s;
    cin >> N >> K >> s;
    vector<int> zero_pos;
    int zero_size;
    vector<int> zero_row;
    vector<int> zero_left_one;
    vector<int> zero_right_one;
    bool zero_continue = false;
    int row = 0;
    rep(i, N){
        if(s[i] == '0'){
            if(zero_continue) row++;
            else{
                zero_pos.push_back(i);
                row = 1;
                zero_continue = true;
            }
        }
        else{
            if(zero_continue){
                zero_row.push_back(row);
                row = 1;
                zero_continue = false;
            }
        }
    }
    if(zero_continue) zero_row.push_back(row);

    zero_size = zero_pos.size();

    rep(i, zero_size){
        if(i == 0){
            zero_left_one.push_back(zero_pos[i]);
        }
        else{
            zero_left_one.push_back(zero_pos[i] - zero_pos[i-1] - zero_row[i-1]);
        }
    }
    rep(i, zero_size-1){
        zero_right_one.push_back(zero_left_one[i+1]);
    }
    if(zero_size > 0) zero_right_one.push_back(N - zero_pos[zero_pos.size()-1] - zero_row[zero_pos.size()-1]);

    if(zero_size <= K) cout << N << endl;
    else{
        int ans = 0;
        rep(i, K){
            ans += zero_left_one[i] + zero_row[i];
            if(i == K-1) ans += zero_right_one[i];
        }
        //なくなるもの: zero_left_one[i-1] + zero_row[i-1]
        //得るもの: zero_row[i+K-1] + zero_right[i+K-1]
        int len = ans;
        for(int i = 1; i+K-1 < zero_size; i++){
            len += zero_row[i+K-1] + zero_right_one[i+K-1] - zero_left_one[i-1] - zero_row[i-1];
            if(len > ans) ans = len;
        } 
        cout << ans << endl;
    }
    return 0;
}

void solve(){}

Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ii {
    int a, b;
    bool operator < (ii o) const {
        return tie(a, b) < tie(o.a, o.b);
    }
};
struct iii {
    int a, b, c;
    bool operator < (iii o) const {
        return tie(a, b, c) < tie(o.a, o.b, o.c);
    }
};
istream &operator >> (istream &is, ii &st) { is >> st.a >> st.b; return is; }
template <typename T> istream &operator >> (istream &is, vector<T> &vec) { for (auto &v: vec) is >> v; return is; }
template <typename T> ostream &operator << (ostream &os, vector<T> &vec) {
    for (int i = 0; i < (int)vec.size(); i++) {
        os << vec[i];
        if (i < (int)vec.size() - 1) os << " ";
    }
    return os;
}

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 1000005;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    cin >> A >> B;
    
    vector<int> cntA(N+1), cntB(N+1);
    for (int i = 0; i < N; i++) {
        cntA[A[i]]++;
        cntB[B[i]]++;
    }
    for (int i = 1; i <= N; i++) {
        if (cntA[i] + cntB[i] > N) {
            cout << "No\n";
            return 0;
        }
    }
    
    reverse(B.begin(), B.end());
    vector<int> idxSame;
    int mid = -1;
    for (int i = 0; i < N; i++) {
        if (A[i] == B[i]) {
            idxSame.push_back(i);
            mid = A[i];
        }
    }
    for (int i = 0; i < N && !idxSame.empty(); i++) {
        if (A[i] == mid || B[i] == mid) continue;
        swap(B[idxSame.back()], B[i]);
        idxSame.pop_back();
    }
    cout << "Yes\n";
    cout << B << "\n";
    
}


Measured memory_bytes: 7000
N=int(input())
A=list(map(int,input().split()))
min_,max_=min(A),max(A)

def f(n,k):
    return n%k==0 if k>0 else False

ans=None
if max_-min_ > 1:
    ans=False
elif max_-min_ == 1:
    k=max_
    nk=len([a for a in A if a==max_])
    nk1=N-nk
    ans=f(nk,k-nk1)
else:
    ans=f(N,min_) or f(N,min_+1)

if ans is True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 55876
n = int(input())
h = list(map(int,input().split()))
inf = 10000
dp = []
for i in range(100000):
    dp.append(inf)
dp[0] = 0
for i in range(1,n):
    if i>1:
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
    else:
        dp[i] = dp[i-1] + abs(h[i]-h[i-1])
print(dp[n-1])
    

Measured memory_bytes: 52856
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <unordered_set>

using namespace std;

int64_t mod = 1000000007;

int main(int argc, char **argv) {
    int n,m;
    cin >> n >> m;
    unordered_set<int> a;
    for (int i=0; i<m; ++i) {
        int am;
        cin >> am;
        a.insert(am);
    }
    std::vector<int64_t> dp(n+1, 0);
    dp[0]=1;
    for (int i=1; i<=n; ++i) {
        auto it = a.find(i);
        if (it != a.end()) continue;
        dp[i] += dp[i-1];
        if (i != 1)
            dp[i] += dp[i-2];
        dp[i] = dp[i] % mod;
        //cout << dp[i] << endl;
    }
    cout << dp[n] << endl;
}

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

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define ll long long
#define Mid ((L+R)/2)
#define pi pair<int,int>
#define pii pair<int,pi>
#define deb(x) cout<<#x<<"="<<x<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
string s;
int main()
{
    go;
    cin>>s;
    if(s.back()=='s')
        cout<<s<<"es";
    else
        cout<<s<<"s";
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr); 
	ll x,n;
	cin>>x>>n;
	map<ll,ll> mp;
	FOR(i,0,n)
	{
		ll a;
		cin>>a;
		mp[a] = 1;
	}
	ll h = 0;
	while(1)
	{
		ll a = abs(x-h);
		ll b = abs(x+h);
		if(mp[a] == 0)
		{
			cout<<a<<endl;
			return 0;
		}
		if(mp[b] == 0)
		{
			cout<<b<<endl;
			return 0;
		}
		h++;
	}
	return 0;
}

Measured memory_bytes: 3640
def to_top_red(cube):
  c1, c2, c3, c4, c5, c6 = cube
  if c2 == "Red":
    c1, c2, c6, c5 = c2, c6, c5, c1
  elif c3 == "Red":
    c1, c4, c6, c3 = c3, c1, c4, c6
  elif c4 == "Red":
    c1, c4, c6, c3 = c4, c6, c3, c1
  elif c5 == "Red":
    c1, c5, c6, c2 = c5, c6, c2, c1
  elif c6 == "Red":
    c1, c2, c6, c5 = c6, c5, c1, c2
  return (c1, c2, c3, c4, c5, c6)

def regist(cube, cube_dic):
  c1, c2, c3, c4, c5, c6 = cube
  cube_dic[(c1, c2, c3, c4, c5, c6)] = True
  cube_dic[(c1, c4, c2, c5, c3, c6)] = True
  cube_dic[(c1, c3, c5, c2, c4, c6)] = True
  cube_dic[(c1, c5, c4, c3, c2, c6)] = True

while True:
  n = int(input())
  if n == 0:
    break

  cube_dic = {}
  ans = 0
  
  for _ in range(n):
    cube = to_top_red(input().split())
    if cube in cube_dic:
      ans += 1
    else:
      regist(cube, cube_dic)
  
  print(ans)


Measured memory_bytes: 5628
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N; cin >> N;
	cout << N * (N + 1) / 2 << endl;
}

Measured memory_bytes: 256
import sys
rl = sys.stdin.readline
def a():
    N, W = map(int, rl().split())
    dp = [-1]*(W+1)
    dp[0] = 0
    for _ in range(N):
        w, v = map(int, rl().split())
        for i in range(W-w, -1, -1):
            dpi = dp[i]
            if dpi == -1:
                continue
            if dp[i+w] < dpi + v:
                dp[i+w] = dpi + v
    print(max(dp))
a()



Measured memory_bytes: 7724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main(){
  
    int a, b;
    cin >> a >> b;
	
  	if(a&1 && b&1)
    	cout << "Yes" << endl;
	else
      	cout << "No" << endl;
  
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265359
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll n, x;
 	cin >> n;
 	ll in = 1;
 	ll ans = 0;
 	for (ll i = 0; i < n; i++) {
 		cin >> x;
 		if (x == in) in++;
 		else ans++;
 	}
 	if (ans == n) {
 		cout << -1 << endl;
 	} 
 	else
 		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main
import "fmt"
func main() {
  var s string
  fmt.Scan(&s)
  var n int = len(s)
  var p int
  for i:=0;i<n;i++ {
    if s[i:i+1] == "p" { p++ }
  }
  fmt.Println((n-2*p)/2)
}

Measured memory_bytes: 1280
S = input()
S = S[1:-1]
#print(S)
S = S.split("LR")

ans = []
for i in range(len(S)):
    tp = "R" + S[i] + "L"
    #print(tp)
    rn = len(tp.split("RL")[0])+1
    ln = len(tp) - rn 
    #print(rn,ln)
    for k in range(rn-1):
        ans.append(0)
    ans.append(-(-rn//2) + ln//2)
    ans.append(-(-ln//2) + rn//2)
    for k in range(ln-1):
        ans.append(0)
    #print()
#print(S)

[print(str(i) + " ",end="") for i in ans]
print()

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

struct FenwickTree{
	vector<ll> data;
	FenwickTree(int n):data(n+1){}
	void Add(int i,int x){
		for(i++;i<data.size();i+=i&-i)
			data[i]+=x;
	}
	ll Sum(int i){
		ll res=0;
		for(;i;i-=i&-i)
			res+=data[i];
		return res;
	}
	ll Sum(int i,int j){
		return Sum(j)-Sum(i);
	}
};

ll solve(int n,int k,vi a)
{
	rep(i,n) a[i]-=k;
	vl b(n+1);
	rep(i,n) b[i+1]=b[i]+a[i];
	vl t=b; sort(all(t));
	rep(i,n+1) b[i]=lower_bound(all(t),b[i])-begin(t);

	FenwickTree ft(n+1);
	ll res=0;
	rep(i,n+1){
		res+=ft.Sum(b[i]+1);
		ft.Add(b[i],1);
	}
	return res;
}

int main()
{
	for(int n,k;cin>>n>>k&&n|k;){
		vi a(n);
		rep(i,n) cin>>a[i];
		cout<<solve(n,k,a)<<endl;
	}
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  ll a,b,n;cin>>a>>b>>n;
  ll i;
  if(n>=b-1) i=b-1;
  else i=n;
  
  ld k=(ld)(i)/(ld)(b);
  k*=a;
  cout<<(ll)(k)<<endl;
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  ll n; cin >> n;
  vi v;
  for(ll i=2;i*i<=n;++i) {
    ll cnt = 0;
    while(n % i == 0) {
      cnt++;
      n /= i;
    }
    v.push_back(cnt);
  }
  if(n != 1) v.push_back(1);

  ll ans = 0;
  for(auto &e: v) {
    for(int i=1;i<=1000;++i) {
      if(i > e) break;
      else {
        ans++;
        e -= i;
      }
    }
  }
  cout << ans << endl;

}
























Measured memory_bytes: 7384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;



int main() {
    int n; cin >> n;
    int a[2][n];
    int sum = 0;
    for(int i = 0;i < n;i++){
        int x; cin >> x;
        sum += x;
        a[0][i] = sum;
    }
    int y; cin >> y;
    a[1][0] = a[0][0]+y;
    sum = a[1][0];
    for(int i = 1;i < n;i++){
        int y; cin >> y;
        a[1][i] = max(sum+y,a[0][i]+y);
        sum = a[1][i];
    }
    cout << sum;
}



Measured memory_bytes: 256
# AGC 011 A - Airport Bus
#time limitは一番待たされている客基準⇒sortの先頭
N,C,K = map(int,input().split())
T = [int(input()) for __ in range(N)]

ans = 1 #最低1台はバスが出る
count = 0 #乗客の数をカウント,最大C人まで
T.sort()
ts = T[0] #一番待たされている客の到着時間

#print(T)
for t in T:
    if t-ts > K or count == C: #時間いっぱい or 乗客がいっぱいになったら
        ans += 1 #バス追加
        ts = t #次の客の待ち時間
        count = 1 #乗客数リセット
    else:
        count += 1 #乗客+1
print(ans)

Measured memory_bytes: 7384
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long;
#define what(x) cerr << #x << " is " << x << endl;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    for(int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    int ret = 0;
    for(int i = 0; i < n; ++i) {
        ret += 2 * min(x[i], k-x[i]);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll v, e;
    cin >> v >> e;

    ll dist[v][v];
    rep(i, v)rep(j, v){
        if(i == j)dist[i][j] = 0;
        else dist[i][j] = LINF;
    }
    rep(i, e){
        ll s, t, d;
        cin >> s >> t >> d;

        dist[s][t] = d;
    }

    rep(k, v)rep(i, v)rep(j, v){
        if(dist[i][k] >= LINF || dist[k][j] >= LINF)continue;
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }

    rep(i, v)if(dist[i][i] < 0){
        cout << "NEGATIVE CYCLE\n";
        return 0;
    }

    rep(i, v){
        rep(j, v){
            if(j > 0)cout << " ";
            if(dist[i][j] >= LINF)cout << "INF";
            else cout << dist[i][j];
        }
        cout << endl;
    }
}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a,ll b){
	return a%b?gcd(b,a%b):b;
}
int main(){
	ll a,b;
	while(cin>>a>>b)
		cout<<gcd(max(a,b),min(a,b))<<" "<<a*b/gcd(max(a,b),min(a,b))<<endl;
	return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>
 
int main(){
    int n,i,out,point,rui1,rui2,rui3;
    char c[8];
    scanf("%d",&n);
    for(i=0; i<n; i++){
        out=0;
        point=0;
        rui1=0;
        rui2=0;
        rui3=0;
        while(out!=3){
            scanf(" %s",c);
            switch(c[1]){
            case 'U':
                out++;
                break;
            case 'O':
                if(rui1==1){
                    point++;
                    rui1=0;
                }
                if(rui2==1){
                    point++;
                    rui2=0;
                }
                if(rui3==1){
                    point++;
                    rui3=0;
                }
                point++;
                break;  
            case 'I':
                if(rui3==1){
                    rui3=0;
                    point++;
                }
                if(rui2==1){
                    rui2=0;
                    rui3=1;
                }
                if(rui1==1){
                    rui2=1;
                    rui1=0;
                }
                rui1=1;
                break;
            }
        }
        printf("%d\n",point);
    }
    return 0;
	
	
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x=0;string a,b,c;cin>>n>>a>>b>>c;
  for(int i=0;i<n;i++){
    if(a.at(i)==b.at(i)){
      if(a.at(i)!=c.at(i))x++;
    }
    else if(a.at(i)==c.at(i)||b.at(i)==c.at(i))x++;
    else x+=2;
  }
  cout<<x<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int n,m,x,y;
int main(){
	n=read(),m=read();
	x=m%2+m-1,y=m-m%2;
	int j=x+2;
	for(int i=1;x>0 and m>0;i++,x-=2,m--)
		printf("%d %d\n",i,i+x);
	for(;y>1 and m>0;j++,y-=2,m--)
		printf("%d %d\n",j,j+y);
	return 0;
}

Measured memory_bytes: 3724
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    a1 = {}
    for i in range(len(a)):
        if a[i] in a1:
            a1[a[i]] += 1
        else:
            a1[a[i]] = 1
    a = sorted(list(a1.keys()))
    ans = [1] * a[-1]

    for i in a:
        if ans[i-1] == 1:
            for j in range(i-1, len(ans), i):
                ans[j] = 0
            ans[i-1] =1
    ans1 = 0
    for i in a:
        if a1[i] == 1:
            ans1 += ans[i-1]
    print(ans1)
resolve()

Measured memory_bytes: 131796
n = int(input())
a = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381, 1451]
[print(i,end = " ") for i in a[:n-1]]
print(a[n-1])

Measured memory_bytes: 3064
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

vvi ans;
void solve(int l, int r, int c) {
	int m = r - l;
	if (m == 1)return;
	int mid = (r + l) / 2;
	for (int i = l; i < mid; ++i) {
		for (int j = mid; j < r; ++j) {
			ans[i][j] = c;
		}
	}
	solve(l, mid, c + 1);
	solve(mid, r, c + 1);
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	ans.resize(n, vi(n));
	solve(0, n, 1);
	REP(i, n) {
		REP(j, n - i - 1) {
			cout << ans[i][i + j + 1] << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int p, q, r; cin >> p >> q >> r;
  int ans = p + q;
  ans = min(ans, q + r);
  ans = min(ans, p + r);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (a, b) = InputLine.to_ia

  if a > b then
    tmp = a
    a = b
    b = tmp
  end
  
  puts (a.to_s * b)
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Control.Monad
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS
import qualified Data.IntMap.Strict as IntMap

main = do
  [n,m] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  xs <- U.replicateM n $ do
    [a,b] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (a,b)
  let ys = V.create $ do
        vec <- VM.replicate (m+1) IntMap.empty
        U.forM_ xs $ \(a,b) -> do
          when (a <= m) $ do
            VM.modify vec (IntMap.insertWith (+) b 1) a
        return vec
  let loop !acc w !i
        | i > m = acc
        | otherwise = let w' = (IntMap.unionWith (+) w (ys V.! i))
                      in if IntMap.null w'
                         then loop acc w' (i+1)
                         else let (b,_) = IntMap.findMax w'
                                  w'' = IntMap.updateMax (\x -> if x == 1 then Nothing else Just (x-1)) w'
                              in loop (acc + b) w'' (i+1)
  print $ loop 0 IntMap.empty 0


Measured memory_bytes: 20860
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
#include<type_traits>
#include<numeric>
#include<array>
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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 int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

const int mod = 1000000007;
const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
}

int main(){

    int N;cin >> N;

    pl((N-2)*180)

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <chrono>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <sstream>
#include <queue>
#include <bitset>

using namespace std;
using ll = unsigned long long;
using triplet = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vi>;

int main()
{
#ifdef LOCAL_TEST
    freopen("data.txt", "r", stdin);
#endif
    
    int n, K;
    scanf("%d %d\n", &n, &K);
    
    vi cards(n);
    for (int i = 0; i < n; ++i) scanf("%d", &cards[i]);
    sort(cards.begin(), cards.end(), std::greater<int>());
    
    // if any sum between [K-cards[i], K) exists that means this card is unnecessary
    bitset<5002> sum;
    sum[0] = 1;
    int result = 0;
    for (auto c : cards)
    {
        if (c >= K) continue;
        result++;
        for (int i = K-c; i < K; ++i)
        {
            if (sum[i])
            {
                result = 0;
                break;
            }
        }
        sum |= sum << c;
    }
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
const int maxn=1000005;
#define all(x) (x).begin(),(x).end()
using namespace std;
void solve() {
    string s;
    cin>>s;
    int cnt=0;
    int ans=0;
    for(int i=0;i<s.size();++i)
    {
       if(s[i]=='R') cnt++;
       else {
           ans=max(ans,cnt);
           cnt=0;
       }
    }
    ans=max(ans,cnt);
    cout<<ans<<"\n";


}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--) solve();
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,ll>;
using Map = map<char,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

ll INF=10000000000000000;

int main(){
    string S;
    cin >> S;
    string T;
    cin >> T;
    int s=S.size();
    int t=T.size();
    vector<vector<int>> dp(s, vector<int>(t,0));
    for(int i=0;i<s;i++){
     for(int j=0;j<t;j++){
         if(i>0&&j>0){
             if(S[i]==T[j]){
                 dp[i][j]=dp[i-1][j-1]+1;
             }
             else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
         }
         else if(i==0&&j>0){
             if(S[0]==T[j]){
                 dp[0][j]=1;
             }
             else dp[0][j]=dp[0][j-1];
         }
         else if(j==0&&i>0){
             if(S[i]==T[0]){
                 dp[i][0]=1;
             }
             else dp[i][0]=dp[i-1][0];
         }
         else if(S[i]==T[0]){dp[i][0]=1;}
        }
    ;}
    deque<char> ans;
    ll A=s-1,B=t-1;
    while(A>0&&B>0){
        if(S[A]==T[B]){
            ans.emplace_front(S[A]);
            A--;B--;
        }
        else if(dp[A][B]==dp[A-1][B]){
            A--;
        }
        else B--;
    }
    if(B==0){
        if(dp[A][0]){
            ans.emplace_front(T[0]);
        }
    }
    else if(A==0){
        if(dp[0][B]){
            ans.emplace_front(S[0]);
        }
    }
    ll D=ans.size();
    for(ll i=0;i<D;i++){
        cout<<ans[i]
    ;}cout<<endl;
return 0;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
#define Mod 1000000007
#define N 200010
#define LL long long
LL a[N],b[N];
LL find(LL x,LL y)
{
    LL ans=1;
    x=x%Mod;
    while(y)
    {
        if(y%2)
            ans=ans*x%Mod;
        x=x*x%Mod;
        y=y/2;
    }
    return ans;
}
LL C(int x,int y)
{
    if(x<y)
        return 0;
    return a[x]*b[y]%Mod*b[x-y]%Mod;
}
int main()
{
    int i,j,k,n,m,d;
    LL ans;
    scanf("%d%d%d",&n,&m,&d);
    a[0]=1;
    for(i=1;i<=200000;i++)
        a[i]=a[i-1]*i%Mod;
    b[200000]=find(a[200000],Mod-2);
    for(i=200000;i>=1;i--)
        b[i-1]=b[i]*i%Mod;
    ans=C(n*m,d)*C(d,2)%Mod*(n+m)%Mod*find(3,Mod-2)%Mod;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9

int main(){
    int a, b;
    string s;
    cin >> a >> b >> s;
    rep (i, a+b+1) {
        if (i == a) {
            if (s[i] != '-') {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            if (s[i] == '-') {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

typedef unsigned long long ULL;
typedef long long LL;

const int PI = 3.1415926535;
const int inf = 1000111222;
const int mod = 1000000007;
const int N = 100007;


int main() {
	
	ios_base :: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	string str; cin >> str;
	LL sum = 0;
	for (int i = 0; i < (int)str.size(); i++) {
		int x = str[i] - '0';
		sum += x;
	}
	if (sum % 9) {
		cout << "No\n";
	}
	else cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 3764
#include <iostream>

using namespace std;

class card{
public:
  char c;
  int v;
};

bool check(card a[], card b[], int n){
  for(int i = 0; i < n; i++){
    if(a[i].c != b[i].c){
      return false;
    }
  }
  return true;
}

void bubblesort(card a[], int n){
  int i,j;
  for(i = 0; i < n; i++){
    for(j = n-1; j>= i+1; j--){
      if(a[j].v < a[j-1].v){
        card tmp = a[j];
        a[j] = a[j-1];
        a[j-1] = tmp;
      }
    }
  }
  for(i = 0; i < n; i++){
    if(i > 0){
      cout << " ";
    }
    cout << a[i].c << a[i].v;
  }
  cout << endl << "Stable" << endl;
}

void selectionsort(card a[], int n){
  int i,j,minj;
  for(i = 0; i < n; i++){
    minj = i;
    for(j = i; j < n; j++){
      if(a[j].v < a[minj].v){
        minj = j;
      }
    }
    card tmp = a[i];
    a[i] = a[minj];
    a[minj] = tmp;
  }
  for(i = 0; i < n; i++){
    if(i > 0){
      cout << " ";
    }
    cout << a[i].c << a[i].v;
  }
  cout << endl;
}

int main(){

  int n,i;
  card A[110],B[110];
  char ch;

  cin >> n;

  for(i = 0; i < n; i++){
    cin >> A[i].c >> A[i].v;
    B[i] = A[i];
  }

  bubblesort(A,n);
  selectionsort(B,n);

  if(check(A,B,n)){
    cout << "Stable" << endl;
  }else{
    cout << "Not stable" << endl;
  }
  return 0;
}


Measured memory_bytes: 3108
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let p: u32 = read();
    let q: u32 = read();
    let r: u32 = read();

    //println!("{}, {}, {}", p, q, r);
    let mut ans = p + q;
    if (ans >= q + r) {
        ans = r + q;
    }
    if (ans >= r + p) {
        ans = r + p;
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352