akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main()
{
    int m, f, r;
    while(true)
    {
        cin>>m>>f>>r;
        int t = m+f;
        if((m+f+r)==-3)
        {
            break;   
        }
        else if((m==-1)||(f==-1))
        {
            cout<<'F'<<endl;
        }
        else if(t>=80)
        {
            cout<<'A'<<endl;
        }
        else if(t>=65)
        {
            cout<<'B'<<endl;
        }
        else if(t>=50)
        {
            cout<<'C'<<endl;
        }
        else if(t>=30)
        {
            if(r>=50)
            {
                cout<<'C'<<endl;
            }
            else
            {
                cout<<'D'<<endl;
            }
        }
        else
        {
            cout<<'F'<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  int N=0,ans=753;
  cin>>S;
  for(int i=0;i<S.size()-2;i++){
    int x=abs(753-(S[i]-'0')*100-(S[i+1]-'0')*10-(S[i+2]-'0'));
    ans=min(x,ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    std::vector<int> h;
    for (int i = 0; i < n; i++) {
        int m1;
        cin >> m1;
        h.push_back(m1);
    }

    std::sort(h.begin(), h.end());
    int result = 1000000001;
    for (int i = 0; i <= n - k; i++) {
        int temp = h[i + k - 1] - h[i];
        if (temp < result)
            result = temp;
    }
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 892
h,w,K=map(int,input().split())
s=[list(input()) for i in range(h)]
from itertools import groupby
ans=10**18
for i in range(1<<h):
  pre=-1
  c=[]
  t_cnt=0
  op=[-1]*h
  for j in range(h):
    if i&(1<<j):op[j]=1
    else:op[j]=0
  gr=groupby(op)
  l=[]
  for key,g in gr:
    l.append(len(list(g)))
  c=[[0]*w for _ in range(len(l))]
  idx=0
  jdx=0
  for idx,li in enumerate(l):
    for k in range(li):
      for a in range(w):
        c[idx][a]+=int(s[jdx][a])
      jdx+=1
  # print(c)
  t_cnt=len(c)-1
  t_cnt1=0
  c_mx=[0]*len(c)
  ok=True
  for a in range(w):
    for b in range(len(c)):
      if c[b][a]>K:
        ok=False
      c_mx[b]+=c[b][a]
      if c_mx[b]>K:
        t_cnt1+=1
        c_mx=[0]*len(c)
        for b in range(len(c)):
          c_mx[b]+=c[b][a]
        break
  if ok:
    ans=min(ans,t_cnt+t_cnt1)
if ans==10**18:
  print(0)
else:
  print(ans)


Measured memory_bytes: 64092
var
  s:string;
  i,a,b,n:longint;
begin
  read(s);
  if s[1]<>'A' then
    begin
      write('WA');
      exit;
    end;
  for i:=3 to length(s)-1 do
    if s[i]='C' then inc(a);
      if a<>1 then
        begin
          write('WA');
          exit;
        end;
  for i:=1 to length(s) do
    if (s[i]>='a') and (s[i]<='z') then inc(b);
      if b<>length(s)-2 then
        begin
          write('WA');
          exit;
        end;
  write('AC');
end.

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

int main(){

    // 1. 入力情報.
    char a[111], b[111];
    scanf("%s %s", a, b);
    string A(a), B(b);
    
    // 2. A, B の 大小を比較.
    string ans = "EQUAL";
    int la = A.size(), lb = B.size();
    if(la != lb)           ans = (la > lb) ? "GREATER" : "LESS";
    if(la == lb && A != B) ans = (A > B) ? "GREATER" : "LESS";
    
    // 3. 出力.
    printf("%s\n", ans.c_str());
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    long double A,B,H,M,a, c ,b;
    cin >> A >> B >> H >>M;
    c = H*30+M*0.5 - M*6;
    if(c < 0){
        c = c *-1;
    }
    if(c > 180){
        c = 360 -c;
    }
    c = c / 180 * 3.14159265358979323846264338327950288419716939937;
    b = A*A+B*B-2*A*B*cos(c);
    b = sqrt(b);
    cout << setprecision(15) <<b;
}

Measured memory_bytes: 4164
N = int(input())
A = map(int, input().split())
Q = int(input())
CONV = dict()

Bl = [0] * Q
Cl = [0] * Q

for _ in range(Q):
    B, C = map(int, input().split())
    CONV[B] = C
    Bl[_] = B
    Cl[_] = C

# print("conv", CONV)
from collections import defaultdict
VAL = defaultdict(int)

for a in A:
    VAL[a] += 1
# print("DEF:", VAL)
DEF = 0
for i, j in VAL.items():
    DEF += i * j
# DEF = sum(VAL.keys())
# print("DEFAULT:", DEF)
for qi in range(Q):
    k = Bl[qi]
    v = Cl[qi]
    if k in VAL.keys():
        DEF += -k*VAL[k] + v*VAL[k]
        VAL[v] += int(VAL[k])
        # print("VAL[{}]={}".format(v, VAL[k]))
        del VAL[k]
    print(DEF)
    # print(VAL)

# ans = 0
# for val, cnt in VAL.items():
#     ans += val * cnt

# print(ans)



Measured memory_bytes: 33420
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

const ll MOD = 1e9+7;


signed main(){
    ll h,w,d;
    cin >> h >> w >> d;
    ll grid[h][w] = {};
    P pos[h*w] = {};
    
    rep(i,0,h) rep(j,0,w){
        cin >> grid[i][j];
        grid[i][j]--;
        pos[grid[i][j]] = P(i,j);
    }

    ll memo[h*w] = {};
    rep(i,0,d){
        ll temp = i+d;
        while(temp < h*w){
            memo[temp] = memo[temp - d] + abs(pos[temp].fs - pos[temp-d].fs) + abs(pos[temp].sc - pos[temp-d].sc);
            temp += d;
        }
    }
    ll q,r,l;
    cin >> q;
    rep(i,0,q){
        cin >> l >> r;
        cout << memo[r-1] - memo[l-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 6408
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int l[1000000],r[1000000];
main()
{
    int n,m,lm=0,rm=999999;
    cin>>n>>m;
    for(int i=1; i<=m; i++)
    {
        cin>>l[i]>>r[i];
        lm=max(lm,l[i]);
        rm=min(rm,r[i]);

    }
    cout<<max(0LL,rm-lm+1)<<endl;

    return 0;
}


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

public class Main {
	static int mod = (int) 1e9 + 7;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int x[] = fs.nextIntArray(n);
		long d[] = new long[n-1];
		
		for(int i=0;i<n-1;i++) {
			d[i] = x[i+1]-x[i];
		}

		long c[] =  new long[n-1];
		c[0]=1;
		for(int i=1;i<n-1;i++) {
			c[i]= mplu(c[i-1] , mdiv(1,i+1)) ;
		}
		
		long ans = 0;
		for(int i=0;i<n-1;i++) {
			ans = mplu(ans, mmul(c[i],d[i]));
		}
		
		for(int i=0;i<n-1;i++) {
			ans = mmul(ans, n-i-1);
		}
		System.out.println(ans);
		
	}
	
	static long mplu(long x, long y) {
		x %= mod;
		y %= mod;
		long res = (x + y) % mod;
		return res;		
	}
	
	static long mdif(long x, long y) {
		x %= mod;
		y %= mod;
		long res = (x - y + mod) % mod;
		return res;		
	}
	
	static long mmul(long x, long y) {
		x %= mod;
		y %= mod;
		long res = x * y % mod;
		return res;		
	}
	
	static long mdiv(long x, long y) {
		x %= mod;
		y %= mod;
		long res = x * modpow(y, mod - 2) % mod;
		return res;
	}
	
	//modの元での高速pow()
	static long modpow(long a, long p) {
		if (p == 0)
			return 1;
		if (p % 2 == 0) {
			long halfP = p / 2;
			long root = modpow(a, halfP);
			return root * root % mod;
		} else
			return a * modpow(a, p - 1) % mod;
	}

	
}

//高速な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: 38564
#include<stdio.h>
#include<stdlib.h>

#define MAX 10000


int main(){

  unsigned short *arr, *p;

  int n, i, j;

  scanf("%d",&n);
  arr = malloc(sizeof(short)*n+1);
  p = malloc(sizeof(short)*n+1);
  int c[MAX+1];  

  for( i = 0; i <= MAX; i++)
    c[i] = 0;

  for( i = 0; i < n; i++){
    scanf("%d", &arr[i+1]);
    c[arr[i+1]]++;
  }

  for( i = 1; i <= MAX; i++)
    c[i] = c[i] + c[i - 1];

  for( i = 1; i <= n; i++){
    p[c[arr[i]]] = arr[i];
    c[arr[i]]--;
  }

  for( i = 1; i <= n; i++){

    printf("%d",p[i]);

    if(i != n)
      printf(" ");
  }
  printf("\n");

  return 0;

}

Measured memory_bytes: 8456
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int dp[100005][105];
int32_t main()
{
	int n,w;
	cin>>n>>w;
	int we[n],val[n];
	for(int i=0;i<n;++i)
	cin>>we[i]>>val[i];
	for(int i=0;i<100005;++i)
	for(int j=0;j<105;++j)
	dp[i][j]=INT_MAX;
	for(int i=0;i<105;++i)
	dp[0][i]=0;
	for(int i=0;i<100005;++i){
        for(int j=0;j<n;++j){
            if(i<val[j])
            dp[i][j+1]=dp[i][j];
            else
            dp[i][j+1]=min(dp[i][j],dp[i-val[j]][j]+we[j]);
        }
    }
    int ans=0;
    for(int i=0;i<=100005;++i){
        for(int j=0;j<105;++j){
            if(dp[i][j]<=w &&  i>ans && dp[i][j]!=0) 
            ans=i;
        }
      //  cout<<endl;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 82304
#include<cstdio>
int a[5],b[5];
bool vis[5];
bool dfs(int u,int h){
	if(h==4)return 1;
	vis[u]=1;
	for(int i=0;i<3;i++)if(a[i]==u&&!vis[b[i]]&&dfs(b[i],h+1)||b[i]==u&&!vis[a[i]]&&dfs(a[i],h+1))return 1;
	vis[u]=0;
	return 0;
}
int main(){
	for(int i=0;i<3;i++)scanf("%d%d",&a[i],&b[i]);
	puts(dfs(1,1)?"YES":"NO");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(T N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
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; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {

	const ll nb = 998244353;

	const ll N = inputVal<ll>();
	vector<ll> D(N);
	inputVec(D);

	if (D[0] != 0) {
		outputVal(0);
		return;
	}

	vector<ll> layer(N,0);
	for (int i = 0; i < N; ++i) {
		++layer[D[i]];
	}

	bool foundzero = false;
	for (int i = 0; i < N; ++i) {
		if (layer[i] == 0) {
			foundzero = true;
		}
		else {
			if (foundzero) {
				outputVal(0);
				return;
			}

		}
	}

	if (layer[0] != 1) {
		outputVal(0);
		return;
	}

	ll cnt = 1;
	for (int i = 1; i < N; ++i) {
		if (layer[i] == 0) break;
		ll m = layer[i-1];
		for (int n = 1; n < layer[i]; ++n) {
			// m = static_cast<ll>(m * (layer[i - 1] % nb)) % nb;
			m = (m * layer[i - 1]) % nb;
		}
		// const ll m = static_cast<ll>(pow(layer[i - 1], layer[i])) % nb;
		cnt = ((cnt * m) % nb);
	}
	outputVal(cnt);
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << std::fixed << std::setprecision(15);
	Main();

	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    int enem[n+1];
    int warr[n];
    for(int i = 0;i <= n;i++){
        scanf("%d",&enem[i]);
    }

    for(int i = 0;i < n;i++){
        scanf("%d",&warr[i]);
    }

    long long int count = 0;
    for(int i = 0;i < n;i++){
        if (enem[i] > warr[i]){
            count += warr[i];
        } else {
            warr[i] -= enem[i];
            count += enem[i];
            if(enem[i+1] > warr[i]){
                enem[i+1] -= warr[i];
                count += warr[i];
            } else {
                count += enem[i+1];
                enem[i+1] = 0;
            }
        }
    }

    printf("%lld",count);
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(void){

    int N, K;
    cin >> N >> K;    
    char S[N];
    for(int i = 0; i < N; i++){
        cin >> S[i];
    }

    switch(S[K-1]){
        case 'A':
            S[K-1] = 'a';
            break;
        case 'B':
            S[K-1] = 'b';
            break;
        case 'C':
            S[K-1] = 'c';
            break;
        default:
            break;
    }

    for(int i = 0; i < N;i++){
        cout << S[i];
    }
    cout << endl;

    return 0;
}

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

int main(void){
	int a,b,add,sub,mul,max;
	
	scanf("%d %d",&a,&b);

	add=a+b;
	sub=a-b;
	mul=a*b;
	max=add>sub?add:sub;
	max=max>mul?max:mul;

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

	return 0;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (100006)
ll n, A[MAXN], cnt[MAXN];
set<int> s[MAXN];
set<int> av;
int main()
{
	FAST
	cin>>n;
	FOR(i,1,n)cin>>A[i], ++cnt[A[i]];
	if(n==2) {
		cout<<"-1\n";
		return 0;
	}
	FOR(i,1,n)s[cnt[i]].ins(i), av.ins(i);
	vector<ll> v;
	while(n-siz(v) > 3) {
		ll V = n-siz(v);
		ll tp = -1;
		assert(siz(s[V])==0);
		if(siz(s[V-1])) {
			tp = *s[V-1].begin();
		} else {
			if(v.empty() || A[v.back()] != *av.begin()) {
				tp = *av.begin();
			} else {
				tp = *++av.begin();
			}
		}
		assert(~tp);
		v.pb(tp);
		av.erase(tp);
		s[cnt[tp]].erase(tp);
		if(av.find(A[tp]) != av.end()) {
			s[cnt[A[tp]]].erase(A[tp]);
			-- cnt[A[tp]];
			s[cnt[A[tp]]].ins(A[tp]);
		}
	}
	assert(n-siz(v)==3);
	/* next permutation here */
	vector<ll> hey = {*av.begin(), *++av.begin(), *++++av.begin()};
	vector<ll> lol = {0, 1, 2};
	do {
		v.pb(hey[lol[0]]), v.pb(hey[lol[1]]), v.pb(hey[lol[2]]);
		bool fk=1;
		FOR(i,max(0ll,n-4),n-2) if(A[v[i]] == v[i+1]) {
			fk=0;
		}
		if(fk) break;
		v.pop_back(), v.pop_back(), v.pop_back();
	} while(next_permutation(all(lol)));
	/* */
	assert(v.size()==n); for(auto i:v) cout<<i<<' '; cout<<'\n'; 
}


Measured memory_bytes: 16512
#include <iostream>

using namespace std;

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

  int ans = 0;
  for (int i=a; i<=b; ++i) {
    if ((i/10000 == i%10) && ((i/1000)%10 == (i/10)%10))
      ans++;
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int N;
  while(cin >>N && N){
    bool f = false;
    vector<int> v(N);
    REP(i, N) cin >>v[i];
    SORT(v);
    int l = 0, r = 0;
    REP(i, N){
      if(r + 1 != N && v[i] + 1 == v[i + 1]){
        ++r;
        continue;
      } else{
        if(f) cout <<" ";
        f = true;
        if(l != r) cout <<v[l] <<"-" <<v[r];
        else cout <<v[r];
        l = i + 1; r = i + 1;
      }
    }
    cout <<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S;
    cin >> S;
    bool ok = 1;
    if(S[0] != 'A')ok = 0;
    if(S[1]-'a'<0 || S[S.size()-1] - 'a'<0)ok = 0;
    sort(ALL(S));
    S[0]+='a' - 'A';
    if(S[1] != 'C'){
        ok = 0;
    }else{
        S[1]+='a' - 'A';
    }
    REP(i,S.size()){
        if(S[i]-'a'<0)ok = 0;
    }
    cout << (ok ? "AC" : "WA") << "\n";
}

Measured memory_bytes: 256
n = int(input())

a = [0 for i in range(n+5)]

for i in range(1,n+2):
    b = a[i-1]+1
    c = 1
    d = 1
    while c*6 <= i:
        c *= 6
        b = min(a[i-c]+1,b)
    while d*9 <= i:
        d *= 9
        b = min(a[i-d]+1,b)
    a[i] = b
print(a[n])

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

long long N, M;
vector<pair<long long, long long> > AB;

int main(){
	cin >> N >> M;
	for(long long i = 0; i < N; i++){
		long long a, b;
		cin >> a >> b;
		AB.push_back(make_pair(a, b));
	}
	sort(AB.begin(), AB.end());
	priority_queue<long long> Q;

	long long abidx = 0;
	long long ans = 0;

	for(long long i = 1; i <= M; i++){
		while(abidx < AB.size() && AB[abidx].first == i){
			Q.push(AB[abidx].second);
			abidx++;
		}

		if(!Q.empty()){
			ans += Q.top();
			Q.pop();
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3568
d, n = map(int, input().split())
start = 100 ** d
counter = 0
while True:
    if start % (100 ** d) == 0 and start % (100 ** (d + 1)) != 0:
        counter += 1
    if counter == n:
        print(start)
        break
    start += 100 ** d


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
constexpr ll inf = 1e9;

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

  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  auto atmp = a, btmp = b;
  sort(atmp.begin(), atmp.end());
  sort(btmp.begin(), btmp.end());
  for (int i = 0; i < n; i++) {
    if (atmp[i] > btmp[i]) {
      //cerr << "!" << endl;
      cout << "No" << endl;
      return 0;
    }
  }
  vector<int> idx(n);
  iota(idx.begin(), idx.end(), 0);
  sort(idx.begin(), idx.end(),
       [&](const int &lhs, const int &rhs) { return b[lhs] < b[rhs]; });
  set<P> st;
  for (int i = 1; i < n; i++) {
    int index = idx[i];
    st.insert(P(a[index], index));
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int index = idx[i];
    st.erase(P(a[index], index));
    if (a[index] <= b[index]) continue;
    cnt++;
    auto itr = st.upper_bound(P(b[index], inf));
    assert(itr != st.begin());
    itr--;
    int tar = (*itr).second;
    swap(a[index], a[tar]);
    st.erase(itr);
    st.insert(P(a[tar], tar));
  }
  cout << (cnt <= n - 2 ? "Yes" : "No") << endl;
}


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

using namespace std;

typedef long long   ll;
typedef long double ld;

#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll solve(int N, const vector<ll> & A) {
  ll res=0;
  ll h=A[0];
  rep(i, N)
    if (h < A[i]) h = A[i];
    else res += h - A[i];
  return res;
}

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

  int N;
  cin >> N;
  vector<ll> A(N);
  rep (i, N) {
    cin >> A[i];
  }

  auto ans = solve(N, A);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4364
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    x,y,z=parseMap(split(readline()))
    println(div(x-z,y+z))
end
main()

Measured memory_bytes: 112668
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
int mod = 1000000000 + 7;
int dp[101][4][4][4];
int main()
{
        //input->compute->output//

        int N, M;
        cin >> N >> M;
        vector<int> A(N), B(N);
        for (int i = 0; i < N; i++)
        {
                cin >> A[i] >> B[i];
        }

        vector<pair<int, int>> vec(N);
        for (int i = 0; i < N; i++)
        {
                vec[i] = make_pair(A[i], B[i]);
        }
        sort(vec.begin(), vec.end());

        ll ans = 0;
        for (int i = 0; i < N; i++)
        {
                int cnt = min(M, vec[i].second);
                ans += (ll)cnt * vec[i].first;
                M -= cnt;
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
//#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);

string s;
int a[500000];
vector <pair <char, int>> v;

ll summ(int l, int r)
{
	ll ans = 0;
	for (ll i = l; i <= r; i++)
		ans += i;
	return ans;
}


int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> s;
	v.pb(mp(s[0], 0));
	for (int i = 0; i < s.length(); i++)
		if (v.back().first == s[i])
			v.back().second++;
		else
			v.pb(mp(s[i], 1));
	ll ans = 0;
	for (int i = 0; i < v.size(); i++)
	{
		if (v[i].first == '<')
		{ 
			if (i + 1 == v.size())
			{
				ans += summ(0, v[i].second);
				break;
			}
			if (v[i + 1].second >= v[i].second)
				ans += summ(0, v[i].second - 1);
			else
				ans += summ(0, v[i].second);
		}
		else
		{
			if (i == 0)
			{
				ans += summ(0, v[i].second);
				continue;
			}
			if (v[i - 1].second > v[i].second)
				ans += summ(0, v[i].second - 1);
			else
				ans += summ(0, v[i].second);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3352
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;


int main() {
	int n; cin >> n;
	int a[100000];
	int mainasu = 0;
	int checkl = 0;
	int checkr = 0;

	int m = INF;

	bool check = false;

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 0) {
			check = true;
		}
		else {
			m = min(m, abs(a[i]));
		}
		if (a[i] < 0) {
			mainasu++;
		}
		
	}

	if (check) {
		for (int i = 0; i < n; i++) {
			ans += abs(a[i]);
		}
	}
	else {
		if (mainasu % 2 == 0) {
			for (int i = 0; i < n; i++) {
				ans += abs(a[i]);
			}
		}
		else {
			for (int i = 0; i < n; i++) {
				ans += abs(a[i]);
			}
			ans -= 2*m;
		}
	}

	cout << ans << endl;







}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 2007;
int n, ans;
bitset<N>defeat[N], R[N], L[N];
char s[N];
int main() {
#ifdef fwat
#endif
	n = gi();
	rep(i, 2, n) {
		scanf("%s", s + 1);
		rep(j, 1, i - 1) {
			int x = s[j] - '0';
			defeat[i][j] = x;
			defeat[j][i] = x ^ 1;
		}
	}
	rep(i, 1, n) R[i][i] = L[i][i] = 1;
	
	rep(len, 2, n) {
		rep(l, 1, n - len + 1) {
			int r = l + len - 1;
			if((R[l + 1] & L[r] & defeat[l]).any()) L[r][l] = 1;
			if((R[l] & L[r - 1] & defeat[r]).any()) R[l][r] = 1;
		}
	}
	rep(i, 1, n) if(R[1][i] && L[n][i]) ++ans;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main(){
	char O[51], E[51];
	cin >> O >> E;
	for(int i = 0; i < 50; i++){
		if(O[i] == '\0'){
			break;
		}
		cout << O[i];
		if(E[i] == '\0'){
			break;
		}
		cout << E[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
require 'pp'

_ = gets.chomp!.to_i
a_n = gets.chomp!.split(" ").map(&:to_i)
KIND = 8

g = a_n.group_by {|x|
    if x < 400
        'gray'
    elsif x < 800
        'brown'
    elsif x < 1200
        'green'
    elsif x < 1600
        'lightblue'
    elsif x < 2000
        'blue'
    elsif x < 2400
        'yellow'
    elsif x < 2800
        'orange'
    elsif x < 3200
        'red'
    else
        'other'
    end
}

k = 0

if g['other']
    k = g['other'].length
    min = [1, g.length - 1].max
    max = g.length - 1 + k
else
    min = g.length
    max = g.length
end

puts "#{min} #{max}"


Measured memory_bytes: 2172
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);i--)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,k;
  string s;
  cin >> n >> k >> s;
  
  s[k-1] = (char)(s[k-1]+32);

  cout << s << endl;


  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;i++) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int cnt[5];

int main()
{jizz
	int a,b,c=0;
	for(int i=0;i<3;++i)
		cin >> a >> b,++cnt[a],++cnt[b];
	for(int i=1;i<=4;++i)
		if(cnt[i]&1) ++c;
	if(c<=2) cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
const int nmax=505;
pair<int,int> v[nmax];
vector<int> ad[nmax];
int a[nmax*nmax],ans[nmax*nmax],fr[nmax*nmax];
int ini[nmax];
int p,u,n,i,j,curr,nr;
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>v[i].first;
        v[i].second=i;
        ini[i]=v[i].first;
    }
    sort(v+1,v+n+1);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<v[i].second;j++)
            a[++u]=v[i].second;
    }
    curr=1;
    for(i=1;i<=n*n;i++)
    {
        if(v[curr].first==i)
        {
            for(j=1;j<=n-v[curr].second;j++)
                fr[++nr]=v[curr].second;
            ans[i]=v[curr].second;
            curr++;
        }
        else
        {
            if(p<u)
            {
                ans[i]=a[++p];
            }
            else
            {
                if(nr) ans[i]=fr[nr--];
            }
        }
        ad[ans[i]].push_back(i);
    }
    for(i=1;i<=n;i++)
        if(ad[i].size()<n||ad[i][i-1]!=ini[i])
    {
        cout<<"No";
        return 0;
    }
    cout<<"Yes\n";
    for(i=1;i<=n*n;i++)
        cout<<ans[i]<<' ';
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll N;
    cin>>N;
    vll A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    sort(ALL(A));
    reverse(ALL(A));
    ll ans=0;
    for(int i=0;i<N;i++){
        if(i==0)continue;        
        ans+=A[i/2];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4840
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        int a = Integer.parseInt(scan.next());
        String strans = "";
        int intans = 0;

        int odd = 0;
        int eve = 0;
            if(a<1200){
                strans = "ABC";
            }else if(a<2800){
                strans = "ARC";
            }else{
                strans = "AGC";
            }
        PrintWriter out = new PrintWriter(System.out);
        out.println(strans);
        out.flush();
        scan.close();
    }
}

Measured memory_bytes: 22612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var h = input[0];
            var w = input[1];
            var maze = new char[w + 2, h + 2];

            for (var i = 1; i <= h; i++)
            {
                var line = Console.ReadLine();
                for (var j = 1; j <= line.Length; j++)
                {
                    maze[j, i] = line[j - 1];
                }
            }
            

            for (var i = 1; i <= h; i++)
            {
                for (var j = 1; j <= w; j++)
                {
                    if (maze[j, i] == '#')
                    {
                        var suc = false;
                        if(maze[j+1,i]=='#'|| maze[j - 1, i] == '#'|| maze[j, i+1] == '#'|| maze[j, i-1] == '#')
                        {
                            suc = true;
                        }
                        if (!suc)
                        {
                            Console.WriteLine("No");
                            return;
                        }
                    }
                }
            }

            Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 11348
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
 
using namespace std;
 
int main()
{
	long long n,k;
	cin>>n>>k;
	n=n%k;
	if(n>k-n)cout<<k-n<<endl;
	else cout<<n<<endl;
	return 0;
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

const int N = 2e5 + 10;

struct DSU {
    int p[N];

    DSU () {};
    DSU (int n) {
        forn(i, 0, n) p[i] = i;
    }

    int get(int i) {
        if (i == p[i]) return i;
        return p[i] = get(p[i]);
    }

    void unite(int i, int j) {
        i = get(i);
        j = get(j);
        p[i] = j;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, l;
    cin >> n >> k >> l;
    DSU a(n), b(n);
    forn(i, 0, k) {
        int u, v;
        cin >> u >> v;
        a.unite(--u, --v);
    }
    forn(i, 0, l) {
        int u, v;
        cin >> u >> v;
        b.unite(--u, --v);
    }
    map<pair<int, int>, int> cnt;
    forn(i, 0, n) cnt[{a.get(i), b.get(i)}]++;
    forn(i, 0, n) cout << cnt[{a.get(i), b.get(i)}] << ' ';
}


Measured memory_bytes: 13568
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
import java.util.Collections;
import java.util.Comparator;

class Main{
        public static void main(String args[]){
                Scanner scan = new Scanner(System.in);
                int A = scan.nextInt();
                int B = scan.nextInt();
                int X = scan.nextInt();

                if(A<=X && X<=A+B){
                        System.out.print("YES");
                }else{
                        System.out.print("NO");
                }
        }
}


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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;





int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	char c;
	cin >> c;

	cout << char(c + 1) << '\n';



	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


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

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

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

        c=c-b;
        if(c<=0){
            cout <<"Yes"<<endl;
            break;
        }
        a=a-d;
        if(a<=0){
            cout <<"No"<<endl;
            break;
    }
}
}

Measured memory_bytes: 3596
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Control.Monad.ST
import Control.Monad.State
import Control.Applicative
import Control.Arrow
import Data.List
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Data.Maybe
import Data.Bits
import Data.Ord
import Data.Ratio
import Data.Int
import Data.Char
import qualified Data.IntMap as IM
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set
import qualified Data.Sequence as Sq
import Data.Tuple
import Data.Function
import Text.Printf
import Debug.Trace
import Numeric

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

listToTuple2 [a,b] = (a,b)
listToTuple3 [a,b,c] = (a,b,c)
listToTuple4 [a,b,c,d] = (a,b,c,d)
listToTuple5 [a,b,c,d,e] = (a,b,c,d,e)

readIntBS = fst . fromJust . BS.readInt
  
for = flip map

infixr 1 ?
(?) :: Bool -> (a,a) -> a
(?) b t = (if b then fst else snd) t





main :: IO ()
main = do
  [a,b,c] <- sort . map read . words <$> getLine
  print $ c*10+b+a


Measured memory_bytes: 508
#include <cstdio>
#include <algorithm>
int A[999999], W[999999];
long long merge_and_count(int l, int r) { // range [l,r)
	if (l+1 >= r) return 0; // empty
	if (l+2 == r) { // [l,r) == [l,l+1] 要素2つだけ
		if (A[l] <= A[l+1]) return 0; // 逆転はなし
		std::swap(A[l], A[l+1]);
		return 1; // 逆転一つ
	}
	int m = (l+r)/2; // [l,r) == [l,m) + [m,r)
	long long cl = merge_and_count(l, m); // 左半分を再帰的に数える
	long long cr = merge_and_count(m, r); // 右半分を再帰的に数える
	long long c = 0; // 左と右を混ぜるときの逆点数
	int i=l, j=m; // iは[l,m)を動き, jは[m,r)を動いて、
	int k=l; // 小さいものから W[k] に書き込む
	while (i<m && j<r) { // A[i]とA[j]を比べながら進む
		if (A[i] <= A[j]) W[k++] = A[i++]; // 左半分の方が小さく逆転なし
		else {
			W[k++] = A[j++];
			c += m-i; // 左半分の方が大きい、左半分で未処理の要素だけ飛び越える
		}
	}
	while (i<m) W[k++] = A[i++]; // 左半分が余った場合
	while (j<r) W[k++] = A[j++]; // 右半分が余った場合
	//assert(k == r);
	std::copy(W+l, W+r, A+l);
	return cl + cr + c;
}
main(){
	int N,i;
	for(;scanf("%d",&N),N;printf("%lld\n",merge_and_count(0,N)))for(i=0;i<N;i++)scanf("%d",A+i);
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1e9+7
using namespace std;
typedef long long ll;
const double pi=acos(-1);

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i=0;i<n;i++) cin >> h[i];
    vector<int> dp(n,inf);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=min(i+k,n-1);j++){
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    cout << dp[n-1] << endl;
}

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


int main()
{
	int N, A, B;
	
	cin >> N >> A >> B;
	
	if ((B-A)%2 == 0) cout << "Alice" << endl;
	else cout << "Borys" << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	int N; cin >> N;
	vector<int>v(N);
	REP(i, N) cin >> v[i];
	sort(v.begin(), v.end());
	double cur;
	REP(i, N) {
		if (i == 0) {
			cur = v[i];
		}
		else {
			cur = (cur + (double)v[i]) / 2.0;
		}
	}
	printf("%.10lf\n", cur);


	return 0;
}


Measured memory_bytes: 256
var
  n,i,l,r,j:longint;
  a:array[0..100001] of boolean;
  f:array[0..100001] of longint;
begin
  readln(n);
  fillchar(a,sizeof(a),true);
  a[0]:=false;a[1]:=false;
  for i:=2 to trunc(sqrt(100000)) do
    if a[i] then
      for j:=i to 100000 div i do a[i*j]:=false;
  f[0]:=0;
  for i:=1 to 100000 do if (a[i]) and (a[(i+1) div 2]) then f[i]:=f[i-1]+1 else f[i]:=f[i-1];
  for i:=1 to n do
    begin
      readln(l,r);writeln(f[r]-f[l-1]);
    end;
end.

Measured memory_bytes: 1024