akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.lang.Math;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int f[] = new int[n];

    for(int i = 0; i < n; i++) {
      f[i] = 0;
    }

    double k = Math.sqrt(n-2) -1;

    for(int x = 1;x < k; x++) {
      for(int y = 1; y < k; y++) {
        for(int z = 1; z < k; z++) {
          int l = x*x + y*y + z*z + x*y + y*z + z*x;
          if(l <= n) f[l-1]++;
        }
      }
    }

    for(int i = 0; i < n; i++) {
      System.out.println(f[i]);
    }
  }
}


Measured memory_bytes: 38852
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
void solve(){
    int n;
    string s, t;
    cin>>n>>s>>t;
    for(int i = 0; i < n; i++)cout<<s[i]<<t[i];
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define ff fflush(stdout)
#define IN(a) freopen(a, "r", stdin)
#define OUT(a) freopen(a, "w", stdout) 
using namespace std;
int main () {
	ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
	scanf("%lld %lld", &a, &b);
	c = e = 0;
	for (i = 1; i <= a; i++) {
		scanf("%lld", &d);
		if (d <= c) {
			e += b - (c - d);
		} else {
			e += b;
		}
		c = d + b;
	}
	printf("%lld\n", e);
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int  n, m, ans = -1;
  cin >> s;
  n = s.size();
  for(int i=0; i<n;i++){
    s[i] = 'x';
  }
  
  cout << s <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
long long int n,A,B;
int a[100001];
int ff(int p)
{
    long long int i;
    long long int sum,t=0;
    for(i=0; i<n; i++)
    {
        sum=a[i]-p*B;
        if(sum>0)
        {
         t+=(int)ceil(sum*1.0/(A-B));
            if(t>p||t<0)
                return false;
        }
    }
     return true;
}
int main()
{
    cin>>n>>A>>B;

        int maxn=0;
        for(int i=0; i<n; i++)
        {
            cin>>a[i];
            maxn=max(maxn,a[i]);
        }
      long long  int l=0,r,h;
        h=maxn;
        while(l<h)
        {
            r=(l+h)/2;
            if(ff(r))
                h=r;
            else l=r+1;
        }
        cout<<l<<endl;

    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
using namespace std;

int main()
{
    int N;
    cin >> N;
    int color[8];
    for (int i = 0; i < 8; i++)
        color[i] = 0;

    int free = 0;

    vector<int> a(N);

    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (0 <= a[i] && a[i] < 400)
            color[0]++;
        else if (400 <= a[i] && a[i] < 800)
            color[1]++;
        else if (800 <= a[i] && a[i] < 1200)
            color[2]++;
        else if (1200 <= a[i] && a[i] < 1600)
            color[3]++;
        else if (1600 <= a[i] && a[i] < 2000)
            color[4]++;
        else if (2000 <= a[i] && a[i] < 2400)
            color[5]++;
        else if (2400 <= a[i] && a[i] < 2800)
            color[6]++;
        else if (2800 <= a[i] && a[i] < 3200)
            color[7]++;
        else if (3200 <= a[i])
            free++;
    }
    int min_ = 0, max_;
    for (int i = 0; i < 8; i++) {
        if (color[i] > 0) min_++;
    }
    max_ = min_ + free;
    min_ = max(min_, 1);
    printf("%d %d\n", min_, max_);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 5e5;
int N;
multiset<int> A;
 
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a; cin >> a; A.insert(a);
    }
    int res = 0;
    while (!A.empty()) {
        auto it = A.end();
        it--;
        int v = *it;
        A.erase(it);
        int i = 0;
        while (v >= (1ll << i)) i++;
        assert(v < (1ll << i));
        int o = int((1ll << i) - v);
        assert(o <= v);
        auto jt = A.find(o);
        if (jt == A.end()) continue;
        res++;
        A.erase(jt);
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 9600
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,t,r){"use strict";e.exports=function(e){Number(e[0]);for(var t=e[1].split(" ").map(function(e){return Number(e)}),r=[];t.length>0;){for(var n=t.length,o=-1,u=0;u<n;u++)t[u]==u+1&&(o=u);if(-1==o)return void console.log(-1);r.push(t[o]),t=[...t.slice(0,o),...t.slice(o+1)]}for(;r.length>0;)console.log(r.pop())}},function(e,t){e.exports=require("fs")}]);

Measured memory_bytes: 21192
N = int(input())
hin = input().split(" ")

hls = []
count = 0
for i in range(0,N):
    hls.append(int(hin[i]))

def water(l,r):
    if l == r:
        return -1
    for i in range(l,r):
        hls[i] = hls[i] - 1
    global count
    count = count + 1

def all0():
    for i in range(0,N):
        if hls[i] != 0:
            return False
    return True
        
while True:
    nowNode = 0
    endNode = 0

    while endNode < N:
        while hls[endNode] != 0:
            endNode = endNode + 1
            if endNode == N:
                break
        water(nowNode,endNode)
        endNode = endNode + 1
        nowNode = endNode
        if all0():
            break

    if all0():
        break

print(count)


Measured memory_bytes: 3064
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.Set as Set
import qualified Data.Sequence as Sq
import qualified Data.Map as Map
import qualified Data.IntMap as IMap
import Data.Sequence (ViewL(..),ViewR(..),(><),(<|),(|>),Seq)

bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt


main = do
    a <- getLine
    b <- getLine
    c <- getLine
    putStrLn $ [a!!0,b!!1,c!!2]

Measured memory_bytes: 380
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
using namespace std;

int A,B,C;
int res[20] = {0};
int t=-1;
void m(int l,int r){
    string s_l = to_string(l);
    string s_r = to_string(r);
    for(int i=0;i<s_l.size();i++){
        for(int j=0;j<s_r.size();j++){
            res[i+j] += ((s_l[s_l.size()-1-i]-'0')*(s_r[s_r.size()-1-j]-'0'))%10;
            res[i+j+1] += ((s_l[s_l.size()-1-i]-'0')*(s_r[s_r.size()-1-j]-'0'))/10;
        }
    }
    for(int i=0;i<20;i++){
        res[i+1] += res[i]/10;
        res[i] = res[i]%10;
        if(res[i]==0){
            if(t==-1) t=i;
        }
        if(res[i]!=0){
            if(t!=-1) t=-1;
        }
    }
//    for(int i=0;i<20;i++){
//        cout << i <<":"<<res[i] <<endl;
//    }
//    cout << "t="<<t<<endl;
}
void solve(){
    if(A%2&&B%2&&C%2){
        if(A<=B){
            if(B<=C) m(A,B);
            else m(A,C);
        }
        else{
            if(A<=C) m(A,B);
            else m(B,C);
        }
        for(int i=t-1;i>=0;i--)
            printf("%d",res[i]);
        printf("\n");
    }
    else{
        printf("0\n");
    }
}

int main() {
    for(int i=0;i<19;i++){
        res[i] = 0;
    }
    scanf("%d%d%d",&A,&B,&C);
    solve();
    return 0;
}

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

void hukasa(int,int);
int takasa(int);

typedef struct node{
  int pa;
  int le;
  int ri;
}TREE;

TREE tree[26];
int n,depth[26],sib[26],height[26];

int main(){
  int i,j,node,left,right,degree[26],root,numchild;
  scanf("%d",&n);
  if(n>25) exit(2);
  for(i=0;i<n;i++) {
    tree[i].pa=tree[i].le=tree[i].ri=-1;
    sib[i]=-1;
    degree[i]=0;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&node,&left,&right);
    if(left != -1){
      tree[left].pa=node;
      tree[node].le=left;
      degree[node]++;
    }
    if(right != -1){
      tree[right].pa=node;
      tree[node].ri=right;
      degree[node]++;
    }
    if(left != -1 && right != -1){
      sib[left]=right;
      sib[right]=left;
    }
  }
  for(i=0;i<n;i++){
    if(tree[i].pa==-1) root=i;
  }

  hukasa(root,0);
  takasa(root);
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,tree[i].pa,sib[i],degree[i],depth[i],height[i]);
    if(tree[i].pa == -1) printf("root");
    else if(tree[i].le != -1 || tree[i].ri != -1)printf("internal node");
    else printf("leaf");
    printf("\n");
  }
  return 0;
}

void hukasa(int u,int p){
  if(u == -1) return;
  depth[u]=p;
  hukasa(tree[u].ri,p+1);
  hukasa(tree[u].le,p+1);
}

int takasa(int u){
  int h1=0,h2=0;
  if(tree[u].le != -1) h1=takasa(tree[u].le)+1;
  if(tree[u].ri != -1) h2=takasa(tree[u].ri)+1;
  if(h1>h2) return height[u]=h1;
  else return height[u]=h2;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
//UnionFind
struct UnionFind{

	std::vector<ll> data;
	// dataの各要素について
	// 負の値:その集合のルートであること示す。また、その絶対値は集合の要素数となっている。
	// 正の値:親ノードの番号(dataのインデックス)。root()を呼び出すたびに集合のルートを指すように書きなおされるので木はそんなに深くならない

	//初期化 size:最大要素数
	UnionFind(ll size): data(size, -1) {}
	
	// 集合を併合する
	// すでに同じ集合だった場合は、falseが返る
	void unite(ll x, ll y){
		x=root(x);
		y=root(y);
		if( x != y ){
			// 要素数の大きな方へ合併するためのswap
			if( data[y] < data[x] ) std::swap(x, y);
			// 要素数を加算する
			data[x] += data[y];
			// yの属する集合のルートをxに変更
			data[y] = x;
		}
		//return x!=y;
	}

	// 同じ集合かどうか判定
	bool find(ll x, ll y){
		return root(x) == root(y);
	}

	// 集合の識別番号を返す
	ll root(ll x){
		// 負の値を持つものがその集合のルート
		// 正の値は同じ集合に属するものを指す(辿ればいずれルートへ着く)
		return (data[x] < 0)? x : data[x]=root(data[x]);
	}

	// 集合の要素数を返す
	ll size(ll x){
		return -data[ root(x) ];
	}
};


int main(){
    ll n,m,k; cin>>n>>m>>k;
    UnionFind tree(n);
    vector<ll> cnt(n,0);
    rep(i,m){
        ll a,b; cin>>a>>b;
        tree.unite(a-1,b-1);
        cnt[a-1]++; cnt[b-1]++;
    }
    vector<ll> res(n,0);
    rep(i,n){
        res[i]=tree.size(i)-1-cnt[i];
    }
    rep(i,k){
        ll c,d; cin>>c>>d;
        if(tree.find(c-1,d-1)){
            res[c-1]--; res[d-1]--;
        }
    }
    rep(i,n){
        cout<<res[i];
        if(i<n-1) cout<<' ';
    }
    cout<<endl;
    return 0;
}

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

int N;
int A[105];

int main() {
	cin >> N;
	for (int i = 1; i <= N; ++i) cin >> A[i];
	int ans = 1e9;
	for (int x = -100; x <= 100; ++x) {
		int f = 0;
		for (int i = 1; i <= N; ++i) f += (A[i] - x) * (A[i] - x);
		ans = min(ans, f);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int N = 0, L = 0;
    int sweet = 0, pie = 0;
    int i = 1, j = 1;

    scanf("%d %d", &N, &L);

    sweet = L*L;

    for(i = 2; i <= N; i++){
        if(sweet > (L+i-1)*(L+i-1)){
            sweet = (L+i-1)*(L+i-1);
            j = i;
        }
    }

    for(i = 1; i <= N; i++){
        pie += L + i - 1;
    }

    pie -= L + j -1;

    printf("%d", pie);

    return 0;
}

Measured memory_bytes: 128
def check(s):
    if len(s) < 2:
        return '{} {}'.format(-1, -1)
    elif len(s) == 2:
        if s[0] == s[1]:
            return '{} {}'.format(1, 2)
    for i in range(len(s)-2):
        a, b, c = s[i], s[i+1], s[i+2]
        if a == b:
            return '{} {}'.format(i+1, i+2)
        elif b == c:
             return '{} {}'.format(i+2, i+3)           
        elif a == c:
            return '{} {}'.format(i+1, i+3)
        else:
            continue
    else:
        return '{} {}'.format(-1, -1)

s = input()
print(check(s))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define set_null(a,n) memset(a,0,sizeof(a))
#define pi acos(-1)
#define ll long long int
#define fr(a,b) for(int i=a;i<b;i++)

int main()
{
    int n;
    cin>>n;
    int a[n+1];
    long long int total=0,sum=0,total1=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int x=ceil((1.0*sum)/n);
    int y=(sum/n);
    for(int i=0;i<n;i++)
    {
        total+=(a[i]-x)*(a[i]-x);
    }
    for(int i=0;i<n;i++)
    {
        total1+=(a[i]-y)*(a[i]-y);
    }
    if(total1<total)
    {
        cout<<total1<<endl;
        return 0;
    }
    cout<<total<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}
 
ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll h,w,m;
    cin>>h>>w>>m;
    map <ll,ll> r,c;
    map <pair<ll,ll>,ll > grid;
    while(m--){
        ll a,b;
        cin>>a>>b;
        r[a]++;
        c[b]++;
        grid[{a,b}]=1;
    }
    pair <ll,ll> ans;
    ll mar,mac;
    mar=mac=0;
    for(auto it : r){
        if(it.second>mar){
            mar=it.second;
            ans.first=it.first;
        }
    }
    for(auto it : c){
        if(it.second>mac){
            mac=it.second;
            ans.second=it.first;
        }
    }
    int f=0;
    for(auto it : c){
        if(it.second==mac){
            if(grid[{ans.first,it.first}]==0){
                ans.second=it.first;
                f=1;
                break;
            }
        }
    }
    for(auto it : r){
        if(f)
            break;
        if(it.second==mar){
            if(grid[{it.first,ans.second}]==0){
                ans.first=it.first;
                break;
            }
        }
    }
    ll out=r[ans.first]+c[ans.second];
    if(grid[{ans.first,ans.second}])
        out--;
    cout<<out<<"\n";
}

Measured memory_bytes: 59908
fun main(args: Array<String>) {
  val n = readInt()
  println((n + 1) / 2)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


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

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

int main() {

    int n, m; cin >> n >> m;

    vector<int> g(n+1, 0);
    for (int i = 0; i < m; ++i) {
        int l, r; cin >> l >> r;
        --l; //0-indexのため
        g[l]++;
        g[r]--;
    }

    //いもす法
    for (int i = 0; i < n; ++i) {
        g[i+1] += g[i];
    }

    int ans = 0;

    for (int i = 0; i < n; ++i) {
        if (g[i] == m) {
            ++ans;
        }
    }

    cout << ans << endl;
}

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

int main() {
  string w;
  cin >> w;
  
  vector<char> vec(w.size());
  
  for (int i=0; i<w.size(); i++){
    vec.at(i) = w.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  bool Ans = true;
  int count = 1;
  
  for (int i=0; i<w.size()-1; i++){
    if (vec.at(i) == vec.at(i+1)){
      count++;
    }
    else if (count%2 != 0){
      Ans = false;
      break;
    }
    else{
      count = 1;
    }
  }
  
  if (count%2!=0){
    Ans = false;
  }
  
  if(Ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int m=1000000007;
int main()
{
    long long int n,k,a[200005],c,i,b[200005],j;long long max,min,s=0;
    scanf("%lld %lld",&n,&k);
    a[0]=0;b[n]=n;
    for(i=1;i<=200002;i++)
    {
        a[i]=(a[i-1]+i);
      //a[i]%=m;
    }


    for(i=k-1;i<=(n);i++)
    {
        min=a[i];
      if(i==n)
        max=a[n]-a[0];
      else
        max=a[n]-a[n-i-1];
      
        s=s+(max-min+1);
        s%=m;
    }

        printf("%lld",s%m);

}


Measured memory_bytes: 3296
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, 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
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


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 ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    n = INT()
    s = list(input())

    t = Counter(s)

    ans = t['R']*t['G']*t['B']

    for i in range(n):
        for j in range(n):
            if i + j*2 < n:
                if s[i] != s[i+j] and s[i+j] != s[i+j*2] and s[i+j*2] != s[i]:
                    ans -= 1
            else:
                break

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73640
package main

import(
	"fmt"
)

func main() {
	var scan_m int
	var scan_d int
	count := 0
	fmt.Scan(&scan_m)
	fmt.Scan(&scan_d)

	for m := 1; m <= scan_m; m++ {
		for d := 11; d <= scan_d; d++ {
			d1 := d % 10
			d10 := (d - d1) / 10
			if d1 * d10 == m && d1 != 1 && d10 != 1 {
				count++
			}
		}
	}

	fmt.Println(count)
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a-c)<=d || (abs(a-b)<=d&&abs(b-c)<=d) ) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
/*
  AUTHOR:SOURABH
  CREATED:12:10:19
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll n,i,j,c=0;
    string s;
    cin>>n;
    cin>>s;
    fn(i,n)
    {
        fs(j,i+1,n)
        {
            if(s[i]!=s[j])
                break;
        }
        c++;
        i=j-1;
    }
    cout<<c;
    return 0;
}









Measured memory_bytes: 512
N = int(input())

A = [int(input()) for i in range(N)]


MAX = max(A)

if A.count(MAX) != 1:
  for _ in range(N):
    print(MAX)

  
else:

  two = sorted(set(A))[-2]
  for i in range(N):
    if A[i] == MAX :
      print(two)
    else:
      print(MAX)

Measured memory_bytes: 17188
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		for (int i = a;i<=b ;i++ ) {
			if (i%k==0) {
				System.out.println("OK");
				System.exit(0);
			}
		}
		System.out.println("NG");


	}
}


Measured memory_bytes: 35776
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c;
    cin>>n;
    map<ll,ll>mp;
    map<ll,ll>::iterator it;
    for(i=0;i<n;i++)
    {
        cin>>k;
        j=k-1;
        l=k+1;
        mp[k]++;
        mp[j]++;
        mp[l]++;
    }
    c=INT_MIN;

    for(it=mp.begin();it!=mp.end();it++)
    {
        k=it->second;
        if(k>c)
        {
            c=k;
        }
    }
    cout<<c<<endl;
    return 0;

}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    int num;
    int odd=0, m2=0, m4=0;
    
    for(int i=0; i<n; i++){
        cin >> num;
        if(num%2==1) odd++;
        else if(num%4==0) m4++;
        else m2++;
    }
    if(m2==0) m4++;
    if(m4>=odd) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>

int main(){
    int N,L[200],j,k,ans=0;
    scanf("%d",&N);
    for(int i=0;i<N;i++)scanf("%d",&L[i]);
    for(int i=0;i<N-2;i++){
        for(j=i+1;j<N-1;j++){
            for(k=j+1;k<N;k++){
                if(L[i]+L[j]>L[k]&&L[j]+L[k]>L[i]&&L[k]+L[i]>L[j]){
                    if(L[i]!=L[j]&&L[j]!=L[k]&&L[k]!=L[i]){
                        ans++;
                    }
                }
            }
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1704
from collections import deque
s = list(input())
q = int(input())
d = deque(s)
rot = 0
for i in range(q):
    que = list(map(str,input().split()))
    if len(que) == 1:
        rot += 1
    else:
        num = int(que[1])
        cha = que[2]
        if num == 1 and rot % 2 == 0:
            d.appendleft(cha)
        elif num == 1 and rot % 2 == 1:
            d.append(cha)
        elif num == 2 and rot % 2 == 0:
            d.append(cha)
        elif num == 2 and rot % 2 == 1:
            d.appendleft(cha)
d = list(d)
if rot % 2 == 1:
    d.reverse()
    print("".join(d))
else:
    print("".join(d))


Measured memory_bytes: 9460
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
signed main(){
  map<char,int>s;
  s['J']=1;
  s['O']=2;
  s['I']=4;
  int a;
  cin>>a;
  char b[1005];
  scanf("%s",b);
  ll c[1005][8]{};
  c[0][1]=1;
  for(int d=1;d<=a;d++){
      for(int e=1;e<8;e++){
	  if(e&s[b[d-1]]){
	      for(int f=1;f<8;f++){
		  if(f&e)c[d][e]+=c[d-1][f];
		  c[d][e]%=10007;
		  }
	      }
	  }
      }
      ll sum=0;
	  for(int q=1;q<8;q++){
	      sum+=c[a][q];
	      }
	      cout<<sum%10007<<endl;
	      
}

Measured memory_bytes: 3216
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long r;
  cin >> r;
  cout << 3 * r * r << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<string> a(n);
  vector<string> b(m);
  rep(i,n) cin >> a.at(i);
  rep(i,m) cin >> b.at(i);
  string ans;
  
  for(int i = 0; i <= n-m; i++){
    for(int j = 0; j <= n-m; j++){
      ans = "Yes";
      for(int k = 0; k < m; k++){
        for(int l = 0; l < m; l++){
          if(b.at(k).at(l) != a.at(i+k).at(j+l)) ans = "No";
        }
      }
      if(ans == "Yes") break;
    }
    if(ans == "Yes") break;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll H, W;
        cin >> H >> W;
        ll N;
        cin >> N;
        vll a(N);
        rep(i, 0, N) cin >> a[i];
        queue<ll> q;
        rep(i, 0, N) {
                rep(j, 0, a[i]) {
                        q.push(i+1);
                }
        }

        vllvll c(1000, vll(1000));

        rep(i, 0, H) {
                rep(j, 0, W) {
                        c[i][j] = q.front();
                        q.pop();
                }
                ++i;
                if (i > H-1) break;
                repreverse(j, W-1, 0) {
                        c[i][j] = q.front();
                        q.pop();
                }
        }
        rep(i, 0, H) {
                rep(j, 0, W) {
                        cout << c[i][j] << ' ';
                }
                cout << endl;
        }
}

Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000001;
const long long LINF = 1e18;
const int MAX = 510000;

int main() {
	int n, cnt = 0, ans = -1;
	cin >> n;
	vector<int> a(n);
	vector<bool> s(n);
	s.at(0) = 1;
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
		
	}
	int d = a.at(0);
	if (a.at(0) == 2) {
		ans = 1;
	}
	else {
		for (int i = 0; i < n; i++) {
			d = a.at(d - 1);
			cnt++;
			if (d == 2) {
				ans = cnt + 1;
				break;
			}
		}
	}
	cout << ans << endl;
		return 0;

	}


Measured memory_bytes: 3780
n, x = map(int, input().split())
if x == 1 or x == 2*n-1:
  print("No")
else:
  print("Yes")
  if n == 2:
    print(1, 2, 3, sep="\n")
  else:
    L = [0]*(2*n-1)
    if x == 2:
      L[n-1] = 1
      L[n] = 2
      K = [i for i in range(3, 2*n)]
      for i in range(n-1):
        L[i] = K.pop()
      for i in range(n+1, 2*n-1):
        L[i] = K.pop()
    else:
      L[n-1] = x
      L[n] = x+1
      L[n-2] = 1
      L[n+1] = 2
      K = [i for i in range(1, 2*n) if 3<=i<x or i>x+1]
      for i in range(n-2):
        L[i] = K.pop()
      for i in range(n+2, 2*n-1):
        L[i] = K.pop()
    print(*L, sep="\n")

Measured memory_bytes: 15684
#include<iostream>
using namespace std;
int main ()
{
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    
    if(H-y>=r&&W-x>=r&&x>=r&&y>=r){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3112
n = int(input())
c = 0
l = 0
for i in range(n):
  x = input().split()
  d1 = int(x[0])
  d2 = int(x[1])
  if d1 == d2:
    c += 1
    if c == 3:
      l = 1
  else:
    c = 0
    

if l == 1:
  print("Yes")

else:
  print("No")

Measured memory_bytes: 9060
n, k = map(int, input().split())
pp = tuple(sorted(map(int, input().split())))

if n >= k:
    print(0)
    exit(0)

intv = []
for i in range(1, len(pp)):
    intv.append(pp[i] - pp[i - 1])
intv = sorted(intv)

ans = pp[-1] - pp[0]
for i in range(n - 1):
    ans -= intv[-i - 1]
print(ans)

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



int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    ll sum=0;
    ll r_num=0;
    ll g_num=0;
    ll b_num=0;
    rep(i,n){
        if(s[i]=='R'){
            r_num+=1;
        }else if(s[i]=='G'){
            g_num+=1;
        }else{
            b_num+=1;
        }
    }
    sum=r_num*g_num*b_num;
    ll e=0;
    rep(i,n-2){
        for(int j=1;i+2*j<n;j++){
            if(s[i]!=s[i+j] &&s[i]!=s[i+2*j] &&s[i+j]!=s[i+2*j]){
                e+=1;
            }
        }
    }
    cout<<sum-e<<endl;
    return 0;
}

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

int main() {  
 	int n,q;
  	cin >>n;
  	long int S[n];
  	for(int i=0;i<n;i++){
    cin >>S[i];
    }
  	cin >>q;
  	long int T[q];
  	for(int i=0;i<q;i++){
    cin >>T[i];
    }
  	int count=0;	
  	for(int i=0;i<q;i++){
    	for(int j=0;j<n;j++){
        if(T[i]==S[j]){count++;break;}
        }
    }
  cout <<count<<endl;
}


Measured memory_bytes: 3104
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MOD 1000000007
#define M_PI           3.14159265358979323846  /* pi */
#define sec second
#define fir first
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define entire(a) (a).begin(),(a).end()
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;

void solve() {
	ll n;
	cin >> n;
	std::vector<ll> v(n);
	rep(i, n)cin >> v[i];
	ll dp[n];
	dp[0] = 0;
	dp[1] = abs(v[1] - v[0]);

	for (ll i = 2; i < n; ++i) {
		dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i-2]-v[i]));
	}
	cout<<dp[n-1]<<endl;

}

int main() {

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


Measured memory_bytes: 4696
#include<cstdlib>
#include<iostream>
#include<string>
using namespace std;

struct Node{
  int num;
  Node *right,*left;
};

Node *insert(Node *p,int x){
  if(p==NULL){
    Node *q=(Node *)malloc(sizeof(Node));
    q->num=x;
    q->right=q->left=NULL;
    return q;
  }else{
    if(x<p->num) p->left=insert(p->left,x);
    else p->right=insert(p->right,x);
    return p;
  }
}

bool find(Node *p,int x){
  if(p==NULL) return false;
  else if(x==p->num) return true;
  else if(x<p->num) return find(p->left,x);
  else return  find(p->right,x);
}


Node *deleteNode(Node *p,int x){
  if(p==NULL) return NULL;
  else if(x<p->num) p->left=deleteNode(p->left,x);
  else if(x>p->num) p->right=deleteNode(p->right,x);
  else if(p->left==NULL){
    Node *q=p->right;
    delete p;
    return q;
  }else if(p->left->right==NULL){
    Node *q=p->left;
    q->right=p->right;
    delete p;
    return q;
  }else{
    Node *q;
    for(q=p->left;q->right->right!=NULL;q=q->right);
    Node *r=q->right;
    q->right=r->left;
    r->left=p->left;
    r->right=p->right;
    delete p;
    return r;
  }
  return p;
}

void inorder(Node *T){
  if(T==NULL)return;
  inorder(T->left);
  cout<<" "<<T->num;
  inorder(T->right);
}

void preorder(Node *T){
  if(T==NULL) return;
  cout<<" "<<T->num;
  preorder(T->left);
  preorder(T->right);
}

int main(){
  int m,k;
  string s;
  struct Node *T;

  T=NULL;

  cin>>m;

  for(int i=0;i<m;i++){
    cin>>s;
    if(s=="insert"){
      cin>>k;
      T=insert(T,k);
    }else if(s=="find"){
      cin>>k;
      if(find(T,k)==false)cout<<"no"<<endl;
      else cout<<"yes"<<endl;
    }else if(s=="print"){
      inorder(T);
      cout<<endl;
      preorder(T);
      cout<<endl;
    }else if(s=="delete"){
      cin>>k;
      deleteNode(T,k);
    }
  }
  return 0;
}

Measured memory_bytes: 13716
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    cin >> N;
    vl A(N);
    vl mn;
    ll money=1000,kabu=0;
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N-1){
        if(A[i]>A[i+1]){
            mn.pb(i);
        }
    }
    ll j=0;
    rep(i,N){
        if(j!=mn.size()&&i==mn[j]){
            money+=kabu*A[i];
            kabu=0;
            j++;
        }
        else if(i==0||(j!=0&&i==mn[j-1]+1)){
            kabu=money/A[i];
            money-=kabu*A[i];
        }
    }
    money+=kabu*A[N-1];
    cout << money << endl;
}

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

int main(void) {
    int64_t N,M;
    int64_t s,c;
    string output = "---";
    bool check = true;
    cin >> N >> M;

    for(int i=0;i<M;i++) {
        cin >> s >> c;

        if((output[s-1] != '-') && (output[s-1] != (c+'0'))) {
            check = false;
        } else {
            output[s-1] = c + '0';
        }

        if(s > N){
            check = false;
        }
    }

    if((output[0] == '0') && (N > 1)) {
        cout << "-1\n";
        return 0;
    }
    if(check) {
        int i=2;

        for(i=0;i<3;i++) {
            if(output[i] == '-'){
                if(i == 0) {
                    if(N == 1) {
                        output[i] = 0 + '0';
                    } else {
                        output[i] = 1 + '0';
                    }
                } else {
                    output[i] = 0 + '0';
                }
            }
        }
        cout << output.substr(0,N) << "\n";
    } else {
        cout << "-1\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
typedef  long long ll;

int main(void)
{
  int x,y;
  scanf("%d %d",&x,&y);
  for(int i=0;i<=x;i++){
    for(int j=0;j<=x;j++){
      if(i*2+j*4==y&&i+j==x){
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 1648
while True:
    M,F,R = map(int,input().split())
    if M == -1 and F == -1 and R == -1:
        break
    elif M == -1 or F == -1:
        print('F')
    elif M + F >= 80:
        print('A')
    elif M + F >= 65:
        print('B')
    elif M + F >= 50 or (M + F >= 30 and R >= 50):
        print('C')
    elif M + F >= 30:
        print('D')
    else:
        print('F')


Measured memory_bytes: 5596
def main():
    N, M = map( int, input().split())
    PS = [tuple( input().split()) for _ in range(M)]
    AC = [False]*(N+1)
    C = [0]*(N+1)
    for p, s in PS:
        p = int( p)
        if AC[p]:
            continue
        if s == "AC":
            AC[p] = True
        else:
            C[p] += 1
    ansac = 0
    anspena = 0
    for i in range(N+1):
        if AC[i]:
            ansac += 1
            anspena += C[i]
    print(ansac, anspena)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 22916
#include <stdio.h>
#include <stdlib.h>
#define N 101
 
int G[N][N];
int queue[N];
int queS=0;
int queE=0;
int breadth[N]; 
 
int dequeue(void);
void enqueue(int);
void bfs(int);
void visit(int); 
 
int main(){
  int i, j, k, l, n, adj;
 
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d%d", &l, &k);
    for(j=0; j<k; j++){
      scanf("%d", &adj);
      G[l][adj] = 1;
    }
  }
 
  bfs(n);
 
  for(i=1; i<=n; i++){
    printf("%d %d\n", i, breadth[i]);
  }
 
  return 0;
}
 
void enqueue(int data){
  queue[queE] = data;
  queE = (queE + 1)%100;
}
 
int dequeue(void){
  int tmp = queue[queS];
  queS = (queS+1)%100;
  return tmp;
}
 
void bfs(int n){
  int i;
  
  for(i=1; i<=n; i++) breadth[i]=-1;
  enqueue(1);
  breadth[1]=0;
  while(queS != queE) visit(n);
}
 
void visit(int n){
  static int qued[N];
  static int depth=0;
  int i, j, p;
  p = dequeue();
   
  qued[p] = 1;
  for(i=1; i<=n; i++){
    if(G[p][i]==1 && qued[i]==0){
      qued[i] = 1;
      breadth[i] = breadth[p]+1;
      enqueue(i);
    }
  }
}

Measured memory_bytes: 636
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N;
int A[123456];
int B[123456];
map<int, int>P, Q;
int cnt;

int main(void)
{
	cin >> N;
	vector<int>vec;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		B[N - 1 - i] = A[i];
	}
	for (int i = 0; i < N; ++i) {
		if (P[A[i]] != Q[A[i]]) {
			cnt--;
		}
		if (A[i] != B[i] && P[B[i]] != Q[B[i]]) {
			cnt--;
		}
		P[A[i]]++;
		Q[B[i]]++;
		if (P[A[i]] != Q[A[i]]) {
			cnt++;
		}
		if (A[i] != B[i] && P[B[i]] != Q[B[i]]) {
			cnt++;
		}
		if (cnt == 0) {
			vec.push_back(i + 1);
		}
	}
	for (int i = 0; i < vec.size(); ++i) {
		cout << vec[i];
		if (i + 1 != vec.size()) {
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 8632
#include<bits/stdc++.h>
using namespace std;
int l;
string s;
int main() {
	cin >> s;
	l = s.size();
	if(l & 1 && s[0] != s[l - 1] || !(l & 1) && s[0] == s[l - 1])
		cout << "First\n";
	else
		cout <<"Second\n" ;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Arrays;
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] str1Ary = str.split(" ");
		int[] ary = new int[str1Ary.length];
		for(int i = 0; i < str1Ary.length; i++){
			ary[i] = Integer.parseInt(str1Ary[i]);
		}
		Arrays.sort(ary);
		for(int i = 0; i < ary.length; i++){
			System.out.print(ary[i]);
			if(i < ary.length - 1){
				System.out.print(" ");
			}
		}
                System.out.println();
	}
}

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

using i64 = long long;

const int N = 1 << 17;

int n, m;
bool flag;

vector<int> g[N];
int f[N], lv[2];

void dfs(int u, int dep = 1) {
	lv[dep % 2]+= 1;
	f[u] = dep;

	for (auto v: g[u])
		if (f[v]) {
			if (abs(f[v] - f[u]) % 2 == 0)
				flag = true; }
		else
			dfs(v, dep + 1); }

int main() {
#ifdef HOME
	freopen("atc.in", "r", stdin);
	freopen("atc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	i64 ant;
	int a, b;

	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a); }

	dfs(1);

	if (flag)
		cout << n * i64(n - 1) / 2 - m << endl;
	else {
		ant = i64(lv[0]) * lv[1] - m;
		cout << ant << endl; }

	return 0; }


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

vector<int> v;
int n, p, last, ans;

int main(){

while(1){

    ans = 0;
    cin >> n >> p;
    if(n == 0 and p == 0) break;
    last = p;
    for(int i=0; i < n; i++) v.push_back(0);

    while(1){
        for(int i=0; i < n; i++){
            //pが残ってるとき
            if(p != 0){
                //最後の一個か
                if(p - 1 == 0){
                    v[i] += 1;
                    p -= 1;
                    //終了確認
                    if(v[i] == last){
                        ans = i;
                        goto end;
                    }
                }
                //そうでないとき
                else{
                    v[i] += 1;
                    p -= 1;
                }
            }
            //椀の中に何もない
            else {
                p += v[i];
                v[i] = 0;
            }
        }
    }

    end:
    cout << ans << endl;
    v.clear();
}//LOOP
    return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N;
	cin >> N;

	int pay = 0;
	for (int i = 1; i <= 10; i++)
	{
		pay += 1000;
		if (pay >= N) break;
	}

	cout << pay - N;
	
	return 0;
}


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

int main(){
  vector<int64_t> L(87);
  for (int i =0;i<=86;i++){
    if (i==0){
      L.at(i)=2;
    }
    if(i==1){
      L.at(i)=1;
    }
    if (i>=2){
      L.at(i)=L.at(i-2)+L.at(i-1);
    }
  }
  int N;
  cin>>N;
  cout<<L.at(N)<<endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
q=int(input())
m=list(map(int,input().split()))
b=[0]*2**n
for i in range(2**n):
  tr=bin(i)[2:].zfill(n)
  cnt=0
  for j in range(n):
    if tr[j]=='1':
      cnt+=a[j]
  b[i]=cnt
for i in m:
  if i in b:print('yes')
  else:print('no')


Measured memory_bytes: 42960
#include<iostream>
#include<array>
#include<math.h>
#include <stdio.h>
#include <stdlib.h>
#include<string>
#include<stack>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
int main()
{
	int N,M,X;
	cin >> N >> M >> X;
	int A[150];
	for (int i = 0; i < M; i++)
		cin >> A[i];
	int sum1 = 0,sum2=0;
	for (int i = 0; i < M; i++)
		for (int j = X; j < N + 1; j++) {
			if (A[i] == j) {
				sum1++;
				break;
			}
		}
	for (int i = 0; i < M; i++)
		for (int j = 0; j <=X; j++) {
			if (A[i] == j) {
				sum2++;
				break;
			}
		}
	if (sum1 > sum2)
	{
		cout << sum2 << endl;
	}
	else {
		cout << sum1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		List<Integer> times = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			times.add(scanner.nextInt());
		}

		int m = scanner.nextInt();
		List<Integer> pList = new ArrayList<>();
		List<Integer> xList = new ArrayList<>();
		for (int i = 0; i < m; i++) {
			pList.add(scanner.nextInt());
			xList.add(scanner.nextInt());
		}

		int index = 0;
		for (int p : pList) {
			List<Integer> t = new ArrayList<>(times);
			t.set(p - 1, xList.get(index));
			int ans = 0;
			for (int time : t) {
				ans += time;
			}
			System.out.println(ans);
			index++;
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const int MAX_N = 100000;
int N, K;
int h[MAX_N];
int dp[MAX_N];

int solve() {
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    REP(i,2,N) {
        dp[i] = dp[i-1] + abs(h[i-1] - h[i]);
        REP(j,max(i-K,0),i) {
            dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
        }
    }
    return dp[N-1];
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> K;
    REP(i,0,N) cin >> h[i];
    cout << solve() << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main()
{   int a,b,c,d,e,f;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    e=a<=b?a:b;
    f=c<=d?c:d;
    printf("%d\n",e+f);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <set>

int main()
{
	std::set<int> s;
	int n, d;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &d);
		s.insert(d);
	}
	printf("%d\n", s.size());
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
int main(){
	string s,t; cin>>s>>t;
	int n=s.size();
	int c=0;
	for(int i=0;i<n;i++) c+=s[i]==t[i];
	cout<<c;

}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    int count=0;
    cin>>s1>>s2;
    for(int i=0;i<s1.size();i++)
    {
        if(s1[i]==s2[i])
            count++;
    }
    if(count==s1.size())
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <vector> 
#include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;


signed main(){
    int n;
    cin>>n;
    deque<char> arr;
    while(n>0) {
        n--;
        arr.push_front(n%26+'a');
        //cout << n%27<<" "<<(char)(n%27+'a'-1) << endl;
        n/=26;
    }
    for(auto c:arr) cout << c << flush;
    cout << "" << endl;    

    return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

int N;
string s;
vector<ll> dp, pp;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> s;
    dp = {1};
    for (int i = 0; i < N - 1; i++) {
        pp.assign(dp.size() + 1, 0);
        for (size_t j = 0; j < dp.size(); j++)
            pp[j + 1] = (pp[j] + dp[j]) % MOD;
        dp.assign(dp.size() + 1, 0);
        for (size_t j = 0; j < dp.size(); j++)
            dp[j] = s[i] == '<' ? pp[j] : (pp.back() - pp[j] + MOD) % MOD;
    }
    ll result = 0;
    for (ll x : dp)
        result = (result + x) % MOD;
    cout << result << endl;
}


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

using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (int)n; i++)

int main(){
  int n,k;
  cin >> n >> k;
  std::vector<ll> vec(n);
  rep(i,n) {
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(), vec.end());
  ll total = 0;
  rep(i,n) {
    if (i < k) {
      continue;
    }
    total += vec.at(i);
  }
  cout << total << endl;
}


Measured memory_bytes: 4840