akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int H, W; cin >> H >> W;
  VS vs(H);
  REP(i,H) cin >> vs[i];

  vector<PII> memo(32, MP(-1,-1));
  vector<pair<PII,PII>> pos;
  REP(y,H) REP(x,W){
	if(vs[y][x] != '.'){
	  int i = vs[y][x] - 'A';
	  if(memo[i].first < 0)
		memo[i] = MP(x,y);
	  else
		pos.PB(MP(memo[i], MP(x,y)));
	}
  }

  int ans = 0;
  bool up  = true;
  while(up){
	up = false;

	for(int i=0;i<SZ(pos);++i){
	  PII p1 = pos[i].first, p2 = pos[i].second;
	  if(p1 > p2) swap(p1, p2);
	  int mx = min(p1.first, p2.first);
	  int Mx = max(p1.first, p2.first);
	  int my = min(p1.second, p2.second);
	  int My = max(p1.second, p2.second);
	  if((mx+1 == Mx && my == My)
		 || (mx == Mx && my+1 == My)) continue;
	  
	  int ok = 0;
	  if(p1.second <= p2.second)
	  for(int j=0;j<SZ(pos);++j){
		if(i == j) continue;
		PII piis[2] = {pos[j].first, pos[j].second};
		for(auto pii:piis){
		  int x = pii.first, y = pii.second;
		  if((y == my && mx <= x && x <= Mx)
			 || (x == Mx && my <= y && y <= My))
			ok |= 1;
		  if((y == My && mx <= x && x <= Mx)
			 || (x == mx && my <= y && y <= My))
			ok |= 2;
		}
	  }
	  else
	  for(int j=0;j<SZ(pos);++j){
		if(i == j) continue;
		PII piis[2] = {pos[j].first, pos[j].second};
		for(auto pii:piis){
		  int x = pii.first, y = pii.second;
		  if((y == my && mx <= x && x <= Mx)
			 || (x == mx && my <= y && y <= My))
			ok |= 1;
		  if((y == My && mx <= x && x <= Mx)
			 || (x == Mx && my <= y && y <= My))
			ok |= 2;
		}
	  }
		
	  if(ok != 3){
		pos.erase(pos.begin() + i);
		ans += 2;
		up = true;
		break;
	  }
	}
  }

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

Measured memory_bytes: 1344
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> data(100002);
  int a;
  for(int i = 0; i < N; i++) {
    cin >> a;
    a++;
    data.at(a - 1)++;
    data.at(a)++;
    data.at(a + 1)++;
  }
  sort(data.begin(), data.end());
  cout << data.at(100001) << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int dp[111111];

int main(){

    // 1. 入力情報.
    int X;
    scanf("%d", &X);
    
    // 2. 100で割った余りは？
    dp[0] = 1;
    rep(i, 111111){
        if(dp[i] > 0){
            if(i + 100 < 111111) dp[i + 100]++;
            if(i + 101 < 111111) dp[i + 101]++;
            if(i + 102 < 111111) dp[i + 102]++;
            if(i + 103 < 111111) dp[i + 103]++;
            if(i + 104 < 111111) dp[i + 104]++;
            if(i + 105 < 111111) dp[i + 105]++;
        }
    }
    
    // 3. 出力.
    printf("%d\n", (dp[X] > 0) ? 1 : 0);
    return 0;
    
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
const int maxn=1e5+10;
char s[maxn];
int b[maxn],a[maxn];
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	int pr=0;
	for (int i=0;i<len;i++){
		if (s[i]!='x')b[pr++]=i;
	}
	for (int i=0;i<pr;i++){
		if (s[b[pr-i-1]]!=s[b[i]])return 0*puts("-1");
		a[pr-i-1]=b[i];
	}
	int ans=0;
	for (int i=1;i<pr;i++){
		ans+=abs((a[i-1]-a[i])-(b[i]-b[i-1]));
	}
	if (pr==0)return 0*puts("0");
	ans+=2*abs((len-b[pr-1])-(b[0]+1));
	printf("%d\n",ans/2);
}

Measured memory_bytes: 1152
// https://beta.atcoder.jp/contests/abc083

#define SUBMIT

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <unordered_map>
#include <map>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    auto left = A + B;
    auto right = C + D;
    if (left > right) cout << "Left";
    else if (left == right) cout << "Balanced";
    else cout << "Right";

    cout << endl;
    return 0;
}

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

int main()
{
    int x;
    cin >> x;
    int ans=1,sum=0;
    for(int i=1;i<=x;++i){
        sum += i;
        if(sum>=x){
            ans = i;
            break;
        }
        if(sum+1==x && sum+i+1<x){
            ans = i+2;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();  // nテ、ツコツコテ」ツ?ョテ・ツァツ氾・ツ督。テ」ツ?古」ツ??」ツ?ヲテ」ツ??
	    int q = kbd.nextInt();  // qテ、ツコツコテ」ツ?古ゥツ?偲・ツ債甘ヲツ閉ー
	    if(n!=0 && q!=0){
		int[] date = new int[100];
		//テ、ツシツ堙ィツュツーテ」ツ?ョテ・ツ?凖ィツ」ツ愿ヲツ猟・テ」ツ?ッ1テヲツ猟・テ・ツセツ古、ツサツ・テ、ツクツ?00テヲツ猟・テ・ツセツ古ヲツ慊ェテヲツコツ?

		while(n!=0){
		    //テ・ツァツ氾・ツ督。テ、ツクツ?、ツコツコテ、ツクツ?、ツコツコテ」ツ?ォテ」ツ?、テ」ツ??」ツ?ヲテ」ツ??
		    int s = kbd.nextInt(); // sテヲツ猟・テ・ツ按?」ツ?ョテ、ツコツ暗・ツョツ堙」ツ?古ァツゥツコテ」ツ??」ツ?ヲテ」ツ??」ツ?ヲテ」ツ??
		    while(s!=0){
			int a = kbd.nextInt(); // テ・ツ?キテ、ツスツ禿ァツ堋?」ツ?ォテ」ツ?ッaテヲツ猟・テ」ツ?古・ツ渉ッ
			date[a]++;
			s--;
		    }
		    n--;
		}

		int ans = 0;
		for(int i=0; i<date.length; i++){
		    //テ」ツ?敕」ツ?ョテヲツ猟・テ」ツ?ォテゥツ崢?」ツ?セテ」ツつ古」ツつ凝、ツコツコテヲツ閉ーテ」ツ?古ゥツ?偲・ツ債甘ヲツ閉ーqテ」ツつ津ィツカツ?」ツ?暗」ツ?ヲテ」ツ??」ツ?ヲテ」ツ??」ツ?凝」ツ?、テヲツ慊?」ツつづ・ツ、ツ堙」ツ??ヲツ猟・テ」ツつ津ヲツ篠「テ」ツ??
		    if(date[i]>=q && date[ans]<date[i])
			ans = i;  //テァツュツ氾」ツ?暗」ツ?ィテ」ツ?療」ツ?ヲテ・ツ?コテ・ツ環崚」ツ?凖」ツつ凝」ツ?ョテ」ツ?ッテ、ツコツコテヲツ閉ー
		}
		//テゥツ?偲・ツ債甘ヲツ閉ーテ」ツつ津ィツカツ?」ツ?暗」ツ?ヲテ」ツ??」ツ?ェテ」ツ??ゥツ卍静」ツつ甘」ツ?‖nsテ」ツ?ッ0テ」ツ?ョテ」ツ?セテ」ツ?セ
		System.out.println(ans);
	    }
	}
    }
}

Measured memory_bytes: 63040
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

S = input()
X,Y=LI()

while S and S[0] == 'F':
    S = S[1:]
    X -= 1
isX = True
cur = 0
xs = []
ys = []
for i in range(len(S)):
    if S[i] == 'T':
        if cur:
            if isX:
                xs.append(cur)
            else:
                ys.append(cur)
        isX = not isX
        cur = 0
    elif S[i] == 'F':
        cur += 1

if cur:
    if isX:
        xs.append(cur)
    else:
        ys.append(cur)

sumxs = sum(xs)
sumys = sum(ys)

if abs(X) > sumxs or abs(Y) > sumys:
    print('No')
    exit()

memo1 = [[0]*(sumxs*2+1) for i in range(len(xs)+1)]
memo2 = [[0]*(sumys*2+1) for i in range(len(ys)+1)]

memo1[0][0] = 1
memo2[0][0] = 1
for i in range(1, len(xs)+1):
    for j in range(-sumxs, sumxs+1):
        memo1[i][j] = memo1[i-1][j+xs[i-1]] or memo1[i-1][j-xs[i-1]]

for i in range(1, len(ys)+1):
    for j in range(-sumys, sumys+1):
        memo2[i][j] = memo2[i-1][j+ys[i-1]] or memo2[i-1][j-ys[i-1]]

print('Yes' if memo1[len(xs)][X] and memo2[len(ys)][Y] else 'No')


Measured memory_bytes: 166364
import sys
from collections import deque
sys.setrecursionlimit(20000000)
input = sys.stdin.readline


def main():
    n = int(input())

    nums = list(map(int, input().split()))

    ans = 'Yes'

    for x in reversed(range(1, len(nums))):
        if nums[x-1] - nums[x] >= 2:
            ans = 'No'

        elif nums[x-1] - nums[x] == 1:
            nums[x-1] -= 1

        else:
            continue

    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 59632
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
using namespace std;
#define int ll

signed main() {
	int K, A, B; cin >> K >> A >> B;
	bool flag = false;
	
	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			flag = true;
		}
	}

	if (flag) {
		cout << "OK" << endl;
	}
	else {
		cout << "NG" << endl;
	}
}


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


int main() {

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

    if (h <= a) {
        printf("Yes");
    }
    else {
        printf("No");
    }

    return 0;
}


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

using namespace std;

int main()
{
ll N,K;
cin>>N>>K;
ll height[N+1];
height[0]=0;

for(ll i=1;i<=N;i++)
{
cin>>height[i];	
}	

ll dp[N+1];
dp[1]=0;
ll findmin[K+1];
for(ll i=2;i<=N;i++)
{
	ll mini=INT_MAX;
	for(ll k=1;k<=K;k++)
	{
		if(i-k>=1)
		{
			findmin[k]=dp[i-k]+abs(height[i]-height[i-k]);
			
			if(findmin[k]<mini)
			{
				mini=findmin[k];
			}
		}
		
	}
	dp[i]=mini;
}
cout<<dp[N]<<endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int i,k;
	char x[81][12];
	FILE *kuku;

	kuku=fopen("kuku.txt","w");

	if(kuku==NULL)exit(0);

	for(i=1;i<=9;i++)
		for(k=1;k<=9;k++)
			fprintf(kuku,"%dx%d=%d\n",i,k,i*k);

	fclose(kuku);

	kuku=fopen("kuku.txt","r");

	for(i=0;i<81;i++){
		fgets(x[i],sizeof(x[i]),kuku);
		printf(x[i]);
	}

	fclose(kuku);

	return 0;
}

Measured memory_bytes: 556
import math
A,B=map(float,input().split())

a=math.ceil(A/0.08)
b=math.ceil(B/0.10)
#print(a,b)
c=max(a,b)
d=int(c*0.08)
e=int(c*0.1)

if A==d and B==e:
    print(int(c))
else:
    print(-1)

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

class Main {
	public static void main(String[] args) throws Exception {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String str = br.readLine();

		int x = Integer.parseInt(SubStringStart(str));//?¬¬????????°
		int y = Integer.parseInt(SubStringMid(str));//?¬¬????????°
		int z = Integer.parseInt(SubStringEnd(str));//?¬¬????????°

//		Integer[] div1 = getDivisor(x);
//		Integer[] div2 = getDivisor(y);
		Integer[] div3 = getDivisor(z);

		Set<Integer> set = new HashSet<>();

		for (int i = x; i <= y; i++) {
//			System.out.println("?????°="+i);
			if (Arrays.asList(div3).contains(i)) {
				set.add(i);
			}
		}
//		for (int i = 0; i < div2.length; i++) {
//			if (Arrays.asList(div3).contains(div2[i])) {
//				set.add(div2[i]);
//			}
//		}

		System.out.println(set.size());
	}

	//?¬¬????????°???????????????????????????
	public static String SubStringStart(String str) {
		int index = str.indexOf(" ");
		return (str.substring(0, index));
	}

	//	?¬¬????????°???????????????????????????
	public static String SubStringEnd(String str) {
		int index = str.lastIndexOf(" ");
		return (str.substring(index + 1));
	}

	//	?¬¬????????°???????????????????????????
	public static String SubStringMid(String str) {
		int index1 = str.indexOf(" ");
		int index2 = str.lastIndexOf(" ");
		return (str.substring(index1 + 1, index2));
	}

	//?????°????´???°???????????????????????????
	public static Integer[] getDivisor(int num) {
		int dnum = getDnum(num);
		Integer[] getNum = new Integer[dnum];
		int dflag = 0;
		for (int i = 1; i < num + 1; i++) {
			if (num % i == 0) {
				getNum[dflag] = i;
				dflag++;
			}
		}
		return (getNum);
	}

	//?´???°?????°???????????????????????????
	public static int getDnum(int num) {
		int dflag = 0;

		for (int i = 1; i < num + 1; i++) {
			if (num % i == 0) {
				dflag++;
			}
		}
		return (dflag);
	}
}

Measured memory_bytes: 25648
import java.io.BufferedReader;
//import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//System.setIn(new FileInputStream("./input.txt"));
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());

		String t;
		Card[] a = new Card[n + 1]; // + 1 is for a sentinel value 
		Card[] a2 = new Card[n + 1];
		for(int i = 0; i < n; ++i){
			t = br.readLine();
			//Card instances can be shared with a[] and a2[]
			a[i] = a2[i] = new Card(t.charAt(0), Integer.parseInt(t.substring(2)));
		}
		quickSort(a, 0, n - 1);
		mergeSort(a2, 0, n);
		
		StringBuilder sb = new StringBuilder();
		
		
		int i = 0;
		a[n] = new Card('T', -1);
		a2[n] = new Card('T', -2);
		while(a[i] == a2[i]){
			i += 1;
		}
		if(i == n){
			sb.append("Stable\n");
		}else{
			sb.append("Not stable\n");
		}
		
		for(i = 0; i < n; ++i) {
				sb.append(a[i] + "\n");
		}
		System.out.print(sb);
		
	}
	public static void quickSort(Card[] a, int p, int r){
		if(p < r){
			int q = partition(a, p, r);
			quickSort(a, p, q - 1);
			quickSort(a, q + 1, r);
		}
	}
	public static int partition(Card[] a, int p, int r){
		 int x = a[r].n;
		 int i = p - 1;
		 Card tmp;
		 for(int j = p; j < r; ++j) {
			 if(a[j].n <= x){
				 i += 1;
				 tmp = a[i];
				 a[i] = a[j];
				 a[j] = tmp;
			 }
		 }
		 tmp = a[i + 1];
		 a[i + 1] = a[r];
		 a[r] = tmp;
		 return i + 1;
	}

	public static void mergeSort(Card[] s, int left, int right) {
		if(left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(s, left, mid);
			mergeSort(s, mid, right);
			merge(s, left, mid, right);
		}
	}
	public static void merge(Card[] s, int left, int mid, int right) {
		Card[] s1 = Arrays.copyOfRange(s, left, mid + 1);
		Card[] s2 = Arrays.copyOfRange(s, mid, right + 1);
		
		s1[mid - left] = new Card('T', Integer.MAX_VALUE);
		s2[right - mid] = new Card('T', Integer.MAX_VALUE);
		int i = 0;
		int j = 0;
		for(int k = left; k < right; ++k) {
			if(s1[i].n <= s2[j].n){
				s[k] = s1[i];
				i += 1;
			}else{
				s[k] = s2[j];
				j += 1;
			}
		}
		
	}
}

class Card{
	public char c;
	public int n;
	Card(char c, int n){
		this.c = c;
		this.n = n;
	}
	@Override
	public String toString() {
		return c + " " + n;
	}
}

Measured memory_bytes: 65056
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
    int a[100];
	int n;

    cin>>n;

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


    return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define Vsort(a) sort(a.bigin(), a.end())
#define rep(i,n) for(int i = 0; i < (n); i++)

using namespace std;
using ll = long long;

int main(){
  int n, ac = 0, wa = 0, tle = 0, re = 0;
  cin >> n;
  vector<string> s(n);
  rep(i,n){
    cin >> s[i];
    if(s[i] == "AC") ac++;
    else if(s[i] == "WA") wa++;
    else if(s[i] == "TLE") tle++;
    else re++; 
}
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}


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

using namespace std;

int main()
{
    long long x;
    cin>>x;
    vector<long long> choices;
    choices.push_back(0);
    choices.push_back(1);
    int i = 2;
    while(choices[i-1] - choices[i-2]  <=1000000000)
    {
        long long  j = 1;
        for(int k = 0;k<5;k++)
        {
            j = j * i;
        }
        choices.push_back(j);
        i++;
    }
    vector<long long> select;
    
    vector<long long> total;
    map<long long,long long> mp;
    for(int j = choices.size()-1; j >0; j--)
    {
        
            mp[-1*choices[j]] = -j;
            total.push_back(-1 * choices[j]);
        
    }
    for(int h = 0;h<choices.size();h++)
    {
        mp[choices[h]] = h;
        total.push_back(choices[h]);
    }

   for(int u =0;u<total.size();u++)
    {
        long long n = total[u] + x;
        auto it = lower_bound(total.begin(),total.end(),n);
        int index = it - total.begin();
        if(total[index] == n)
        {
            if(mp[n] > mp[total[u]])
            {
                cout<<mp[n]<<" "<<mp[total[u]];
            }
            else
            {
                cout<<mp[total[u]]<<" "<<mp[n];
            }
            
            break;
        }
    }


   

    return 0;
}

Measured memory_bytes: 3660
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

int main(){
    unsigned N, K;
    scanf("%u %u", &N, &K);
    int ruiseki[N];
    unsigned A[N];
    for(int i = 0; i < N; ++i){
        scanf("%u", A + i);
    }
    bool done = false;
    unsigned times = 0;
    while(!done && times++ < K){
        memset(ruiseki, 0, sizeof ruiseki);
        for (size_t i = 0; i < N; i++){
            ruiseki[(i >= A[i]) ? i - A[i] :0]++;
            if(i + A[i] + 1 < N) ruiseki[i + A[i] + 1]--;
        }
        for (size_t i = 1; i < N; i++){
            ruiseki[i] += ruiseki[i-1];
        }
        done = true;
        for (size_t i = 0; i < N; i++){
            if((A[i] = ruiseki[i]) < N) done = false;
        }
    }
    printf("%u", A[0]);
    for (size_t i = 1; i < N; i++){
        printf(" %u", A[i]);
    }
    printf("\n");
	return 0;
}

Measured memory_bytes: 3292
#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 now=1;
  while(1){
      if(now>n){
          cout << now/2 << endl;
          return 0;
      }
      now*=2;
  }
}


Measured memory_bytes: 3088
N, K = map(int, input().split())
A = list(map(int, input().split()))
bin_str1 = format(K+1, "b")
bin_str2 = format(max(A), "b")
l = max(len(bin_str1), len(bin_str2))
P = [0]*l

for i in range(N):
    t = format(A[i], "b")
    t = t[::-1]
    for j in range(len(t)):
        if t[j] == "1":
            P[j] += 1

if N % 2 == 0:
    bor = N//2
else:
    bor = N//2 + 1

result = 0
bin_str1 = bin_str1[::-1]
for i in range(len(bin_str1)):
    s = 1
    ans = 0
    if bin_str1[i] == "1":
        for j in range(i):
            if P[j] >= bor:
                ans += s*P[j]
            else:
                ans += s*(N - P[j])
            s *= 2
        ans += s*P[i]
        s *= 2
        for j in range(i+1, len(bin_str1)):
            if bin_str1[j] == "0":
                ans += s*P[j]
            else:
                ans += s*(N - P[j])
            s *= 2
        if len(bin_str2) > len(bin_str1):
            for j in range(len(bin_str1), len(bin_str2)):
                ans += s*P[j]
                s *= 2
    result = max(ans, result)

print(result)

Measured memory_bytes: 84560
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	vector<int> vc;
  	for(int n=0;n<3;n++){
    	int x;
      	cin >> x;
      	vc.push_back(x);
    }
	sort(vc.begin(),vc.end());
	cout << vc[2]-vc[0] << endl;
  	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5;
int a[maxn+5],b[maxn+5],c[maxn+5];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		cin>>b[i];
	}
	for(int i=1;i<=n;i++){
		cin>>c[i];
	}
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	long long ans=0;
	for(int i=1;i<=n;i++){
		int x = lower_bound(a+1,a+n+1,b[i])-(a+1);
		int y = upper_bound(c+1,c+n+1,b[i])-(c+1);
		ans+=(long long)x*(n-y);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
	
	int N, ans;
  	cin >> N;
  	
  	for(int i = 0; i < 10; i++){
    	if(N > 111 * i && N <= 111 * (i+1)){
        	cout << 111*(i+1) << endl;
        }
    }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << endl;
  return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> t(n+1, 0), x(n+1, 0), y(n+1, 0);
    for(int i = 1; i<= n; i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    for(int i = 0; i < n; i++){
        int t_gap = t[i+1]-t[i];
        int x_gap = abs(x[i+1]-x[i]);
        int y_gap = abs(y[i+1]-y[i]);
        if(t_gap < x_gap + y_gap){
            cout << "No" << endl;
            return 0;
        }else{
            if(t_gap % 2 != (x_gap + y_gap)%2){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(void){
    int N;
    int arr[100];
    int i, j;
    int count = 0;
    int tmp;
    bool flag = true;
    
    cin >> N;
    for(i = 0; i < N; i++){
        cin >> arr[i];
    }
    
    while(flag){
        flag = false;
        for (j = N - 1; 0 < j; j--) {
            if(arr[j] < arr[j-1]){
                tmp = arr[j - 1];
                arr[j - 1] = arr[j];
                arr[j] = tmp;
                
                count++;
                flag = true;
            }
        }
    }
    
    cout << arr[0];
    for(i = 1; i < N; i++){
        cout << " " << arr[i];
    }
    cout << endl << count << endl;
    
    return 0;
}

Measured memory_bytes: 3080
H,W = map(int, input().split())

if W == 1 or H == 1:
    print(1)
    exit()
    
ans = (W // 2) * H

if W % 2 != 0:
    if H % 2 == 0:
        ans += H / 2
    else:
        ans += (H + 1) / 2

print(int(ans))

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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int N;
  cin>>N;
  vector<int> a(N);
  int answer=0;
  rep(i,N)
    cin>>a[i];
  sort(a.begin(),a.end());
  rep(i,N-1)
    if(a[i]==a[i+1])
      answer=1;
  if(answer==0)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
      
}

Measured memory_bytes: 1152
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;
#define int ll
signed main() {
	int N, K; cin >> N >> K;
	vector<int> temp(N);
	rep(i, N) {
		int x; cin >> x;
		--x;
		temp[i] = x;
	}

	vi counter(N);
	vi loop;
	int mark;
	int t = 0;

	while (true) {
		if (counter[t] == 1) {
			mark = t;
			break;
		}
		else {
			loop.push_back(t);
			counter[t]++;
			t = temp[t];
		}
	}

	auto iter1 = find(ALL(loop), mark);
	int f = distance(loop.begin(), iter1);
	int p = distance(loop.begin() + f, loop.end());

	int d = (K - f) % p;
	int index = min(K, f + d);

	cout << loop[index]  + 1<< endl;


}

Measured memory_bytes: 8496
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
 
ll n;
ll happy[110000][3];
ll dp[110000][3];
// 0: umi
// 1: yama
// 2: HW
 
int main(){
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> happy[i][0] >> happy[i][1] >> happy[i][2];
    }
 
    for(int i = 1;i <= n;i++){
        for(int place = 0;place < 3;place++){
            for(int placeY = 0; placeY < 3;placeY++){
                if(place == placeY)continue;
                dp[i][place] = max(dp[i][place],
                                   dp[i-1][placeY] + happy[i][place]);
            }
        }
    }
    
    ll ans = 0;
    for(int place = 0;place < 3;place++){
        ans = max(ans, dp[n][place]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8244
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define debug freopen("input", "r", stdin);freopen("output", "w", stdout)
#define endl '\n'
#define all(var) var.begin(), var.end()
int const MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
    ll n, b, r;
    cin >> n >> b >> r;
    ll p = n/(b+r);
    ll mod = n%(b+r);
    if(b < mod) mod = b;
    cout << p*b + mod << endl;
}


Measured memory_bytes: 256
n=int(input())
D=[int(i) for i in input().split()]
C=[1]+[0]*12

for d in D:
  C[min(d,24-d)]+=1
if max(C)>2 or C[0]>1 or C[12]>1:
  print(0)
else:
  ans=0
  
  for i in range(2**(11)):
    CC=[1]+[0]*23+[1]
    for j in range(1,12):
      if C[j]==2:
        CC[j]=1
        CC[24-j]=1
      elif C[j]==1:
        if i&(1<<(j-1)):
          CC[j]=1
        else:
          CC[24-j]=1
    if C[12]==1:
      CC[12]=1
    cur=24
    t=0
    for j in range(1,25):
      if CC[j]==1:
        cur=min(cur,t+1)
        t=0
      else:
        t+=1
    ans=max(ans,cur)
  print(ans)





Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>

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

using namespace std;

typedef pair<int, int> P;

int main(){
	int n, m;
	while(cin >> n >> m, n|m){
		vector<vector<P> > G(n+1);
		map<string, int> num;
		string s, p, g;
		cin >> s >> p >> g;
		int idx = 1;
		num[s] = idx++, num[p] = idx++, num[g] = idx++;
		rep(i, m){
			string a, b;
			int d, t;
			cin >> a >> b >> d >> t;
			if(num[a] == 0) num[a] = idx++;
			if(num[b] == 0) num[b] = idx++;
			G[num[a]].push_back(MP(num[b], d/40+t));
			G[num[b]].push_back(MP(num[a], d/40+t));
		}

		vector<int> visit(n+1);
		vector<int> dist(n+1);

		priority_queue<P, vector<P>, greater<P> > q;
		q.push(MP(0, num[p]));
		while(!q.empty()){
			int d = q.top().first;
			int pos = q.top().second;
			q.pop();

			if(visit[pos]) continue;
			visit[pos] = 1;
			dist[pos] = d;

			rep(i, G[pos].size()){
				P next;
				next.first = d+G[pos][i].second;
				next.second = G[pos][i].first;
				q.push(next);
			}
		}

		cout << dist[num[s]]+dist[num[g]] << endl;
	}

	return 0;
}

Measured memory_bytes: 1556
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int a1,a2,a3,b1,b2,b3;
    cin>>a1>>b1>>a2>>b2>>a3>>b3;
    int a[4];
    for (int i=0;i<4;i++){
        a[i]=0;
    }
    a[a1-1]+=1;
    a[a2-1]+=1;
    a[a3-1]+=1;
    a[b3-1]+=1;
    a[b2-1]+=1;
    a[b1-1]+=1;
    int k=0;
    for (int i=0;i<4;i++){
        if (a[i]>2){
            k=1;
        }
    }
    if (k==1){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
   lli A,B,L,R,N,M,K,sum=0,num=0,flag=0;
   string S;
   cin >> S;
   N=S.size();
   rep(i,0,N){
      if(i%2==0&&S[i]=='L'){
         Out("No");flag=1;break;
      }
      if(i%2==1&&S[i]=='R'){
         Out("No");flag=1;break;
      }
   }
   if(!flag)Out("Yes");
}

Measured memory_bytes: 256
H,W=[int(x) for x in input().split()]

A = [list(map(lambda x: x=="#" ,input())) for _ in range(H)]

#print(A)


try:
    for i in range(H):
        for j in range(W):
            if A[i][j]:
                start=i,j
                raise
except:
    pass


def a(i,j):
    if i<H and j<W:
        return A[i][j]
    return False

tmp =start
used = [start]
while True:
    #print(tmp)
    i,j =tmp
    if a(i+1,j):
        tmp = i+1,j
        used.append(tmp)
        continue
    if a(i,j+1):
        tmp = i ,j+1
        used.append(tmp)
    else:
        break

for i in range(H):
    for j in range(W):
        if A[i][j]:
            if (i,j) in used:
                continue
            else:
                #print(i,j)
                print("Impossible")
                exit()
print("Possible")


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


int main() {
  rep(i,3){
    char a; cin >> a;
    if(a == '1') cout << 9;
    else cout << 1;
  }
  cout << endl;
  return 0;
  
}

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

using namespace std;

#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair

#define debug(args...) { string _s = #args; replace(ALL(_s), ',', ' '); stringstream ss(_s); cerr << endl;_debug(ss, args); }
#define _rg auto it = next(v.begin()); it != v.end(); it++
#define _input ostream& operator <<(ostream& out

template<typename T, typename U>
_input, const pair<T, U>& p) {
	out << "(" << p.first << ", " << p.second << ")";
	return out;
}

#define cont(c) template<typename T> _input, const c<T>& v) { \
					if (v.empty()) return out; \
					out << "[" << *v.begin(); \
					for (_rg) out << ", " << *it; \
					out << "]"; return out; \
				}
				
#define cont2(c) template<typename T, typename U> _input, const c<T, U>& v) { \
					if (v.empty()) return out; \
					out << "[" << *v.begin(); \
					for (_rg) out << ", " << *it; \
					out << "]"; return out; \
				}

cont(vector) cont(set) cont(multiset) cont(queue) cont2(map)

template<typename T, size_t n, typename= enable_if_t<!is_same<T, char>::value>>
_input, const T(&v)[n]) {
	if (n == 0) return out;
	out << "[" << v[0];
	for (int i = 1; i < (int)n; i++) out << ", " << v[i];
	out  << "]"; return out;
}

template<typename T, typename... Ts>
void _debug(stringstream& ss, const T &arg) {
	string name; ss >> name;
	cerr << name << " = " << arg << endl;
}

template<typename T, typename... Ts>
void _debug(stringstream& ss, const T& arg, const Ts&... args) {
	string name; ss >> name; 
	cerr << name << " = " << arg << ", ";
	if (is_class<T>::value || is_array<T>::value) cerr << endl;
	_debug(ss, args...);
}

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;
const double PI = 3.141592653589793238;

int32_t main() {
	FAST_IO;
	
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;

	int sec1 = h1*3600 + m1*60;
	int sec2 = h2*3600 + m2*60;
	
	int diff = sec2-sec1;
	diff -= k*60;
	
	cout << diff/60 << endl;;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17


Measured memory_bytes: 3652
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int long long

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 1e5 + 20 ;
int n , m ;
ll ans ;

bool in[N] , out[N] ;
vector <pii> g[N] ;

vector <int> vec ;
int dist[N] ;
bool vis[N] ;

void dfs (int v) {
	vis[v] = 1 ;
	vec.push_back(v) ;

	for (pii ed : g[v]) {
		int u = ed.F , w = ed.S ;
		if (!vis[u]) {
			dist[u] = (dist[v] + w + 3) % 3 ;
			dfs(u) ;
		}
	}
}

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> n >> m ;

	for (int i = 0 ; i < m ; i ++) {
		int u , v ;
		cin >> u >> v ;
		u -- , v -- ;

		g[u].push_back({v , +1}) ;
		g[v].push_back({u , -1}) ;

		out[u] = 1 , in[v] = 1 ;
	}

	for (int i = 0 ; i < n ; i ++) {
		if (vis[i]) continue ;
		vec.clear() ;
		dfs(i) ;

		int ed_num = 0 , ve_num = _sz(vec) ;
		int num[3] = {0 , 0 , 0} ;
		bool fl1 = 0 , fl2 = 0 ;

		for (int v : vec) {
			ed_num += _sz(g[v]) ;
			fl1 |= (in[v] && out[v]) ;
			num[dist[v]] ++ ;

			for (pii ed : g[v]) {
				int u = ed.F , w = ed.S ;
				fl2 |= (dist[u] != (dist[v] + w + 3) % 3) ;
			}
		}

		ed_num /= 2 ;

		if (!fl1) {
			ans += ed_num ;	
		}
		else if (!fl2) {
			ans += 1ll * num[0] * num[1] + 1ll * num[1] * num[2] + 1ll * num[2] * num[0] ;
		}
		else {
			ans += 1ll * ve_num * ve_num ;
		}
	}

	cout << ans << '\n' ;
}


Measured memory_bytes: 13944
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,count=1;
  cin>>a;
  vector<int> v{a};
  while(1){
    count++;
    if(a%2==0){
      a = a/2;
    }
    else{
      a = 3*a + 1;
    }
    for(int i=0;i<v.size();++i){
      if(v[i]==a){
        cout<<count;
        return 0;
      }
    }
    v.emplace_back(a);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int, int>
#define ld long double
const int mod = 1e9 + 7;
 
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
 
 
 
 
 int bin(multiset<int>&s)
 {

	 
	 int l=0,r=s.size()-1,mid,ans=1;
	 while(l<=r)
	 {
		 mid=(l+r)/2;
		 auto k =s.begin();
	   	advance(k,mid);
		 if(*k>=s.size()-mid)
		 { 
			 ans=s.size()-mid; r=mid-1;
		 }
		 else l=mid+1;
	 }
	 return ans;
 }
 
 
 
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);


int n;
cin>>n;
vector<int>a(n+1),b(n+1),c(n+1);

for(int i=1;i<=n;i++)
{
	cin>>a[i]>>b[i]>>c[i];
}


vector<vector<int>>dp(n+1,vector<int>(3,0));
dp[1][0]=a[1],dp[1][1]=b[1],dp[1][2]=c[1];

for(int i=2;i<=n;i++)
{
	dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
	dp[i][1]=b[i]+max(dp[i-1][2],dp[i-1][0]);
	dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);
}

cout<<max({dp[n][0],dp[n][1],dp[n][2]});
 
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, c;
  cin >> n >> c;
  vector<vector<ll>> a(3, vector<ll>(c, 0)), d(c, vector<ll>(c));
  REP(i, c) REP(j, c) { cin >> d[i][j]; }
  REP(i, n) {
    REP(j, n) {
      ll x;
      cin >> x;
      x--;
      a[(i + j) % 3][x]++;
    }
  }
  ll ans = 1e18;
  REP(i, c) REP(j, c) REP(k, c) if (i != j && i != k && j != k) {
    ll t = 0;

    REP(m, c) {
      t += a[0][m] * d[m][i];
      t += a[1][m] * d[m][j];
      t += a[2][m] * d[m][k];
    }
    ans = min(ans, t);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

// constants for this code
#define len_string_max (int)4
#define sym_pls1       '+'
#define sym_mns1       '-'

int calculate_points (char* data_string)
{
    // variables for `calculate_points`
    int points;

    // STEP.01
    // initialize the points
    points = 0;

    // STEP.02
    // calculate the points using given string
    for (size_t itr = 0; itr < len_string_max; itr++)
    {
        if (data_string[itr] == sym_pls1) points++;
        if (data_string[itr] == sym_mns1) points--;
    }

    // STEP.END
    return points;
}

int main (void)
{
    // variables for `main`
    char given_string[len_string_max];
    int  rtvl_scanf;

    // STEP.01
    // read out the given string
    rtvl_scanf = scanf("%s", given_string);

    // STEP.02
    // calcualte & output the points
    printf("%d\n", calculate_points(given_string));

    // STEP.END
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N;
  	string S; 
	cin >> N >> S; 
	S = S + S.at(0); 
	bool SS[100010] = {}, SW[100010] = {}, WS[100010] = {}, WW[100010] = {};
	SS[0] = 0, SS[1] = 0, SW[0] = 0, SW[1] = 1;
	WS[0] = 1, WS[1] = 0, WW[0] = 1, WW[1] = 1; 
	for(int i = 2; i <= N + 1; i++){
		if((SS[i-1] == 0 && S.at(i-1) == 'o') || (SS[i-1] == 1 && S.at(i-1) == 'x')){SS[i] = SS[i-2]; 
        }
      	else if((SS[i-1] == 1 && S.at(i-1) == 'o') || (SS[i-1] == 0 && S.at(i-1) == 'x')){SS[i] = 1-SS[i-2];
        }
		if((SW[i-1] == 0 && S.at(i-1) == 'o') || (SW[i-1] == 1 && S.at(i-1) == 'x')){SW[i] = SW[i-2]; 
        }
      	else if((SW[i-1] == 1 && S.at(i-1) == 'o') || (SW[i-1] == 0 && S.at(i-1) == 'x')){SW[i] = 1-SW[i-2];
        }
        if((WS[i-1] == 0 && S.at(i-1) == 'o') || (WS[i-1] == 1 && S.at(i-1) == 'x')){WS[i] = WS[i-2]; 
        }
      	else if((WS[i-1] == 1 && S.at(i-1) == 'o') || (WS[i-1] == 0 && S.at(i-1) == 'x')){WS[i] = 1-WS[i-2];
        }
        if((WW[i-1] == 0 && S.at(i-1) == 'o') || (WW[i-1] == 1 && S.at(i-1) == 'x')){WW[i] = WW[i-2]; 
        }
      	else if((WW[i-1] == 1 && S.at(i-1) == 'o') || (WW[i-1] == 0 && S.at(i-1) == 'x')){WW[i] = 1-WW[i-2];
        }
	} 
	if(SS[0] == SS[N] && SS[1] == SS[N + 1]){
		for(int i = 0; i < N; i++){
			if(SS[i] == 0){
				cout << 'S'; 
			}
			else if(SS[i] == 1){
				cout << 'W'; 
			}
		}
      cout << endl; 
    }
	else if(SW[0] == SW[N] && SW[1] == SW[N + 1]){
		for(int i = 0; i < N; i++){
			if(SW[i] == 0){
				cout << 'S'; 
			}
			else if(SW[i] == 1){
				cout << 'W'; 
			}
		}
      cout << endl; 
	}
	else if(WS[0] == WS[N] && WS[1] == WS[N + 1]){
		for(int i = 0; i < N; i++){
			if(WS[i] == 0){
				cout << 'S'; 
			}
			else if(WS[i] == 1){
				cout << 'W'; 
			}
		}
      cout << endl; 
    }
	else if(WW[0] == WW[N] && WW[1] == WW[N + 1]){
		for(int i = 0; i < N; i++){
			if(WW[i] == 0){
				cout << 'S'; 
			}
			else if(WW[i] == 1){
				cout << 'W'; 
			}
		}
      cout << endl; 
	}
	else cout << "-1" << endl; 
}

Measured memory_bytes: 936
N=int(input())
S=input()
r=S.count('R')
b=S.count('B')
g=S.count('G')
ans=r*b*g
for i in range(N):
    for s in range(N):
        j=i+s
        k=j+s
        if k>=N:
            break
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ans-=1
print(ans)


Measured memory_bytes: 9164
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int N,T,i,r = 0;
    cin >> N >>T;
    int t[N];
    for (i=0;i<N;i++){//t_nの入力
        cin >>t[i];
    }
    for (i=0;i<N-1;i++){
        int a=t[i+1]-t[i];
        if (a>T){
            r += T;
        }else{
            r += a;
        }
    }
    r += T;
    cout <<r;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    map<int,int>mp;
    int min1=1e9;
    rep(i,n){
        cin>>a[i];
        min1=min(min1,a[i]);
        mp[a[i]/400]++;
    }
    int cnt1=0,cnt2=0;
    if(min1>=3200){
        cnt1++;
        cnt2--;
    }
    for(int i=0; i<8; ++i){
        if(mp[i]!=0){
            cnt1++;
        }
    }
    for(int i=8; i<mp.size(); ++i){
        cnt2+=mp[i];
    }
    cout<<cnt1<<" "<<cnt1+cnt2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<ll>value,weight;
ll memopad[100005][105];
ll recursion(ll W , ll i)
{
	if(memopad[W][i]!=-1)
		return memopad[W][i];
	if(i<0 || W<0)
		return 0;
	
//	else if(weight[i] > W)
//		return recursion(W,i-1);
	if(W-weight[i]>=0)	
		{
			ll yo= max(recursion(W-weight[i],i-1) +  value[i] , recursion(W,i-1));
			memopad[W][i]=yo;
			return yo;
		}
		
	
	else
		return recursion(W,i-1);	
}
int main()
{
	ll i,j,n,W,temp1,temp2;
	cin>>n;
	cin>>W;
	for(i=0;i<n;i++)
		{
			cin>>temp1;
			cin>>temp2;
			weight.push_back(temp1);
			value.push_back(temp2);
		}
	memset(memopad,-1,sizeof(memopad));	
	cout<<recursion(W,n-1);
}

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

using namespace std;

int main(){
int H, N;
cin >> H >> N;
vector<int> A;
vector<int> B;

int a, b;
for(int i = 0; i < N; i++){
  cin >> a >> b;
  A.push_back(a);
  B.push_back(b);
}

vector<int> dp;
for(int i = 0; i < H+1; i++)dp.push_back(0);

for(int i = 0; i < H+1; i++){
  int temp = 10000 * 10000;
  for( int j = 0; j < N; j++){
    if( i - A[j] > 0){
      temp = min(temp, dp[ i - A[j] ] + B[j] );
    }
    else{
      temp = min(temp, B[j]);
    }
  }
  dp[i] = temp;
}

cout << dp[H] << endl;
}

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

using namespace std;
typedef long long int lli;
lli v[102];
lli dp[100003][2];
lli solve(lli k,lli c);
lli n;

int main(){
	lli k;
	cin>>n>>k;
	for (int i=0;i<n;i++) cin>>v[i];
	for (int i=0;i<=k;i++){
		dp[i][0]=999999;
		dp[i][1]=999999;
	}
	solve(k,0);
	if (dp[k][0]>0) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
}

lli solve(lli k,lli c){
	if (k<=0){
		if (c==0){
			if (k<0) return 1;
			else return -999;
		}
		else{
			if (k<0) return -999;
			else return 1;
		}
	}
	if (dp[k][c]!=999999) return dp[k][c];
	if (c==0) dp[k][c]=-99999999999999;
	else dp[k][c]=99999999999999;
	for (int i=0;i<n;i++){
		if (c==0) dp[k][c]=max(solve(k-v[i],(c+1)%2),dp[k][c]);
		else dp[k][c]=min(solve(k-v[i],(c+1)%2),dp[k][c]);
	}
	return dp[k][c];
	
}

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

int n,mn[2010],mx[2010],siz[2010];
vector<int> v[2010];
char s[2010];

void dfs(int np,int fath)
{
	siz[np]=(s[np]=='1');
	mx[np]=mn[np]=0;
	pair<int,int> m=make_pair(0,0);
	for(int &x:v[np])
	{
		if(x==fath)continue;
		dfs(x,np);
		siz[np]+=siz[x];
		mx[np]+=mx[x];
		m=max(m,make_pair(mn[x],mx[x]));
	}
	mn[np]=max(0,m.first-(mx[np]-m.second));
	if(fath)mn[np]+=siz[np],mx[np]+=siz[np];
}

int main()
{
	scanf("%d%s",&n,s+1);
	for(int i=1,ti,tj;i<n;i++)
	{
		scanf("%d%d",&ti,&tj);
		v[ti].push_back(tj);
		v[tj].push_back(ti);
	}
	int ans=0x3f3f3f3f;
	for(int i=1;i<=n;i++)
	{
		dfs(i,0);
		if(mx[i]&1)continue;
		if(mn[i]==0)
		{
			ans=min(ans,mx[i]/2);
		}
	}
	if(ans!=0x3f3f3f3f)printf("%d\n",ans);
	else puts("-1");
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

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

    cout << (n - 1) * (m - 1) << endl;
    return 0;
}


Measured memory_bytes: 256