akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> w;
    for(int i=0;i<n;i++){
        int m;
        cin >> m;
        w.push_back(m);
    }

    int sum=0;
    for(int i=0;i<n;i++) sum+=w.at(i);

    int ans=sum;
    int tmp=0;
    for(int i=0;i<n;i++){
        tmp+=w.at(i);
        ans=min(ans,abs((sum-tmp)-tmp));
        //cout << ans << endl;
    }

    cout << ans << endl;
}

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

int main(){
    int A,B,C,X,ans;
    cin >> A >> B >> C >> X;
    
    for(int a = 0; a <= A; a++){
        for (int b = 0; b <= B; b++){
            for (int c = 0; c<= C; c++){
                if (a * 500 + b * 100 + c * 50 == X){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
    int count[26]={0};
    char ch;
    int i, num;

	while(scanf("%c", &ch)!=EOF){
		if ( ch >= 'A' && ch <= 'Z' ){
			num = ch - 'A';
		} else if (ch >= 'a' && ch <= 'z') {
			num = ch - 'a';
		}else{
            continue;
        }
		count[num]++;
	}
	
	for(i=0;i<26;i++){
        printf("%c : %d\n", 'a'+i, count[i]);
    }

    return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
const ll INFll = 1LL << 60;
typedef pair<long, long> PL;

/* dijkstra(G,s,dis)
    入力：グラフ G, 開始点 s, 距離を格納する dis
    計算量：O(|E|log|V|)
    副作用：dis が書き換えられる,負のコストの際利用できない
*/
void dijkstra(const vector<vector<Edge>> &G, int s, vector<ll> &dis) {
  int N = G.size();
  dis.resize(N, INFll);
  priority_queue<PL, vector<PL>, greater<PL>>
      pq;  //「仮の最短距離、頂点」が小さい順にならぶ
  dis[s] = 0;
  pq.emplace(dis[s], s);
  while (!pq.empty()) {
    PL p = pq.top();
    pq.pop();
    int v = p.second;
    if (dis[v] < p.first) continue;  //最短経路でなければ無視
    for (auto &e : G[v]) {
      if (dis[e.to] > dis[v] + e.cost) {  //最短距離候補ならpriority_queueに追加
        dis[e.to] = dis[v] + e.cost;
        pq.emplace(dis[e.to], e.to);
      }
    }
  }
}
/* dijkstra(G,s,dis,prev)
    入力：グラフ G, 開始点 s, 距離を格納する dis, 最短経路の前の点を記録するprev
    計算量：O(|E|log|V|)
    副作用：dis, prevが書き換えられる
*/
void dijkstraRestore(const vector<vector<Edge>> &G, int s, vector<ll> &dis,
                     vector<int> &prev) {
  int N = G.size();
  dis.resize(N, INFll);
  prev.resize(N, -1);  // 初期化
  priority_queue<PL, vector<PL>, greater<PL>>
      pq;  //「仮の最短距離、頂点」が小さい順にならぶ
  dis[s] = 0;
  pq.emplace(dis[s], s);
  while (!pq.empty()) {
    PL p = pq.top();
    pq.pop();
    int v = p.second;
    if (dis[v] < p.first) continue;  //最短経路でなければ無視
    for (auto &e : G[v]) {
      if (dis[e.to] > dis[v] + e.cost) {  //最短距離候補ならpriority_queueに追加
        dis[e.to] = dis[v] + e.cost;
        prev[e.to] = v;  // 頂点 v を通って e.to にたどり着いた
        pq.emplace(dis[e.to], e.to);
      }
    }
  }
}

/* get_path(prev, t)
    dijkstraRestore で得た prev, ゴール t
    出力： t への最短路のパス
*/
vector<int> get_path(const vector<int> &prev, int t) {
  vector<int> path;
  for (int cur = t; cur != -1; cur = prev[cur]) {
    path.push_back(cur);
  }
  reverse(path.begin(), path.end());//逆順なのでひっくり返す
  return path;
}
//参考:https://algo-logic.info/dijkstra/
int main() {
  ll N, M;
  cin >> N >> M;
  vector<vector<Edge>> Graph(N, vector<Edge>(0));
  REP(i,M){
    int a, b;
    cin >> a >> b,a--,b--;
    Graph[a].push_back(Edge{b, 10});
    Graph[b].push_back(Edge{a, 10});
  }
  vector<ll> distance(0);
  dijkstra(Graph,0,distance);
  if(distance[N-1]!=0&&distance[N-1]==20){
    cout << "POSSIBLE" << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
}

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

int N, M, Q;
int i, j;
string ss[2000];
int blue_accum[2001][2001];
int line_accum_row[2001][2001];
int line_accum_col[2001][2001];

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

    for(i = 1; i <= N; i++){
        for(j = 1; j <= M; j++){
            if(ss[i-1][j-1] == '1'){
                blue_accum[i][j] = 1;
                if(j >= 2 && ss[i-1][j-2] == '1'){
                    line_accum_row[i][j] = 1;
                }
                if(i >= 2 && ss[i-2][j-1] == '1'){
                    line_accum_col[i][j] = 1;
                }
            }
        }
    }

    for(i = 1; i <= N; i++){
        for(j = 1; j <= M; j++){
            blue_accum[i][j] += blue_accum[i][j-1];
            line_accum_row[i][j] += line_accum_row[i][j-1];
            line_accum_col[i][j] += line_accum_col[i][j-1];
        }
    }
    for(i = 1; i <= N; i++){
        for(j = 1; j <= M; j++){
            blue_accum[i][j] += blue_accum[i-1][j];
            line_accum_row[i][j] += line_accum_row[i-1][j];
            line_accum_col[i][j] += line_accum_col[i-1][j];
        }
    }

    int x1, y1, x2, y2;
    int blue, line_row, line_col;
    for(i = 0; i < Q; i++){
        cin >> x1 >> y1 >> x2 >> y2;
        blue = blue_accum[x2][y2] - blue_accum[x1-1][y2] - blue_accum[x2][y1-1] + blue_accum[x1-1][y1-1];
        line_row = line_accum_row[x2][y2] - line_accum_row[x1-1][y2] - line_accum_row[x2][y1] + line_accum_row[x1-1][y1];
        line_col = line_accum_col[x2][y2] - line_accum_col[x1][y2] - line_accum_col[x2][y1-1] + line_accum_col[x1][y1-1];
        cout << blue - line_row - line_col << endl;
    }
    return 0;
}

Measured memory_bytes: 52864
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        int ans = 0;
        x = x - z;
        ans = x/(y+z);
        System.out.println(ans);
	}
}

Measured memory_bytes: 24020
#include <stdio.h>
#include <string.h>

int main(void){
	char str[200];
	int cnt = 0;

	while(scanf("%s", str) != EOF){
		int i, j;
		for(i=0, j=strlen(str)-1; i<=j; i++, j--){
			if(str[i] != str[j]) break;
		}
		if(i > j) cnt++;
	}

	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main(){
  int n,h,w; cin >> n >> h >> w;
  int ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(h+i-1 >= n) break;
      if(w+j-1 >= n) break;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3580
N,*a = map(int,open(0).read().split())
ans = []
for i in range(N)[::-1]:
    part_rem = sum(a[i::i+1]) % 2
    if a[i] != part_rem:
        a[i] = abs(a[i] - 1) 

print(sum(a))
print(*[i+1 for i,v in enumerate(a) if v == 1])

Measured memory_bytes: 11644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	String s=sc.next();
	char c[]=s.toCharArray();

	if(c[0]!=c[1]&&c[1]!=c[2]&&c[0]!=c[2]){
		System.out.println("Yes");
	}else{
		System.out.println("No");
	}
	}}

Measured memory_bytes: 23252
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

sx, sy, tx, ty = list(map(int, sys.stdin.readline().split()))

x1 = tx - sx
y1 = ty - sy
ans = ''
ans += 'U' * y1
ans += 'R' * x1
ans += 'D' * y1
ans += 'L' * x1
ans += 'L'
ans += 'U' * (y1 + 1)
ans += 'R' * (x1 + 1)
ans += 'D'
ans += 'R'
ans += 'D' * (y1 + 1)
ans += 'L' * (x1 + 1)
ans += 'U'
print(ans)


Measured memory_bytes: 13672
K = int(input())
ans = 0

def gcd(x, y):
    if x < y: x, y = y, x
    while y:
        n = x%y
        x = y
        y = n
    return x
    
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            ret = gcd(i, j)
            ans += gcd(ret, k)

print(ans)

Measured memory_bytes: 68892
N,K = map(int,input().split())
V = list(map(int,input().split()))

ans = -1

for l in range(N+1):
    for r in range(N+1):
        tmp = V[:l] + V[N-r:]
        if l+r > N:
            break
        res = K - (l+r)
        if res < 0:
            break
        tmp.sort()
        for i in range(min(res,len(tmp))):
            if tmp[0] < 0:
                tmp.pop(0)
            else:
                break
        ans = max(ans,sum(tmp))
            
print(ans)

Measured memory_bytes: 9212
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>

using namespace std;

typedef long long ll;

int a, b, c, d;
int main() {
  scanf("%d %d %d %d", &a, &b, &c, &d);
  int res1 = abs(a - c);
  if (abs(a - c) > d && (abs(a - b) > d || abs(c - b) > d)) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;


int dp[10005];
int main(){
    ll n,d,a; cin >> n >> d >> a;
    vector<pair<ll,ll>> v(n); 
    rep(i,n) cin >> v[i].first >> v[i].second;
    queue<pair<ll,ll>> st;
    sort(all(v));
    ll sub = 0;
    ll ans = 0;
    for(int i=0;i<n;i++){
        ll x = v[i].first, h = v[i].second;
        while(!st.empty() && st.front().second < x) {sub -= st.front().first; st.pop();}
        
        if(sub < h){
            ll dif = h - sub;
            ll t;
            if(dif % a == 0) t = dif/a; 
            else t = (dif/a) + 1;
            st.push(mp(t * a, x+2*d));
            sub = sub + t*a;
            ans = ans + t;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int primenm(int x){
  int i;
  if(x==2){
    return 1;
  }else if(x%2==0){
    return 0;
  }else{
    for(i=3; i<=sqrt(x); i+=2){
      if(x%i==0){
	return 0;
      }
    }
    return 1;
  }
}

int main(){
  int n, a, i, cnt=0;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%d", &a);

    if(primenm(a)){
      cnt++;
    }
  }

  printf("%d\n", cnt);
  
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  int count = 0;
  REP(i, N) {
    int p;
    cin >> p;
    if (p != i + 1) count++;
  }
  cout << (count <= 2 ? "YES" : "NO") << '\n';
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int a[51][51],w,h,c;
bool f;

void visit(int i,int j,int bw){
  a[i][j] = 3;
  c++;
  int di[4] = {1,0,-1,0};
  int dj[4] = {0,1,0,-1};
  for(int t=0;t<4;t++){
    int vi = i + di[t];
    int vj = j + dj[t];
    if(bw == 1){
      if(a[vi][vj] == 2){
	f = false;
      }
      else if(vi >= 0 && vj >= 0 && vi < w && vj < h && !a[vi][vj]){
	visit(vi,vj,1);
      }
    }
    else if(bw == 2){
      if(a[vi][vj] == 1){
	f = false;
      }
      else if(vi >= 0 && vj >= 0 && vi < w && vj < h && !a[vi][vj]){
	visit(vi,vj,2);
      }
    }
  }
}

int main(){
  int i,j,b,wh;
  char str;
  while(1){
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    for(i=0;i<=h;i++){
      for(j=0;j<=w;j++){
	if(i == h || j == w) a[j][i] = 3;
	else{
	  cin >> str;
	  if(str == 'B') a[j][i] = 1;
	  else if(str == 'W') a[j][i] = 2;
	  else a[j][i] = 0;
	}
      }
    }

    b = wh = 0;
    int di[4] = {1,0,-1,0};
    int dj[4] = {0,1,0,-1};
    for(j=0;j<h;j++){
      for(i=0;i<w;i++){
	if(a[i][j] == 1 || a[i][j] == 2){
	  for(int t=0;t<4;t++){
	    int vi = i + di[t];
	    int vj = j + dj[t];
	    if(a[i][j] == 1 && vi >= 0 && vj >= 0 && vi < w && vj < h && !a[vi][vj]){
	      c = 0;
	      f = true;
	      visit(vi,vj,1);
	      if(f) b += c;
	    }
	    else if(a[i][j] == 2 && vi >= 0 && vj >= 0 && vi < w && vj < h && !a[vi][vj]){
	      c = 0;
	      f = true;
	      visit(vi,vj,2);
	      if(f) wh += c;
	    }
	  }
	}
      }
    }
    cout << b <<" " << wh << endl;   
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>

const double pi = atan(1.) * 4;

struct Point;
using Vector = Point;
using Polygon = std::vector<Point>;

struct Point {
    int x,y,id;

    Point() {}

    Point(int _x,int _y, int id = -1) : x(_x),y(_y),id(id) {}

    Point operator + (const Point &rhs) const {
        return Point(x + rhs.x,y + rhs.y);
    }

    Point operator - (const Point &rhs) const {
        return Point(x - rhs.x,y - rhs.y);
    }

    bool operator == (const Point &rhs) const {
        return x == rhs.x && y == rhs.y;
    }

    bool operator < (const Point &rhs) const {
        if (x != rhs.x) return x < rhs.x;
        return y < rhs.y;
    }
};

using LL = long long;

LL det(const Point &a,const Point &b) {
    return a.x * 1LL * b.y - a.y * 1LL * b.x;
}

LL det(const Point &a, const Point &b, const Point &c) {
    return det(b - a, c - a);
}

LL dot(const Point &a,const Point &b) {
    return a.x * 1LL * b.x + a.y * 1LL * b.y;
}

const int kN = 100 + 5;
int n;
Point pts[kN];
double result[kN];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i) {
        scanf("%d%d", &pts[i].x, &pts[i].y);
        pts[i].id = i;
    }
    std::sort(pts, pts + n);
    std::vector<Point> stack;
    for (int i = 0; i < n; ++ i) {
        while (stack.size() > 1 && det(stack[stack.size() - 2], stack.back(), pts[i]) >= 0) stack.pop_back();
        stack.push_back(pts[i]);
    }
    int m = stack.size();
    for (int i = n - 2; i >= 0; -- i) {
        while (stack.size() > m && stack.size() > 1 && det(stack[stack.size() - 2], stack.back(), pts[i]) >= 0) stack.pop_back();
        stack.push_back(pts[i]);
    }
    stack.pop_back();

    if (stack.size() == 2) {
        result[stack.back().id] = .5;
        result[stack[0].id] = .5;
    }
    else {
        for (int i = 0; i < stack.size(); ++ i) {
            const Point &cur = stack[i];
            Point left = stack[(i + stack.size() - 1) % stack.size()] - cur;
            Point right = cur - stack[(i + 1) % stack.size()];
            result[cur.id] = .5 * acos(1. * dot(left, right) / sqrt(dot(left, left)) / sqrt(dot(right, right))) / pi;
            // result[cur.id] = (pi - acos(1. * dot(left, right) / sqrt(dot(left, left)) / sqrt(dot(right, right)))) / (2 * pi);
        }
    }
    for (int i = 0; i < n; ++ i)
        printf("%.10f\n", result[i]);
}


Measured memory_bytes: 256
def main():
    N = int(input())
    S = list(input())
    ans = []
    a = ord("A")
    z = ord("Z")
    for s in S:
        if ord(s) + N <= z:
            ans.append(chr(ord(s) + N))
        else:
            ans.append(chr(ord(s) + N - z + a - 1))
    print("".join(ans))
    return


main()


Measured memory_bytes: 3188
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    if (a < k) {
        k -= a;
        a = 0;
        if (b <= k) {
            b = 0;
        }
        else {
            b -= k;
        }
    }
    else {
        a -= k;
    }
    
    cout << a << " " << b << endl;

    return 0;
}

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

void course0();

int main()
{
	int c = 0;
	if (c == 0) course0();
	getchar();
	getchar();
    return 0;
}

void course0()
{
	int N, M, X;
	int cost = 100000000;
	cin >> N >> M >> X;
	bool master = true;
	int price[15];
	int A[15][15];
	for (int i = 0; i < N; i++) {
		cin >> price[i];
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}
	for (int x = 0; x < (1 << N); x++) {
		int y = x;
		int sum[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
		int newcost = 0;
        int c = 0;
		while (y > 0) {			
			if (y % 2 == 1) {
				for (int i = 0; i < M; i++) {
					sum[M-1-i] = sum[M-1-i] + A[c][M-1-i];
					
				}
                newcost += price[c];
               
			}
			 y = y >> 1;
			 c++;
		}
        //for (int i = 0; i < N; i++) cout << sum[i] << " ";
        //cout << x << " " << newcost << endl;
        master = true;
		for (int i = 0; i < M; i++) {
			if (sum[i] < X) {
                //cout << "not master" << endl;
				master = false;
                break;
			}
            
		}
        
		if (master == true && cost > newcost) cost = newcost;

	}
	if (master == true) cout << cost << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			String s = sc.next();
			
			if(s.equals("AAA") || s.equals("BBB")) {
				System.out.println("No");
			}else {
				System.out.println("Yes");
			}
			
			
		}

	}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    long cnt=0, prev = 0, best = 0;
    for (int i=0; i<n; i++) {
        long h; cin >> h;
        if (h > prev) cnt = 0;
        cnt++;
        prev = h;
        best = max(best, cnt);
    }
    cout << best - 1 << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
	int n;
    int count = 0;
	cin >> n;
	
    int tmp;
    
    for(int i=0; i < n;i++){
        cin >> tmp;
        while(!(tmp%2)){
            count++;
            tmp=tmp/2;
        }
    }
    cout << count << endl;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N;
    cin >> N;
    VI a(N);
    REP(i, N) cin >> a[i];
    int ans = 0;
    REP(i, N) {
        const int key = a[i];
        int j = i;
        while (j < N && a[j] == key) {
            j++;
        }
        if (a[j] != key) {
            j--;
        }
        int foo = j - i + 1;
        ans += foo / 2;
        i = j;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<limits.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int IINF=INT32_MAX;
static const ll LINF=INT64_MAX;
static const ll mod=1e9+7;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};

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

int a,b;

int main(){
    cin>>a>>b;
    cout<<a*b<<endl;
}

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

const int N = 103;
int n;
int a[N];

void solve(){
    cin >> n;
    for(int i=0;i<n;++i) 
        cin >> a[i];
    sort(a,a+n);
    long long ans=0;
    for(int i=0;i<n;++i) {
        for(int j=i+1;j<n;++j) {
            if(a[j] == a[i])
                continue;
            for(int k=j+1;k<n;++k) {
                if(a[j] == a[k] || a[k] == a[i])
                    continue;
                ans += (a[i] + a[j] > a[k]);
            }
        }
    }
    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    while(t--)
        solve();
    return  0;
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q.r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    vll a(n);
    rep(i, n) cin >> a[i];
    for(ll i = 0;i < n;i++)
    {
        ll minj = i;
        for(ll j = i;j < n;j++)
        {
            if(a[j] < a[minj])
            {
                minj = j;
                
            }
        }
        if(i != minj)
        {
            swap(a[i], a[minj]);
            ans++;
        }
    }
    for (ll i = 0; i < a.size() - 1; i++)
        cout << a[i] << " ";
    cout << a[a.size() - 1] << endl;
    fin(ans) return;
}

//前処理
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20); //高精度少数表示
    Main();
    return 0;
}



Measured memory_bytes: 3172
n=int(input())
c1=0
c2=0
c3=0
c4=0
s1='AC'
s2='WA'
s3='TLE'
s4='RE'
for _ in range(n):
	str1=str(input())
	if(str1=='AC'):
		c1=c1+1
	elif(str1=='WA'):
		c2=c2+1
	elif(str1=='TLE'):
		c3=c3+1
	elif(str1=='RE'):
		c4=c4+1
s1=s1+' ' + 'x' + ' ' + str(c1)
s2=s2+' ' + 'x' + ' ' + str(c2)
s3=s3+' ' + 'x' + ' ' + str(c3)
s4=s4+' ' + 'x' + ' ' + str(c4)

print(s1)
print(s2)
print(s3)
print(s4)


Measured memory_bytes: 9180
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Deque<Character> dq = new ArrayDeque<>();
        char[] s = sc.next().toCharArray();
        int cnt = 0;
        for(char c : s){
            dq.addLast(c);
            cnt++;
        }
        int n = sc.nextInt();
        boolean ret = false;
        for(int i = 0; i < n; i++){
            int q = sc.nextInt();
            if(q == 1){
                if(ret){
                    ret = false;
                }else{
                    ret = true;
                }
            }else{
                int q2 = sc.nextInt();
                if(q2 == 1 && !ret || q2 == 2 && ret){
                    dq.addFirst(sc.next().charAt(0));
                }else{
                    dq.addLast(sc.next().charAt(0));
                }
                cnt++;
            }
        }
        if(ret){
            for(int i = 0; i < cnt; i++){
                System.out.print(dq.removeLast());
            }
        }else{
            for(int i = 0; i < cnt; i++){
                System.out.print(dq.removeFirst());
            }
        }
        
    }
}


Measured memory_bytes: 158488
process.stdin.resume();
process.stdin.setEncoding('utf8');


process.stdin.on('data', function (chunk) {
    let n = chunk.toString() // 文字列化する
        .split("\n") // \nで分割
        .map(x => Number(x));
        // .filter(x => x !== );
    for (let i = 0; i < n.length; i++) {
        if (n[i] <= 40) {
            n[i] = 40;
        }
    }

    const ans = (n[0] + n[1] + n[2] + n[3] + n[4]) / 5;
    console.log(ans);



})


Measured memory_bytes: 15304
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  int b=0,c=0;
  for(int i=n-1;i>0;i--){
    if(b==0){
      if(a[i]==a[i-1]){
        b=a[i];
        i--;
      }
    }
    else if(a[i]==a[i-1])c=a[i];
    if(c!=0&&b!=0)break;
  }
  cout<<(long long)b*c<<endl;
}


Measured memory_bytes: 640
import sys; from collections import deque ; readline = sys.stdin.readline

N = int(readline())
A = list(map(lambda x:int(x)-1, readline().split()))
B = list(map(int, readline().split()))
C = list(map(int, readline().split()))

a = 0
for i in range(N - 1):
    if A[i + 1] == A[i] + 1:
        a += C[A[i]]

a += sum(B)

print(a)

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

using namespace std;
const int dx[] = { -1,0,1,0 };
const int dy[] = { 0,-1,0,1 };
const int ddx[] = { 0,1,1,  0,2, 1,-1,-2, 2, 2, -2,-2,1,-1,1,-1,2,2,-2,-2 };
const int ddy[] = { 2,1,-1,-2,0, 1, 1, 0,2, -2,  2,-2,2,2, -2,-2, 1,-1,1,-1 };


int main() {
	int H, W;
	cin >> H >> W;
	int ch, cw, dh, dw;
	cin >> ch >> cw >> dh >> dw;
	ch--; cw--; dh--; dw--;
	vector<string> S(H);
	for (int n = 0; n < H; ++n) {
		cin >> S[n];
	}

	vector<vector<int>> D(H, vector<int>(W, 1e9));//回数
	deque<pair<int, int>> q;
	q.push_front(make_pair(ch, cw));
	D[ch][cw] = 0;

	while (!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop_front();
		//範囲内かつ0を4セット
		for (int l = 0; l < 4; ++l) {
			int x1 = x + dx[l];
			int y1 = y + dy[l];
			if ((0 <= x1) && (H > x1) && (0 <= y1) && (W > y1) && ('.' == S[x1][y1])) {
				if (D[x1][y1] > D[x][y]) {
					D[x1][y1] = D[x][y];
					q.push_front(make_pair(x1, y1));
				}
			}
		}
		//範囲内かつ0を20セット
		for (int l = 0; l < 20; ++l) {
			int x1 = x + ddx[l];
			int y1 = y + ddy[l];
			if ((0 <= x1) && (H > x1) && (0 <= y1) && (W > y1) && ('.' == S[x1][y1])) {
				if (D[x1][y1] > D[x][y] + 1) {
					D[x1][y1] = D[x][y] + 1;
					q.push_back(make_pair(x1, y1));
				}
			}
		}
	}
	if (1e9 == D[dh][dw]) {
		cout << -1 << endl;
	}
	else {
		cout << D[dh][dw] << endl;
	}
	return 0;
}


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

int main(){
  int A , B ; 
  cin >> A >> B ; 
  
  if(A <= 8 && B <= 8){
    cout << "Yay!" << endl ; 
  }
  else{
    cout << ":(" << endl ; 
  }
}

Measured memory_bytes: 3616
n=int(input())
s=input()
a=[]
now=0
for i in s:
    a.append(now)
    if i=="W":
        now+=1
    
now=0
for i in range(n):
    a[n-i-1]+=now
    if s[n-i-1]=="E":
        now+=1
    
a=sorted(a)
print(a[0])

Measured memory_bytes: 24756
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	fastio
	int n,k;
	cin>>n>>k;
	int cnt=0;
	cnt+=n/k;
	if(n%k!=0) ++cnt;
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

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


int main() {
    int N,M; cin>>N>>M;

    ll ans=0ll;
    ans+=max(0,400000-100000*N);
    ans+=max(0,400000-100000*M);

    if(N==1&&M==1) ans+=400000;

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import time
import copy

start_time = time.time()

#input
D = int(input())
c_list = list(map(int, input().split()))

s_grid = []
for i in range(D):
    array = list(map(int, input().strip().split(' ')))
    s_grid.append(array)

t_list = [(i%26) for i in range(D)] #task_list

def calculate_score(query_list,previous_score,last_list,F):
    score = previous_score
    for d in range(F,F+1):
        score += s_grid[d][query_list[d]]
        last_list = [n+1 for n in last_list]
        last_list[query_list[d]] = 0
        for i in range(26):
            score -= c_list[i]*last_list[i]
    return score , last_list

score = 0
last_list = [0 for i in range(26)]

for k in range(0,D):
    X = -1  # k-日目に変える番号を探す
    t_list_loop = copy.deepcopy(t_list)
    p = 0
    for i in range(26):  # 26通り試す
        t_list_loop[k] = i
        score_k, last_list_k = calculate_score(t_list_loop,score,last_list,k)
        if score_k > p:
            X = i
            p = score_k
            m = last_list_k
        #print(t_list_loop,i,X,p,score_k)

    if X != -1:
        #最大のXを投入
        t_list[k] = X
        score = p
        last_list = m
    else:
        score = p
        last_list = m

    if time.time() - start_time > 1.9:
        break

for j in range(len(t_list)):
    print(int(t_list[j]) + 1)

Measured memory_bytes: 9576
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
S = input()

R = S.count("R")
G = S.count("G")
B = S.count("B")

cnt = 0
for l, r in combinations(range(N), 2):
	if l%2 != r%2:
		continue
	m = (l+r)//2
	if len(set([S[l], S[m], S[r]])) == 3:
		cnt += 1

print(R*G*B - cnt)

Measured memory_bytes: 75448
#include <iostream>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	int C = B - A - 1;
	int num = 0;

	for (int i = 1; i <= C; i++)
	{
		num += i;
	}

	cout << num - A << endl;

	return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;

long long MOD = 1000000000 + 7;



int main(){
  cout << setprecision(10);
  int N,K; cin >> N >> K;

  auto pil_greator = [](pil x, pil y){
    return x.second < y.second;
  };
  auto pil_less = [](pil x, pil y){
    return x.second > y.second;
  };

  priority_queue<pil, vector<pil>, decltype(pil_greator)> pq(pil_greator);
  priority_queue<pil, vector<pil>, decltype(pil_less)> pq_second(pil_less);

  for(int i = 0; i < N; i++){
    int t; ll d; cin >> t >> d;
    pq.push(make_pair(t,d));
  }

  ll ans = 0;
  map<int,int> m;
  for(int i = 0; i < K; i++){
    pil now = pq.top();
    // cerr << "now: " << now.first << " " << now.second << endl;
    pq.pop();
    ans += now.second;
    if(m.count(now.first) == 0){
      m[now.first]++;
      continue;
    } else {
      pq_second.push(now); // 外す対象
    }
  }

  ll max_val = ans + ( m.size() * m.size() );
  // pq_second にいる人を外す
  // pq にいる人で、mapにいない人を追加する 
  
  // cerr << "change" << endl;

  while(!pq.empty()){
    pil now = pq.top();
    // cerr << "now: " << now.first << " " << now.second << endl;
    pq.pop();
    if(m.count(now.first) == 0){

      if(pq_second.empty()) break;

      pil remove = pq_second.top();
      pq_second.pop();
      ans -= remove.second;

      m[now.first] = 1;
      ans += now.second;
      ll t = m.size() * m.size();
      max_val = (max_val > ans + t ? max_val : ans + t);
    } else { 
      // 追加する必要ない
      continue;
    }
  }

  cout << max_val << endl;
}


Measured memory_bytes: 8612
using System.Collections.Generic;
using System.Linq;
using System;
using static System.Console;

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var s = ReadLine().ToCharArray();
    var max = 0;
    var cnt = 0;
    foreach (var ch in s)
    {
      if("ACGT".Contains(ch))
      {
        max = ++cnt > max ? cnt : max;
      }
      else
      {
        cnt = 0;
      }
    }

    var ans = max;
    WriteLine(ans);
  }
}

Measured memory_bytes: 13152
#include <iostream>
#include <set>
using namespace std;
int main(){
  int a,b,k;
  cin >> a >> b >> k;
  set<int> s;
  for(int i = 0; i < k; ++i){
    s.insert(a+i);
    s.insert(b-i);
  }
  for(const auto x: s){
    if(a <= x && x <= b){
	  cout << x << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    REP(i,N) cin >> H[i];

    vector<bool> good(N,true);
    REP(i,M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (H[a] <= H[b]) good[a] = false;
        if (H[b] <= H[a]) good[b] = false;
    }
    int ans = N;
    REP(i,N) {
        if (!good[i]) ans--;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cmath>

int main(){
    int weeks, debt = 100000;
    std::cin >> weeks;
    for(int i=0; i<weeks; i++){
        debt *= 1.05;
        debt = ceil(debt / 1000.0) * 1000;
    }
    std::cout << debt << std::endl;
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
  cin>>n;
  for (int i=1;i<=9;i++)
    for (int j=1;j<=9;j++)
      if (i*j==n)
        return puts("Yes"),0;
  puts("No");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    int n; cin>>n;
    int a[n],vier=0,zwei=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]%4==0) vier++;
        else if(a[i]%2==0) zwei++;
    }
    if(zwei%2==0){
        if(vier>=(n-zwei)/2) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }else{
        if(vier>=(n-zwei+1)/2) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
/*
ID: jerrywcy
TASK: AtCoder ABC 108 Problem C
LINK: https://abc108.contest.atcoder.jp/tasks/abc108_c
LANG: C++
*/
#include <bits/stdc++.h>

using namespace std;

long long n,k;
long long ans;

int main(){
	cin>>n>>k;
 	
 	if (k%2==1){
 		ans=(n/k)*(n/k)*(n/k);
 		cout<<ans<<endl;
	}
	else {
		long long t;
		int a;
		for (a=k/2;a<=n;a+=k/2){
			t=(n-a)/k-(1-a)/k+1;
			ans+=t*t;
		}
		cout<<ans<<endl;
	}
 
	return 0;
}



Measured memory_bytes: 384
//scanf("%d", &a);
//printf("%d", a);
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int Maxn = 10005;

int n, k; 
int main() {
	cin >> n >> k;
	if(n % k == 0) {
		cout << 0;
		return 0;
	}
	
	cout << 1;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>

using namespace std;

int main(void){
    int H=0, W=0;

    while(cin >> H >> W){
        if(H==0 && W==0)
            break;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();

		int[] dice2 = Dice.Diceget(line1);

		String line2 = sc.nextLine();
		int q = Integer.parseInt(line2);

		String[] str = new String[q];
		for (int i = 0; i < q; i++) {
			str[i] = sc.nextLine();
		}

		for (int i = 0; i < q; i++) {
			int breakcount = 0;
			String[] sp = str[i].split(" ");
			int X = Integer.parseInt(sp[0]);
			int Y = Integer.parseInt(sp[1]);

			for (int j = 0; j < 4; j++) {
				
				for (int k = 0; k < 4; k++) {
								
					for (int l = 0; l < 4; l++) {
						dice2 = Dice.DiceS(dice2);
						if (dice2[1] == X && dice2[2] == Y) {
							System.out.println(dice2[3]);
							breakcount++;
							break;
						}
					}
					
					if (breakcount >= 1) {
						break;
					}					
					
					dice2 = Dice.DiceE(dice2);
					if (dice2[1] == X && dice2[2] == Y) {
						System.out.println(dice2[3]);
						breakcount++;
						break;
					}
				
				}
				
				if (breakcount >= 1) {
					break;
				}
				
				dice2 = Dice.DiceN(dice2);
				if (dice2[1] == X && dice2[2] == Y) {
					System.out.println(dice2[3]);
					break;
				}
			}

		}

	}

}

class Dice {
	public static int[] Diceget(String line) {
		int[] set = new int[7];
		String[] s = line.split(" ");
		for (int i = 1; i <= 6; i++) {
			set[i] = Integer.parseInt(s[i-1]);
		}
		return set;
	}

	public static int[] DiceE(int[] d){
		int[] dd = new int[7];
		dd[1] = d[4];
		dd[2] = d[2];
		dd[3] = d[1];
		dd[4] = d[6];
		dd[5] = d[5];
		dd[6] = d[3];
		return dd;
	}

	public static int[] DiceN(int[] d){
		int[] dd = new int[7];
		dd[1] = d[2];
		dd[2] = d[6];
		dd[3] = d[3];
		dd[4] = d[4];
		dd[5] = d[1];
		dd[6] = d[5];
		return dd;
	}

	public static int[] DiceS(int[] d){
		int[] dd = new int[7];
		dd[1] = d[5];
		dd[2] = d[1];
		dd[3] = d[3];
		dd[4] = d[4];
		dd[5] = d[6];
		dd[6] = d[2];
		return dd;
	}

	public static int[] DiceW(int[] d){
		int[] dd = new int[7];
		dd[1] = d[3];
		dd[2] = d[2];
		dd[3] = d[6];
		dd[4] = d[1];
		dd[5] = d[5];
		dd[6] = d[4];
		return dd;
	}
}

Measured memory_bytes: 26260
n = int(input())
s = input()
ans = 0
ans = s.count('R')*s.count('G')*s.count('B')
for i in range(0,n-2):
    for j in range(1,n-1):
        k = -i + 2*j
        if j < k <= n-1:
            if s[i] == s[j]:
                continue
            if s[i] == s[k]:
                continue
            if s[j] == s[k]:
                continue
        else:
            continue
        ans -= 1 
print(ans)

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

int n, a[30];

int solve(int i, int m) {
	if (m == 0) return 1;
	if (i >= n) return 0;
	int res = solve(i + 1, m) || solve(i + 1, m - a[i]);
	return res;
}

int main(){
	int q, t;;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> t;
		if (solve(0, t)) cout << "yes\n";
		else cout << "no\n";
	}
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <algorithm>

int main(void) {
  using namespace std;

  uint n, l;
  cin >> n >> l;
  vector<string> s(n);
  for(uint i=0; i<n; i++) {
    cin >> s[i];
  }

  sort(s.begin(), s.end());
  
  for(uint i=0; i<s.size(); i++)
    cout << s[i];
  cout << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1e6
using namespace std;

int main(){
	int n,hh[2],mm[2],ss[2];
	while(cin>>n,n){
		int time[86500];
		rep(i,86500)time[i]=0;
		rep(i,n){
			scanf("%d:%d:%d",&hh[0],&mm[0],&ss[0]);
			scanf("%d:%d:%d",&hh[1],&mm[1],&ss[1]);
			time[hh[0]*3600+mm[0]*60+ss[0]]++;
			time[hh[1]*3600+mm[1]*60+ss[1]]--;	
		}
		rep(i,86490){
			time[i+1]+=time[i];
		}
		int inf=0;
		rep(i,86500){
			if(time[i]==0)continue;
			else if(inf<time[i]){
				inf=time[i];
			}
		}
		cout<<inf<<endl;
	}
	return 0;
}

Measured memory_bytes: 3468
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <functional>

using namespace std;

int INF = 10000000;




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

	while(cin >> n >> a >> b >> c >> x && ( n || a || b || c || x))
	{
		int y[101];

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

		bool f[101];
		memset(f,0,101*sizeof(bool));
		bool flag = false;
		int out = 0;
		int Min = 0;

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

			if(x == y[Min])
			{
				f[Min++] = true;

				if(Min == n){flag = true;out = i;break;}
			}


			int temp = (a * x + b) % c;


			x = temp;
		}

		if(flag)cout << out << endl;
		else    cout << -1  << endl;

		
	}

  return 0;
}

Measured memory_bytes: 1160
def cin; gets.split.map(&:to_i) end
def cout(*x); puts x.join(" ") end

# exit if $0 != __FILE__

n = cin
hs = cin

h = 0
c = 0
hs.each do |x|
  if x >= h then
    c += 1
    h = x
  end
end
  
puts c


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a,b;
  cin >> a >> b;
  if(a == 'H'){
    if(b == 'H'){
      cout << 'H';
    }
    if(b == 'D'){
      cout << 'D';
    }
  }
  if(a == 'D'){
    if(b == 'H'){
      cout << 'D';
    }
    if(b == 'D'){
      cout << 'H';
    }
  }
}

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

using ll = long long;
using namespace std;
int main() {
	ll K;
	scanf("%lld", &K);

	if (K <= 49) {
		printf("%d\n", 50);
		for(int i = 0; i < 49; i++)
			printf("%d ", 0);
		printf("%d\n", K * 50);
	} else if (50 <= K) {
		ll a[50] = { 0 };
		for (int i = 0; i < 50; i++)
			a[i] = i + 1 + (K - 50) / 50;
		for (int i = 0; i < K % 50; i++)
			a[49 - i]++;
		printf("%d\n", 50);
		for (int i = 0; i < 49; i++)
			printf("%lld ", a[i]);
		printf("%lld\n", a[49]);
	}
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  bool x=false;
  for(int i=0;i<n;i++){
    char c;
    cin>>c;
    if(c=='Y')x=true;
    }
  if(!x){
    cout<<"Three"<<endl;
    }
  else{
    cout<<"Four"<<endl;
    }
  }

Measured memory_bytes: 256
n = int(input())
ans = 0
red = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:-x[1])
blue = sorted([list(map(int, input().split())) for _ in range(n)])
for i in red:
    for num, j in enumerate(blue):
        if i[0] < j[0] and i[1] < j[1]:
            ans += 1
            del blue[num]
            break
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int i;
	long long int l[100];
	l[0]=2;
	l[1]=1;
	for(i=2;i<=n;i++)
	  l[i]=l[i-1]+l[i-2];
	printf("%lld\n",l[n]);
	return 0;
}

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

int main() {
    vector<int> vec(4);
for (int i = 0; i < 4; i++) {
  cin >> vec.at(i);
}
  if(vec.at(0)+vec.at(1)==vec.at(2)+vec.at(3))
  cout <<"Balanced"<< endl;
  if(vec.at(0)+vec.at(1)>vec.at(2)+vec.at(3))
  cout <<"Left"<< endl;
  if(vec.at(0)+vec.at(1)<vec.at(2)+vec.at(3))
  cout <<"Right"<< endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int x = Integer.parseInt(in.next());
            int y = Integer.parseInt(in.next());
            int turtle = 0;

            boolean ok = false;

            for (int i = 0; i < 101; i++) {
                for (int j = 0; j < 101; j++) {
                    if (i + j == x && i * 2 + j * 4 == y) ok = true;
                }
            }

            out.println(ok ? "Yes" : "No");

        }

    }
}



Measured memory_bytes: 35800
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
        int N;
        cin>>N;
        if(N==0)break;
        int maxnum=0,maxatai=0;
        for(int i=0;i<N;i++){
            int a,b,c;
            cin>>a>>b>>c;
            if(maxatai<b+c){
                maxnum=a;
                maxatai=b+c;
            }
        }
        cout<<maxnum<<" "<<maxatai<<endl;
    }
    return 0;
}

Measured memory_bytes: 1164
s = input()
answer = 'WA'
if s[0] == 'A':
    if s.count('C',2,len(s) - 1) == 1:
        a = s.index('C')
        t = s[1:a] + s[a + 1:]
        if t.islower():
            answer = 'AC'
            
print(answer)

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    ll sum = 0;
    for(int i = 1; i <= n; ++i)
        if(i%3 == 0 || i%5 == 0);
        else
            sum += i;
    cout << sum;
    return 0;
}


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

int mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int64_t A;
    long double B;
    cin >> A >> B;
    cout << (int64_t)(A * B * 100) / 100;
}

Measured memory_bytes: 3696
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n = int(input())
cnt = 0
ans = 'No'
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        cnt += 1
        if cnt == 3:
            ans = 'Yes'
    else:
        cnt = 0
print(ans)

Measured memory_bytes: 61876