akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define dump(x) cout << #x << " = " << (x) << endl
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    cout << pow(n, 3) << endl;
    return 0;
}

Measured memory_bytes: 4208
n = int(input())

sList = []
for i in range(n):
  sList.append(input())

for i in sList:
  if sList.count(i) > 1:
    print("No")
    exit(0)

for i in range(0,n-1):
  if sList[i][-1] != sList[i+1][0]:
    print("No")
    exit(0)

print("Yes")


Measured memory_bytes: 3060
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Scanner;

class State{
	int h, w;
	public State(int _h, int _w) {
		h = _h; w = _w;
	}
}
public class Main{
	static int[] dx = {0, 0, -1, 1};
	static int[] dy = {-1, 1, 0, 0};
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt(), W = sc.nextInt();
		int ans = 0;
		int[][] map = new int[H][W];
		Queue<State> que = new ArrayDeque<State>();
		for(int i = 0; i < H; i++) {
			Arrays.fill(map[i], Integer.MAX_VALUE);
			String str = sc.next();
			for(int j = 0; j < W; j++) {
				if(str.charAt(j) == '#') {
					map[i][j] = 0;
					que.add(new State(i, j));
				}
			}
		}
		while(!que.isEmpty()) {
			State now = que.poll();
			for(int k = 0; k < 4; k++) {
				if(now.h + dx[k] < 0 || now.h + dx[k] >= H || now.w + dy[k] < 0 || now.w + dy[k] >= W) continue;
				int nh = now.h + dx[k], nw = now.w + dy[k];
				if(map[nh][nw] == Integer.MAX_VALUE) {
					map[nh][nw] = map[now.h][now.w] + 1;
					que.add(new State(nh, nw));
				}
			}
		}
		for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) ans = Math.max(ans, map[i][j]);
		System.out.println(ans);
	}
}


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

int main() {
  int N;
  cin >> N;
  int a, b, x = 0;
  
  rep (cnt, N) {
    cin >> a >> b;
    x += (b - a + 1);
  }
  
  cout << x << endl;  
}

Measured memory_bytes: 3620
import sys
inf = float('inf')
 
def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None
 
def solve():
    N, Ma, Mb = map(int, input().split())
    wa = [None]
    wb = [None]
    costs = [None]
 
    for i in range(N):
        a, b, c = map(int, input().split())
        wa.append(a)
        wb.append(b)
        costs.append(c)
 
    dp = [[[inf]*(10*N + 1) for j in range(10*N + 1)]
                           for k in range(N + 1)]
 
    # debug(dp, locals())
    dp[0][0][0] = 0
 
    for k in range(1, N + 1):
        for a in range(10*N + 1):
            for b in range(10*N + 1):
                dp[k][a][b] = dp[k - 1][a][b]
                if a - wa[k] >= 0 and b - wb[k] >= 0:
                    dp[k][a][b] = min(dp[k][a][b],
                                        dp[k - 1][a - wa[k]][b - wb[k]] + costs[k])
 
    min_c = inf
 
    for a in range(1, 10*N + 1):
        for b in range(1, 10*N + 1):
            if a * Mb == b * Ma:
                min_c = min(min_c, dp[N][a][b])
 
    if min_c == inf:
        ans = -1
    else:
        ans = min_c
 
    print(ans)
 
if __name__ == '__main__':
    solve()

Measured memory_bytes: 144348
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
  string sInput;
  string sOutput ="";
  int length = 0;

  cin >> sInput;
  length = (int)sInput.length();
//  printf("%d\n",length);
  
  for(int i = 0; i < length; i++){
    sOutput.append("x");
  }
  
  cout << sOutput << "\n";
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

"""数字が1種類の場合は半分を書き換える必要が確定"""
if len(set(v)) == 1:
    print(len(v) // 2)
    exit()

"""要素出現数を集計"""
odd_count = Counter(v[1::2])
even_count = Counter(v[::2])

"""一番多く出現する2つの数字を探す"""
max_hit = 0
odd = None
even = None
for odd_val, odd_hit in odd_count.most_common(2):
    for even_val, even_hit in even_count.most_common(2):
        if odd_val == even_val:
            continue  # 奇数と偶数は同じ数字じゃだめ
        if odd_hit + even_hit > max_hit:
            max_hit = odd_hit + even_hit
            odd = odd_val
            even = even_val

"""一致していない要素が書き換え必要回数"""
print(len(v) - max_hit)


Measured memory_bytes: 18652
#include <iostream>
using namespace std;
int main(){
	int n , m , a[1001] , b[1001];
	cin >> n >> m;
	for( int i=0 ; i<m ; i++ ){
			cin >> a[i] >> b[i] ;
	}
	for( int i=0 ; i<m ; i++ ){
		for( int j=0 ; j<m ; j++ ){
			if( a[i] > a[j] )
				swap( a[i] , a[j] );
		}
	}
	int ans=0;
	for( int i=0 ; i<m-1 ; i++ ){
		if( a[i] <= n )
			ans += n - a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define dd double
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ll long long
#define ull unsigned long long
#define ld long double
#define mx 1000005
#define mod 1000000007
#define fr first
#define se second
#define End cout<<"\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define memo(Array,val) memset(Array, val, sizeof Array)
#define PI acos(-1)
bool check(ll n, ll pos){ return (n&(1<<pos)); }
bool Set(ll n, ll pos) {  return (n | (1<<pos)); }
ld LOG(ld b, ld e){ return log(b)/log(e); }

int tc=1;

void solve(int kk)
{
    int n,pre=0;
    cin >> n;
    vector <int> cnt(2e5+5,0);

    for(int i=0,a; i<n-1; i++){
       cin >> a, cnt[a-1]++;
    }
    for(int i=0; i<n; i++) cout << cnt[i] << "\n";
}

int main()
{
   //freopen("text.txt", "r", stdin);
   //freopen("text2.txt", "w", stdout);
   fast;
   int kk=0;
   //cin >> tc;
   //scanf("%d", &tc);
   while(++kk<=tc) solve(kk);

   return 0;
}


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

int main() {
    int n = 0, m = 0;
    scanf("%d %d\n", &n, &m);
    int ans = 0;
    ans = 3 * n + m;
    printf("%d\n", ans / 2);
    return 0;
}


Measured memory_bytes: 128
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>

#define mod 1000000007
#define MAXX  1e18
#define MINN -1e18
 
#define f first
#define s second
#define ll long long
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pi pair<ll, ll>
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define lb(a, key) lower_bound(all(a), key) - a.begin();
#define ub(a, key) upper_bound(all(a), key) - a.begin();
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define add(a, b) (((a)%mod + (b)%mod + mod)%mod)
#define mul(a, b) (((a)%mod * (b)%mod) % mod)
#define endl cout<<"\n";
#define debug(vari) cerr<< "["<< #vari << " " << (vari) << "]";endl;
#define read(a) for(auto &i: a) cin >> i;
#define out(a)  for(auto i: a) cout << i << " ";endl
#define ordered_set tree<ll, null_type, std::less<ll>, rb_tree_tag, tree_order_statistics_node_update>





using namespace __gnu_pbds;
using namespace std;

struct point {
    int x;
    int y;
};

bool cmp(point p, point q) {
    if(p.x == q.x) return p.y < q.y;
    return p.x < q.x;
}

int main() {
    fastio
    int n; cin >> n;
    vector<int> a(n);
    read(a);
    map<int, int> mp;
    for(int i=0; i<n; i++) {
        mp[a[i]] = i;
    }
    int ans = 0; int mx = INT_MAX;
    for(auto i: mp) {
        if(i.second < mx) {
            ans++;
            mx = i.second;
        }
    }

    cout << ans << "\n";
    
}



Measured memory_bytes: 10368
#include <iostream>
#include <vector>

using namespace std;

bool isprime(int n) {
	for (int i = 2; i * i <= n; i++)
		if (n % i == 0)
			return false;
	return n != 1;
}

int main() {
	vector<long long> v;
	int n = 0;
	for (int i = 2; n <= 10000; i++) {
		if (isprime(i)) {
			v.push_back(i);
			n++;
		}
	}
	while (cin >> n && n) {
		long long sum = 0;
		vector<long long>::iterator it = v.begin();
		int i = 0;
		while (i < n) {
			sum += *it;
			it++;
			i++;
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1336
#include <stdio.h>

int main(void)
{
	int i, j, n, S[10000], q, T[10000], a, b;
	int count = 0;
	
	scanf("%d",&n);
	
	for(i = 0; i < n; i++){
		scanf(" %d",&S[i]);
	}
	scanf("%d",&q);
	
	for(j = 0; j < q; j++){
		scanf(" %d",&T[j]);
	}
	
	for(a = 0; a < q; a++){
		b = 0;
			while (T[a] != S[b]){
				b++;
				if(b == n)  break;
			}
		if(b != n)  count++;
	}
	
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 1776
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int N;
    int ans = 0;
    int fac = 1;
    int added = 9;
    cin >> N;
    for(int i = 0; ;i++) {
        if (fac * 10 <= N) {
            if (i % 2 == 0)
                ans += added;
        } else {
            if (i % 2 == 0) {
                ans += N-fac+1;
            }
            break;
        }
        added *= 10;
        fac *= 10;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

template<class T> T umax(T a,T b) {return (a>b?a:b);}
template<class T> T umin(T a,T b) {return (a<b?a:b);}
template<class T,class P> T umax(T a,P b) {return (a>b?a:b);}
template<class T,class P> T umin(T a,P b) {return (a<b?a:b);}

typedef long long int ll;
const int maxn = 1e5+7;
const ll mod = 1e9+7;

bool compare(const pair<ll,ll>& x, const pair<ll,ll>& y) {
    if(x.second == y.second) return x.first < y.first;
    return x.second < y.second;
}

ll power(ll a,ll b) {
    ll res = 1;
    while(b) {
        if(b&1) {
            res = (res*a)%mod;
        }
        a = (a*a)%mod;
        b >>= 1;
    }
    return res;
}

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


bool visit[maxn][3];
int dp[maxn][3];
vector<vector<int> > points(3);
int n;

int solve(int pos,int last) {
    if(pos >= n) {
        return 0;
    }
    if(visit[pos][last]) {
        return dp[pos][last];
    }
    int ans = 0;
    for(int i=0;i<3;i++) {
        if(last != i) {
            ans = max(ans,points[i][pos] + solve(pos+1,i));
        }
    }
    visit[pos][last] = true;
    dp[pos][last] = ans;
    return ans;
}

int main() {
    int x,y,z;
    cin >> n;
    for(int i=0;i<n;i++) {
        cin >> x >> y >> z;
        points[0].push_back(x);
        points[1].push_back(y);
        points[2].push_back(z);
    }
    cout << solve(0,-1) << endl;
    return 0;
}

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

int main() {
    ll N; cin >> N;
    ll ans = 0;
    ll cur_min = N + 1;
    for (int i = 0; i < N; ++i) {
        ll cur_num; cin >> cur_num;
        if (cur_num <= cur_min) {
            ans++;
            cur_min = cur_num;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
while True:
    (m, f, r) = [int(i) for i in input().split()]
    if m == f == r == -1:
        break

    s = m + f

    if m == -1 or f == -1 or s < 30:
        print('F')
    elif s < 50 and r < 50:
        print('D')
    elif s < 65:
        print('C')
    elif s < 80:
        print('B')
    else:
        print('A')

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    printf("%d\n",max(a*b,c*d));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <stack>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

int main(){
	while(1){
		string str;
		bool ok=true;
		getline(cin, str);
		//debug(str);
		if (str.length()==1 && str[0]=='.') break;
		stack<int> po;
		for (int i=0; i<str.length(); i++){
			if (str[i]=='(') po.push(0);
			else if (str[i]=='[') po.push(1);
			else if (str[i]==')'){
				if (po.size()>0 && po.top()==0){
					po.pop();
				}else{
					printf("no\n");
					ok = false;
					break;
				}
			}else if (str[i]==']'){
				if (po.size()>0 && po.top()==1){
					po.pop();
				}else{
					printf("no\n");
					ok = false;
					break;
				}
			}
		}
		
		if (ok && po.size()>0){
			printf("no\n");
			ok = false;
		}
		if (ok) printf("yes\n");
		
	}
	return 0;
}






Measured memory_bytes: 3064
h, w = list(map(int, input().split()))
# b = list(map(int, input().split()))
s = []
s.append("."*(w+2))
for i in range(h):
    s.append("."+input()+".")
s.append("."*(w+2))

for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == "#":
            if s[i-1][j] == "." and s[i][j-1] == "." and s[i][j+1] == "." and s[i+1][j] == ".":
                print("No")
                exit()

print("Yes")


Measured memory_bytes: 3064
object Main extends App {
var k = readLine.split(" ")(3).toInt
var a, b, c = readLine.split(" ").map(_.toLong)
var sum = for (v1 <- a; v2 <- b) yield {
v1 + v2
}
java.util.Arrays.sort(sum)
var len = math.min(sum.length, k)
var temp = new Array[Long](len)
for (i <- 0 to len - 1) {
temp(i) = sum(sum.length - 1 - i)
}
var sum2 = for (v1 <- temp; v2 <- c) yield {
v1 + v2
}
java.util.Arrays.sort(sum2)
val out = new java.io.PrintWriter(System.out)
for (i <- 0 to k - 1) {
out.println(sum2(sum2.length - 1 - i))
}
out.flush
}

Measured memory_bytes: 169308
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int k,s,i,t;
  ll ans=0;
  
  cin >> k >> s;
  
  for (i=0;i<=min(k,s);i++){
    t=s-i;
    ans+=max(0,min(k,t)-max(0,t-k)+1);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
a,b = A[1]-A[0],A[2]-A[0]
c,d = B[1]-B[0],B[2]-B[0]
e,f = C[1]-C[0],C[2]-C[0]
if a==c==e and b==d==f:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <random>
#include <vector>
//#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
 
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()
 
int main()
{
	char c;
	int ans=700;
	rep(i,3){
		cin>>c;
		if(c=='o')ans+=100;
	}
	cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INIT(a, b) memset(a, b, sizeof(a))
using namespace std;
const int maxn = 1000 + 7;

int H, W;
char mp[maxn][maxn];
int ans = 0;
int stk[maxn * maxn][2];
int wat[maxn * maxn][2];
int tail, p;

void bfs()
{
    while (tail)
    {
        p = 0;
        for (int i = 0; i < tail; ++i)
        {
            if (stk[i][0] - 1 >= 1 && mp[stk[i][0] - 1][stk[i][1]] == '.')
            {
                mp[stk[i][0] - 1][stk[i][1]] = '#';
                wat[p][0] = stk[i][0] - 1;
                wat[p][1] = stk[i][1];
                p++;
            }
            if (stk[i][0] - 1 <= H && mp[stk[i][0] + 1][stk[i][1]] == '.')
            {
                mp[stk[i][0] + 1][stk[i][1]] = '#';
                wat[p][0] = stk[i][0] + 1;
                wat[p][1] = stk[i][1];
                p++;
            }
            if (stk[i][1] - 1 >= 1 && mp[stk[i][0]][stk[i][1] - 1] == '.')
            {
                mp[stk[i][0]][stk[i][1] - 1] = '#';
                wat[p][0] = stk[i][0];
                wat[p][1] = stk[i][1] - 1;
                p++;
            }
            if (stk[i][1] - 1 <= W && mp[stk[i][0]][stk[i][1] + 1] == '.')
            {
                mp[stk[i][0]][stk[i][1] + 1] = '#';
                wat[p][0] = stk[i][0];
                wat[p][1] = stk[i][1] + 1;
                p++;
            }
        }
        tail = p;
        if (p)
        {
            ans++;
            for (int i = 0; i < p; ++i)
            {
                stk[i][0] = wat[i][0];
                stk[i][1] = wat[i][1];
            }
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin >> H >> W;
    for (int i = 0; i <= H+1; ++i)
    {
        for (int j = 0; j <= W+1; ++j)
        {
            mp[i][j] = '#';
        }
    }
    tail = 0;
    for (int i = 1; i <= H; ++i)
    {
        for (int j = 1; j <= W; ++j)
        {
            cin >> mp[i][j];
            if (mp[i][j] == '#')
            {
                stk[tail][0] = i;
                stk[tail][1] = j;
                tail++;
            }
        }
    }
    bfs();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14976
W, H, N = map(int, input().split())
cells = [[0 for _ in range(W)] for _ in range(H)]
lists = [list(map(int, input().split())) for _ in range(N)]

for ls in lists:
    x, y, a = ls[0], ls[1], ls[2]
    if a == 1:
        # xi の左側を塗りつぶす
        for h in range(H):
            for w in range(x):
                cells[h][w] = 1
    elif a == 2:
        # xi の右側を塗りつぶす
        for h in range(H):
            for w in range(x, W):
                cells[h][w] = 1
    elif a == 3:
        # yi の下側を塗りつぶす
        for h in range(H-y, H):
            for w in range(W):
                cells[h][w] = 1
    else:
        # yi の上側を塗りつぶす
        for h in range(H-y):
            for w in range(W):
                cells[h][w] = 1

count = 0
for rows in cells:
    count += rows.count(0)

print(count)

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; ++i) cin >> A[i];

    bool flag = true;
    for (int i = 0; i < N; ++i) {
        if (A[i] % 2 == 0) {
            if (A[i] % 3 != 0 && A[i] % 5 != 0) {
                flag = false;
                break;
            }
        }
    }
    if (flag) cout << "APPROVED";
    else cout << "DENIED";

    return 0;
}


Measured memory_bytes: 256
s=list(map(int,input().split()))
a=0
b=0
c=0
d=0
list=[]
a=s[0]%10
list.append(a)
b=s[0]%100-a
b=int(b/10)
list.append(b)
c=s[0]%1000-b-a
c=int(c/100)
list.append(c)
d=s[0]-a-b-c
d=int(d/1000)
list.append(d)
p=0
q=0
for p in range(3):
  if list[p]==list[p+1]:
    q=q+1
if 0<q:
  print('Bad')
else:
  print('Good')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/
template<typename T=lnt>
struct RangeMax
{
	T v;
	static RangeMax I() { return RangeMax(std::numeric_limits<T>::min()); }
	RangeMax(T v) : v(v) {}
	static RangeMax f(const RangeMax& lhs, const RangeMax& rhs) { return std::max(lhs,rhs); }
	operator T() const { return v; }
};

template<typename M>
struct SegmentTree
{
	const int n;
	std::vector<M> data;
	SegmentTree(int n) : n(n),data(n<<1,M::I()) {}
	M& operator[](int i) { return data[i+n]; } // pair with update/build
	void update(int i) { for(i+=n;i>1;i>>=1) data[i>>1]=M::f(data[i],data[i^1]); }
	void build() { for(int i=n-1;i>0;i--) data[i]=M::f(data[i<<1],data[i<<1|1]); }
	M fold(int l, int r) const {
		M L=M::I(),R=M::I();
		for(l+=n,r+=n;l<r;l>>=1,r>>=1) {
			if(l&1) L=M::f(data[l++],L);
			if(r&1) R=M::f(R,data[--r]);
		}
		return M::f(L,R);
	}
};


int main() {
	int h,w,m;
	std::cin >> h >> w >> m;
	using M=RangeMax<int>;
	SegmentTree<M> seg(w);
	rep(i,w) seg[i]=0;
	std::vector<std::vector<int> > v(h);
	rep(i,m) {
		int x,y;
		std::cin >> x >> y;
		x--;y--;
		seg[y]=seg[y]+1;
		v[x].emplace_back(y);
	}
	seg.build();
	int max=0;
	rep(i,h) {
		for(auto e:v[i]) {
			seg[e]=seg[e]-1;
			seg.update(e);
		}
		max=std::max(max,(int)seg.fold(0,w)+(int)v[i].size());
		for(auto e:v[i]) {
			seg[e]=seg[e]+1;
			seg.update(e);
		}
	}
	print(max);
}


Measured memory_bytes: 21920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> ll gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> ll lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  vector<bool> vec(x+200, false);
  vec[0] = true;
  for (int i = 0; i < x; ++i) {
    if (vec[i]) {
      for (int j = 100; j < 106; ++j) {
        vec[j + i] = true;
      }
    }
  }
  cout << vec[x] << '\n';
}


Measured memory_bytes: 256
//============================================================================
// Name        : (^o^).cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int i,n,x;
    cin>>n;
    i=1;
    while(1){while(1){
    x=i;
    if(x%3==0){
    	cout<<" "<<i;
    	break;
    }while(1){
    if(x%10==3){
    	cout<<" "<<i;
    	break;
    }
    x/=10;
    if(x==0){
    	break;
    }}break;}
    if(++i>n){
    	break;
    }}
    cout<<endl;
	return 0;
}



Measured memory_bytes: 3072
#include<iostream>
using namespace std;
int W,H;
char map[101][101];
int dir[4][2]={{-1,0},{0,1},{1,0},{0,-1}};
void DFS(int x,int y,char ch)
{
	map[x][y]='.';
	int newx,newy;
	for(int i=0;i<4;i++)
	{
	  newx=dir[i][0]+x;
	  newy=dir[i][1]+y;
	  if(newx>=0&&newx<H&&newy>=0&&newy<W&&map[newx][newy]==ch)
	    DFS(newx,newy,ch);
	}

}
int main()
{
	int count;
	char ch;
  while(cin>>H>>W&&W!=0&&H!=0)
  {
	  count=0;
    for(int i=0;i<H;i++)
    	for(int j=0;j<W;j++)
	  cin>>map[i][j];
	  
	for(int i=0;i<H;i++)
	  for(int j=0;j<W;j++)
	  {
		  ch=map[i][j];
	     if(ch!='.')
		 {
			 count++;
			 DFS(i,j,ch);
		 }
	  }
	  cout<<count<<endl;
  }

}

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

int main(){
	int a,b,c;

	scanf("%d%d%d", &a, &b, &c);

	if (a == b) printf("%d\n", c);
	else if (b == c) printf("%d\n", a);
	else printf("%d\n", b);

	return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

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

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

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

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
//////////////

void solve() {
	int N, L;
	cin >> N >> L;
	vector<int> A(N);
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		A[i] = L + i;
		sum += A[i];
	}
	
	int sa = INF;
	int ans = -INF;
	for (int i = 0; i < N; ++i) {
		int res = sum - A[i];
		if (sa > abs(sum - res)) {
			ans = res;
			sa = abs(sum - res);
		}
	}
	cout << ans << endl;
}

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

	solve();
}


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

using namespace std;

const int MAXN=555;
int n;
char str[MAXN][22];
int vis[255][255];
int in[255];
queue<int> q;

bool topsort()
{
    while(!q.empty())   q.pop();
    for(int i=0;i<255;i++)  if(in[i]==0)   q.push(i);
    int num=0;
    while(!q.empty())
    {
        int u=q.front();q.pop();num++;
        for(int i=0;i<255;i++)
            if(vis[u][i]==1)
            {
                in[i]--;
                if(in[i]==0)   q.push(i);
            }
    }
    return num==255;
}

bool check()
{
    memset(vis,0,sizeof vis);memset(in,0,sizeof in);
    for(int i=2;i<=n;i++)
    {
        for(int j=0;str[i][j] || str[i-1][j];j++)
        {
            if(str[i][j]==str[i-1][j])  continue;
            if(!str[i][j])    return false;
            int x=(int)(str[i-1][j]);
            int y=(int)(str[i][j]);
            if(vis[y][x])   return false;
            if(!vis[x][y])
            {
                vis[x][y]=1;
                in[y]++;
            }
            break;
        }
    }
    return topsort();
}


int main()
{
    //freopen("data.txt","r",stdin);
    while(cin>>n && n)
    {
        memset(str,0,sizeof str);
        for(int i=1;i<=n;i++)
            scanf("%s",str[i]);
//        for(int i=1;i<=n;i++)
//        {
//            int len=strlen(str[i]);
//            for(int j=0;j<len;j++)
//                if(str[i][j]>= 'a' && str[i][j]<='z')
//                    continue;
//                else
//                    while(1){}
//        }
        if(check())
            puts("yes");
        else
            puts("no");
    }
    return 0;
}

Measured memory_bytes: 1468
#include <iostream>

#include <string>

#include <vector>
using namespace std;

const int N = 110;

char q[N][N];

int main()
{

   int h,w;
   cin>>h>>w;
   string s;
   vector<string>res;
   for(int i=0;i<h;i++){
    cin>>s;
    res.push_back(s);
   }
   s.clear();
   for(int i=0;i<w+2;i++)
   {
       s+='#';
   }
   cout<<s<<endl;
   for(auto &x :res)
   {
       cout<<"#";
       cout<<x;
       cout<<"#"<<endl;
   }
   cout<<s<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int d(ll n) {
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int g_3(int n, int i) {
    if(i == 0) return n % 10;
    if(i == 1) return n / 10 % 10;
    if(i == 2) return n / 100;
}

int main() {
    int n, m;
    cin >> n >> m;
    map<int, int> ma;
    bool bo[5];
    fill(bo, bo + 5, false);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a = n - a;
        if(ma.count(a) && ma[a] != b) {
            cout << -1 << endl;
            return 0;
        }
        ma[a] = b;
        bo[a] = true;
    }
    bool ok = false;
    for(int i = ma[2] * 100 + ma[1] * 10 + ma[0] * 1; i < 1000; i++) {
        if(d(i) == n) {
            ok = true;
            rep(j, n) {
                if(bo[j]) {
                    if(ma[j] != g_3(i, j)) ok = false;
                }
            }
        }
        if(ok) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

bool isPalin(string s){
   string faltu(s.rbegin(), s.rend());
   return faltu == s;
}

int32_t main(){_
      
   string s;
   cin >> s;

   n = (int)(s.size());
   bool good = isPalin(s);

   string tmp = "";
   for (int i = 0; i < (n-1)/2; ++i)
   {
      tmp += s[i];
   }

   good &= isPalin(tmp);

   tmp = "";
   for (int i = (n+3)/2 - 1; i < n; ++i)
   {
      tmp += s[i];
   }

   good &= isPalin(tmp);

   if(good){
      cout<<"Yes\n";
   }
   else{
      cout<<"No\n";
   }

   return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll res;
  if (x / d >= k) {
    res = x - (k * d);
  } else {
    ll y = x / d;
    ll yy = abs(x - y * d); // 近づいたところ
    ll z = abs(yy - d); // すぎたところ
    if ((k - y) % 2 == 0) {
      res = yy;
    } else {
      res = z;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<vector>

std::vector<std::vector<int>> hen;//各頂点がどこに向かう辺を持つか
std::vector<int> parent;//各頂点の親
std::vector<int> num;
std::vector<int> add;

void dfs(int i,int prev,int cur_add){
    cur_add += add[i];
    num[i] = cur_add;
    for(auto j : hen[i]){
        if( j == prev)continue;
        dfs(j,i,cur_add);
    }
}



int main()
{
    int n,q;
    std::cin>>n>>q;
    int a[n-1],b[n-1];
    hen.resize(n);
    for(int i=0;i+1<n;i++){
        std::cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
        hen[a[i]].push_back(b[i]);
        hen[b[i]].push_back(a[i]);
    }
    parent.resize(n);
    num.resize(n);
    add.resize(n);
    for(int i=0;i<q;i++){
        int p,x;
        std::cin>>p>>x;
        p--;
        add[p] += x;
    }
    dfs(0,-1,0);
    for(int i=0;i<n;i++)std::cout<<num[i]<<" ";
    return 0;
}

Measured memory_bytes: 26624
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  a = a%10;
  if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9) cout << "hon";
  else if(a == 0 || a == 1 || a == 6 || a == 8) cout << "pon";
  else if(a == 3) cout << "bon";
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <string>
 
using Edge = std::map< std::string, int>;
using Tree = std::map<int, std::vector<Edge> >;
 
int main(int argc, char *argv[]){
    int N, Q;
    std::cin >> N >> Q;
 
    int a,b;
    Tree tree;
    Edge edge;
    for(int i=0; i<N-1; ++i){
        std::cin >> a >> b;
        edge.clear();
        edge["child"] = b;
        tree[a].emplace_back(edge);
        edge["child"] = a;
        tree[b].emplace_back(edge);
    }
 
    std::vector<int> X(N,0);
    int p,x;
    for(int i=0; i<Q; ++i){
        std::cin >> p >> x;
        X[p-1] += x;
    }
 
 
    std::vector<bool> isVisited(N,false);
    std::vector<int> sum(N);
    std::stack<int> stack;
    int parent = 1;
    sum[parent-1] = X[parent-1];
    isVisited[parent-1]=true;
    stack.push(parent);
    int child;
    while(!stack.empty()){
        parent = stack.top();
        stack.pop();
        for(auto &edge : tree[parent]){
            child = edge["child"];
            if(!isVisited[child-1]){
                sum[child-1] = sum[parent-1]+X[child-1];
                isVisited[child-1] = true;
                stack.push(child);
            }
        }
    }
 
    for(int i=0; i<N; ++i){
        std::cout << sum[i] << " ";
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 80000
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C;
    cin >> A >> B >> C;
    string tar = to_string(100 * A + 10 * B + C);
    if (tar == "557" || tar == "575" || tar == "755") cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

void print(vector<int> &v1) {
  for(int j = 0; j < (int)v1.size(); ++j) {
	cout << v1[j];
	cout << (j < (int)v1.size() - 1 ? " " : "\n");
  }
}

int loop_cnt;
void op(vector<int> &v1) {
  vector<int> v2 = v1;
  for(int i = 0; i < (int)v1.size(); ++i) {
	int cnt = 0;
	for(int j = 0; j < (int)v1.size(); ++j) {
	  if(v1[j] == v1[i]) {
		cnt++;
		v2[j] = -1;
	  }
	}
	for(int j = 0; j < (int)v2.size(); ++j) {
	  if(v2[j] == -1) {
		v2[j] = cnt;
	  }
	}
  }
  if(v2 != v1) {
	loop_cnt++;
	op(v2);
  }
  else {
	cout << loop_cnt << endl;
	print(v1);
  }
}

int main() {
  int n;
  while(cin >> n && n) {
	loop_cnt = 0;
	vector<int> v(n);
	for(int i = 0; i < n; ++i) {
	  cin >> v[i];
	}
	op(v);
  }
  return 0;
}

Measured memory_bytes: 3136
#include <stdio.h>
#define MAX 100
#define INF 1<<21
#define WHITE 0
#define GRAY 1
#define BLACK 2

int prim();

int n,BY[MAX][MAX];

int main(){
    int i,j,t;

    scanf("%d",&n);

    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            scanf("%d",&t);
    BY[i][j]=(t==-1)?INF:t;
    }
    }
    printf("%d\n",prim());

    return 0;
}

int prim(){
    int minicost,i,u,v,sum=0;
    int wei_min[MAX],parent[MAX],color[MAX];

    for(i=0;i<n;i++){
        parent[i]=-1;
        color[i]=WHITE;
        wei_min[i]=INF;
}
wei_min[0]=0;

while(1){
    minicost=INF;
    u=-1;
    for(i=0;i<n;i++){
        if(color[i]!=BLACK && wei_min[i]<minicost){
            minicost=wei_min[i];
            u=i;
        }
    }
    if(u==-1) break;

    color[u]=BLACK;

    for(v=0;v<n;v++){
        if(color[v]!=BLACK && BY[u][v]!=INF){
            if(BY[u][v]<wei_min[v]){
                wei_min[v]=BY[u][v];
                parent[v]=u;
                color[v]=GRAY;
            }
        }
    }
}
for(i=0;i<n;i++){
    if(parent!=INF) sum+=BY[i][parent[i]];
}
return sum;
}






Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <functional>
#include <string>
#include <math.h>

using namespace::std;

int main()
{
    int n;
    string a,b,c;

    cin >> n >> a >> b >> c;
    int cnt(0);
    for(int i(0); i < n; ++i)
    {
        if(a.at(i) == b.at(i) && a.at(i) == c.at(i))
            cnt += 0;
        else if(a.at(i) == b.at(i) || a.at(i) == c.at(i) || b.at(i) == c.at(i))
            cnt += 1;
        else
        {
                cnt += 2;
        }
        
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, -1, 0, 1 , 1,  1, -1, -1 };

VI _array( 5 ), _copy( 5 );
bool is_open[ 3 ];

int main() {
	while ( ~scanf( "%d", &_array[ 0 ] ) && _array[ 0 ] ) {
		memset( is_open, 0, sizeof( is_open ) );
		is_open[ _array[ 0 ] - 1 ] = true;
		for ( int i = 1; i < 5; i++ ) {
			scanf( "%d", &_array[ i ] );
			is_open[ _array[ i ] - 1 ] = true;
		}
		if ( ( is_open[ 0 ] && !is_open[ 1 ] && !is_open[ 2 ] ) || ( !is_open[ 0 ] && is_open[ 1 ] && !is_open[ 2 ] ) || ( !is_open[ 0 ] && !is_open[ 1 ] && is_open[ 2 ] ) || ( is_open[ 0 ] && is_open[ 1 ] && is_open[ 2 ] ) ) {
			for ( int i = 0; i < 5; i++ ) {
				printf( "3\n" );
			}
			continue;
		}
		for ( int i = 0; i < 5; i++ ) {
			if ( is_open[ ( _array[ i ] + 1 ) % 3 ] ) {
				printf( "2\n" );
			}
			else {
				printf( "1\n" );
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1168
N, T = map(int,input().split())
ct = [[int(i) for i in input().split()]for i in range(N)]
res = 100000
for c, t in ct:
  if t > T:
    continue
  else:
    res = min(res, c)
if res == 100000:
  res = 'TLE'
print(res)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 123456789012


int main(){
    ll i,j;
    ll n,m;
    cin>>n>>m;
    priority_queue<ll> qu;
    for(i=0;i<n;i++){
        ll a;
        cin>>a;
        qu.push(a);
    }

    for(i=0;i<m;i++){
        ll a=qu.top();
        qu.pop();
        qu.push(a/2);
    }

    ll ans=0;
    while(!qu.empty()){
        ans+=qu.top();
        qu.pop();
    }
    cout<<ans<<endl;

    
    return 0;
}

Measured memory_bytes: 1400
def ints():
  return [int(x) for x in input().split()]
def ii():
  return int(input())

n, k = ints()
R, S, P = ints()
cpu = input()
jibun = [0] * n

w = ['r', 's', 'p']

for i in range(n):
  c = cpu[i]
  if c=='r':
    t = ['p']
  elif c=='s':
    t = ['r']
  else:
    t = ['s']

  j = i-k
  if j>=0:
    o = jibun[j]
    te = t[0]
    if te in o:
      if len(o)==1:
        ww = w.copy()
        ww.remove(te)
        t = ww
      else:
        o.remove(te)

  jibun[i] = t

s = 0
for i in range(n):
  w = jibun[i][0]+cpu[i]
  if w=='rs':
    s += R
  elif w=='sp':
    s += S
  elif w=='pr':
    s += P
print(s)



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

int main() {
  ll a,b;
  cin >> a >> b;
  ll gcd;
  gcd = __gcd(a,b);
  ll count = 0;
  ll ans = 1;
  
  for(ll i=2; i < gcd+1; i++){
    if(i*i > gcd && i < gcd){
      ans++;
      break;
    }
    if(gcd%i == 0){
      ans++;
    }
    while(gcd%i == 0){
      gcd /= i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

set<ll> ss;

int main(){
  ll N, K;

  cin >> N >> K;

  vector<pair<ll,pair<ll,ll> > > ans;


  for (int i=N; i<N*2; i++)
    ss.insert(i);

  ll j = 0;
  for (ll i=2*N; i<3*N; i++, j++) {
    ll t = i - K;

    ll s = j < (N+1)/2 ? j * 2 : (j - (N+1)/2) * 2 + 1;

    auto it = ss.upper_bound(t - s);

    if (it == ss.begin()) break;
    it--;

    ll u = *it;

    ans.push_back({u, {s, i}});
    debug(ans[ans.size()-1]);

    ss.erase(u);
  }

  if (ans.size() == N) {
    for (auto p : ans) {
      cout << p.first+K << " " << p.second.first+K << " " << p.second.second+K << '\n';
    }
  } else {
    cout << -1 << endl;
  }


  return 0;
}


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

int main() {
  long n, a, b;

  cin >> n >> a >> b;

  if (a % 2 == b % 2) {
    cout << (b - a) / 2;
  } else {
    cout << min(a - 1, n - b) + 1 + ((b - a) / 2);
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
 
int main() {
	string s;
  	cin>>s;
  	int a=s.size();
  	
  
  	string r=s;
    reverse(r.begin(),r.end());

  	

  	string m=s.substr(0,a/2);
  	string o=m;
  	reverse(o.begin(),o.end());

   
	if(s==r&&m==o){
    	cout<<"Yes"<<endl;
    }

  	else{
    	cout<<"No"<<endl;
    }
  
}

Measured memory_bytes: 256
gx, gy = 0, 0
th = 90
while gets do
  st, rot = $_.split(',').map(&:to_i)
  break if st == 0 && rot == 0
  gx = gx + st*Math.cos(th/180.0*Math::PI)
  gy = gy + st*Math.sin(th/180.0*Math::PI)
  th -= rot
end
puts [gx.to_i, gy.to_i]

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

using namespace std;

int main(){
		string a;
		while(getline(cin,a) && a!="."){
				int n=a.length();
				int i;
				stack<int> st;
				for(i=0;i<n;i++){
						if(a[i]=='['){
								st.push(1);
						}else if(a[i]==']'){
								if(st.empty()==1){
										cout<<"no"<<endl;
										break;
								}
								if(st.top()==1){
										st.pop();
								}else{
										cout<<"no"<<endl;
										break;
								}
						}else if(a[i]=='('){
								st.push(2);
						}else if(a[i]==')'){
								if(st.empty()==1){
										cout<<"no"<<endl;
										break;
								}
								if(st.top()==2){
										st.pop();
								}else{
										cout<<"no"<<endl;
										break;
								}
						}
				}
				
				if(i==n && st.empty())cout<<"yes"<<endl;
				else if(i==n && !st.empty())cout<<"no"<<endl;
		}
		return 0;
}

Measured memory_bytes: 3144
n,m = map(int, input().split())
pre = {}
city = []
for i in range(m):
    p,y = map(int, input().split())
    if p not in pre:
        pre[p] = []
    pre[p].append(y)
    city.append((p,y))

d = {}
for k in pre.keys():
    pre[k].sort()
    for i in range(len(pre[k])):
        d[(k, pre[k][i])] = i+1

for p,y in city:
    print(str(p).zfill(6) + str(d[(p, y)]).zfill(6))
    

Measured memory_bytes: 53700
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll l;
	cin>>l;
	double val = l/(3.0);
	val = val*val*val;
	printf("%.8f", val);
}

Measured memory_bytes: 256
n, d = map(int, input().split())

List = []

for _ in range(n):
  r = list(map(int,input().split()))
  List.append(r)
  
Answers = []

for i in range(n):
  for j in range(n-i-1):
    Lsquare = 0
    for k in range(d):
      Lsquare += (List[i][k]-List[i+j+1][k])**2
    Answers.append(Lsquare**0.5)

Answer = []
for s in Answers:
  if s.is_integer()==True:
    Answer.append(s)

print(len(Answer))


Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n;
int c[128][128];

int main()
{
  cin >> n;
  rep(i, n) rep(j, n) cin >> c[i][j];
  ll res = 0;
  for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) res += min(c[i][j], c[j][i]);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1212
n = int(input())
n -= 1
if (n == 0):
	print('a')
else:
	ans = []
	ln = 1
	s = 0
	v = []
	while (s <= n):
		v.append(s)
		s += 26 ** ln
		ln += 1
	v.append(s)
	ln -= 1
	n -= (s - 26 ** (ln + 1))
	# print(ln, "len")
	while (ln > 0):
		ans.append(n % 26)
		n //= 26
		# # n -= v[ln - 1]
		# n -= ((26 ** (ln - 1)) * max(1, (n % 26 + 1)))
		# # n += v[ln]
		ln -= 1
	ans = ans[::-1]
	# print(ans)
	# ans[0] -= 1;
	for x in ans:
		print(chr(x + ord('a')), end = "")

Measured memory_bytes: 9212