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

int N;
string s;
int main(){
	cin >> N;
	cin >> s;
	int r = 0, b = 0;
	for(int i = 0; i < N; i++){
		r += (s[i] == 'R');
		b += (s[i] == 'B');
	}
	cout << (r > b ? "Yes" : "No") <<'\n';
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	scanf("%d", &n);

	int cur = 0;
	long long int sum = 0;
	while (n--) {
		int a;
		scanf("%d", &a);

		if (a < cur) {
			sum += cur-a;
			a = cur;
		} else
			cur = a;
	}

	printf("%lld\n", sum);
}


Measured memory_bytes: 1712
#include<iostream>
using namespace std;
int main(){
int a,b;
char op;
while(1){
cin>> a >> op >> b;
if(op=='?'){break;}
if(op == '+'){
cout<<a+b<<endl;
}else if(op=='-'){
cout<<a-b<<endl;
}else if(op=='*'){
cout<<a*b<<endl;
}else if(op=='/'){
cout<<a/b<<endl;
}else{
cout<<endl;
}
}
return 0;
}



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

int main(){
  int a,b,c,x,y;
  int p = 0;
  cin >> a >> b >> c >> x >> y;
  if(a+b > 2*c){
    if(x>y){
      p = y*c*2;
      x -= y;
      y = 0;
      //cout << x << endl;
    }else{
      p = x*c*2;
      y -= x;
      x = 0;
    }
  }
  
  if(x){
    if(a > c*2){
      p += x*c*2;
    }else{
      p += x*a;
      //cout << x*a << endl;
    }
  }
  if(y){
    if(b > c*2){
      p += y*c*2;
    }else{
      p += y*b;
    }
  }

  cout << p << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#define INF 0x3f3f3f3f
#define eps 1e-10
using namespace std;
map<int,int>tim;
long long n,a[200005],big=-1,ans;
int main(){
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    big=a[1];
    for(int i=2;i<=n;i++){
        if(a[i]<big)
            ans+=(big-a[i]);
        big=max(big,a[i]);
    }
    printf("%lld",ans);
}

Measured memory_bytes: 4792
def knight(x, y):
    mod = 10 ** 9 + 7
    x, y = min(x, y), max(x, y)

    if (x + y) % 3 != 0:
        return 0
    if y > 2 * x:
        return 0

    move = (x + y) // 3
    right = 2 * move - y
    up = move-right

    ans = 1
    tmp = 1
    for i in range(up):
        ans *= (move - i)
        tmp *= i + 1
        ans %= mod
        tmp %= mod
    ans *= pow(tmp, mod - 2, mod)
    return ans % mod


if __name__ == "__main__":
    x, y = map(int, input().split())
    ans = knight(x, y)
    print(ans)


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

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

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

typedef long long ll;

void solve(long long N, long long K, std::vector<long long> p, vector<double> S)
{
    double ans = 0;
    rep(i, N - K + 1) { ans = max(ans, S[i + K] - S[i]); }
    printf("%lf\n", ans);
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> p(N);
    vector<double> S(N + 1, 0);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &p[i]);
        S[i + 1] = S[i] + (p[i] + 1) / 2.0;
    }
    solve(N, K, std::move(p), move(S));
    return 0;
}


Measured memory_bytes: 3328
import math

n, k = map(int, input().split())
mod = 1000000007
n1 = int(math.sqrt(n))
if n1 * n1 == n:
    n2 = n1 - 1
else:
    n2 = n1

num = [n]
for i in range(1, n2):
    num.append(n // (i + 1))
    num[i - 1] -= num[i]
num[-1] -= n1

dp1 = [1      for i in range(n1)]
dp2 = [num[i] for i in range(n2)]
for _ in range(k - 1):
    l = sum(dp1) % mod
    newdp1 = [l for i in range(n1)]
    newdp2 = [0 for i in range(n2)]

    dp1sum = 0
    for j in range(0, n2):
        dp1sum = (dp1sum + dp1[j]) % mod
        newdp2[j] = (newdp2[j] + dp1sum * num[j]) % mod

    dp2sum = 0
    for j in range(n2 - 1, -1, -1):
        dp2sum = (dp2sum + dp2[j]) % mod
        newdp1[j] = (newdp1[j] + dp2sum) % mod
    dp1 = newdp1
    dp2 = newdp2
print((sum(dp1) + sum(dp2)) % mod)

Measured memory_bytes: 82140
n = int(input())
a = [int(s) for s in input().split()]

combn = max(a)

ar = [abs(num-combn/2) for num in a]
if int(combn/2 - min(ar)) in a:
  combr = int(combn/2 - min(ar))
else:
  combr = int(combn/2 + min(ar))

print(' '.join(map(str,[combn,combr])))

Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);
const ll MOD=1000000007;

ll Power(ll base , ll e)
{
    if(e == 0) return 1;
    ll ans = base; e--;
    while(e)
    {
        if(e & 1) ans = (ans * base) %MOD;
        base = (base * base) %MOD;
        e >>= 1;
    }
    return (ans+MOD)%MOD;
}

int main(){
 IOS
 ll n,k;
 cin>>n>>k;
 //ll ans=0;
 ll dp[k+1];
 for(ll i=k;i>=1;i--){
 	ll total=(Power(k/i,n)%MOD);
 	ll tmp=0;
 	for(ll j=2;i*j<=k;j++){
 		tmp=(tmp+dp[j*i])%MOD;

 	}
 	dp[i]=(total-tmp+MOD)%MOD;

 }
 ll ans=0;
 //dbg(dp[2]);
 FOR(i,1,k){
 	ans=(ans+i*dp[i])%MOD;
 }
 cout<<ans<<endl;



}

Measured memory_bytes: 4428
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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;
}

ll ctoi(const char c) {
  if ('0' <= c && c <= '9') return (c - '0');
  return -1;
}

signed main() {
  string ABCD;
  cin >> ABCD;
  ll A = ctoi(ABCD[0]);
  ll B = ctoi(ABCD[1]);
  ll C = ctoi(ABCD[2]);
  ll D = ctoi(ABCD[3]);

  ll N = 3;
  rep(bit, 1 << N) {
    ll ans = A;
    rep(i, N) {
      if (bit >> i & 1) {
        if (i == 0) {
          ans += B;
        }
        if (i == 1) {
          ans += C;
        }
        if (i == 2) {
          ans += D;
        }
      } else {
        if (i == 0) {
          ans -= B;
        }
        if (i == 1) {
          ans -= C;
        }
        if (i == 2) {
          ans -= D;
        }
      }
    }
    if (ans == 7) {
      cout << A;
      rep(i, N) {
        if (bit >> i & 1) {
          cout << "+";
        } else {
          cout << "-";
        }
        if (i == 0) {
          cout << B;
        }
        if (i == 1) {
          cout << C;
        }
        if (i == 2) {
          cout << D;
        }
      }
      COUT("=7");
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

long long f(int n)
{
  if (n == 0) return 1;
  return f(n - 1) * n;
}
int main()
{
  int n;
  scanf("%d", &n);
  printf("%lld\n", f(n));
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ff(i,a,b) for(int i = a; i < b; i++)
#define fb(i,a,b) for(int i = a; i > b; i--)
#define MOD 1000000007


ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


void solve(){
	int n,k;
	cin>>n>>k;
	ll a[n],b[n-k+1];
	ff(i,0,n) cin>>a[i];
	//ff(i,0,n) cout<<a[i]<<" "
	/*b[0]=1;
	ff(i,0,k) b[0]*=a[i];

	ff(i,k,n) b[i-k+1]=((b[i-k])/(a[i-k]))*a[i];
	ff(i,1,n-k+1)
	    if(b[i]>b[i-1]) cout<<"Yes\n";
	    else cout<<"No\n";*/
	ff(i,k,n)
	    if(a[i]>a[i-k]) cout<<"Yes\n";
	    else cout<<"No\n";
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	//int t;
    //cin>>t;
	//while(t--)
		solve();
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 5368
import numpy as np
C = np.array([[int(i) for i in input().split()] for i in range(3)])
a=0
if(C[0,0]-C[0,1] == C[1,0]-C[1,1] == C[2,0]-C[2,1]):
    a +=1
if(C[0,1]-C[0,2] == C[1,1]-C[1,2] == C[2,1]-C[2,2]):
    a +=1
if(C[0,0]-C[1,0] == C[0,1]-C[1,1] == C[0,2]-C[1,2]):
    a +=1
if(C[1,0]-C[2,0] == C[1,1]-C[2,1] == C[1,2]-C[2,2]):
    a +=1
if(a == 4):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12204
#include <stdio.h>

int main()
{
    char a[4],b[4],c[4];
    int i,j;


    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);

    
    printf("%c",a[0]);
    printf("%c",b[1]);
    printf("%c",c[2]);
    printf("\n");

    return 0;
}

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

#define MAX 100000
#define ROOT 0
#define INODE 1
#define LEAF 2

struct CHILDREN {
	int id;
	struct CHILDREN *next;
};
typedef struct CHILDREN CHILDREN;

struct NODE {
	int parent;
	short depth;
	short type;
	CHILDREN *children;
};
typedef struct NODE NODE;

int main( void ) 
{   
    int n;
    int id,k,c,prec;
    int i,j,depth;
    char types[3][32] = { "root", "internal node", "leaf" };
	NODE nodes[ MAX+1 ];
	CHILDREN *child=NULL,*pre=NULL;
	       
    scanf( "%d", &n );
    for( i=0; i<n; i++ ) {
        scanf( "%d%d", &id, &k );
        if( k ) {
       		prec=id;
       		child = (CHILDREN *)malloc( sizeof( CHILDREN ) );
       		nodes[id].children=child;
       		pre=child;
        	for( j=0; j<k; j++ ) {
	           	scanf( "%d", &c );
	           	if( !nodes[c].type ) {
          			nodes[c].type=INODE;        	
        		}
	           	nodes[c].parent=id;
	           	nodes[c].depth=nodes[id].depth+1;
	           	child->id=c;
	           	pre->next=child;
	           	pre=child;
	           	if( j < k-1 ) {
	      			child = (CHILDREN *)malloc( sizeof( CHILDREN ) );
	      		}
        	}
        	if( 0 == nodes[id].depth ) {
        		nodes[id].parent = -1; 
        		nodes[id].type=ROOT;
        	}        	
        	pre->next=NULL;     	
       	} else {
       		nodes[id].type=LEAF;
	   		nodes[id].children=NULL;
       	}
    }
    if( 1 == n ) {
    	nodes[id].parent = -1; 
    	nodes[id].type=ROOT;
   	}
    
    for( i=0; i<n; i++ ) {
    	depth=(-1 == nodes[i].parent)? 0: nodes[ nodes[i].parent ].depth+1;
		printf( "node %d: parent = %d, depth = %d, %s, ", i, nodes[i].parent,  depth,  types[ nodes[i].type ] );
		if( NULL != nodes[i].children ) {
			child=nodes[i].children;
			printf( "[%d", child->id );
			child=child->next;
			while( NULL != child ) {
				printf( ", %d", child->id );
				child=child->next;
			}
			printf( "]\n" );
		} else {
			printf( "[]\n" );
		}
	}

    return 0;
}

Measured memory_bytes: 5300
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<long long> p(N);
	for (auto& x : p) {
		cin >> x;
	}

	long long s = 0;
	for (int i = 0; i < K; ++i) {
		s += p[i];
	}
	long long s_max = s;
	for (int i = K; i < N; ++i) {
		s -= p[i - K];
		s += p[i];
		s_max = max(s_max, s);
	}
	double ans = (s_max + K) / 2.0;
	printf("%.10f\n", ans);
}


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


int main(){
    int k,s;
    cin>>k>>s;
    long long p=0;
    for(int i=0;i<k+1;i++){
        for(int j=0;j<k+1;j++){
            if(s-i-j>=0&&s-i-j<=k){
                p++;
            }
        }
    }
    cout<<p;
}

Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
using namespace std;

int main() {
    double n, s[1001];
    
    while (1) {
        double ave = 0, bunsan = 0;
        scanf("%lf", &n);
        if (n == 0) break;
        for (int i = 0; i < n; i++) {
            scanf("%lf", &s[i]);
            ave = ave + s[i];
        }
        ave = ave / n;


        for (int i = 0; i < n; i++) {
            bunsan = bunsan + ((s[i] - ave)*(s[i] - ave));
        }
        bunsan = sqrt(bunsan / n);

        printf("%f\n", bunsan);
    }


    return 0;
}

Measured memory_bytes: 3212
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		int nodeCount = 0;
		int edgeCount = 0;

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		nodeCount = sc.nextInt();
		edgeCount = sc.nextInt();

		int[][] matrix = new int[nodeCount+1][nodeCount+1];
		// 入力される2辺(a, b)
		int[] a = new int[edgeCount];
		int[] b = new int[edgeCount];

		// 辺を取得
		for (int i = 0; i < edgeCount; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}

		// 辺の情報をもとに無向グラフの行列を作成
		for (int i = 0; i < edgeCount; i++) {
			matrix[a[i]][b[i]] = 1;
			matrix[b[i]][a[i]] = 1;
		}

		// 訪問済かどうかを保持
		boolean[] d = new boolean[nodeCount+1];

		// 非連結になる辺の数
		int bridgeCount = 0;
		for (int i = 0; i < edgeCount; i++) {
			// 1辺を取り除く
			matrix[a[i]][b[i]] = 0;
			matrix[b[i]][a[i]] = 0;

			// 頂点1から順番に各頂点を探索
			d = dfs(matrix, d, 1);

			// 各頂点を訪問できなかった場合は非連結
			for (int j = 1; j < d.length; j++) {
				if (d[j]) {
					continue;
				} else {
					bridgeCount++;
					break;
				}
			}

			// 1辺を元に戻す
			matrix[a[i]][b[i]] = 1;
			matrix[b[i]][a[i]] = 1;
			Arrays.fill(d, false);

		}
		System.out.println(bridgeCount);
	}

	static boolean[] dfs(int[][] matrix, boolean[] d, int now) {
		// すでに初回訪問済の場合はとばす
		if (d[now]) {
			return d;
		}
		// 初回訪問時の記録
		for (int i = 1; i < matrix.length; i++) {
			// 遷移先頂点が存在する場合は遷移して、再帰的に探索
			if (matrix[now][i] == 1) {
				d[now] = true;
				d = dfs(matrix, d, i);
			}
		}
		return d;
	}

}

Measured memory_bytes: 22612
// 全探索
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k,s,i,j,l;
    cin >> k >> s;
    int count = 0;
    for(i=0;i<k+1;i++){
        for(j=i;j<k+1;j++){
            for(l=j;l<k+1;l++){
                int sum = i + j + l;
                if(sum==s){
                    if(i==j&&j==l){
                        count++;
                    }else if(i==j||j==l||l==i){
                        count = count + 3;
                    }else{
                        count = count + 6;
                    }
                }else if(sum>s){
                    break;
                }
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<tuple>
#include<utility>
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb push_back
#define mp make_pair

int main() {
	LL n, m;
	cin >> n >> m;
	LL l = 1, r = n;
	rep(i, 0, m) {
		LL L, R;
		cin >> L >> R;
		l = max(l, L);
		r = min(r, R);
	}
	if (r < l) {
		cout << 0 << endl;
		return 0;
	}

	cout << r - l + 1 << endl;

	return 0;
}

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

long solve(string s, string t) {
    long ans = 0;
    unordered_map<char, vector<int> > mp;
    const long s_size = s.size();
    for (int i = 0; i < s_size; i++) {
        mp[s[i]].push_back(i + 1);
    }
    int p = 0;
    for (int i = 0; i < t.size(); i++) {
        if (mp.find(t[i]) == mp.end())
            return -1;
        int ub = upper_bound(mp[t[i]].begin(), mp[t[i]].end(), p) - mp[t[i]].begin();
        if (ub == mp[t[i]].size()) {
            p = mp[t[i]][0];
            ans += s_size;
        } else {
            p = mp[t[i]][ub];
        }
    }
    ans += p;
    return ans;
}

int main() {
    string s, t;
    cin >> s >> t;
    cout << solve(s, t) << endl;
    return 0;
}


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

int main(){
    int n;
    scanf("%d",&n);
    int a[n+1];
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
    }
    a[0] = a[1];
    int dp[n+1];
    dp[0] = 0;
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        dp[i] = min(dp[i-2] + abs(a[i] - a[i-2]), dp[i-1] + abs(a[i] - a[i-1]));
    }
    printf("%d\n",dp[n]);
    return 0;
}

Measured memory_bytes: 1024
N, A, B, C = gets.split.map(&:to_i)
L = N.times.map{gets.to_i}

def dfs(i, a, b, c)
  if i == N
    if a == A || b == B || c == C
      Float::INFINITY
    else  
      return a.abs + b.abs + c.abs - 30
    end 
  else
    return [dfs(i + 1, a, b, c),
            dfs(i + 1, a - L[i], b, c) + 10,
            dfs(i + 1, a, b - L[i], c) + 10,
            dfs(i + 1, a, b, c - L[i]) + 10].min
  end 
end

puts dfs(0, A, B, C)


Measured memory_bytes: 1788
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* ]]] */

int n;
int a[100];

int main(){
  cin >> n;
  rep(i, n) cin >> a[i];
  int mn = inf;
  rep(i, -100, 101){
    int s = 0;
    rep(j, n){
      int b = a[j] - i;
      s += b * b;
    }
    chmin(mn, s);
  }
  cout << mn << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,i,j,w,r,c,k,l,flag=0;
    cin>>h>>w;
    string s[h+10];
    for(i=0;i<h;i++)
    {
        cin>>s[i];
    }
    r=h+2;
    c=w+2;

        k=0;
    for(i=0;i<r;i++)
    {
        l=0;
        flag=0;
        for(j=0;j<c;j++)
        {
            if(i>0 && i<r-1)
            {
                if(j>0 && j<c-1)
                {
                   cout<<s[k][l];
                   l++;
                   flag=1;

                }
                else
                    cout<<"#";
            }

            else
                cout<<"#";

        }
        cout<<endl;
//        cout<<flag<<endl;
        if(flag==1)
        {
            k++;
            l=0;
            flag=0;
        }
//        cout<<"k = "<<k<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  vector<P> v;
  rep(i,n){
    int x,l;
    cin>>x>>l;
    v.PB(P(x+l,x-l));
  }

  sort(all(v));

  int ans=0;
  int t=-INF;
  rep(i,n){
    if(t>v[i].S) continue;
    ans++;
    t=v[i].F;
  }

  cout<<ans<<endl;


}

Measured memory_bytes: 2420
#include <stdio.h>

int main(){
 int a[3];
 scanf("%d %d %d",&a[0],&a[1],&a[2]);
 int s[3],t;

 for(int i=0;i<3;i++){
	 for(int j=i;j<3;j++){
		 if(a[i] > a[j]){
			 t=a[i];
			 a[i]=a[j];
			 a[j]=t;
		 }
	 }
 }

 printf("%d %d %d\n",a[0],a[1],a[2]);

 return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, h[100100];
ll dp[100100];

ll rec(ll i) {
    if(dp[i] != inf) return dp[i];

    if(i == 0) return 0;

    ll res = inf;
    res = min(res, rec(i-1) + abs(h[i] - h[i-1]));
    if(i > 1) res = min(res, rec(i-2) + abs(h[i] - h[i-2]));

    return dp[i] = res;
}

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) cin >> h[i];

    for(int i = 0; i < 100100; i++) dp[i] = inf;

    dp[0] = 0;

    cout << rec(n-1) << endl;
}

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



int main() {
	vector<string>b{ "Sunny","Cloudy","Rainy" };
	string a,ans;
	cin >> a;
	for (int i = 0; i < b.size(); i++) {
		if (a == b.at(i)) {
			i + 1 < b.size() ? ans = b.at(i + 1) : ans = b.at(0);
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	string s;
	while(cin>>N>>s) {
		REP(i, s.size()) {
			s[i] = (s[i]-'A'+N)%26+'A';
		}
		
		cout<<s<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.math;

void main() {
    auto input = getStdin!(string[])[1..$];
    foreach (line; input) {
    	auto num = line.split(" ").to!(int[]).sort;
    	if (num[0].pow(2) + num[1].pow(2) == num[2].pow(2))
    		"YES".writeln;
    	else
    		"NO".writeln;
    }
}

T getStdin(T)() {
    string[] cmd;
    string line;
    while ((line = chomp(stdin.readln())) != "") cmd ~= line;
    return to!(T)(cmd);
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end



int main(){
   ll n; scanf("%lld",&n);
   string s; tostr(n,s);
   bool f=1;
   rep(i,1,s.size())if(s[i]!='9')f=0;
   if(f){
      int res=0;
      rep(i,0,s.size())res+=(s[i]-'0');
      printf("%d\n",res);
   }
   else{
      int c=s[0]-'1';
      printf("%d\n",c+s.size()*9-9);
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    sort(a.begin(), a.end(), greater<int>());
    
    ll ans = 0, mxi = 0;
    for (int i = 1; i < n; i++) {
        ans += a[mxi];
        if (i % 2 == 1)
            mxi++;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4048
//Falling Asleep
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

int main ()
{
    int N;
   
    cin >> N;

    vector<string> s(N);
    vector<int> t(N);

    for (int i = 0; i < N; i++) {
        cin >> s[i] >> t[i];
    }

    string X;
    cin >> X;

    int j = 0;
    for (int i = 0; i < N; i++,j++) {
        if (s[i] == X) {
            break;
        }
    }
    int result = 0;
    for (j++; j < N; j++) {
        result += t[j];
    }

    cout << result << endl;
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);
bool f(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
    return a.s<b.s;
}
int main()
{
	IOS;
    cout.precision(30);
    int n; cin >> n; ll a,b; vector <pair<ll,ll> > A;
    for (int i=0;i<n;i++)
    {
        cin >> a >> b;
        A.pb(make_pair(a,b));
    }
    sort(A.begin(),A.end(),f);
    for (int i=0;i<n;i++)
    {
        int deb=i,fin=i;
        for (int j=deb+1;j<n;j++)
        {
            if (A[i].s==A[j].s)
                fin++;
            else break;
        }
        i=fin+1;
        sort(A.begin()+deb,A.begin()+fin+1);
    }
    ll s=0; bool res=true;
    for (int i=0;i<n;i++)
    {
        s+=A[i].f;
        if (s>A[i].s){res=false; break;}
    }
    if (res) cout << "Yes"; else cout << "No";
    return 0;
}


Measured memory_bytes: 6512
n=input()
k=int(input())
l=len(n)
dp=[[[0]*(k+1) for i in range(2)] for i in range(l+1)]
#len,satu?,k
dp[0][0][0]=1#first
for i in range(1,l+1):
    x=int(n[i-1])
    for j in range(k+1):
        dp[i][1][j]+=dp[i-1][1][j]
        if j!=0:
            dp[i][1][j]+=9*dp[i-1][1][j-1]
            if x>0:
                dp[i][1][j]+=(x-1)*dp[i-1][0][j-1]
        if x!=0:
            dp[i][1][j]+=dp[i-1][0][j]
        if x==0:
            dp[i][0][j]+=dp[i-1][0][j]
        elif j>0:
            dp[i][0][j]+=dp[i-1][0][j-1]

print(dp[-1][0][-1]+dp[-1][1][-1])

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 200005;

int n, m;
int a[N];

bool ok(int i, int j, int x) {
	return ((a[i] >= x && a[j] >= x) || (a[i] < x && a[j] < x));
}

bool valid(int x) {
	for (int i = 0; i < m - 1; i++) {
		if (ok(m + i, m + i + 1, x))
			return a[m + i] >= x;
		if (ok(m - i, m - i - 1, x))
			return a[m - i] >= x;
	}
	return a[1] >= x;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> m;
	n = 2 * m - 1;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int st = 1, en = n;
	while (st < en) {
		int mid = st + (en - st + 1) / 2;
		if (valid(mid))
			st = mid;
		else
			en = mid - 1;
	}
	cout << st << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)   for(signed i=0; i<n; i++)
#define FOR(i, k, n)    for(signed i=k; i<n; i++)
#define yn(b)   cout << ((b)?"Yes":"No") << endl
#define YN(b)   cout << ((b)?"YES":"No") << endl
#define pr(r)   cout << r << endl
#define min(x,y)    (x<y)?x:y
#define max(x,y)    (x>y)?x:y
#define ll  long long
int main(void){
    int N;
    cin >> N;
    int i = (N+1)/2;
    cout << (double)i/N << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define vvv(type, c, m, n, l, i) vector<vector<vector<type>>> c(m, vector<vector<type>>(n, vector<type>(l, i)));
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	string s, p; cin >> s >> p;
	s += s;
	P(s.find(p) != string::npos ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3216
package main

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

func solve() {
	n := getInt()

	ans := inf
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			x := f(n / i)
			ans = min(ans, x)
		}
	}
	fmt.Fprintln(wr, ans)
}

func f(b int) int {
	ret := 0
	for b > 0 {
		ret++
		b /= 10
	}
	return ret
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(1000,10000)(rng)

ll binpow(ll a, ll b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,k;
    cin>>n;
    k=n;
    while (k%360)
        k+=n;
    cout<<k/n;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define fcout cout << fixed << setprecision(15)
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int c[550][550];

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m, q;
	cin >> n >> m >> q;
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		REP(j, r, 550) c[l][j]++;
	}

	while(q--) {
		int ans = 0;
		int l, r;
		cin >> l >> r;
		for(int i = l; i <= r; i++) ans += c[i][r];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main(){  
  int m,n; cin>>m>>n;
  char grid[m][n];
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      cin>>grid[i][j];
    }
  }
  int dp[m][n];
  memset(dp,0,sizeof(dp));
  for(int i=0;i<m;i++){
    if(grid[i][0]=='#'){
      break;
    }
    else{
        dp[i][0]=1;
    }
  }
  for(int i=0;i<n;i++){
    if(grid[0][i]=='#'){
      break;
    }
    else{
        dp[0][i]=1;
    }
  }
  
  for(int i=1;i<m;i++){
    for(int j=1;j<n;j++){
      if(grid[i][j]=='#'){
        dp[i][j]=0;
      }
      else{
        dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
        }
    }
  }
  cout<<dp[m-1][n-1]%mod;
  return 0;
}




Measured memory_bytes: 8424
n = int(input())
aa = []
for i in range(n):
    a = input()
    aa.append(a)

bb = []
if len(set(aa)) != len(aa):
    print('No')
else:
    for i in range(n-1):
        if aa[i][-1] == aa[i+1][0]:
            bb.append(True)
        else:
            bb.append(False)
    if all(bb):
        print('Yes')
    else:
        print('No')

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

using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  
  if(a >= 1 && a <= 9 && b >= 1 && b <= 9){
  	cout<<a*b<<'\n';
  }else{
    cout<<-1<<'\n';
  }
  return 0;
}

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

using namespace std;

int main () {
    double d; cin >> d;
    double ans;
    if(d>1-1e10) ans=max(sqrt(2)*d,floor(d)+1);
    else ans=sqrt(2)*d;
    printf("%.10f\n",ans);
    
    return 0;
}


Measured memory_bytes: 3288
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = 998244353;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b=mod-2,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int n, a, d[100100], res, mx;

signed main() {
    cin >> n;
    rep(i,n) {
        cin >> a;
        if (i==0 && a!=0) return cout << 0 << endl, 0;
        if (i!=0 && a==0) return cout << 0 << endl, 0;
        d[a]++;
        chmax(mx, a);
    }
    res = 1;
    reps(i,1,mx+1) {
        if (d[i]==0) res = 0;
        (res *= mop(d[i-1], d[i])) %= mod;
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	x := make([]int, n)
	mean := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&x[i])
		mean += x[i]
	}
	mean = int(round(float64(mean) / float64(n)))
	sum := 0
	for i := 0; i < n; i++ {
		sum += (x[i] - mean) * (x[i] - mean)
	}
	fmt.Println(sum)
}

func round(f float64) float64 {
	return math.Floor(f + .5)
}


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

int main(){
  string s;
  cin >> s;
  int even[26]={};
  for(char i:s){
      even[i-'a']++;
  }
  for(int i:even){
      if(i%2!=0){
          cout << "No" << endl;
          return 0;
      }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
inputs = readlines

input=[]
for i in 1..inputs.size do
    input.push(inputs[i-1].split)
    input[i-1].map!(&:to_i)
end

a = input[0][0]
b = input[0][1]

coins = 0

if a > b
    coins = a + a-1
elsif a == b
    coins = a + b       
else
    coins = b + b-1
end

p coins

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b; cin >> a >> b;
	ll ans=0;
	for(int i=0; i<2; i++){
		ans += max(a, b);
		if (a > b){
			a--;
		}else{
			b--;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  GVI(d, N);
  sort(ALL(d));
  if (N % 2 == 1) {
    print(0);
  } else {
    print(d[N / 2] - d[N / 2 - 1]);
  }
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    int a, b, c, d;
    in >> a, b, c, d;
    out << (a == c ? 0 : 1);

    return 0;
}


Measured memory_bytes: 256