akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
int cnt,cnt1,cnt2;
int main(){
int n=read();
for (int i=1;i<=n;++i){
  int x=read();
  if (!(x&1)){
    if (!(x>>1&1)){
      ++cnt1;
      }else{
      ++cnt2;
      }
    }
  }
if (cnt2/2+cnt1>=n/2) puts("Yes");
else puts("No");
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        string t = Console.ReadLine();
        Console.WriteLine(Validate(s, t) && Validate(t, s) ? "Yes" : "No");
    }
    static bool Validate(string s, string t) => s.Zip(t, (x, y) => new Tuple<char, char>(x, y)).Distinct().GroupBy(x => x.Item1).All(x => x.Count() == 1);
}


Measured memory_bytes: 19168
#!/usr/bin/env python3
import sys, math, fractions, itertools

MOD = 1000000007  # type: int

def solve(N: int):
    a = 1
    for i in range(1, N+1):
        a = a * i % MOD
    print(a)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5052
#include<bits/stdc++.h>
#define betheflash ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vs vector<string>
#define vvi vector<vector<int>>
#define mii map<int,int>
#define msi map<string,int>
#define mis map<int,string>
#define pb push_back
#define mod 1000000007
using namespace std;
void solve()
{
	ll n,k,b,c,min=999999999;
	cin>>k>>n;
	ll a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];		
	}
	for(int i=0;i<n-1;i++)
	{
		if(a[i]+(k-a[i+1])<min)
			min=a[i]+(k-a[i+1]);
	}
	if(a[n-1]-a[0]<min)
		min=a[n-1]-a[0];
	cout<<min;
}
int main()
{
    betheflash
	int t=1;
	//cin>>t;
	for(int ha=0;ha<t;ha++)
	{
		solve();
	}
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(){
  int l,a,b,c,d,p,i;
  scanf("%d %d %d %d %d",&l,&a,&b,&c,&d);
  for(i = 1 ; a > c || b > d ; i++){
    a = a-c;
    b = b-d;
  }
  p = l - i;
  printf("%d\n",p);
  return 0;
}

Measured memory_bytes: 1024
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M = map(int, readline().split())
    S = list(map(int, readline().split()))
    T = list(map(int, readline().split()))

    dp = [[0] * (M + 1) for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0] = 1
    for j in range(M + 1):
        dp[0][j] = 1

    for i in range(N):
        for j in range(M):
            if S[i] == T[j]:
                dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j]) % MOD
            else:
                dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j] - dp[i][j]) % MOD

    print(dp[N][M])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 98352
use whiteread::parse_line;

fn main() {
    let s: String = parse_line().unwrap();
    let mut max_len: u32 = 0;
    let mut len: u32 = 0;
    for c in s.chars() {
        if "ACGT".contains(c) {
            len += 1;
        } else {
            len = 0;
        }
        if len > max_len {
            max_len = len;
        }
    }
    println!("{}", max_len);
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
#define LL long long
#define INF 0x3f3f3f3f

const int MAXN = 1e2 + 5;
const LL MOD = 1e9 + 7;

int a[MAXN];

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
#endif

    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    sort(a, a + n);
    int aa = 0;
    int bb = 0;
    for(int i = 0; i < n; i++)
    {
        if(i % 2 == 0)
            aa += a[n - i - 1];
        else
            bb += a[n - i - 1];
    }
    cout << aa - bb << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9;
const long long LLINF = 1e18;

int sx, sy, tx, ty;
int main() {
    cin>>sx>>sy>>tx>>ty;

    int y=ty-sy;
    int x=tx-sx;
    REP(i, 0, y) cout<<"U";
    REP(i, 0, x) cout<<"R";
    REP(i, 0, y) cout<<"D";
    REP(i, 0, x) cout<<"L";

    cout<<"L";
    REP(i, 0, y+1) cout<<"U";
    REP(i, 0, x+1) cout<<"R";
    cout<<"D";

    cout<<"R";
    REP(i, 0, y+1) cout<<"D";
    REP(i, 0, x+1) cout<<"L";
    cout<<"U"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
const LL MOD = 1000000007LL;
const int inf = 1e9;
const LL INF = 1e18;
const int MAX_V = 100;
struct edge {
	int to, cap, cost, rev;
	edge(int to, int cap, int cost, int rev) :to(to), cap(cap), cost(cost), rev(rev) {}
};
vector<edge> G[MAX_V];
int h[MAX_V];
int dist[MAX_V];
int prevv[MAX_V], preve[MAX_V];
int V;
void add_edge(int from, int to, int cap, int cost) {
	G[from].emplace_back(to, cap, cost, G[to].size());
	G[to].emplace_back(from, 0, -cost, G[from].size() - 1);
}
int min_cost_flow(int s, int t, int f) {
	int res = 0;
	fill(h, h + V, 0);
	while (f > 0) {
		priority_queue<PI, vector<PI>, greater<PI>> que;
		fill(dist, dist + V, inf);
		dist[s] = 0;
		que.push(PI(0, s));
		while (!que.empty()) {
			PI p = que.top(); que.pop();
			int v = p.second;
			if (dist[v] < p.first) continue;
			for (int i = 0; i < G[v].size(); i++) {
				edge e = G[v][i];
				if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
					dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
					prevv[e.to] = v;
					preve[e.to] = i;
					que.push(PI(dist[e.to], e.to));
				}
			}
		}
		if (dist[t] == inf) return -1;
		for (int v = 0; v < V; v++) h[v] += dist[v];
		int d = f;
		for (int v = t; v != s; v = prevv[v]) {
			d = min(d, G[prevv[v]][preve[v]].cap);
		}
		f -= d;
		res += d*h[t];
		for (int v = t; v != s; v = prevv[v]) {
			edge &e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		}
	}
	return res;
}
int main() {
	cin >> V;
	int E, F;
	cin >> E >> F;
	for (int i = 0; i < E; i++) {
		int u, v, c, d;
		cin >> u >> v >> c >> d;
		add_edge(u, v, c, d);
	}
	cout << min_cost_flow(0, V - 1, F) << endl;
}


Measured memory_bytes: 3180
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    int n;
    cin>>n;
    vector<int> fst(n), snd(n);
    for(int i = 0; i < n; i++)
        cin>>fst[i];
    for(int i = 0; i < n; i++)
        cin>>snd[i];
    reverse(snd.begin(), snd.end());
    int c = -1, l = 0, r = -1;
    for(int i = 0; i < n; i++){
        if(snd[i] == fst[i]){
            c = fst[i];
            l = i;
            break;
        }
    }
    for(int i = n-1; i >= 0; i--){
        if(fst[i] == snd[i]){
            r = i;
            break;
        }
    }
    for(int i = 0; i < n; i++){
        if(fst[l] == snd[l] && fst[i] != snd[l] && fst[l] != snd[i]){
            swap(snd[i], snd[l]);
            ++l;
        }
    }
    if(l <= r){
        cout<<"No";
        return ;
    }
    cout<<"Yes\n";
    for(int i : snd)
        cout<<i<<" ";
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 4800
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	int arr[3];
	fill(arr,arr+3,0);
	while(n--) {
		int a,b,c;
		cin>>a>>b>>c;
		a+=max(arr[1],arr[2]);
		b+=max(arr[0],arr[2]);
		c+=max(arr[0],arr[1]);
		arr[0]=a;
		arr[1]=b;
		arr[2]=c;
	}
	cout<<max(arr[0],max(arr[1],arr[2]));
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

using namespace std;

int main() {
	int w, a, b;
	scanf("%d %d %d", &w, &a, &b);
	if (a > b)
		swap(a, b);
	int ans = 0;
	if (a + w >= b)
		printf("%d\n", ans);
	else printf("%d\n", abs(b - (a + w)));
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

    int H_, W_, h, w, ans=0, i, j, g;

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

    int masu[H_][W_];

    for (i=0; i<H_; i++){
        for (j=0; j<W_; j++){
            masu[i][j] = 0;
        }
    }


    for (i=0; i<H_; i++){
        for (j=0; j<W_; j++){
            if (h>i) {//行の塗りつぶし
                masu[i][j] = 1;
            }
            if (w>j) {
                masu[i][j] = 1;
            }
        }
    }
    
    for (i=0; i<H_; i++){
        for (j=0; j<W_; j++){
            if (masu[i][j] == 0) ans++;
        }
    }

    printf("%d", ans);


    return 0;
}

Measured memory_bytes: 128
n=int(input())
s=input()
a=[int(s[i])-1 for i in range(n)]

div=[0]*(n+1)
for i in range(1,n+1):
  div[i]+=div[i-1]
  x=i
  while not x&1:
    x>>=1
    div[i]+=1

XOR=0
for i in range(n):
  if div[n-1]<=div[i]+div[n-1-i]:
    XOR^=a[i]
if XOR&1:
  print(1)
  exit(0)


for i in a:
  if i==1:
    print(0)
    exit(0)

XOR=0
for i in range(n):
  if div[n-1]<=div[i]+div[n-1-i]:
    XOR^=a[i]>>1
if XOR&1:
  print(2)
  exit(0)
print(0)

Measured memory_bytes: 55240
H, W = map(int,input().split())
A = [input() for k in range(H)]
B = []
for k in range(len(A)):
    if A[k] != "."*W:
        B.append(A[k])

C = []
for k in range(len(B[0])):
    T = ""
    for l in range(len(B)):
        T += B[l][k]
    C.append(T)

D = []
for k in range(len(C)):
    if C[k] != "."*len(C[0]):
        D.append(C[k])

for k in range(len(D[0])):
    T = ""
    for l in range(len(D)):
        T += D[l][k]
    print(T)




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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<vector<pii>> r(n);
	VI cnt(n), ps(n);
	rep(i, n-1){
		int a, b; cin >>a >>b;
		r[a-1].emplace_back(b-1, i);
		r[b-1].emplace_back(a-1, i);
		cnt[a-1]++; cnt[b-1]++;
	}
	int bmx = *max_element(all(cnt));
	
	auto f =[&](auto f, int s, int c, int p=-1)->void{
		int nc = c;
		for(auto x: r[s]) if(p != x.first){
			nc = (nc + 1) %bmx;
			ps[x.second] = nc;
			f(f, x.first, nc, s);
		}
	};
	f(f, 0, -1,-1);
	cout <<bmx <<"\n";
	rep(i, n-1) cout<<ps[i]+1<<"\n";
	return 0;
}


Measured memory_bytes: 7424
#include<stdio.h>

typedef struct{
  char name[10];
  int time;
}Process;

void enqueue(Process *,Process);
Process dequeue(Process *);

int head,tail;

int main(void){

  Process p[100000];
  int n,q,i,totaltime=0;

  head = 0;

  scanf("%d%d",&n,&q);

  for(i = 0 ; i < n ; i++){
    scanf("%s%d",p[i].name,&p[i].time);
  }

  tail = n;

  while(head!=tail){
    
    if(p[head].time > q){
      
      totaltime += q;
      p[head].time -= q;

      enqueue(p,p[head]);
      dequeue(p);

      
    }
    
    else {
      
      totaltime += p[head].time;
      printf("%s %d\n",p[head].name,totaltime);
      dequeue(p);
      
    }

  }
  
  return 0;
}

Process dequeue(Process *p){
  
  Process x;
  
  x = p[head];
  if(head+1 == 100000) head = 0;
  else head++;
  
  return x;
}

void enqueue(Process *p,Process x){
  
  p[tail] = x;
  if (tail+1 == 100000) tail = 0;
  else tail++;


}





  

Measured memory_bytes: 2160
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  string s;
  ll k, n;
  cin >> s >> k;
  n = s.size();
  ll start = 0, end = n - 1, i, cnt = 0;
  if(s[0] == s[n - 1]) {
    ll left, right;
    i = 0;
    while(s[i] == s[0] && i < n)
      i++;
    start = i;
    left = i;
    i = n - 1;
    while(s[i] == s[n - 1] && i >= 0)
      i--;
    end = i;
    right = n - 1 - i;
    // all characters are the same
    if(left == n) {
      cout << n * k / 2 << endl;
      return 0;
    }
    ans += left / 2 + right / 2 + (left + right) / 2 * (k - 1);
  }
  fi(start, end) {
    if(s[i] == s[i + 1]) {
      cnt++;
      i++;
    }
  }
  ans += cnt * k;

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;


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

Measured memory_bytes: 256
import bisect
import numpy as np
N = int(input())
S = input()

dic_ = {}
array =  np.zeros((10, 300001), np.int8)

for i in range(N):
    array[int(S[i]), i] = 1

def get_first_pos(i, k):
    ar = array[i, k+1:]
    wh = np.where(ar>0)
    if len(wh[0]) > 0:
        return wh[0][0] + k+1
    return None

ans = 0
        
for i in range(10):
    x1 = get_first_pos(i, -1)
    if x1 is None:
        continue
    for j in range(10):
        x2 = get_first_pos(j, x1)
        if x2 is None:       
            continue
        for k in range(10):
            x3 = get_first_pos(k, x2)
            if x3 is None:       
                continue
            ans += 1

print(ans)


Measured memory_bytes: 20580
#include<bits/stdc++.h>
using namespace std;
#define int long long int

vector<int>res;
int n;

void gen(int num,int dig)
{

    if(num>3234566667)return;
    if(dig>10)return;
    res.push_back(num);
    int ld = num%10;
    if(ld>0 && ld<9){
        gen(num*10+ld+1,dig+1);
        gen(num*10+ld-1,dig+1);
        gen(num*10+ld,dig+1);
    }
    else if(ld==0){
        gen(num*10+ld+1,dig+1);
        gen(num*10+ld,dig+1);
    }
    else{
        gen(num*10+ld-1,dig+1);
        gen(num*10+ld,dig+1);
    }
}
int32_t main()
{
     cin>>n;
     for(int i=1;i<=9;i++){
        gen(i,1);
     }
     sort(res.begin(),res.end());
     cout<<res[n-1];

}


Measured memory_bytes: 1400
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

ll N,M,K,A,B,C,ans=0,cnt=0;
string S,T;
vector<int> P,Q;
vector<pair<int,int>> PP;
bool CAN=false,CAN2=true;



ll gcd(ll a,ll b){
		if (a%b==0){
			return(b);
    	}
		else{
			return(gcd(b,a%b));
    	}
}




int main(){
  cin>>A>>B;
  N=gcd(A,B);
  
  if(N==1){
    cout<<1<<endl;
    return 0;
  }
  
  for(ll i=2; i<=N; ++i){
    while(N%i==0){
      N/=i;
      CAN=true;
    }
    if(CAN){
      ans++;
      CAN=false;
      CAN2=false;
    }
    if(i*i>N){
      if(N!=1) ans++;
      break;
    }
    if(N==1) break;
  }
  
  
  if(CAN2){
    cout<<2<<endl; //Nが素数
    return 0;
  }
  cout<<ans+1<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++)
    cin >> p[i];
  vector<int> q(n);
  for (int i = 0; i < n; i++)
    q[i] = p[i];
  sort(p.begin(), p.end());
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] != q[i])
      cnt++;
  }
  cout << (cnt <= 2 ? "YES" : "NO") << endl;
}

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

int main(){
    int64_t n, m;
    double a = 0;
    cin >> n >> m;
    vector<int> vec(n);
    string ans = "No";
  
    for (int i = 0; i < n; i++){
      cin >> vec.at(i);
      a = a + vec.at(i);
    }
  
  a = a/(4 * m);
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  if(a <= vec.at(m-1)) ans ="Yes";
  
  cout <<  ans  << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll powmod(ll x,ll y){
ll res=1;
  for(ll i=0;i<y;i++){
     res=res*x%1000000007;
  }
  return res;
}

int main(){
  int n;
  cin>>n;
  ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
  ans%=1000000007;
  ans=(ans+1000000007)%1000000007;
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 3636
import * as fs from 'fs';
const input = fs.readFileSync("/dev/stdin", "utf8").split(' ');

// A- キャンディとN人の子供イージー

const N = +input[0];
let result = 0;

for (let i = 1; i <= N; i++) {
    result += i;
}

console.log(result);

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

int comp(const void *a, const void *b)
{
	return *(char*)a - *(char*)b;
}

int main(void){
	
	char str[5];
	
	fgets(str,sizeof(str),stdin);
//	printf("%s\n",str);
	
	qsort(str,4,sizeof(char),comp);
	
//	printf("%s\n",str);
	
	if(str[0] == str[1] && str[2] == str[3] && str[0] != str[2])
		printf("Yes");
	else
		printf("No");
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int A,B;
  cin>>A>>B;
  if(A<=9 && B<=9){
    cout << A*B << endl;
  }
  else{
    cout << "-1" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 200

int main(){
  int n,u,k,v,a[MAX][MAX],i,j;
  
  scanf("%d",&n);
  
  for(i=1; i<=n; i++){
    for(j=1; j<=n; j++){
      a[i][j]=0;
    }
  }
  
  for(i=1; i<=n; i++){
    scanf("%d%d",&u,&k);

    for(j=1; j<=k; j++){
      scanf("%d",&v);
      a[i][v] = 1;
    }
  }
  
  for(i=1; i<=n; i++){
    for(j=1; j<=n; j++){
      if( j == n)printf("%d",a[i][j]);
      else printf("%d ",a[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 684
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i,n) for(int i=n; i>=0; i--)
#define FOR(i,m,n) for(int i=m; i<(n); i++)
#define ALL(v) v.begin(),v.end()
#define INF 2e9
using namespace std;
typedef long long ll;
 
 
int main()
{
    int A, B, K;
    cin >> A >> B >> K;

    int a = 0;

    for (int i = 100; i >= 1; i--)
    {
        if (A%i == 0 && B%i == 0)
        {
            a += 1;
            if(a == K){
                cout << i << endl;
                break;
            } 
            
        }
        

    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

int SumOfDigits(int x) {
  int result = 0;
  while (x > 0) {
    result += x % 10;
    x /= 10;
  }
  return result;
}

int main()
{
  int n;
  cin >> n;
  int result = 1 << 30;
  for (int i = 1; i < n; ++i) {
    result = min(result, SumOfDigits(i) + SumOfDigits(n - i));
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
($N,$C)=glob<>;
@D=map[glob<>],@@=0..$C-1;
for(<>){
	$j=0;
	for$x(split){
		$k=($i+$j)%3;
		for(@@){
			$_[$k][$_]+=$D[$x-1][$_]
		}
		++$j
	}
	++$i
}
$\=1e15;
for$i(@@){
	for$j(@@){
		for(@@){
			$\-=$-=$i-$j&&$i-$_&&$j-$_&&$\-$_[0][$i]-$_[1][$j]-$_[2][$_]
		}
	}
}
print


Measured memory_bytes: 1664
#include <iostream>
#include<string>
using namespace std;
int num[100][200];
void get_num( string s ,int i)
{
    for(int k=0;k<s.size();k++)
    {
        num[i][s[k]]++;
    }
    return ;
}
int main()
{
    int n; cin>>n; string s[200];
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
        get_num(s[i],i);
    }
    int ans[200]; for(int i=0;i<200;i++)ans[i]=1e9;
    for(int i=0;i<n;i++)
    {
        for(int k='a';k<='z';k++)
        {
            ans[k]=min(ans[k],num[i][k]);
        }
    }
    for(int i='a';i<='z';i++)
    {
        while(ans[i]--)cout<<char(i);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

bool IsPrime(long long num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
    ll N;
    cin >> N;
    map<ll,ll> mp;
    vector<ll> prime;
    for (ll i = 1;i*i <= N;i++) {
        if (N%i == 0) {
            if (IsPrime(i)) prime.push_back(i);
            if (IsPrime(N/i)) prime.push_back(N/i);
        }
    }
    ll ans = 0;
    for (ll i = 0;i<prime.size();i++) {
        ll p = prime.at(i);
        ll sp = prime.at(i);
        ll cnt = 1;
        ll n = N;
        //cout << n << endl;
        //cout << n << p << endl;
        //cout << n%p << endl;
        while(n%p == 0) {
            ans++;
            cnt++;
            //cout << "aaaa";
            n /= p;
            //cout << n << p << endl;
            p = pow(sp,cnt); 
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4108
M, D = map(int,input().split())

ans = 0
for m in range(1, M+1):
    for d in range(22, D+1):
        d1 = d % 10
        d10 = d // 10
        if d1 >= 2 and d10 >= 2 and d1 * d10 == m:
            ans += 1

print(ans)

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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        long N = cin.nextLong();
        var task = new List<Tuple<long, long>>();

        for (int i = 0; i < N; i++)
        {
            long A = cin.nextLong();
            long B = cin.nextLong();
            task.Add(Tuple.Create(A, B));
        }

        task.Sort((a, b) => (int)a.Item2 - (int)b.Item2);

        long sum = 0;

        for (int i = 0; i < N; i++)
        {
            sum += task[i].Item1;
            if (task[i].Item2 < sum)
            {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}



Measured memory_bytes: 29092
#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define sevensins ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define GO ll t; cin>>t; while(t--)
#define mod  1000000007
#define vect vector<long long int>
#define fore(p) for(auto& x:p)
#define bins binary_search
#define vecti vector<int>::iterator
#define bitout __builtin_popcount
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(), x.rend()
#define PY 3.141592653589793238
ll power(ll a,ll b){
    ll res = 1;
    while(b > 0)
    {
        if(b%2 == 11) res *= a;
        a *= a;
        b /= 2;
    }
    return res;
}
int main() 
{sevensins
    ll i,j,k,l,n;
    cout.precision(10);
    //GO
    {
        cin>>n;
        
        vect dp(3,0);
        
        for(i=0;i<n;i++)
        {   
            vect v(3);
            
            fore(v)
            cin>>x;
            
            vect new_dp(3,0);
            
            for(j=0;j<3;j++){
                
                for(k=0;k<3;k++){
                    
                    if(j!=k){
                        
                        new_dp[k] = max(new_dp[k] , dp[j] + v[k]);
                    }
                }
            }
            dp = new_dp;
        }
       
        cout <<max({dp[0],dp[1],dp[2]})<<"\n";
    }
return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Vaibhav Pal
 */

#include <bits/stdc++.h>

using namespace std;

struct DEvenRelation {

    static const int MAXN=1e5+5;
    vector<pair<int,int>> adj[MAXN];
    int col[MAXN];

    void dfs(int u, int pa){
        for(auto p:adj[u]){
            int v=p.first,x=p.second;
            if(v==pa)continue;
            if(x){
                col[v]=(col[u]^1);
            } else col[v]=col[u];
            dfs(v,u);
        }
    }

    void solve(istream& in, ostream& out) {
        int n;
        in>>n;
        for(int i=0;i<n-1;i++){
            int u,v,w;
            in>>u>>v>>w;
            adj[u].emplace_back(v,w%2);
            adj[v].emplace_back(u,w%2);
        }
        col[1]=0;
        dfs(1,0);
        for(int i=1;i<=n;i++)out<<col[i]<<"\n";
    }
};


int main() {
	DEvenRelation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 7680
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::num::Wrapping;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

const BASE: Wrapping<u64> = Wrapping(1e9 as u64 + 7);

fn main() {
    let n = read::<usize>();
    let mut s = vec![];
    for i in 0..n {
        let mut ss = read::<String>()
            .chars()
            .map(|x| x.to_digit(36).unwrap() as usize - 10)
            .collect::<Vec<_>>();
        ss.reverse();
        s.push(ss);
    }

    s.sort_by_key(|x| x.len());
    // debug!(s);

    let s_len_max = s.iter().map(|ref x| x.len()).max().unwrap();

    let mut count: Vec<HashMap<Wrapping<u64>, i64>> = vec![HashMap::new(); s_len_max + 1];
    let mut ans = 0i64;
    for ss in s {
        let mut char_count = vec![0; 26];

        for &ch in &ss {
            char_count[ch] += 1;
        }

        let mut s_hash = Wrapping(0);
        for l in 1..ss.len() + 1 {
            if !count[l].is_empty() {
                for ai in 0..26 {
                    if char_count[ai] == 0 {
                        continue;
                    }
                    s_hash += Wrapping(ai as u64);
                    if count[l].contains_key(&s_hash) {
                        ans += count[l][&s_hash];
                        // debug!(ss, cur_key);
                    }
                    s_hash -= Wrapping(ai as u64);
                }
            }
            s_hash = (s_hash + Wrapping(ss[l - 1] as u64)) * BASE;

            // cur_key.push(ss[l - 1]);
            char_count[ss[l - 1]] -= 1;
        }
        let mut hash = Wrapping(0u64);
        for &ch in &ss {
            hash = hash * BASE + Wrapping(ch as u64);
        }

        *count[ss.len()].entry(hash).or_insert(0) += 1;
    }
    // debug!(count);
    println!("{}", ans);
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 63192
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<string,int>> v(n);
    for (auto & p : v) {
        cin >> p.first >> p.second;
        static int k = 0;
        p.second = (100-p.second) * 1000 + ++k;
    }
    sort(begin(v),end(v));
    for (auto p : v)
        cout << p.second%1000 << '\n';
}


Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main _ =
    let [|H;W|] = reads int
    let N = read int
    let AS = reads int

    let data =
        [|
            for i, c in Seq.zip AS (Seq.initInfinite ((+) 1)) do
                for j in 1 .. i do
                    yield c
        |]

    let mutable k = 0
    let ans = Array2D.create H W 0

    for i in 0 .. H - 1 do
        let ix =
            if i % 2 = 0 then
                [|0 .. W - 1|]
            else
                [|W - 1 .. -1 .. 0|]
        for j in ix do
            ans.[i,j] <- data.[k]
            k <- k + 1

    for i in 0 .. H - 1 do
        printfn "%s" (String.Join(" ", ans.[i,*]))

    0

Measured memory_bytes: 19164
#include <iostream>

using namespace std;

void solve()
{
	int y, m, d;
	while(cin >> y >> m >> d)
	{
		int num = y * 10000 + m * 100 + d;
		if(num >= 19890108)
		{
			cout << "heisei " << y - 1988 << " " << m << " " << d << endl;
		}
		else if(num >= 19261225)
		{
			cout << "showa " << y - 1925 << " " << m << " " << d << endl;
		}
		else if(num >= 19120730)
		{
			cout << "taisho " << y - 1911 << " " << m << " " << d << endl;
		}
		else if(num >= 18680908)
		{
			cout << "meiji " << y - 1867 << " " << m << " " << d << endl;
		}
		else
		{
			cout << "pre-meiji" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {

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

        for (int i = 0; i < n; i++) {
            aArr[i] = sc.nextInt();
        }

        // 出現した回数をカウントする
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            if (map.containsKey(aArr[i])) {
                map.put(aArr[i], map.get(aArr[i]) + 1);
            } else {
                map.put(aArr[i], 1);
            }
        }

        int res = 0;
        for (Map.Entry<Integer, Integer> entry: map.entrySet()) {
            if (entry.getValue() % 2 == 1) res++;
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 56296
#include <bits/stdc++.h>
using namespace std;
int main(){
double a,b,h,m;
  cin>>a>>b>>h>>m;
double pi=3.141592653589793;
  cout<<fixed<<setprecision(10)<<sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(min(abs(2*pi*m/60-2*pi*h/12-2*pi*m/720),2*pi-abs(2*pi*m/60-2*pi*h/12-2*pi*m/720))))<<endl;
return 0;
}

Measured memory_bytes: 4228
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }

        void Solve(ConsoleInput cin)
        {
            int a = cin.ReadInt;
            int b = cin.ReadInt;
            int k = cin.ReadInt;
            
            for(int i = Min(a, b); i >= 0; i--)
            {
                if (a % i == 0 & b % i == 0)
                {
                    k--;
                }

                if(k == 0)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }

        class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;

            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }

            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }

            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}

Measured memory_bytes: 13268
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  double ans = 0;
  rep(i, 0, N) {
    double x;
    string u;
    cin >> x >> u;

    if (u == "JPY") {
      ans += x;
    } else {
      double yen = x * 380000.0;
      ans += yen;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define speed ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ub(a,x) upper_bound(a.begin(),a.end(),x)-a.begin()
#define lb(a,x) lower_bound(a.begin(),a.end(),x)-a.begin()
#define ll long long
#define endl "\n"
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define PI 3.1415926535897932384626
#define inf 1e18
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define MOD 1000000007

int main()
{
    speed;
    ll t;
    cin>>t;
    vector<ll> h(t,0);
    forn(i,t)
        cin>>h[i];

    for(ll i=t-1;i>0;--i)
    {
        if(h[i-1]>h[i])
        {
            --h[i-1];
            if(h[i-1]>h[i])
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 1024
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int k=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		for(int i=a; i<=b; i++){
			if(i%k==0){
				System.out.println("OK");
				return;
			}
		}
		System.out.println("NG");
	}
}

Measured memory_bytes: 35700
N,K=map(int, input().split())
R,S,P=map(int, input().split())
T=input()

w1=''
w2=''
ans=0
for i in range(N):
    if T[i]=='r':
        w1+='p'
    elif T[i]=='p':
        w1+='s'
    else:
        w1+='r'

for i in range(0,K):
    if T[i]=='r':
        w2+='p'
        ans+=P
    elif T[i]=='p':
        w2+='s'
        ans+=S
    else:
        w2+='r'
        ans+=R

if N>=2:
    for i in range(K,N):
        if w1[i]==w2[i-K]:
            w2+='_'
        else:
            if w1[i]=='p':
                w2+='p'
                ans+=P
            elif w1[i]=='s':
                w2+='s'
                ans+=S
            else:
                w2+='r'
                ans+=R
print(ans)


Measured memory_bytes: 9448
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void) {
    int N;cin>>N;
    vector<int> A(N);
    for (int i = 0 ; i < N; i++) cin>>A[i];
    sort(A.begin(), A.end());
    int mi = 1e9;
    for (int i = A.at(0); i <= A.at(N - 1); i++) {
        int sum = 0;
        for (int j = 0; j < N; j++) {
            sum += pow((A.at(j) - i), 2);
        }
        if (mi > sum) mi = sum;
    }
    cout << mi << endl;
    return 0;
}

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

bool comp(int a, int b){
	return abs(a) < abs(b);
}

int main(){

	int n,l,ans=0;
	cin>>n>>l;
	int arr[n];
	for(int i=0;i<n;i++){
		arr[i] = l+i;
		ans = ans + arr[i];
	}
	sort(arr,arr+n,comp);
	ans = ans - arr[0];
	cout<<ans<<endl;

	return 0;
}

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

int main(){
    string s;
    cin >> s;
    bool flag=true;
    for(int i=0;i<s.size();++i){
        if(i%2==0){
            if(s.at(i)=='L') flag=false;
        }
        else {
            if(s.at(i)=='R') flag=false;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <assert.h>
#include <queue>
#include <string.h>
#include <string>
#include <set>
#include <memory.h>
#include <functional>
#include <bitset>
using namespace std;
#define ll long long

const int N = 2e5+15;

int a[N];

ll sum[N];

pair<ll,ll> dp[N][2];
void solve() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;++i) {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;++i) {
        sum[i] = sum[i-1] + a[i];
    }
    int pos = n;
    for(int i=n;i>=1;--i) {
        ll cur = sum[n] - sum[i-1];
        while(i<=pos-1 && (sum[pos-1] - sum[i-1])*2>=cur) {
            --pos;
        }
        for(int j=-1;j<=0;++j) {
            dp[i][j+1] = make_pair(sum[pos+j] - sum[i-1], sum[n] - sum[pos+j]);
        }
    }
    pos = 1;
    ll ret = 4e18;
    for(int i=2;i<=n-2;++i) {
        while(pos+1<=i && (sum[pos+1]*2 <= sum[i]) ) {
            ++pos;
        }
        for(int j=0;j<=1;++j) {
            dp[i][j] = make_pair(sum[i] - sum[pos+j] , sum[pos+j]);
        }
        for(int x=0;x<2;++x) {
            for(int y=0;y<2;++y) {
                ll maxi = max( max(dp[i][x].first,dp[i][x].second),max(dp[i+1][y].first,dp[i+1][y].second));
                ll mini = min( min(dp[i][x].first,dp[i][x].second),min(dp[i+1][y].first,dp[i+1][y].second));
                ret = min(ret, maxi - mini);
            }
        }
    }
    cout<<ret<<endl;
}

int main() {
    //freopen("/Users/gotop/Documents/ps_practice/ps_practice/input.txt", "r", stdin);
    solve();
}


Measured memory_bytes: 8832
count = {"AC":0, "WA":0, "TLE":0, "RE":0}
n = int(input())
for i in range(n):
    s = input()
    count[s] += 1

print("AC x {}".format(count["AC"]))
print("WA x {}".format(count["WA"]))
print("TLE x {}".format(count["TLE"]))
print("RE x {}".format(count["RE"]))

Measured memory_bytes: 9108
#include<bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
int main(){
    string  n;
    cin >> n;
    if(n.at(0)=='7'||n.at(1)=='7'||n.at(2)=='7')
    puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<stack>
#include<string>
#include<sstream>
using namespace std;

int main()
{
	stack<int> stk;
	string line;
	getline(cin, line);
	stringstream s;

	s << line;
	string str;

	while (!s.eof())
	{
		s >> str;
		if (str == "+")
		{
			int a = stk.top();
			stk.pop();
			int b = stk.top();
			stk.pop();
			stk.push(a+b);
		}
		else if (str == "-")
		{
			int a = stk.top();
			stk.pop();
			int b = stk.top();
			stk.pop();
			stk.push(b-a);
		}
		else if (str == "*")
		{
			int a = stk.top();
			stk.pop();
			int b = stk.top();
			stk.pop();
			stk.push(a * b);
		}
		else
		{
			stk.push(stoi(str));
		}

	}
	std::cout << stk.top() << endl;

	return 0;
}

Measured memory_bytes: 3188
(N,M),*AB=[list(map(int, x.split())) for x in open(0).readlines() if len(x)>1]

class UnionFind:
    def __init__(self, n):
        self.n=n
        self.parents=[-1 for i in range(n)]

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx == ry:
            return
        if self.parents[rx] > self.parents[ry]:
            rx,ry=ry,rx
        self.parents[rx] = self.parents[ry]
        self.parents[ry] = rx

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i,x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}


d=UnionFind(N)
for a,b in AB:
    d.union(a-1,b-1)
print(d.group_count() - 1)

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

int main(){
  int a,b,x;
  cin >> a >> b >> x;
  double s = double(x)/a;
  double rad;
  if(s>=(a*b)/2){
    double h = 2*(a*b-s)/a;
    rad = atan2(h,a);
  }else{
    double h = (2*s)/b;
    rad = atan2(b,h);
  }
  double PI = acos(-1);
  double ans = rad/PI*180;
  printf("%.10f\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int R,G,B,N;
  cin >>R>>G>>B>>N;
  int answer=0;
  for(int i=0;i*R<=N;i++){
    for(int j=0;j*G<=N;j++){
      if((N-i*R-j*G)>=0&&(N-i*R-j*G)%B==0){
        answer++;
        }
      }
    }
  cout <<answer<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a, const void *b)
{
	return *(int*)b - *(int*)a;
}
int main()
{
	int h[10], i;
	for (i = 0; i < 10; i ++)
		scanf("%d", &h[i]);
	qsort(h, 10, sizeof(*h), cmp);
	for (i = 0; i < 3; i ++)
		printf("%d\n", h[i]);
	return 0;
}

Measured memory_bytes: 0