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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if ((b - a) == (c - b))
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
int main()
{
  int a,b,c,d,e,f;
  double A[2][2];
  double B[2];
  double inv_A[2][2];
  while(~scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)){
    int det = a*e-b*d;
    A[0][0]=a; A[0][1] = b;
    A[1][0]=d; A[1][1] = e;
    B[0] = c;
    B[1] = f; 
 
    inv_A[0][0]=A[1][1]; inv_A[0][1]=-A[0][1];
    inv_A[1][0]=-A[1][0]; inv_A[1][1]=A[0][0];
 
    double res[2];
    res[0]=0;
    res[1]=0;
 
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
	res[j]+=1.0/(double)det *inv_A[j][k]*B[k];
      }
    }
 
    printf("%.3f %.3f\n",res[0],res[1]);
  }
}

Measured memory_bytes: 1220
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	x1 := scanInt(sc)
	y1 := scanInt(sc)
	x2 := scanInt(sc)
	y2 := scanInt(sc)

	x3 := x2 - (y2 - y1)
	y3 := y2 + (x2 - x1)
	x4 := x3 - (y3 - y2)
	y4 := y3 + (x3 - x2)

	fmt.Println(x3, y3, x4, y4)
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

Measured memory_bytes: 640
use proconio::input;


fn main() {
    pub const PI: f64 = 3.14159265358979323846264338327950288f64; // 3.1415926535897931f64

let mut r : f64 ;


    input! {

       r : f64 ,

  
    }
   
 
let ans : f64  = 2.0 * r * PI ;
println!("{}",ans)
}


Measured memory_bytes: 2204
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
#define DEBUG

typedef struct node{
  struct node* parent;
  struct node* left;
  struct node* right;
  int k;
}Node;

Node* tree;

void insert(int);
void inorder(Node*);
void preorder(Node*);
int find(Node*,int);

int main(){
  int m,i,k,f;
  char hairetu[10];

  scanf("%d",&m);

  for(i=0;i<m;i++){
    scanf("%s",hairetu);
    if(hairetu[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    else if(hairetu[0]=='p'){
      inorder(tree);
      printf("\n");
      preorder(tree);
      printf("\n");
    }
    else if(hairetu[0]=='f'){
      scanf("%d",&k);
      f=find(tree,k);
      if(f) printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}

void insert(int k){
  Node* y = NIL;
  Node* x = tree;
  Node* z;
  z=(Node *)malloc(sizeof(Node));
  z->k=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->k < x->k ){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;

  if(y==NIL) tree=z;
  else if(z->k < y->k) y->left=z;
  else y->right=z;
  return;
}

void inorder(Node* tree){
  if(tree != NIL){
    inorder(tree->left);
    printf(" %d",tree->k);
    inorder(tree->right);
  }
  return;
}

void preorder(Node* tree){
  if(tree != NIL){
    printf(" %d",tree->k);
    preorder(tree->left);
    preorder(tree->right);
  }
  return;
}

int find(Node* tree,int f){
  if(tree != NIL){
    if(tree->k == f) return 1;
    if(tree->k > f) return find(tree->left,f);
    else return find(tree->right,f);
  }
  else return 0;
}

Measured memory_bytes: 19364
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  map<string, int> x;
  int maxNum = 1;
  rep(i, n){
    string s;
    cin >> s;
    if(x.find(s) == x.end()){
      x[s] = 1;
    }
    else{
      x[s]++;
      maxNum = max(maxNum, x[s]);
    }
  }
  
  for(auto itr = x.begin(); itr != x.end(); itr++){
    if (itr->second == maxNum){
      cout << itr->first << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 25216
def examA():
    N, X, T = LI()
    ans = (1 + (N-1)//X)*T
    print(ans)
    return

def examB():
    N = SI()
    s = 0
    for n in N:
        s += int(n)
    if s%9==0:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 10768
def main():
  n = int(input())
  a = list(map(int, input().split()))
  a = sorted(a)
  a_i = a[-1]
  a_j = 0
  dist = a_i
  for i in range(len(a)-1):
    if abs(a_i/2-a[i]) < dist:
      a_j = a[i]
      dist = abs(a_i/2-a[i])
  print(a_i, a_j)

if __name__ == "__main__":
  main()

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

int main(int argc, const char * argv[]) {
    int men[6];
    int men1;
    string cmd;
    
    for ( int i = 0; i < 6 ; i++){
        cin >> men[i];
    }
    cin >> cmd;
    
    for(int i = 0;cmd[i] != '\0';i++){
        switch (cmd[i]) {
            case 'E':
                men1   = men[0];
                men[0] = men[3];
                men[3] = men[5];
                men[5] = men[2];
                men[2] = men1;
                break;
                
            case 'W':
                men1   = men[0];
                men[0] = men[2];
                men[2] = men[5];
                men[5] = men[3];
                men[3] = men1;
                break;
                
            case 'N':
                men1   = men[0];
                men[0] = men[1];
                men[1] = men[5];
                men[5] = men[4];
                men[4] = men1;
                break;
                
            case 'S':
                men1   = men[0];
                men[0] = men[4];
                men[4] = men[5];
                men[5] = men[1];
                men[1] = men1;
                break;
            default:
                break;
        }
    }
    
    cout << men[0] << endl;
    
    return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
vector<int>ansl;
string s;
int main(){
  int M,N_MIN,N_MAX;

  cin >>M>>N_MIN>>N_MAX;
  while(!((M==0)&&(N_MIN==0)&&(N_MAX==0))){
    vector<int> v;
    for(int i = 0;i<M;i++){
      int x;
      cin >>x;
      v.push_back(x);
    }
    int ans = N_MIN-1;
    int gap = v[N_MIN-1]-v[N_MIN];
    for(int i = N_MIN;i <= N_MAX-1;i++){
      int z = v[i]-v[i+1];
      int mx = gap;
      gap = max(gap,z);
      if(mx != gap){
        ans = i;
      }
      if(mx == z){
          ans = i;
      }
    }
    ansl.push_back(ans+1);
    cin >>M>>N_MIN>>N_MAX;
  }

  for(int i = 0;i<(int)ansl.size();i++){
    cout <<ansl[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 100005;

int n, m, a[MAXN], k[MAXN];
LL b[MAXN];

inline void Solve(int l, int r)
{
	if (l < r)
	{
		b[1] += r - l;
		b[l + 1] -= r - l;
		b[r + 1] += r - l;
		k[l + 1] --;
		k[r + 1] ++;
		b[l + 1] += r + 1;
		b[r + 1] -= r + 1;
	}
	else
	{
		b[r + 1] += m + r - l;
		b[l + 1] -= m + r - l;
		k[1] --;
		k[r + 1] ++;
		b[1] += r + 1;
		b[r + 1] -= r + 1;
		k[l + 1] --;
		b[l + 1] += r + m + 1;
	}
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), m = Read();
	for (int i = 1; i <= n; i ++)
		a[i] = Read();
	for (int i = 1; i < n; i ++)
		Solve(a[i], a[i + 1]);
	LL ans = 1LL << 60;
	for (int i = 1; i <= m; i ++)
		k[i] += k[i - 1], b[i] += b[i - 1], ans = min(ans, 1LL * k[i] * i + b[i]);
	return printf("%lld\n", ans), 0;
}


Measured memory_bytes: 1792
// ref: https://img.atcoder.jp/abc084/editorial.pdf

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

vector<int> prime_list(const int size){
    vector<bool> v(size+1, true);
    v[0] = false;
    v[1] = false;
    
    for(int prime=2; prime<=size; ++prime){
        if(!v[prime]){ continue; }
        for(int tmp=2*prime; tmp<=size; tmp+=prime){ v[tmp]=false; }
    }
    
    vector<int> vPrime;
    for(int i=0; i<=size; ++i){
        if(v[i]){ vPrime.push_back(i); }
    }
    return vPrime;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    
    int Q; cin >> Q;
    
    int N=100000;
    vector<int> vPrime = prime_list(N);
    
    unordered_map<int,int> ht(vPrime.size());
    for(uint i=0; i<vPrime.size(); ++i){ ht[vPrime[i]]=1; }
    
    vector<int> vSimilar2017;
    for(uint i=0; i<vPrime.size(); ++i){
        if(ht.find((vPrime[i]+1)/2) != ht.end()){ vSimilar2017.push_back(vPrime[i]); }
    }
    
    vector<int> cSum(N+1, 0);
    for(uint i=0; i<vSimilar2017.size(); ++i){
        ++cSum[ vSimilar2017[i] ];
    }
    for(int i=1; i<=N; ++i){ cSum[i] += cSum[i-1]; }
    
    for(int i=0; i<Q; ++i){
        int l, r; cin >> l >> r;
        cout << (cSum[r] - cSum[l-1]) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < (int) n; i++)
#define forin(i, a, b) for(int i = a; i < (int) b; i++) 
#define rofin(i, a, b) for(int i = a; i > b; i--)
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(i) cout << #i << ": " << i << endl
using ll = long long;
using pii = pair<int, int>;

int n, m, v, p;
int a[1000000];

bool ok(int i) {
    int _v = max(0, v - (n - i) - (p - 1));
    ll cnt_v = 1ll * m * _v;
    int j = i - 1;
    
    while(cnt_v > 0 && j >= p) {
        if(a[i] + m - a[j] >= 0) {
            cnt_v -= a[i] + m - a[j];
        } else { break; }
        j--;
    }

    return (max(cnt_v, 0ll) + a[p-1] <= a[i] + m);
}



int main() {
    // freopen("c_input.txt", "r", stdin);
    // freopen("c_output.txt", "w", stdout);
    // freopen("c_error.txt", "r", stderr);
    crap
    cin >> n >> m >> v >> p;
    forn(i,n) { cin >> a[i]; }

    sort(a, a + n);
    reverse(a, a + n);

    int l = p - 1, r = n, mid;
    while(l+1<r) {
        mid = (l+r) / 2;
        if(ok(mid)) l = mid;
        else r = mid;
    }
    cout << (l+1) << endl;
    return 0;


}

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




int main() {
	//freopen("data_in.txt", "r",stdin);
	
	vector<int> v = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5,
		1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int x;
	cin >> x;
	cout << v[x - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, n, k, x,l;
    string s, t;
    ll ans = 0;
    double dans = 0;
    string sans = "Good";

    cin  >> a >> b;

    if(a>=13) ans=b;
    else if(a>=6) ans = b/2;
    else ans = 0;



    std::cout << ans << endl; 
    // std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int fill(int y, int x, int from, int to, vector<vector<int> > &panel){
	if(panel[y][x] != from) return 0;
	panel[y][x] = to;
	int ret = 1;
	for(int d=0; d<4; d++){
		ret += fill(y+dy[d], x+dx[d], from, to, panel);
	}
	return ret;
}

int solve(int step, int color, vector<vector<int> > &panel){
	if(step == 0){
		vector<vector<int> > tmp = panel;
		return fill(1, 1, tmp[1][1], 0, tmp);
	}
	int ret = 0;
	for(int i=1; i<=6; i++){
		if(i == panel[1][1]) continue;
		if(step==1 && i!=color) continue;
		vector<vector<int> > tmp = panel;
		fill(1, 1, tmp[1][1], i, tmp);
		ret = max(ret, solve(step-1, color, tmp));
	}
	return ret;
}

int main(){
	while(1){
		int h,w,c;
		cin >> h >> w >> c;
		if(h == 0) break;

		vector<vector<int> > panel(h+2, vector<int>(w+2, -1));
		for(int i=1; i<=h; i++){
			for(int j=1; j<=w; j++){
				cin >> panel[i][j];
			}
		}
		cout << solve(5, c, panel) << endl;
	}
	return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
const int INF = 1<<29;
using namespace std;
using ll = long long;
int main(){
    int a , b , c;
    cin >> a >> b >> c;
    if(a <= b * c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(void){

    int A,B,X;
    cin >> A >> B >> X;
    if(A/2>=B){
        if(X%500==0){
            cout << B*(X/500) << endl;
        }else{
            cout << B*(X/500 + 1) << endl;
        }
        }else{
        if(X%1000==0){
            cout << A*(X/1000) << endl;
        }else if(X%1000>500){
            cout << A*(X/1000 + 1) << endl;
        }else{
            if(A>=B){
                cout << A*(X/1000) + B << endl;
            }else{
                cout << A*(X/1000 + 1) << endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;

const long long MOD = 1000000007;
const int MAX = 2000001;
long long fac[MAX];
long long finv[MAX];
long long inv[MAX];

void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int H;
  int W;
  int A;
  int B;
  cin >> H >> W >> A >> B;

  comb_init();
  long long ans = 0;
  //long long prev_cum = 0;
  for(int i = 0; i < H - A; i++){
    long long tmp = comb(i + B - 1, i);
    long long tmp_add = (tmp * comb(H - 1 - i + W - 1 - B, H - 1 - i)) % MOD;
    //cout << tmp_add << endl;
    ans = (ans + tmp_add) % MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 47232
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	std::string str;
	std::cin >> str;
	std::cout << str.substr(0, 3) << '\n';
}

Measured memory_bytes: 3616
import java.util.Scanner;

class Main{

  static boolean binarySearch(int[] a, int x){
    int left = 0;
    int right = a.length;

    while(left < right){
      int k = (left + right) / 2;
      int w = a[k];
      if(w == x)
        return true;
      else if(x > w)
        left = k + 1;
      else
        right = k;
    }

    return false;
  }

  public static void main(String[] arsg){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int[] a = new int[n];

    for(int i = 0; i < n; i++)
      a[i] = stdIn.nextInt();

    int q = stdIn.nextInt();
    int count = 0;
    for(int i = 0; i < q; i++){
      int x = stdIn.nextInt();
      if(binarySearch(a, x))
        count++;
    }


    System.out.println(count);
  }
}

Measured memory_bytes: 81076
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#include <cctype>
#include <cstdlib>
using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;
typedef long long ll;

int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;

    /*if(s[k-1]=='A') s[k-1]='a';
    if(s[k-1]=='B') s[k-1]='b';
    if(s[k-1]=='C') s[k-1]='c';*/

    s[k-1]=s[k-1]-'A'+'a';

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
ll k (ll a){
    a--;
    ll ans =0;
    while(a != 0){
        ans += a;
        a--;
        
    }
    return ans;
}


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

    int x =0;
    int t= 0;
    REP(i,b){
        cin >> t;
        x += t;
    }

    if(a <= x){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
}



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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int a[3][3];
    rep(i,3) rep(j,3) cin >> a[i][j];
    int n; cin >> n;
    int b[n];
    rep(i,n) cin >> b[i];

    bool isa[3][3];
    rep(i,3) rep(j,3) isa[i][j] = false;

    rep(k,n){
        rep(i,3){
            rep(j,3){
                if(a[i][j] == b[k]){
                    isa[i][j] = true;
                }
            }
        }
    }
    /*
    rep(i,3){
        rep(j,3){
            cout << isa[i][j] << " ";
        }cout << endl;
    }
    */
    bool isbingo = false;


    rep(i,3){
        int cnt = 0;
        rep(j,3){
            if(isa[i][j] == true){
                cnt++;
            }
        }
        if(cnt == 3) isbingo = true;
    }

    rep(i,3){
        int cnt = 0;
        rep(j,3){
            if(isa[j][i] == true){
                cnt++;
            }
        }
        if(cnt == 3) isbingo = true;
    }

    int cnt1 = 0;
    int cnt2 = 0;
    rep(i,3){
        if(isa[i][i] == true) cnt1++;
        if(isa[3-1-i][i] == true) cnt2++;
    }
    if(cnt1 == 3 || cnt2 == 3) isbingo = true;

    if(isbingo) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3612
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	tmp := 0
	ans := 0
	for i := 0; i < n; i++ {
		a := nextInt()
		b := nextInt()
		if tmp < a {
			tmp = a
			ans = a + b
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3840
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	int a,b,c;
	cin >> a >> b >> c;
	int d=a;
	for (int i=0;i<b;i++) {
		if (a%b==c) {
			cout << "YES";
			return 0;
		}
		else {
			a+=d;
		}
	}
	cout << "NO";
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, m;
vector<int>e[2000];
ld dp[2000];
signed main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		e[u].push_back(v);
	}
	ld ans = inf;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= n; j++) dp[j] = 0;
		dp[1] = inf;
		for (int j = n - 1; j >= 1; j--) {
			ld sum = 0, ma = 0;
			for (int k = 0; k < e[j].size(); k++) {
				sum += dp[e[j][k]];
				ma = max(ma, dp[e[j][k]]);
			}
			if (j == i) {
				sum -= ma;
				if (e[j].size() == 1) {
					dp[j] = inf;
				}
				else {
					dp[j] = sum / (e[j].size() - 1) + 1;
				}
			}
			else {
				dp[j] = sum / e[j].size() + 1;
			}
		}
		ans = min(ans, dp[1]);
	}
	printf("%.20LF\n", ans);
}

Measured memory_bytes: 2560
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

struct edge {
    long long from;
    long long to;
    long long cost;
};

bool comp_edge(const edge &e1, const edge &e2) {
    return e1.cost < e2.cost;
}

struct UnionFind {
private:
    vector<int> par;
    vector<int> sizes;

public:
    UnionFind(int n)
            : par(n), sizes(n, 1) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int find(int x) {
        if (x == par[x]) return x;
        else return par[x] = find(par[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

    int getSize(int x) {
        return sizes[find(x)];
    }

    bool all_same() {
        bool b = true;
        for (int i = 0; i < par.size(); i++) if (!same(0, i)) b = false;
        return b;
    }

};

int main() {

    while (true) {

        long long N, M;
        cin >> N >> M;

        if (!(N | M)) break;

        vector<edge> edges;
        for (int i = 0; i < M; i++) {
            long long a, b, w;
            cin >> a >> b >> w;
            a--, b--;
            edges.push_back({a, b, w});
        }

        sort(edges.begin(), edges.end(), comp_edge);

        long long minV = LONG_LONG_MAX;
        for (int i = 0; i < edges.size(); i++) {
            UnionFind UF(N);
            vector<long long> costs;
            for (int j = i; j < edges.size(); j++) {
                long long from = edges[j].from;
                long long to = edges[j].to;
                if (!UF.same(from, to)) {
                    UF.unite(from, to);
                    costs.push_back(edges[j].cost);
                }
            }
            if (UF.all_same()) minV = min(minV, costs.back() - costs.front());
        }

        if (minV == LONG_LONG_MAX) cout << -1 << endl;
        else cout << minV << endl;
    }

    return 0;
}






























































Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

class UnionFind {
public:
  vector<int> par, rank;
  // if par is negative, it is a root, of which tree size is the abs-value.
  // rank represents depth
  UnionFind(int sz) : par(sz, -1), rank(sz, 0){}
  int find(int x){
    if(par[x]<0) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x, int y){
    x=find(x); y=find(y);
    if(x==y) return;
    if(rank[x] < rank[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    if(rank[x]==rank[y]) rank[x]++;
  }
  inline bool same(int x, int y){ return find(x) == find(y); }
  inline int size(int x){ return -par[find(x)]; }
};


bool solve(){
  string s;
  int q;
  cin>>s>>q;
  int n = s.size();
  vector<int> l(q),r(q);
  rep(i,q) cin>>l[i]>>r[i];

  if(n==1) return true;

  rep(i,q){
    l[i]--;
    if(l[i]<n/2 && (n+1)/2<r[i]){
      if(l[i] < n-r[i]){
        r[i] = n-r[i];
      }
      else if(n-r[i] < l[i]){
        swap(l[i], r[i]);
        l[i] = n - l[i];
      }
      else {
        // to ignore this
        l[i] = (n+1)/2;
        r[i] = (n+1)/2;
      }
    }
    else if(n/2<=l[i]){
      swap(l[i],r[i]);
      l[i] = n-l[i];
      r[i] = n-r[i];
    }
  }

  UnionFind uf(q);

  map<int,int> pos;
  // positions -> idx
  rep(i,q){
    if(pos.count(l[i])){
      uf.unite(i, pos[l[i]]);
    } else {
      pos[l[i]] = i;
    }
    if(pos.count(r[i])){
      uf.unite(i, pos[r[i]]);
    } else {
      pos[r[i]] = i;
    }
  }

  // build range group
  map<int,vector<int>> gp;
  rep(i,q){
    gp[uf.find(i)].pb(l[i]);
    gp[uf.find(i)].pb(r[i]);
  }

  vector<int> ranges(n/2+1, -1); // begin -> end
  for(auto &&pv : gp){
    auto &&v = pv.second;
    if(v.size()){
      uniq(v);
      rep(i,v.size()-1){
        ranges[v[i]] = v[i+1];
      }
    }
  }

  int crnt = 0;
  vector<int> memo(n/2+1, 0);
  rep(i,n/2){
    int req = (s[n-i-1] - s[i] + 26)%26;
    crnt = (crnt + memo[i]) % 26;
    if(crnt != req){
      if(ranges[i] == -1) return false;
      int add = (req + 26 - crnt)%26;
      memo[ranges[i]] = 26-add;
      crnt = (crnt + add) % 26;
    }
    assert(crnt == req);
  }

  return true;
}

int main(){
  if(solve()) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 6016
// 20:47 - 20:51
// debug: 20:51 - 21:03
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> pint;

const int N = (1 << 18) + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

int a[N];
pint b[N][2];
int ans[N];

int main(){
	ios::sync_with_stdio(0);

	int n; cin >> n;
	int m = 1 << n;
	for(int i=0; i<m; i++){
		cin >> a[i];	
		for(int j=i; j<m; j = (j+1) | i){
			if(a[i] >= b[j][0].fi){
				b[j][1] = b[j][0];
				b[j][0] = make_pair(a[i], i);
			}else if(a[i] >= b[j][1].fi){
				b[j][1] = make_pair(a[i], i);
			}
		}
	}

	for(int i=1; i<m; i++){
		ans[i] = ans[i-1];
		if(b[i][0].se != b[i][0].se)
			ans[i] = max(ans[i], b[i][0].fi + b[i][0].fi);
		if(b[i][0].se != b[i][1].se)
			ans[i] = max(ans[i], b[i][0].fi + b[i][1].fi);
		if(b[i][1].se != b[i][0].se)
			ans[i] = max(ans[i], b[i][1].fi + b[i][0].fi);
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 9216
#include <iostream>

using namespace std;

int main(){
	int N, M, sum = 0;
	cin >> N >> M;
	for (int i = 0; i < M; i++){
		int A;
		cin >> A;
		sum += A;
	}

	if (sum > N){
		cout << -1 << endl;
	} else {
		cout << N - sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>>
using namespace std;
int main()
{
  int a,b,c,cnt=0;
  cin>>a>>b>>c;
if(a==b && b!=c)
    cnt=1;
if(b==c && c!=a)
     cnt=1;

if(c==a && a!=b)
     cnt=1;

  if(cnt==1)
    cout<<"Yes";
  else
    cout<<"No";


   return 0;
}






Measured memory_bytes: 3620
nk = [int(x) for x in input().split()]
n = nk[0]
k = nk[1]
a = [int(x) for x in input().split()]

many = 1000000
cnt = [many for x in range(200001)]
kind = 0
for ai in a:
  if cnt[ai] == many:
    cnt[ai] = 1
    kind += 1
  else:
    cnt[ai] += 1

cnt.sort()
res = 0
if kind > k:
  for i in range(kind - k):
    res += cnt[i]

print(res)


Measured memory_bytes: 25748
#include <iostream>
#include <map>
#include <vector>

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define EACH(it, v) for (const auto& it : v)

lint C(int x)
{
    static lint cach[200001] = {0};
    if (x < 2) return 0;
    if (cach[x] == 0) cach[x] = (lint)x * (x - 1) / 2;
    return cach[x];
}

void resolve()
{
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> B;
    RPT0(i, N)
    {
        cin >> A[i];
        B[A[i]]++;
    }

    lint total = 0;
    EACH(it, B) total += C(it.second);

    RPT0(i, N)
    {
        lint ans = total - (B[A[i]] - 1);
        cout << ans << endl;
    }
}

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


Measured memory_bytes: 8320
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n],b,c;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    b=a[0];c = -1000000000;
    for(int i=1;i<n;i++){
        c=max(c,a[i]-b);
        b=min(b,a[i]);
    }
    cout << c << endl;
}



Measured memory_bytes: 3856
import math
from sys import stdin, stdout
 
def main():
	arr = [int(x) for x in stdin.readline().split()]
	H, A = arr
	count = 0
	while H > 0:
		H -= A
		count += 1
	stdout.write(str(count))
    
if __name__ == "__main__":
	main()

Measured memory_bytes: 2940
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<int>;


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

	if (n == 0)return false;

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

	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		ans += a[i] * n <= total;
	}

	cout << ans << endl;

	return true;
}


int main()
{
	while (solve());

	return 0;
}


Measured memory_bytes: 3156
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  int *A, *C, key, bangou;
  int *B;
  int n, i, j;
  int count=0, max;

  scanf("%d", &n);
  if(n<1 || n>=MAX) exit(1);
  
  A = malloc(sizeof(int)*n);
  C = malloc(sizeof(int)*n);
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
    if(A[i]<0 || A[i]>VMAX) exit(2);
  }
  
  max = A[0];
  for(i=1; i<n; i++) if(max < A[i]) max = A[i];
  B = malloc( (max+2)*sizeof(int) );

  /*for(i=0; i<=max; i++){
    for(j=0; j<n; j++){
      if(A[j] == i) count++;
    }
    B[i] = count;
    }*/
  
  for(i=0; i<n; i++) B[A[i]]++;
  for(i=0; i<=max+1; i++) B[i] = B[i] + B[i-1];
  //for(i=0; i<=max+1; i++) printf("%-2d",B[i]);

  //for(i=0; i<=max; i++) printf("%d ",B[i]);
  //printf("\n");

  for(i=n-1; i>=0; i--){
    C[B[A[i]]-1] = A[i];
    B[A[i]]--;
  }

  //for(i=0; i<=max+1; i++) printf("%-2d", B[i]);
  
  for(i=0; i<n; i++){
    printf("%d",C[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 17420
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		String s = fs.next(), T = fs.next();
		int a = fs.nextInt(), b = fs.nextInt();
		String u = fs.next();
		
		if(u.equals(s)) {
			a--;
		}
		else {
			b--;
		}
		System.out.println(a + " " + b);
		
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
struct P{int x,y;};
int H, W;
bool S[400][400];
bool d[400][400];

bool check(int y, int x){
	return y>=0 and y<H and x>=0 and x<W;
}
ll bfs(int x, int y){
	ll bc = 1, wc = 0;
	queue<P> q;
	q.push(P{x,y});
	d[y][x] = true;
	while(!q.empty()){
		P p = q.front(); q.pop();
		rep(i, 4){
			int nx = p.x + dx[i], ny = p.y + dy[i];
			if(check(ny, nx) and S[ny][nx]!=S[p.y][p.x] and !d[ny][nx]){
				d[ny][nx]=true;
				if(S[ny][nx])
					bc++;
				else
					wc++;
				q.push(P{nx,ny});
			}
		}
	}
	return bc * wc;
}
void solve(){
	ll ans = 0;
	rep(i, H){
		rep(j, W){
			if(S[i][j] && !d[i][j]){
				ans += bfs(j, i);
			}
		}
	}
	cout<<ans<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>H>>W;
	rep(i, H)
		rep(j, W) {
			char s;
			cin>>s;
			S[i][j] = s=='#';
		}
		solve();
	return 0;
}


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

bool isPrime(int n){
    if(n == 2) return true;
    if(n % 2 == 0) return false;
    
    double sqrtNum = sqrt(n);
    for (int i = 3; i <= sqrtNum; i+=2) {
        if(n % i == 0) return false;
    }
    return true;
}

int main() {

    int input;
    while(cin >> input,input){
        int count = 0;
        int sum = 0;
        for (int i = 2;; ++i) {
            if (isPrime(i)) {
                count++;
                sum += i;
                if(count == input){
                    cout << sum << endl;
                    break;
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int gcd(int x,int y){
	if(y==0)return x;
	return gcd(y,x%y);
}
int mod_pow(int x,int y,int m=mod){
	int res=1;
	while(y>0){
		if(y&1)res=(__int128_t(res)*x)%m;
		y>>=1;x=(__int128_t(x)*x)%m;
	}
	return res;
}

bool prime(int n){
	if(n<2||n%2==0)return n==2;
	int d=n-1;while(d%2==0)d>>=1;
	for(int x:{2,325,9375,28178,450775,9780504,1795265022}){
		if(n<=x)break;
		int t=d,y=mod_pow(x,t,n);
		while(t!=n-1&&y!=1&&y!=n-1){
			y=(__int128_t(y)*y)%n;t<<=1;
		}
		if(y!=n-1&&t%2==0)return false;
	}return true;
}
int rho(int n){
	if(n%2==0)return 2;
	int MOD=n;
	auto f=[&](int x){return ((__int128_t)x*x+1)%MOD;};
	auto g=[](int x,int y){
		if(x<y)return y-x;
		return x-y;
	};
	for(int x1=0;;x1++){
		for(int x=x1,y=f(x);;x=f(x),y=f(f(y))){
			int d=gcd(g(y,x),n);
			if(1<d&&d<n)return d;
			if(d==n)break;
		}
	}
}
vector<int>factor(int n){
	if(n==1)return {};
	if(prime(n))return {n};
	int d=rho(n);
	vector<int>res=factor(d);
	for(int i:factor(n/d))res.pb(i);
	return res;
}
int N,A[100005];
signed main(){
	cin>>N;
	map<int,int>mp1,mp2;
	rep(i,N){
		int a;cin>>a;
		auto v=factor(a);
		map<int,int>mp;
		for(int i:v)mp[i]++;
		int n=1,m=1;
		for(auto &p:mp){
			p.second%=3;
			rep(j,p.second)n*=p.first;
			rep(j,(3-p.second)%3)m*=p.first;
		}
		mp1[n]++;mp2[n]=m;
	}
	int ans=0;
	for(auto p:mp1){
		if(mp2[p.first]>p.first&&mp1[mp2[p.first]])continue;
		if(p.first==1)ans+=1;
		else ans+=max(p.second,mp1[mp2[p.first]]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 23808
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };


int main()
{
	while (true)
	{
		int W, H;
		cin >> W >> H;
		if (W == 0 && H == 0) break;

		char C[30][30];
		int B[30][30];

		int sx = -1; int sy = -1;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cin >> C[i][j];
				B[i][j] = 0;
				if (C[i][j] == '@')
				{
					sy = i;
					sx = j;
				}
			}
		}

		queue<pi> Q;
		Q.push(pi(sy, sx));
		B[sy][sx] = 1;
		int ans = 1;
		while (!Q.empty())
		{
			int ty = Q.front().first; int tx = Q.front().second;
			Q.pop();

			for (int r = 0; r < 4; r++)
			{
				int y = ty + dd[r];
				int x = tx + dd[r + 1];
				if (y < 0 || y >= H || x < 0 || x >= W)continue;
				if (C[y][x] == '#')continue;
				if (B[y][x])continue;
				ans++;
				B[y][x] = 1;
				Q.push(pi(y, x));
			}
		}

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

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

int main(){
    string s;
    cin >> s;
    int cnt = 0, temp = 0;
    rep(i, 3){
        if(s[i] == 'R')temp++;
        else{
            cnt = max(cnt, temp);
            temp = 0;
        }
    }
    cnt = max(cnt, temp);
    cout << cnt << endl;
}

Measured memory_bytes: 3596
s = gets.chomp
t = gets.chomp
shash = Hash.new { |h, k| h[k] = [] }
thash = Hash.new { |h, k| h[k] = [] }
s.size.times do |i|
  shash[s[i]] << i
  thash[t[i]] << i
end

puts shash.values == thash.values ? "Yes" : "No"


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

typedef struct {
    int x,y;
}Vec;

typedef struct{
    int A;
    Vec *Tes;
} Human;

int main(){
    int N,i,j;
    // 入力---------
    scanf("%d",&N);
    Human *Hum = malloc(sizeof(Human)*N);
    for(i=0;i<N;i++){
        scanf("%d",&Hum[i].A);
        Hum[i].Tes=malloc(sizeof(Vec)*Hum[i].A);
        for(j=0;j<Hum[i].A;j++) scanf("%d %d",&Hum[i].Tes[j].x,&Hum[i].Tes[j].y);
    }
    int bit,max=0;
    for(bit=0;bit<(1<<N);bit++){
        int flag=0,num=0;
        for(i=0;i<N && (!flag);i++){
            if((bit>>i)&1) {//i桁目のビットが立っていたらHum[i]が正直者
                num++;
                for(j=0;j<Hum[i].A;j++){//証言に合致するか検証
                    int index = Hum[i].Tes[j].x-1;
                    //証言に合致しないものを見つけたら旗を立てる
                    if(((bit>>index)&1)!=Hum[i].Tes[j].y) flag=1;
                }
            }
        }
        if(!flag && max < num) max = num;
    }
    printf("%d\n",max);
}

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

void solve(int n, int arr[], pair<int, long long> st[][40], long long k)
{
    int pos = 0;
    for (int i = 39; i != -1; --i)
    {
        while (k > st[pos][i].second)
        {
            k -= st[pos][i].second;
            pos = st[pos][i].first;
        }
    }
    
    vector<bool> kek(200000);
    deque<int> s;
    
    while (k--)
    {
        for (int i = pos; i != n; ++i)
        {
            if (kek[arr[i]])
            {
                while (s.back() != arr[i])
                {
                    kek[s.back()] = 0;
                    s.pop_back();
                }
                kek[s.back()] = 0;
                s.pop_back();
            }
            else
            {
                kek[arr[i]] = 1;
                s.push_back(arr[i]);
            }
        }
        pos = 0;
    }
    
    for (int x : s)
        cout << x + 1 << ' ';
    cout << '\n';
}

int main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);
    
    int n;
    long long k;
    cin >> n >> k;
    
    int arr[n];
    vector<int> positions[200000];
    for (int i = 0; i != n; ++i)
    {
        cin >> arr[i];
        arr[i]--;
        
        positions[arr[i]].push_back(i);
    }
    
    vector<int> counters(200000);
    pair<int, long long> st[n][40];
    for (int i = 0; i != n; ++i)
    {
        int x = arr[i];
        
        if (counters[x] + 1 == positions[x].size())
            st[i][0] = make_pair(positions[x].front() + 1, 1LL);
        else
            st[i][0] = make_pair(positions[x][counters[x] + 1] + 1, 0LL);
        
        if (st[i][0].first == n)
        {
            st[i][0].first = 0;
            st[i][0].second++;
        }
        
        counters[x]++;
    }
    
    for (int j = 1; j != 40; ++j)
        for (int i = 0; i != n; ++i)
            st[i][j] = make_pair(st[st[i][j - 1].first][j - 1].first, st[st[i][j - 1].first][j - 1].second + st[i][j - 1].second);
    
    solve(n, arr, st, k);
    
    return 0;
}

Measured memory_bytes: 139904