akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define PI 3.14159265
#define ll long long
#define ld long double
#define vi vector<int>
#define pb push_back
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 300000000000000001
#define infx 9223372036854775806
#define all(c) c.begin(),c.end()
#define mk(x,yy) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define ff first
#define ss second
#define re return
// #define endl "\n"
#define max2(x,y)           (x>y)?x:y
#define min2(x,y)           (x<y)?x:y
#define mid(s,e)               (s+(e-s)/2)
#define mini                   INT_MIN
#define maxo                   INT_MAX
#define rep(i,a,b) for(int i=a;i<(int)(b);++i)
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define show(a,n) for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl
#define ene cout<<"\n";

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
ll power(ll x,  ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
 
bool compr(std::vector<ll> a, std::vector<ll> b)
{
    if(a[0]==b[0])
        return a[1]<b[1];
    else
        return a[0]<b[0];
}

bool comp(std::vector<ll> a, std::vector<ll> b)
{
    if(a[1]==b[1]&&a[2]==b[2])
        return a[0]<b[0];
    else if(a[1]==b[1])
        return a[2]>b[2];
    else
        return a[1]<b[1];
}

vector<ll> ans;
ll dfs(vector<ll> adj[], ll x, ll visited[], ll n)
{
    visited[x] = 1;
    ll child = 1;
    for(ll i=0;i<adj[x].size();i++)
    {
        if(visited[adj[x][i]]==0)
        {
            ll ch = dfs(adj,adj[x][i],visited,n);
            ans.push_back(ch*(n-ch));
            child += ch;
        }
    }
    return child;
}
int main()
{
    #ifdef SHIVANSH 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll dp[n] = {};
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(ll i=2;i<n;i++)
    {
        dp[i] = INT_MAX;
        for(ll j=1;j<=k&&i-j>=0;j++)
        dp[i] = min(abs(a[i]-a[i-j])+dp[i-j],dp[i]);
    }
    cout<<dp[n-1]<<endl;
}

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

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

// Verified: ABC133E, ABC132D, ABC130E
struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 input_x) : x(input_x) {}
  FiniteField() : x(0) {}
  int64 Value() { return x; }
  inline FiniteField operator+(FiniteField o) {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

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

  int h, w, n;
  cin >> h >> w >> n;
  vector<pair<int, int>> ps;
  for (int i = 0; i < n; i++) {
    int r, c;
    cin >> r >> c;
    r--;
    c--;
    ps.push_back(make_pair(r, c));
  }
  sort(ps.begin(), ps.end(), [](auto& p1, auto& p2) {
    if (p1.first != p2.first) return p1.first < p2.first;
    return p1.second < p2.second;
  });
  ps.push_back(make_pair(h - 1, w - 1));

  vector<FiniteField> factorials(h + w + 1);
  factorials[0] = 1;
  for (int i = 1; i <= h + w; i++) {
    factorials[i] = factorials[i - 1] * i;
  }

  vector<FiniteField> inv_factorials(h + w + 1);
  for (int i = 0; i <= h + w; i++) {
    inv_factorials[i] = FiniteField(1) / factorials[i];
  }

  auto base_count = [&](int dr, int dc) -> FiniteField {
    if (dr < 0) return 0;
    if (dc < 0) return 0;
    return factorials[dr + dc] * inv_factorials[dr] * inv_factorials[dc];
  };

  n = ps.size();
  vector<FiniteField> dp(n);
  for (int i = 0; i < n; i++) {
    int r, c;
    tie(r, c) = ps[i];
    FiniteField value = base_count(r, c);
    for (int j = 0; j < i; j++) {
      value -= dp[j] * base_count(r - ps[j].first, c - ps[j].second);
    }
    dp[i] = value;
  }
  cout << dp[n - 1].Value() << endl;
}


Measured memory_bytes: 3456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

			String inputLine;
			while ((inputLine = br.readLine()) != null) {

				final String[] inputs = inputLine.split(" ");

				final Integer H = Integer.valueOf(inputs[0]);
				final Integer W = Integer.valueOf(inputs[1]);

				if (H.equals(0) && W.equals(0)) {
					break;
				}

				for(Integer h = 0; h < H; h++) {
					for(Integer w = 0; w < W; w++) {
						System.out.print("#");
					}
					System.out.println();
				}
				System.out.println();
			}
		}
	}
}



Measured memory_bytes: 34192
import java.util.Scanner

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    scanner.nextInt()
    val a = scanner.nextInt()
    val b = scanner.nextInt()
    if ((a - b) % 2 == 0) {
        println("Alice")
    } else {
        println("Borys")
    }
}

Measured memory_bytes: 31136
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include <string.h>
using namespace std;
int main(){
	int i,j,m,n,a,b;
	while(cin>>a>>b){
		if(a>b&&b!=1){
			cout<<"Alice"<<endl;
		}else if(a<b&&a==1){
			cout<<"Alice"<<endl;
		}else if(a==b){
			cout<<"Draw"<<endl;
		}else if(a<b&&a!=1){
			cout<<"Bob"<<endl;
		}else if(a>b&&b==1){
			cout<<"Bob"<<endl;
		}
	}
	return 0;
}

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

int main(){
  int A, B, ans = -1;
  cin >> A >> B ;
  for(int i=1;i<15000;i++){
      if( ( (i * 8 / 100) == A ) && ( (i * 10 / 100) == B ) ){
          ans = i ;
          break ;
      }
  }
  cout << ans << endl ;
  return 0 ;
}

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

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 0; i < N; i++)if(S[i] == 'A')if(S[i+1] == 'B' && S[i+2] == 'C') ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = inputI()
a = [0]+inputILs(N)

now = 1
ans = 0
flag = [0 for i in range(N+1)]
while True:
  ans += 1
  now = a[now]
  if flag[now] == 1:
    print(-1)
    exit()
  flag[now] = 1
  if now == 2:
    print(ans)
    exit()
  

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

int main() {
    map<char, bool> ab;
    string s;
    cin >> s;
    for(char c = 'a'; c <= 'z'; c++) {
        ab[c] = false;
    }
    for(char c : s) {
        ab[c] = true;
    }
    for(auto c : ab) {
        if(!c.second) {
            cout << c.first << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
import sys
S = input()
S = S[::-1]
f = 1

while f > 0 and len(S)>0:
    if S.find('maerd') ==0 or S.find('esare') == 0:
        S = S[5:]
    elif S.find('remaerd') == 0:
        S = S[7:]
    elif S.find('resare') == 0:
        S = S[6:]
    else:
        f = -1

if f > 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3188
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def sol():
    N = int(input())
    P = list(map(int, input().split()))

    index = [-1] * (N + 1)
    for i, p in enumerate(P):
        index[p] = i + 1

    offset = 30000
    A = [0] * N
    B = [0] * N
    for i, p in enumerate(P):
        A[i] = index[i + 1] + offset * (i + 1)
        B[i] = offset * N - offset * i

    print(*A)
    print(*B)


sol()

Measured memory_bytes: 7424
package main

import "fmt"
import "os"
import "strings"
import "bufio"
import "strconv"

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	is := sc.Text()

	i, _ := strconv.Atoi(is)
	s := 0
	for _, c := range strings.Split(is, "") {
		n, _ := strconv.Atoi(c)
		s += n
	}

	if i % s == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 640
/************************************************
 *Author*        :ZZZZone
 *reated Time*  : 一  8/ 7 23:47:34 2017
 *ended  Time*  : 一  8/ 7 23:59:17 2017
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
const int MaxN = 100;
int r, c, n;
int a[MaxN * MaxN + 5];
int ans[MaxN + 5][MaxN + 5];

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    while(~scanf("%d %d", &r, &c)){
        scanf("%d", &n);
        int p = 1;
        for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
        for(int i = 1; i <= r; i++){
            if(i & 1){
                for(int j = 1; j <= c; j++){
                    if(a[p] == 0) p++;
                    ans[i][j] = p;
                    a[p]--;
                }
            }
            else{
                for(int j = c; j >=1 ; j--){
                    if(a[p] == 0) p++;
                    ans[i][j] = p;
                    a[p]--;
                }
            }
        }
        for(int i = 1;  i<= r; i++){
            for(int j = 1; j <= c; j++)
                printf("%d ", ans[i][j]);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 384
using System;

namespace AOJ
{
    class Program
    {
        static void Main()
        {
            string line;
            int i = 1;
            while((line = Console.ReadLine()) != "0")
            {
                Console.WriteLine("Case " + i.ToString() + ": " + line);
                i++;
            }
        }
    }
}

Measured memory_bytes: 5732
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const long long INF = 1LL << 60;

string s,t;

int main()
{
  cin >> s >> t;
  bool check = false;
  rep(i,s.size())
  {
    if(s[i] != t[i]) check = true;
  }
  if(check) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 998244353
#define inf 1e18 
 
using namespace std;
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    int l;
    cin>>l;
    int sum=0,i,j,k;
    for(i=1;i<=l;i++)
    {
        for(j=1;j<=l;j++)
        {
            for(k=1;k<=l;k++)
            {
                sum+=gcd(i,gcd(j,k));
            }
        }
    }
    cout<<sum;
}

Measured memory_bytes: 3660
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<queue>	

using namespace std;

namespace MyLib {
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
}

using namespace MyLib;


int main() {
	int h, w;
	int sq;
	while (cin >> h >> w, h) {
		sq = h*h + w*w;
		int wa=10000, ha=10000,msq=100000;
		for (int i = 1; i <= 150; i++)
			for (int j = i + 1; j <= 150; j++)
				if (sq <= i*i + j*j)
					if (sq == i*i + j*j&&h >= i)
						continue;
					else {
						if (msq > i*i + j*j || msq == i*i + j*j && ha > i) {
							msq = i*i + j*j;
							wa = j;
							ha = i;

						}
					}


		cout << ha <<' '<< wa << endl;





	}



	return 0;


}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	ll a[n];
	for(int i = 0; i<n; i++)
		cin>>a[i];
	sort(a,a+n,greater<ll>());
	ll cnt = 0;
	while(a[0]>=n)
	{
		for(int i = 0; i<n; i++)
		{
			ll g = a[i]/n;
			cnt += g;
			a[i] = a[i]%n;
			for(int j = 0; j<n; j++)
				if(j!=i)
					a[j] += g;
		}
		sort(a,a+n,greater<ll>());
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>
/**  '' "\n" ^ - **/

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(a<10&&b<10)cout<<a*b;
    else cout<<-1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  string s;
  cin >> N >> s;
  
  /*for(int i=0; i<N; i++){
    cout<<"s.at("<<i<<") : "  << s.at(i) << endl;
  }*/
  //cout << s.size()<< endl;

  for(int i = 0; i<s.size()-1; i++){
    if(s.at(i) == s.at(i+1)){
      s.erase(s.begin() + (i+1));//i+2番目の要素(インデックがi+1の要素)を削除
      i--;
    }
  }
  
  //ちゃんと思うように消されたか確認
  /*for(int i=0; i<s.size(); i++){
    cout<<"s.at("<<i<<") : "  << s.at(i) << endl;
  }*/
  
  cout << s.size() << endl;
}


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

int main(){

    int N;
    string S,S1,S2;
    cin >> N;
    cin >> S;
    if( N%2 == 1 ){
        cout << "No" << endl;
    } else {
        for(int i=0; i<(N/2); i++){
            S1 += S[i];
            S2 += S[N/2+i];
        }
        if(S1 == S2){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a,b;
    cin>>a>>b;
    if (a==b){
        cout<<"Draw"<<endl;
    }
    else{
        if ((a<b && a!=1) || b==1){
            cout<<"Bob"<<endl;
        }
        else{
            cout<<"Alice"<<endl;
        }
    }
	return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>

int main() {
    
    int n, m;
    scanf("%d%d", &n, &m);
    
    for (int i = 0; i < m; ++i) {
        int c;
        scanf("%d", &c);
        n -= c;
    }
    
    if (n < 0)
        printf("%d", -1);
    else
        printf("%d", n);

    return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>

int main(void)
{
	int n, di, dy;
	int i, j = 0, count = 0;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d %d", &di, &dy);
		if (di == dy) {
			count++;
			if (count == 3) {
				j++;
				count = 0;
			}
		}
		else {
			count = 0;
		}
	}

	if (j > 0) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 1640
// https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

template <typename F>
class
#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
    [[nodiscard]]
#elif defined(__GNUC__) && \
    (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
    __attribute__((warn_unused_result))
#endif
    FixPoint : private F {
 public:
  explicit constexpr FixPoint(F && f) noexcept : F(std::forward<F>(f)) {}

  template <typename... Args>
  constexpr decltype(auto) operator()(Args&&... args) const
#if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
      noexcept(noexcept(
          F::operator()(std::declval<FixPoint>(), std::declval<Args>()...)))
#endif
  {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};

template <typename F>
static inline constexpr decltype(auto) makeFixPoint(F&& f) noexcept {
  return FixPoint<F>{std::forward<F>(f)};
}

void solve() {
  ll N;
  cin >> N;

  V<string> res(0);

  auto append =
      makeFixPoint([&](auto f, ll used_ct, ll rest_len, string cur) -> void {
        // f(ll u, ll rest_len, string cur)
        if (rest_len == 0) {
          res.emplace_back(cur);
          return;
        }

        rep(i, used_ct + 1) {
          string next = cur + (char)('a' + i);
          f(i == used_ct ? used_ct + 1 : used_ct, rest_len - 1, next);
        }
      });

  append(0, N, "");

  sort(all(res));

  for (auto st : res) {
    cout << st << endl;
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

#ifndef TEST
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 7796
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  if (a == 0) {
    cout << 1 + b / x << endl;
  } else {
    cout << b / x - (a - 1) / x << endl;
  }
  return 0;
}

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

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

    int min = 9999999;
    int needPowder = 0;
    int n = sc.nextInt();
    int powder = sc.nextInt();
    
    for(int i = 0; i < n; i++){
      int tmp = sc.nextInt();
      needPowder += tmp;
      
      if(tmp < min){
        min = tmp;
      }
    }
    
    System.out.println(n + ((powder - needPowder) / min));
  }
}


Measured memory_bytes: 23764
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		List<Integer> p = new ArrayList<>();
		for (int i = 0; i < N; ++i) {
			p.add(in.nextInt());
		}
		in.close();
		Collections.sort(p);
		int sum = 0;
		for (int i = 0; i + 1 < p.size(); ++i) {
			sum += p.get(i);
		}
		sum += p.get(p.size() - 1) / 2;
		System.out.println(sum);
	}

}

Measured memory_bytes: 22228
//（double精度会损失的）https://www.cnblogs.com/xijie/p/6756156.html?utm_source=itdadao&utm_medium=referral
//https://blog.csdn.net/qq_36916968/article/details/84702339
#include<bits/stdc++.h>
#define eps 1e-6
using namespace std;
typedef unsigned long long ll;

signed main()
{	
	ll a;double b;
	cin>>a>>b;
	ll ans=a*(ll)((b+eps)*100);//转低精度 
	cout<<ans/100<<endl;
}

Measured memory_bytes: 3716
import math
D,G = map(int,input().split())
p = []
c = []
for i in range(D):
  P,C = map(int,input().split())
  p.append(P)
  c.append(C)

res = float("inf")        
for i in range(2**D):
  bs = format(i,"0{}b".format(D))
  ans = 0
  cnt = 0
  #コンプするやつをたす
  for j in range(D):
    if bs[j] == "1":
      ans += (j+1)*100*p[j] + c[j]
      cnt += p[j]
  if ans >= G:
    res = min(cnt,res)
    continue

  #コンプしないやつを寸止めでたす
  for j in range(D-1,-1,-1):
    if bs[j] == "0":
      ans += (j+1)*100*(p[j]-1)
      cnt += (p[j]-1)
      if ans >= G:
        cnt -= (ans-G)//((j+1)*100)
        res = min(res,cnt)
        break
print(res)      

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
int gcd(int x,int y){
int r;
while(y)
{
    r=x%y;
    x=y;
    y=r;
}
return x;
}
int main()
{
    int K;
    long long sum = 0;
    scanf("%d",&K);
    for(int i=1;i<=K;i++)
       for(int j = 1;j<=K;j++)
       for(int k=1;k<=K;k++)
       sum+=gcd(gcd(i,j),k);
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 1736
import sys
readline = sys.stdin.readline

def main():
    N, M = map(int, readline().rstrip().split())
    H = list(map(int, readline().rstrip().split()))
    Good = [1] * N
    for _ in range(M):
        a, b = map(int, readline().rstrip().split())
        a -= 1
        b -= 1
        if H[a] > H[b]:
            Good[b] = 0
        elif H[b] > H[a]:
            Good[a] = 0
        else:
            Good[a] = 0
            Good[b] = 0
    print(sum(Good))

if __name__ == '__main__':
    main()

Measured memory_bytes: 20144
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1;
    int i,sum1=0,sum2=1;
    s2=s1;
    if(s2[0]=='0')  s2[0]='1'; else s2[0]='0';

    for(i=0;i<s1.size()-1;i++)
    {
        if(s1[i]==s1[i+1]){sum1++;  if(s1[i]=='0')  s1[i+1]='1'; else s1[i+1]='0'; }
        if(s2[i]==s2[i+1]){sum2++;    if(s2[i]=='0')  s2[i+1]='1'; else s2[i+1]='0';}
    }
    cout<<min(sum1,sum2);
    return 0;
}



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

int main(){
    int N;
    cin>>N;
    vector<pair<int,int>> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i].second>>A[i].first;
    }
    bool flg=true;
    int sum=0;
    int maxv=0;
    for(int i=0;i<N;i++){
        if(A[i].second>A[i].first) flg=false;
        sum+=A[i].second;
        maxv=max(maxv,A[i].first);
    }
    if(sum>maxv) flg=false;
    sort(A.begin(),A.end());
    int sum1=0;
    for(int i=0;i<N;i++){
        sum1+=A[i].second;
        if(A[i].first<sum1) flg=false;
    }
    if(flg){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll n, t, sum = 0;
    string s;
    cin >> n >> t >> s;
    for(int i=2;i<s.size();i+=4){
        ll tmp = 1;
        for(int j=0;j<s[i]-'0';j++){
            tmp *= n;
            if(tmp > ll(1e9))break;
        }
        sum += tmp;
        if(sum > ll(1e9))break;
    }
    if(sum <= ll(1e9))sum *= t;
    if(sum <= ll(1e9)){
        cout << sum << endl;
    }
    else{
        cout << "TLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 3236
N = int(input())
P = [int(x) for x in input().split()]

answer = 0
for i in range(1,N-1):
  a,b,c = P[i-1:i+2]
  if b != min(a,b,c) and b != max(a,b,c):
    answer += 1

print(answer)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int T = scanner.nextInt();
		int ans = T / A * B;
		System.out.println(ans);
		scanner.close();
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define rep(i,start,lim) for(lld i=start;i<lim;i++)
#define repd(i,start,lim) for(lld i=start;i>=lim;i--)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define br printf("\n")
#define sz(a) lld((a).size())
#define YES printf("YES\n")
#define NO printf("NO\n")
#define all(c) (c).begin(),(c).end()
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define MOD         1000000007
#define PI          3.14159265358979323
using namespace std;
typedef long double ldb;
typedef long long lld;
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
lld ctl(char x,char an='a') {return (lld)(x-an);}
char ltc(lld x,char an='a') {return (char)(x+an);}
#define bit(x,j) ((x>>j)&1)
typedef vector<lld> vlld;
typedef pair<lld,lld> plld;
typedef map<lld,lld> mlld;
typedef set<lld> slld;
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mxm(a,b) a = max(a,b)
#define mnm(a,b) a = min(a,b)
#define endl '\n'
#define fre freopen("1.in","r",stdin); freopen("1.out","w",stdout);
#define N 1000005
lld get(lld x) {
    lld ret = 0;
    while(x) {
        ret += x%10;
        x/=10;
    }
    return ret;
}
int main()
{
    //sync;
    lld ans = LLINF;
    lld n;
    cin>>n;
    rep(i,1,n) ans = min(ans, get(i) + get(n-i));
    cout<<ans;
    return 0;
}

Measured memory_bytes: 764
#include<stdio.h>
int main()
{
int m[11],i,j,M;
for(i=0;i<10;i++)
    {
 scanf("%d",&m[i]);
    }
for(i=0;i<10;i++)
{
 for(j=0;j<10;j++)
 {
  if(m[i]>m[j])
  {
   M=m[i];
   m[i]=m[j];
   m[j]=M;
   }
  }
 }
for(i=0;i<3;i++)
{
 printf("%d\n",m[i]);
}
return 0;
}

Measured memory_bytes: 1856
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

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

void solve(){
    int n;
    cin >> n;

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

    map<int, int> even, odd;
    for (int i = 0; i < n; i+=2) {
        // cout << "i = " << i << endl;
        even[v[i]]++;
        odd[v[i+1]]++;
    }


    // for (auto itr = even.begin(); itr != even.end(); itr++) {
    //     cout << itr->first << " " << itr->second << endl;
    // }
    // cout << "fin" << endl;

    vector<pair<int, int>> paireven, pairodd;
    for (auto iter = even.begin(); iter != even.end(); iter++) {
        paireven.push_back(make_pair(iter->second, iter->first));
    }

    for (auto iter = odd.begin(); iter != odd.end(); iter++) {
        pairodd.push_back(make_pair(iter->second, iter->first));
    }

    sort(all(paireven));
    sort(all(pairodd));

    int lenpaireven = paireven.size();
    int lenpairodd = pairodd.size();

    int c1,a1,cp1,b1;
    int c2,a2,cp2,b2;

    c1 = paireven[lenpaireven - 1].first;
    a1 = paireven[lenpaireven - 1].second;
    if (lenpaireven == 1) {
        c2 = 0;
        a2 = -1;
    }else{
        c2 = paireven[lenpaireven - 2].first;
        a2 = paireven[lenpaireven - 2].second;
    }

    cp1 = pairodd[lenpairodd - 1].first;
    b1 = pairodd[lenpairodd - 1].second;
    if (lenpairodd == 1) {
        cp2 = 0;
        b2 = -1;
    }else{
        cp2 = pairodd[lenpairodd - 2].first;
        b2 = pairodd[lenpairodd - 2].second;
    }


    // for (auto iter = paireven.begin(); iter != paireven.end(); iter++) {
    //     cout << iter->first << " " << iter->second << endl;
    // }


    if (a1 != b1) {
        // cout << c1 << " " << cp1 << endl;
        cout << n - c1 - cp1 << endl;
        return;
    }

    cout << n - max(c1+cp2, c2+cp1) << endl;
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 6520
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a ^ b ^ c) << endl;
  return 0;
}


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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T>
vector<vector<T> > make_v(size_t a,size_t b){
  return vector<vector<T> >(a,make_v<T>(b));
}
template<typename T>
vector<vector<vector<T> > > make_v(size_t a,size_t b,size_t c){
  return vector<vector<vector<T> > > (a,make_v<T>(b,c));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//INSERT ABOVE HERE
signed main(){
  Int n,m,q;
  cin>>n>>m>>q;
  vector<string> s(n);
  for(Int i=0;i<n;i++) cin>>s[i];

  auto J=make_v<Int>(n+1,m+1);
  auto O=make_v<Int>(n+1,m+1);
  auto I=make_v<Int>(n+1,m+1);

  fill_v(J,0);
  fill_v(O,0);
  fill_v(I,0);

  for(Int i=0;i<n;i++){
    for(Int j=0;j<m;j++){
      J[i+1][j+1]=J[i+1][j]+(s[i][j]=='J');
      O[i+1][j+1]=O[i+1][j]+(s[i][j]=='O');
      I[i+1][j+1]=I[i+1][j]+(s[i][j]=='I');
    }
  }

  for(Int i=0;i<n;i++){
    for(Int j=0;j<=m;j++){
      J[i+1][j]+=J[i][j];
      O[i+1][j]+=O[i][j];
      I[i+1][j]+=I[i][j];
    }
  }

  auto calc=[](auto &dp,Int a,Int b,Int c,Int d){
    return (dp[c][d]+dp[a][b])-(dp[c][b]+dp[a][d]);
  };
  
  for(Int i=0;i<q;i++){
    Int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;b--;
    cout<<calc(J,a,b,c,d)<<" "<<calc(O,a,b,c,d)<<" "<<calc(I,a,b,c,d)<<endl;
  }
  
  
  return 0;
}



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

int bubbleSort(int A[],int N){
    int count = 0;
    bool flag = 1;
    while(flag){
        flag = 0;
        for(int i=N-1;i>0;i--){
            if(A[i]<A[i-1]){
                swap(A[i],A[i-1]);
                count++;
                flag = 1;
            }
        
        }
    }
    return count;
}

int main(){
    int N;
    int A[100];
    int count;
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
    count=bubbleSort(A,N);
    for(int i=0;i<N;i++){
        if(i!=N-1) cout << A[i] <<' ';
        else cout << A[i] << endl;
    }
    cout << count << endl;
    
    return 0;
}


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

int d, ans, c[30], s[370][30], t, lst[30];

int main() {
	int i, j;
	cin >> d;
	for(i=1; i<=26; i++) cin >> c[i];
	for(i=1; i<=d; i++) for(j=1; j<=26; j++) cin >> s[i][j];
	for(i=1; i<=d; i++) {
		cin >> t;
		ans += s[i][t];
		lst[t] = i;
		for(j=1; j<=26; j++) ans -= c[j] * (i-lst[j]);
		cout << ans << endl;
	}
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<int, int> P;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int h, w;

bool inside(int x, int y) {
    return (0 <= x) && (x <= w-1) && (0 <= y) && (y <= h-1);
}

int main(){
    cin >> h >> w;

    string a[h];
    queue<P> que;
    REP(i, h) cin >> a[i];
    REP(i, h) REP(j, w) if(a[i][j] == '#') que.push(P(i, j));

    int ans = 0;

    while(1){
        int s = que.size();

        REP(i, s) {
            P top = que.front();
            que.pop();

            REP(j, 4) {
                int x = top.second + dx[j];
                int y = top.first + dy[j];
                if(inside(x, y)) if(a[y][x] == '.') {
                        a[y][x] = '#';
                        que.push(P(y, x));
                }
            }
        }

        if(!que.size()) break;

        ans++;
    } 

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9488
#include  <stdio.h>

int  main()
{
	int i,n,a[10000];
	long max,min,sum=0;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sum=a[0];
	max=a[0];
	min=a[0];
	for(i=1;i<n;i++)
	{
		if(a[i]>max)
		{
			max=a[i];
		}
		else if(a[i]<min)
		{
			min=a[i];
		}
		sum+=a[i];
	}
	printf("%ld %ld %ld\n",min,max,sum);

	return  0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
    int i,n;
    int a[1000];
    int min=1000;int max=0;

    scanf("%d",&n);

    for(i=0;i<n;i++){
    	scanf("%d",&a[i]);
    	if(a[i]<min) min=a[i];
    	if(a[i]>max) max=a[i];
    }

    printf("%d\n",max-min);
}

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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int sum = 0;
  int a[3];
  for(int i=0; i<3; i++) cin >> a[i];
  int k;
  cin >> k;
  sort(a, a+3);
  sum = a[0] + a[1] + pow(2, k) * a[2];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import Data.Maybe (fromMaybe)
import Control.Exception (assert)

{-
S と T の重なるところは整数倍しても同じなので、最小公倍数かそうでないか。
-}

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  s <- getLine
  t <- getLine
  let
    result = assert (length s == n && length t == m) $ f n m s t
  print $ fromMaybe (-1) result


f :: Int -> Int -> String -> String -> Maybe Int
f n m s t = if s' == t' then Just lcm' else Nothing
  where
    gcd' = gcd n m
    lcm' = lcm n m
    s' = everyN (n `div` gcd') s
    t' = everyN (m `div` gcd') t

everyN :: Int -> [a] -> [a]
everyN n xs | n < 1 = xs
everyN _ [] = []
everyN n (x:xs) = x : everyN n (drop (n - 1) xs)


Measured memory_bytes: 8828
N, K=map(int, input().split())
S=list(input())
SS=[S[0]]

for i in range(1, len(S)):
  if SS[-1]!=S[i]:
    SS.append(S[i])

if len(SS)==1:
  print(N-1)
  exit()
  
if len(SS)==2:
  if K>0:
    print(N-1)
    exit()
  else:
    print(N-2)
    exit()
  
for i in range(1, len(SS)-1):
  if SS[i]!=SS[i-1] and SS[i]!=SS[i+1] and K>0:
    SS[i]=SS[i-1]
    K-=1
  
if SS[0]!=SS[1] and K>0:
  S[0]=S[1]
  K-=1
  
if SS[-1]!=SS[-2] and K>0:
  SS[-1]=SS[-2]
  K-=1
  
unhappy=0
if (SS[0]=='L') or (SS[0]=='R' and SS[1]=='L'):
  unhappy+=1
  
for i in range(1, len(SS)-1):
  if (SS[i]=='L' and SS[i-1]=='R') or (SS[i]=='R' and SS[i+1]=='L'):
    unhappy+=1
    
if (SS[-1]=='R') or (SS[-1]=='L' and SS[-2]=='R'):
  unhappy+=1
  
happy=N-unhappy
print(happy)

Measured memory_bytes: 49728
#include<cstdio>
#include<iostream>
#include<map>
using namespace std;
int prime[300000];
int main() {
	prime[1] = 1;
	for(int i = 2; i * i <= 246912; i++) {
		if(prime[i] == 1) continue;
		for(int j = i * i; j <= 246912; j += i) {
			prime[j] = 1;
		}
	}
	int n;
	while(cin >> n,n) {
		int ans = 0;
		for(int i = n + 1; i <= n * 2; i++) {
			if(prime[i] == 0) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pii pair<int,int> 
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
int inf=1000001000;
ll INF=100000000000000000;
//int 2×10の9乗
//vector<vector<int>> a(n, vector<int>(m));
//rep(i,n) rep(j,m) cin >> a[i][j]; 
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int x, int y){
//if(y==0) return x;
//return gcd(y, x%y);
//}
//sort小さい順(昇順)
//g++ code.cpp   ./a.out 
int main(){
  ll n; 
  cin >> n;
  vector<int> x(n), y(n);
  rep(i,n) cin >> x[i] >> y[i]; 
  double ans=0;
  int num=2;
  for(int i=1; i<n; i++) num*=i;
  rep(i,n){
    for(int j=i; j<n; j++){
      double kx=x[i]-x[j], ky=y[i]-y[j];
      double dis=sqrt( (kx*kx) + (ky*ky) );
      ans += dis * num;
    }
  } 
    int k=1;
    rrep(i,n) k*=i;
    ans=ans/k;
    printf("%.10f\n", ans);
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    if(a*b <= 0){
        pl("Zero")
    } else {
        if(min(a,b) > 0){
            pl("Positive")
        } else {
            if((b-a+1)%2==0){
                pl("Positive")
            } else {
                pl("Negative")
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
from collections import deque

N,M=list(map(int,input().split()))
g=[set() for _ in range(N+1)]
visit=[0]*(N+1)
anslst=[0]*(N+1)

for _ in range(M):
    a,b=list(map(int,input().split()))
    g[a].add(b)
    g[b].add(a)

q=deque([1])
visit[1]=1

while len(q)>0:
    u=q.popleft()

    for v in g[u]:
        if visit[v]==1:
            continue

        anslst[v]=u
        visit[v]=1
        q.append(v)

if sum(visit)==N:
    print('Yes')
    for i in range(2,N+1):
        print(anslst[i])
else:
    print('No')

Measured memory_bytes: 119996
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<math.h>
#include<set>
#include<iomanip>
#include<stdio.h>
#include<deque>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define int long long
using namespace std;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int N;cin>>N;
	int d[N],i,j,o=0;
	for(i=0;i<N;i++)
		cin>>d[i];
	for(i=0;i<N;i++)
	{
		for(j=i+1;j<N;j++)
		{
			o+=d[i]*d[j];
		}
	}
	cout<<o<<endl;
}

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

int main() {
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
        cout << "vowel" << endl;
    else cout << "consonant" << endl;
}


Measured memory_bytes: 256
h, w = map(int,input().split())
a = [input() for _ in range(h)]
y = [1,-1,0, 0]
x = [0, 0,1,-1]
flag = True
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            for k in range(4):
                if i + y[k] < 0 or i + y[k] >= h or j + x[k] < 0 or j + x[k] >= w:continue
                if a[i+y[k]][j+x[k]] == "#":
                    break
            else:
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
int main(){
	fast;
	char ch; cin>>ch;
	(isupper(ch))?cout<<"A\n":cout<<"a\n";
	return 0;
}

Measured memory_bytes: 3636