akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define ll long long
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, n) for(int i = 0; i < n; ++i)

using namespace std;	

const int nax = 100005;

int n, m, t;
int x[nax];
int y[nax];
int dif;
int ile[nax];
char s[nax];
int g[nax];

bitset <50005> bit[50005];
bitset <50005> c;

void go(int k) {
	c.reset();
	c[k] = 1;
	for(int i = m; 1 <= i; --i) {
		if(c[x[i]] == c[y[i]])
			s[i] = '^';
		else if(c[x[i]] < c[y[i]]) {
			s[i] = 'v';
			c[x[i]] = 1;
		}
		else if(c[x[i]] > c[y[i]]) {
			s[i] = '^';
			c[y[i]] = 1;
		}
	}
	for(int i = 1; i <= m; ++i)
		printf("%c", s[i]);
	exit(0);
}
		
int T[nax];	

void solve1() {
	for(int i = 1; i <= n; ++i)
		bit[i][i] = 1;
	for(int i = m; 1 <= i; --i) {
		c = (bit[x[i]] | bit[y[i]]);
		bit[x[i]] = c;
		bit[y[i]] = c;
	}
	
	c.set();
	for(int i = 1; i <= n; ++i) 
		c = (c & bit[i]);
	for(int i = 1; i <= n; ++i)
		if(c[i] == 1)
			go(i);
			
	printf("-1\n");
}

void solve2() {
	if(n == 2) {
		printf("-1\n");
		return;
	}
	for(int i = 1; i <= n; ++i) {
		ile[i] = 1;
		g[i] = i;
	}
	dif = n;
	for(int i = m; 1 <= i; --i) {
		int xp = g[x[i]];
		int yp = g[y[i]];
		if(ile[xp] < ile[yp]) {
			ile[yp]--;
			ile[xp]++;
			g[y[i]] = xp;
			s[i] = '^';
		}
		else {
			ile[yp]++;
			ile[xp]--;
			g[x[i]] = yp;
			s[i] = 'v';
		}
	}
	for(int i = 1; i <= m; ++i)
		printf("%c", s[i]);
		
}
			
int main() {
	scanf("%d %d %d", &n, &m, &t);
	for(int i = 1; i <= m; ++i) {
		scanf("%d %d", x + i, y + i);
	}
	if(t == 1)
		solve1();
	else
		solve2();
	
	return 0;
}



Measured memory_bytes: 307584
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(2e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;
map<int,int> cnt;
int a[N],b[N];
int ans[N];
void solve(){
    int n;
    cin >> n;
    for(int i= 1;i<=n;i++){
        cin >> a[i];
        cnt[a[i]]++;
    }
    for(int i =1;i<=n;i++){
        cin >> b[i];
        cnt[b[i]]++;
    }
    for(auto x:cnt){
        if(x.s > n){
            cout << "No\n";
            return;
        }
    }
    reverse(b+1,b+n+1);
    int l = 1,r = n;
    for(int i = 1;i<=n;i++){
        if(a[i] == b[i]){
            if(b[l] != b[i] && a[l] != a[i]){
                swap(b[l],b[i]);
                l++;
            }
            else{
                swap(b[r],b[i]);
                r--;
            }
        }
    }



    cout << "Yes\n";
    for(int i=1;i<=n;i++){
        cout << b[i] << " ";
    }
    cout << endl;

}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 19224
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
	int a,b;
	cin>>a>>b;
	cout<<6-a-b<<"\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);

	int t=1;       
	// cin >> t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
//19
#include<iostream>
#include<utility>
#include<string>
#include<set>
#include<algorithm>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    pair<int,string> sc[500];
    for(int i=0;i<n;i++){
      string s;
      int d,t;
      cin>>s>>d>>t;
      sc[i]=make_pair(d*24*60+t/100*60+t%100,s);
    }
    sort(sc,sc+n);
    set<string> fa;
    int np;
    cin>>np;
    while(np--){
      string f;
      cin>>f;
      fa.insert(f);
    }
    int p=-100000;
    bool m=false;
    int c=0;
    for(int i=0;i<n;i++){
      if(p+30>sc[i].first){
	if(fa.count(sc[i].second)){
	  if(m){
	    c=-1;
	    break;
	  }else{
	    m=true;
	    p=sc[i].first;
	  }
	}
      }else{
	c++;
	p=sc[i].first;
	m=fa.count(sc[i].second);
      }
    }
    cout<<c<<endl;
  }
  return 0;
}

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

int main() {
  int N, M;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
      cin >> A.at(i);
  }
  reverse(A.begin(),A.end());
  for(int k = 0; k < N; k++){
      cout << A.at(k);
      if(k != N-1){
          cout << " ";
      }
  }
  cout << endl;
}


Measured memory_bytes: 3092
#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];
  int64_t all;
  for(int i=0; i<N; i++)
  all+=a[i];
  
  vector<int64_t> x(N);
  int64_t y=0;
 
  for(int j=0;j<(N-1)/2;j++){
     y+=a[(1+2*j)];
  }
  x[0]=all-2*y;
  
  for(int i=1; i<N;i++)
    x[i]=2*a[i-1]-x[i-1];
  for(int i=0; i<N; i++)
    cout <<x[i]<<" ";
}

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

template <typename T>
class LazySegmentTree {
	const int n;
	const T flag;
	const int id;
	vector<int> data, data2;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	T sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return id;
		if (data[node] != flag) {
			return data[node];
		}
		if (l <= lb && ub <= r) {
			return data[node] == flag ? data2[node] : data[node];
		}
		int left = node * 2, right = node * 2 + 1;
		if (data[node] != flag) {
			data[left] = data[node];
			data[right] = data[node];
		}
		return min(sub(l, r, node * 2, lb, (lb + ub) / 2), sub(l, r, node * 2 + 1, (lb + ub) / 2, ub));
	}
	void suc(int l, int r, int node, int lb, int ub, T val) {
		if (ub <= l || r <= lb) return;
		if (data[node] == val) return;
		if (l <= lb && ub <= r) {
			data[node] = val;
			return;
		}
		int left = node * 2, right = node * 2 + 1;
		if (data[node] != flag) {
			data[left] = data[node];
			data[right] = data[node];
		}
		data[node] = flag;
		suc(l, r, left, lb, (lb + ub) / 2, val);
		suc(l, r, right, (lb + ub) / 2, ub, val);
		data2[node] = min(data[left] == flag ? data2[left] : data[left], data[right] == flag ? data2[right] : data[right]);
	}
public:
	LazySegmentTree(int n_, T flag_, T id_) :
		n(size(n_)), flag(flag_), id(id_), data(n * 2, id), data2(n * 2) {}
	void update(int l, int r, T val) {
		suc(l, r + 1, 1, 0, n, val);
	}
	T find(int l, int r) {
		return sub(l, r + 1, 1, 0, n);
	}
};

int main()
{
	int n, q, b, s, t, x;
	cin >> n >> q;
	LazySegmentTree<int> lst(n, -1, INT_MAX);
	while (q--) {
		cin >> b;
		if (b) {
			cin >> s >> t;
			cout << lst.find(s, t) << endl;
		}
		else {
			cin >> s >> t >> x;
			lst.update(s, t, x);
		}
	}
	return 0;
}

Measured memory_bytes: 4948
dict = {}
data = input()

for i in range(len(data)):
  if data[i] in dict.keys():
    dict[data[i]] = (dict[data[i]] + 1)%2
  else:
    dict[data[i]] = 1
    
if 1 in dict.values():
  print("No")
else:
  print("Yes")


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



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

	vector< vector<int> >v(3, vector<int>(n+1, 0));
	rep(i, 0, 2) {
		rep(j, 0, n) {
			cin >> v[i+1][j+1];
		}
	}

	//dp[i][j]:座標(i,j)まで来た時の最大個数
	vector< vector<int> >dp(3, vector<int>(n+1, 0));

	rep(i, 1, 3) {
		rep(j, 1, n+1) {
			dp[i][j] = max(dp[i - 1][j] + v[i][j], dp[i][j - 1] + v[i][j]);
		}
	}

	cout << dp[2][n] << endl;


	return 0;

}

Measured memory_bytes: 256
/*
  Warn - Don't change next line else you will get WA verdict. Online Judge is configured to give WA if next line is not present.
  Author - Aryan Choudhary (@aryanc403)
 
  const short DEBUG { 0 };
  #define debug(x) if (DEBUG) cout << #x << " = " << x << '\n'
*/

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"
#define PI 3.1415926535897932384626433832795
typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

//const lli [3] ={ 999119999L,1000000007L,1000992299L};
//const lli [3] ={ 97L,101L,103L};
//const lli  = chrono::high_resolution_clock::now().time_since_epoch().count();
clock_t time_p=clock();
void aryanc403()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

class CMP
{
public:
    bool operator()(lli a , lli b) //For min priority_queue .
    {
        return ! ( a <= b );
    }
};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    map<lli,lli> ::iterator jt;
    jt=m.find(x);
    if(jt==m.end())         m.insert(mp(x,cnt));
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    map<lli,lli> ::iterator jt;
    jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}
const lli INF = 0xFFFFFFFFFFFFFFFL;
const lli mod = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r;
    lli m;
    string s;
    vi a;
    vi :: iterator it;
    //priority_queue < lli , vector < lli > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n>>m;
    cout<<std::fixed<<std::setprecision(35)<< n/(mytype)m <<endl;
}   aryanc403();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main(){
  int n;
  cin >> n;
  int N = n;
  vector<long int> a;
  for(int i = 0;i < n;i++){
    long int p;
    cin >> p;
    a.push_back(p);
  }

  sort(a.begin(),a.end());
  int i = 0;
  int count = 0;
  for(i = 0;i < n;i++){
    if(a[i] < 0){
      count++;
      a[i] = a[i]*(-1);
    }
  }
  sort(a.begin(),a.end());
  long int ans = 0;
  if(count%2 == 0){
    for(int j = 0;j < n;j++){
      ans += a[j];
    }
  }
  else{
    ans -= a[0];
    for(int j = 1;j < n;j++){
      ans += a[j];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  ll a,b,c,k;
  cin>>a>>b>>c>>k;

  if(k%2) cout<<b-a<<endl;
  else cout<<a-b<<endl;
  
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(int(i) for i in input().split())
b = list(int(i) for i in input().split())
c = list(int(i) for i in input().split())
total = 0

for i in range(n):
    total += b[a[i]-1]
    if i-1 >= 0 and a[i]-a[i-1] == 1:
        total += c[a[i-1]-1]

print(total)

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

#define EPS (1e-7)

typedef struct {
	double x,y,z;
} xyz_t;

typedef struct {
	int x,y,l;
} kui_t;

int n;
kui_t kui[10];

int is_valid(xyz_t b) {
	int i;
	if(b.z<0)return 0;
	for(i=0;i<n;i++) {
		if((b.x-kui[i].x)*(b.x-kui[i].x)+(b.y-kui[i].y)*(b.y-kui[i].y)+b.z*b.z>kui[i].l*kui[i].l+EPS)return 0;
	}
	return 1;
}

int hts_solve(double* x,double* y,int a,int b,int c,int d,int p,int q) {
	int delta=a*d-b*c;
	if(delta==0)return 0;
	*x=(double)(d*p-b*q)/delta;
	*y=(double)(-c*p+a*q)/delta;
	return 1;
}

xyz_t get_one(int id) {
	xyz_t result={kui[id].x,kui[id].y,kui[id].l};
	return result;
}

xyz_t get_two(int id1,int id2) {
	double a=sqrt((kui[id1].x-kui[id2].x)*(kui[id1].x-kui[id2].x)+(kui[id1].y-kui[id2].y)*(kui[id1].y-kui[id2].y));
	double x=(a*a-kui[id2].l*kui[id2].l+kui[id1].l*kui[id1].l)/(2.0*a);
	double h=sqrt(kui[id1].l*kui[id1].l-x*x);
	xyz_t result={kui[id1].x+(kui[id2].x-kui[id1].x)*x/a,kui[id1].y+(kui[id2].y-kui[id1].y)*x/a,h};
	return result;
}

xyz_t get_three(int id1,int id2,int id3) {
	kui_t k1=kui[id1];
	kui_t k2=kui[id2];
	kui_t k3=kui[id3];
	double x,y,zz;
	xyz_t err={0,0,-1};
	xyz_t result;
	if(!hts_solve(&x,&y,2*(k1.x-k2.x),2*(k1.y-k2.y),2*(k2.x-k3.x),2*(k2.y-k3.y),
			k2.l*k2.l-k1.l*k1.l-k2.x*k2.x+k1.x*k1.x-k2.y*k2.y+k1.y*k1.y,
			k3.l*k3.l-k2.l*k2.l-k3.x*k3.x+k2.x*k2.x-k3.y*k3.y+k2.y*k2.y)) {
		return err;
	}
	zz=k1.l*k1.l-k1.y*k1.y+2*y*k1.y-y*y-k1.x*k1.x+2*x*k1.x-x*x;
	if(zz<0)return err;
	result.x=x;result.y=y;result.z=sqrt(zz);
	return result;
}

int main(void) {
	while(scanf("%d",&n)==1 && n>0) {
		int i,j,k;
		for(i=0;i<n;i++)scanf("%d%d%d",&kui[i].x,&kui[i].y,&kui[i].l);
		double max_z=0;
		xyz_t now;
		/* one */
		for(i=0;i<n;i++) {
			now=get_one(i);
			if(is_valid(now) && now.z>max_z)max_z=now.z;
		}
		/* two */
		for(i=0;i<n;i++) {
			for(j=i+1;j<n;j++) {
				now=get_two(i,j);
				if(is_valid(now) && now.z>max_z)max_z=now.z;
			}
		}
		/* three */
		for(i=0;i<n;i++) {
			for(j=i+1;j<n;j++) {
				for(k=j+1;k<n;k++) {
					now=get_three(i,j,k);
					if(is_valid(now) && now.z>max_z)max_z=now.z;
				}
			}
		}
		printf("%.15f\n",max_z);
	}
	return 0;
}

Measured memory_bytes: 648
import java.util.Scanner;


public class Main {
	public static int count;
	public static int m;
	public static int[] G = new int[100];
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int n = stdIn.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
		}
		stdIn.close();
		shellSort(a, n);

		System.out.println(m);
		for (int i = m - 1; i >= 0; i--) {
			if (i != 0)
				System.out.print(G[i] + " ");
			else
				System.out.println(G[i]);
		}
		System.out.println(count);
		for (int i = 0; i < n; i++)
			System.out.println(a[i]);

	}

	public static void insertionSort(int[] A, int n, int g) {
		for(int i = g; i < n; i++) {
			int v = A[i];
			int j = i - g;
			while(j >= 0 && A[j] > v) {
				A[j + g] = A[j];
				j = j -g;
				count++;
			}
			A[j + g] = v;
		}
	}

	public static void shellSort(int[] A, int n) {
		count = 0;
		m = 0;
		for(int i = 1; ;i = 3 * i + 1) {
			if(i > n) break;
			G[m] = i;
			m++;
		}

		for(int i = m - 1; i >= 0; i--) {
			insertionSort(A, n, G[i]);
		}
	}
}


Measured memory_bytes: 298940
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int n,k;
	cin >> n >> k;
	if((n-2)*(n-1)/2 < k){
		cout << -1 << endl;
	}else{
		int tmp = (n-2)*(n-1)/2-k;
		cout << n-1+tmp << endl;
		for(int i = 2; i <= n; i++) cout << 1 << " " << i << endl;
		for(int i = 2; i <= n; i++){
			if(tmp<=0) break;
			for(int j = i+1; j <= n; j++){
				cout << i << " " << j << endl;
				if(--tmp<=0) break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
int n,m;
int ind[MAXN];
vector<int> a[MAXN];
int dfn[MAXN],low[MAXN],cnt;
bool used[MAXN];
void dfs(int x,int fa=0){
    dfn[x]=low[x]=++cnt;
    bool flag=0;
    int tot=0;
    for(int i=0;i<int(a[x].size());i++){
        int u=a[x][i];
        if(u==fa)
            continue;
        if(dfn[u]==0){
            tot++;
            dfs(u,x);
            low[x]=min(low[x],low[u]);
            if(low[u]>=dfn[x])
                flag=1;
        }
        else
            low[x]=min(low[x],dfn[u]);
    }
    if(x==1)
        flag=(tot>1);
    used[x]=flag;
}
int main(){
	int u,v;
	SF("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		SF("%d%d",&u,&v);
		a[u].push_back(v);
		a[v].push_back(u);
		ind[u]++,ind[v]++;
	}
	for(int i=1;i<=n;i++)
		if(ind[i]%2==1){
			PF("No");	
			return 0;
		}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(ind[i]>=6){
			PF("Yes");
			return 0;
		}
	dfs(1);
	int cnt1=0,cnt2=0;
	for(int i=1;i<=n;i++)
		if(ind[i]>=4){
			cnt1++;
			if(used[i])
				cnt2++;	
		}
	if(cnt1>2||(cnt1==2&&cnt2))
		PF("Yes");
	else
		PF("No");
}

Measured memory_bytes: 12288
use std::collections::VecDeque;
use std::io;

fn main() {
    /// 7 1
    /// 100 10 1
    /// ssssppr
    let line1 = parse_line::<String>();
    let mut cs1 = line1.split_whitespace();
    let n = cs1.next().unwrap().parse::<u64>().unwrap();
    let k = cs1.next().unwrap().parse::<usize>().unwrap();

    let line2 = parse_line::<String>();
    let mut cs2 = line2.split_whitespace();
    let r = cs2.next().unwrap().parse::<u64>().unwrap();
    let s = cs2.next().unwrap().parse::<u64>().unwrap();
    let p = cs2.next().unwrap().parse::<u64>().unwrap();

    let t: Vec<char> = parse_line::<String>().chars().collect();

    println!("{}", resolve(n, k, r, s, p, t));
}

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

fn resolve(n: u64, k: usize, r_score: u64, s_score: u64, p_score: u64, t: Vec<char>) -> u64 {
    let mut score_sum: u64 = 0;
    let mut history = VecDeque::with_capacity(k);
    for _ in 0..k {
        history.push_front('-');
    }
    //println!("{:?}", history);
    for c in t {
        let no = history.pop_back().unwrap();
        //println!("{}", c);
        let win = match c {
            'r' => 'p',
            's' => 'r',
            'p' => 's',
            _ => '-',
        };
        //println!("{}", no);
        let win_score = if no == win {
            history.push_front('-');
            0
        } else {
            history.push_front(win);
            match win {
                'r' => r_score,
                's' => s_score,
                'p' => p_score,
                _ => 0,
            }
        };
        //println!("{}", win_score);
        score_sum += win_score;
    }
    score_sum
}

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


int main()
{
	vector<int> num(3);
	rep(i,3) cin>>num[i];
	sort(num.begin(),num.end());
	if(num[0]==5&&num[1]==5&&num[2]==7) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


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

int main()
{
    int s;
    cin >> s;
    int n1 = s / 100,
        n2 = s % 100;
    bool s1, s2;
    if (n1 > 12 || n1 == 0)
    {
        s1 = true;
    }
    else
    {
        s1 = false;
    }

    if (n2 > 12 || n2 == 0)
    {
        s2 = true;
    }
    else
    {
        s2 = false;
    }

    if (s1 && s2)
    {
        cout << "NA" << endl;
    }
    else if (s1 && !s2)
    {
        cout << "YYMM" << endl;
    }
    else if (!s1 && s2)
    {
        cout << "MMYY" << endl;
    }
    else
    {
        cout << "AMBIGUOUS" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    int n;
    cin >> n;
    pair<int,int> pr[n + 5];
    for(int i = 0; i < n; i++){
        cin >> pr[i].first;
        pr[i].second = i + 1;
    }
    sort(pr, pr + n);
    for(int i = 0; i < n; i++)
        cout << pr[i].second << " ";
    return 0;
}

Measured memory_bytes: 1664
a, b = gets.split.map(&:to_i)

t = []

1.upto(999) do |i|
  if i == 1
    t << 1
  else
    t << t[i - 2] + i
  end
end

0.upto(999 - 2) do |i|
  if t[i] - a  == t[i + 1] - b
    puts t[i] - a
    break
  end
end

Measured memory_bytes: 1788
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
ll pattern(ll n){
	return n*(n-1)/2;
}
int main(){
  	ll N;
  	cin >> N;
  	ll A[N], cnt[N+1];

  	for(int i=0;i<=N;i++) cnt[i] = 0;

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

  	ll sum  = 0;
  	for(int i=1;i<=N;i++){
  		sum += pattern(cnt[i]);
  	}

  	for(int i=0;i<N;i++){
  		cout << sum - pattern(cnt[A[i]]) + pattern(cnt[A[i]]-1) <<endl; 
  	}
    
  	return 0;
}


Measured memory_bytes: 5760
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	S := nextLine()
	if S == "ABC" {
		fmt.Println("ARC")
	} else {
		fmt.Println("ABC")
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 1796
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int b[210000];
pair<int,int> z[210000];
int ans[210000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",b+i);
	for(int i=0;i<a;i++){z[i]=make_pair(b[i],i);}
	std::sort(z,z+a);
	for(int i=0;i<a;i++){
		if(i<a/2)ans[z[i].second]=z[a/2].first;
		else ans[z[i].second]=z[a/2-1].first;
	}
	for(int i=0;i<a;i++)printf("%d\n",ans[i]);
}


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

int main(){
  ll n, x;
  cin >> n >> x;
  ll a[n];
  ll cnt = 0;
  for(ll i = 0; i < n; i++){
    cin >> a[i];
    if(a[i] > x){
      cnt += a[i] - x;
      a[i] = x;
    }
  }

  for(ll i = 0; i < n - 1; i++){
    if(a[i] + a[i + 1] > x){
      cnt += a[i] + a[i+1] - x;
      a[i + 1] = x - a[i];
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1152
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;

void solve()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    vi red(a), green(b);
    multiset<int> colorless;

    rep(i, 0, a)
    scn(red[i]);

    rep(i, 0, b)
    scn(green[i]);

    rep(i, 0, c) {
        int val;
        scn(val);
        colorless.insert(val);
    }

    multiset<int> best;

    sort(red.begin(), red.end(), greater<int>());
    sort(green.begin(), green.end(), greater<int>());

    rep(i, 0, x)
    best.insert(red[i]);

    rep(i, 0, y)
    best.insert(green[i]);

    while(1) {
        int here = *best.begin();

        auto j = colorless.upper_bound(here);
        if(j == colorless.end())
            break;

        int val = *j; colorless.erase(colorless.find(val));

        best.erase(best.find(here)); best.insert(val);
    }

    ll sum = 0;

    for(auto x : best) {
        sum += 1LL * x;
    }

    lprin(sum);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 17320
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int a,b;
    cin >> a >> b;
    if(a == b){
        P(a*2);
    }else{
        P(max(a,b)*2 - 1);
    }
}

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b;
  if(a!=1&&b!=1)
    cout<<"1";
    if(a!=2&&b!=2)
    cout<<"2";
    if(a!=3&&b!=3)
    cout<<"3";
return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	s := scanner.Text()

	scanner.Scan()
	p := scanner.Text()

	sum_s := s
	for i, rune_s := range s {
		if i != len(s) {
			sum_s += string(rune_s)
		}
	}

	if strings.Contains(sum_s, p) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}



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

int main()
{
  int A, B;
  cin >> A >> B;
  vector <int> calc;
  calc.push_back(A+B);
  calc.push_back(A-B);
  calc.push_back(A*B);
  sort(calc.begin(),calc.end());
  cout << calc[2] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
#define load ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ll long long
#define ull unsigned long long
#define fori(i,n) for (int i=0; i<int(n);i++)
#define srt(v) sort(v.begin(), v.end())
#define MOD 1000000007
const int INF = 1e9;
const double PI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
    return b != 0 ? gcd(b, a % b) : a;
}
 
ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

void solve(){

}

int main(){
	load;
    int n;
    cin >> n;
    unordered_map<int,int> m;
    ull sum = 0;
    while(n--){
    	int temp;
    	cin>> temp;
    	m[temp]++;
    	sum += temp;
    }
    int q;
    cin >> q;
    while(q--){
    	int  a,b;
    	cin >> a >> b;
    	sum += (b-a)*m[a];
    	m[b] += m[a];
    	m.erase(a);
    	cout << sum << "\n";
    }
	return 0;
}



Measured memory_bytes: 6672
def examA(mod):
    N = I(); S = SI()
    d = defaultdict(int)
    ans = 1
    for s in S:
        d[s] +=1
    for i in d.values():
        ans *=(i+1)
    print((ans-1)%mod)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA(mod)

Measured memory_bytes: 39664
import itertools

length, max_num, comb_num = map(int, input().split())
targets = [list(map(int, input().split())) for i in range(comb_num)]

combs = list(itertools.combinations_with_replacement(
    range(1, max_num+1), length))

result = 0
for comb in combs:
    total = 0
    for a, b, c, d in targets:
        a -= 1
        b -= 1
        if comb[b] - comb[a] == c:
            total += d
    if result < total:
        result = total

print(result)


Measured memory_bytes: 21620
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($cond:expr, $a:expr, $b:expr) => {
        if $cond {
            $a
        } else {
            $b
        }
    }
}

fn main() {
    input! {
        n: usize,
        a: [usize; n]
    };

    let one = a.iter().filter(|u| **u == 1).count();
    let two = a.iter().filter(|u| **u == 2).count();
    let three = a.iter().filter(|u| **u == 3).count();

    let mut memo = vec![vec![vec![-1.0; n+1]; n+1]; n+1];
    println!("{}", solve(one, two, three, n, &mut memo));
}


fn solve(one: usize, two: usize, three: usize, n: usize, memo: &mut Vec<Vec<Vec<f64>>>) -> f64 {
    if one + two + three == 0 {
        return 0.0;
    }
    if memo[one][two][three] >= 0.0 {
        return memo[one][two][three];
    }

    let ott = (one + two + three) as f64;
    let one_rate = (one as f64) / ott;
    let two_rate = (two as f64) / ott;
    let three_rate = (three as f64) / ott;
    let mut total = 0.0;
    let add = (n as f64) / ott;
    if one >= 1 {
        total += one_rate * (solve(one-1, two, three, n, memo) + add);
    }
    if two >= 1 {
        total += two_rate * (solve(one+1, two-1, three, n, memo) + add);
    }
    if three >= 1 {
        total += three_rate * (solve(one, two+1, three-1, n, memo) + add);
    }
    memo[one][two][three] = total;
    return total;
}

Measured memory_bytes: 237948
using System;

namespace ABC055B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var m = 1000000007L;
            var a = 1L;

            for(var i = 1; i <= n; i++)
            {
                a = ((a % m) * (i % m)) % m;
            }

            Console.WriteLine(a);
        }
    }
}


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

ll b[10101010];

int main() {
    string s;
    cin >> s;
    rep(i, s.size()) {
        if (s[i] == 'B') b[i]++;
    }
    rep(i, s.size()) {
        if (i) b[i] += b[i-1];
    }
    ll ans = 0;
    rep(i, s.size()) {
        if (s[i] == 'W') ans += b[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2180
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		String S=stdIn.next();
		char s[]=S.toCharArray();
		long r=0,g=0,b=0,ans=0;
		for(int i=0;i<N;i++){
			if(s[i]=='R')
				r++;
			if(s[i]=='G')
				g++;
			if(s[i]=='B')
				b++;
		}
		ans=r*g*b;
		for(int i=0;i<N-2;i++){
			for(int l=0;i+2+(l*2)<N;l++){
				if(s[i]!=s[i+1+l]&&s[i]!=s[i+2+(l*2)]&&s[i+2+(l*2)]!=s[i+1+l])
					ans--;
			}
		}
		System.out.println(ans);
	}
}


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

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> ss(h);
	for (auto &s : ss)
	{
		cin >> s;
	}

	vector<vector<int>> u(h, vector<int>(w, 0)), d(h, vector<int>(w, 0)), l(h, vector<int>(w, 0)), r(h, vector<int>(w, 0));

	for (int j = 0; j < w; j++)
	{
		u[0][j] = (ss[0][j] == '.');
	}
	for (int i = 1; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (ss[i][j] == '#')
			{
				continue;
			}
			u[i][j] = u[i - 1][j] + 1;
		}
	}

	for (int j = 0; j < w; j++)
	{
		d[h - 1][j] = (ss[h - 1][j] == '.');
	}
	for (int i = h - 2; 0 <= i; i--)
	{

		for (int j = 0; j < w; j++)
		{
			if (ss[i][j] == '#')
			{
				continue;
			}
			d[i][j] = d[i + 1][j] + 1;
		}
	}

	for (int i = 0; i < h; i++)
	{
		l[i][0] = (ss[i][0] == '.');
	}
	for (int i = 0; i < h; i++)
	{
		for (int j = 1; j < w; j++)
		{
			if (ss[i][j] == '#')
			{
				continue;
			}
			l[i][j] = l[i][j - 1] + 1;
		}
	}

	for (int i = 0; i < h; i++)
	{
		r[i][w - 1] = (ss[i][w - 1] == '.');
	}
	for (int i = 0; i < h; i++)
	{
		for (int j = w - 2; 0 <= j; j--)
		{
			if (ss[i][j] == '#')
			{
				continue;
			}
			r[i][j] = r[i][j + 1] + 1;
		}
	}

	int ans = 0;

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			ans = max(ans, u[i][j] + d[i][j] + l[i][j] + r[i][j] - 3 * (ss[i][j] == '.'));
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    int n,a[101][3];
    int score;
    int highScore;

    scanf("%d",&n);
    for(int j=1;j<=2;j++){
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i][j]);
        }
    }
    
    for(int i=1;i<=n;i++){
        score=0;
        for(int j=1;j<=i;j++){
            score+=a[j][1];
        }
        for(int j=i;j<=n;j++){
            score+=a[j][2];
        }
        if(highScore<score)highScore=score;
    }

    printf("%d",highScore);
    return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) = ripPro0408a()

fun ripPro0408a() {
    val (n, a, b) = readLine()!!.split(' ').map { it.toInt() }

    val answer = if ((a - b) % 2 == 0) "Alice" else "Borys"

    println(answer)
}


Measured memory_bytes: 38184
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

# N個の部屋とM本の通路
N, M = [int(x) for x in stdin.readline().rstrip().split()]

route = [[] for _ in range(N+1)]

# A->B と B->A をリストに保存していく
# AとBは "1以上" を想定
for _ in range(M):
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    route[A].append(B)
    route[B].append(A)

# 場所1までの距離
dist_to_1 = [INF for _ in range(N+1)]
dist_to_1[1] = 0

# next_route[i] = j: 場所iがゴールに最短でたどり着くために向かう場所j
next_route = [0 for _ in range(N+1)]

# 場所iに訪れたかどうか
is_visited = [False for _ in range(N+1)]

# 幅優先探索
# 試すべき位置をキューで管理
que = deque([1])

# キューが空じゃなければ
while len(que) != 0:
    now = que.popleft()
    
    # 過去に訪れていれば無視
    if is_visited[now]:
        continue

    is_visited[now] = True

    # そこからいける場所を幅優先探索で
    for place in route[now]:
        que.append(place)

        # 距離とルートの更新
        if dist_to_1[now]+1 < dist_to_1[place]:
            dist_to_1[place] = dist_to_1[now]+1
            next_route[place] = now

# 場所2以降において、どこか次の道が見つかってない場合は
# ゴールにいけないということ
if 0 in next_route[2:]:
    print("No")
else:
    print("Yes")
    for i in range(2, N+1):
        print(next_route[i])

Measured memory_bytes: 111600
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<assert.h>

#define max(a,b) ((a)>(b))?(a):(b)
#define min(a,b) ((a)>(b))?(b):(a)

typedef long long ll;
typedef unsigned long long ull;

int main(void)
{
	int x, a;
	scanf("%d%d", &x, &a);
	if (x<a)
	{
		printf("0");
	}
	else
	{
		printf("10");
	}
}

Measured memory_bytes: 128
/**
*    author:  souzai32
*    created: 02.08.2020 19:41:11
**/

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {

    int n,k;
    cin >> n >> k;
    int r,s,p;
    cin >> r >> s >> p;
    long long point=0;
    string t;
    cin >> t;

    rep(i,n){
        if(t.at(i)=='r') point+=p;
        if(t.at(i)=='s') point+=r;
        if(t.at(i)=='p') point+=s;
    }

    for(int i=k; i<n; i++){
        if(t.at(i)==t.at(i-k)){
            if(t.at(i)=='r') point-=p;
            if(t.at(i)=='s') point-=r;
            if(t.at(i)=='p') point-=s;
            t.at(i)='a';
        }
    }

    cout << point << endl;

    return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#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++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  auto t=s;
  reverse(all(t));
  if(t==s)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a,b,r,temp;
        scanf("%d%d",&a,&b);
        if(a<b){temp = a;
		 a = b;
		 b = temp; 
		}
        while(1) {
	  r = a%b;
	  if(r==0) break;
            a = b;
            b = r;
	    //  printf("%d %d %d\n",a,b,r);
	    
        }
        //printf("%d\n",b);
        printf("%d\n",b);

	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r;
  cin >> r;
  cout << 3*r*r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
char s[12];
void dfs(int x, int y) {
    int i;
    if (x == n) {
        printf("%s\n", s);
    } else {
        for (i = 0; i < y; i++) {
            s[x] = 'a' + i;
            //cout<<"("<<x+1<<","<<y<<")"<<endl;
            dfs(x + 1, y);
        }
        s[x] = 'a' + y;
        //cout<<"("<<x+1<<","<<y+1<<")"<<endl;
        dfs(x + 1, y + 1);
    }
}
int main() {
    int i;
    while(cin>>n){
    dfs(0, 0);
    }
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using vec = vector<int>;
using intk = int64_t;

int main() {
 string S;
  cin >> S;
  int ans =0;
  int N = S.size();
  for(int i=0;i<N-1;i++){
   if(S[i] == S[i+1]){
    if(S[i+1] == '1') S[i+1] = '0';
     else S[i+1] = '1';
     ans++;
   }
  }
  cout << ans <<endl;
}
  


Measured memory_bytes: 512
import java.util.*;

public class Main {
	static ArrayList<Integer>[] lists;

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		lists = new ArrayList[n + 1];
		for (int i = 1; i <= n; i++) {
			lists[i] = new ArrayList<Integer>();
		}
		int[] a = new int[m];
		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			lists[a[i]].add(b[i]);
			lists[b[i]].add(a[i]);
		}
		int count = 0;
		for (int i = 0; i < m; i++) {
			boolean[] test = new boolean[n + 1];
			Arrays.fill(test, false);
			search(1, a[i], b[i], test);
			if (!isAllTrue(test)) {
				count++;
			}
		}
		System.out.print(count);
	}
	
	static void search(int idx, int a, int b, boolean[] test) {
		for (int i : lists[idx]) {
			if (!test[i] && !((a == i && b == idx) || (a == idx && b == i))) {
				test[i] = true;
				search(i, a, b, test);
			}
		}
	}
	
	static boolean isAllTrue(boolean[] bs) {
		for (int i = 1; i < bs.length; i++) {
			if (!bs[i]) {
				return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

    ll n;
    cin >> n;
    string s[n];
    for(ll i=0;i<n;i++)cin >> s[i];

    sort(s,s+n);

    vector<string> v;

    ll m=1;
    ll c=1;
    string t=s[0];
    for(ll i=1;i<n;i++){
        if(t==s[i])c+=1;
        else{
            if(c>m){
                v.clear();
                v.push_back(t);
                m=c;
            }
            else if(c==m){
                v.push_back(t);
            }
            t=s[i];
            c=1;
        }
    }
    if(c>m){
        v.clear();
        v.push_back(s[n-1]);
        m=c;
    }
    else if(c==m){
        v.push_back(s[n-1]);
    }

    for(ll i=0;i<v.size();i++){
        for(ll j=0;j<v[i].size();j++)cout << v[i][j];
        cout << endl;
    }


}

Measured memory_bytes: 17900
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
n = int(input())
# A = list(map(int, input().split()))

cites = defaultdict(list)
for i in range(n):
    s, p = input().split()
    p = int(p)
    cites[s].append((p, i+1))

for k in sorted(cites.keys()):
    [ print(i[1]) for i in sorted(cites[k], reverse=True)]





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

long long mod=1000000007;
long long ara[1000009];

long long bigmod(long long n,long long p)
{
     if(p==0)return 1;
     if(p%2==0)
     {
         long long ret=bigmod(n,p/2);
         return ((ret%mod)*(ret%mod))%mod;
     }
     else
        return ((n%mod)*(bigmod(n,p-1)%mod))%mod;
}


int main()
{


        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,t,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        scanf("%lld %lld",&x,&y);

        ara[0]=1;

        for(i=1;i<=1000004;i++)
        {
            ara[i]=(ara[i-1]*i)%mod;
        }

        for(i=0;i<=x;i++)
        {

            f=i*2; g=x-f; if(f>x)break;

            t=i+g;

            a=g*2; b=i; fr=f+g; sc=a+b;

            if(fr==x && sc==y)
            {
                d=(ara[i]*ara[t-i])%mod;
                e=bigmod(d,mod-2); q=(ara[t]*e)%mod; ans=ans+q;

            }


        }

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






    return 0;
}





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

long long n;
string s;

int main(){
	cin >> s;
	cin >> n;
	int i = 0;
	int so;
	while (n>0) {
		so = s[i] - '0';
		if (so == 1) {
			n--;
		}
		else {
			break;
		}
		++i;
	}
	cout << so;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void main() {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String str = sc.next();
			if(str.equals("-")) break;
			int m = sc.nextInt();
			for(int i=0;i<m;i++) {
				int h = sc.nextInt();
				String head = str.substring(0, h);
				String tail = str.substring(h,str.length());
				str = tail + head;
			}
			System.out.println(str);
		}
			
	}
			public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		new Main().main();
	}

}


Measured memory_bytes: 26396
N=int(input())
A=[i for i in map(int,input().split())]

dp_p={}
dp_m={}
dp_p[0]=0
dp_m[0]=-9999999999

for i in range(N):
    dp_p[i+1]=max(dp_p[i]+A[i], dp_m[i]-A[i])
    dp_m[i+1]=max(dp_p[i]-A[i], dp_m[i]+A[i])    

print(dp_p[N])

Measured memory_bytes: 37452
#include <bits/stdc++.h>
using namespace std;
int main() {
   vector<int> vec(3);
cin >> vec[0];
cin >> vec[1];
cin >> vec[2];
sort(vec.begin(), vec.end());
if(vec[0] == 5 && vec[1] == 5 && vec[2] == 7)
    cout << "YES" << endl;
else
    cout << "NO" << endl; 

    return 0;
}

Measured memory_bytes: 256