akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

vector<pair<string, int>> solve(int N) {
	if (N == 1)
		return { {"a", 1} };
	vector<pair<string, int>> tmp = solve(N - 1);
	vector<pair<string, int>> res;
	for (auto p : tmp) {
		for (int i = 0; i <= p.second; ++i) {
			string s = p.first + (char)('a' + i);
			if (i < p.second)
				res.emplace_back(s, p.second);
			else res.emplace_back(s, p.second + 1);
		}
	}
	return res;
}

int main() {
	int n; cin >> n;
	auto res = solve(n);
	sort(res.begin(), res.end());
	for (auto p : res) cout << p.first << endl;
	return 0;
}

Measured memory_bytes: 10080
import java.util.Scanner;

class Main{
  public static void main(String[] args) throws Exception{
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    System.out.println(check(S));
    sc.close();
  }
  static String check(String s) {
    //aaパターン
    for (int i = 0; i < s.length() - 1 ; i++) {
      if (s.substring(i,i+1).equals(s.substring(i+1,i+2))) {
        return (i+1) + " " + (i+2);
      }
    }
    //abaパターン
    for (int i = 0; i < s.length() - 2 ; i++) {
      if (s.substring(i,i+1).equals(s.substring(i+2,i+3))) {
        return (i+1) + " " + (i+3);
      }
    }
    // no match
    return (-1) + " " + (-1);
  }
}

Measured memory_bytes: 40172
def show(A):
    output = ""
    for i in range(len(A)):
        output += str(A[i]) + " "
    print(output[:-1])

def insertionsort(A, N):
    for i in range(1, N):
        show(A)
        A[:i+1] = sorted(A[:i+1])
    show(A)
    
N = int(input())
A = list(map(int, input().split())) 

insertionsort(A, N)


Measured memory_bytes: 5600
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n, k = IN()
	
	i=1
	while n > (k**i)-1:
		#pa((k**i)-1)
		i+=1
	ret = i
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
ll mod = 1000000007;
inline int fast_expo(int base,int power,int modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    // int tmp=ans;
    return ans;
}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int INF = (int)1e9;
//=========================CODE STARTS HERE=============================//


int main() {

	  fast_cin();
	
		ll x, y;
		cin >> x >> y;
		cout << 6 - x - y;
				
     

    return 0;
}


Measured memory_bytes: 256
x, y = map(int,input().split())
ans = 0
if 1 <= x <= 3:
    ans += (4-x) * 10**5
if 1 <= y <= 3:
    ans += (4-y) * 10**5
if x==1 and y==1:
    ans += 4 * 10**5
print(ans)

Measured memory_bytes: 38384
//author: zekigurbuz (Zeki Gurbuz) 2019

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef queue<int> qi;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, vi> mvi;
typedef map<int, vpii> mvpii;
typedef priority_queue<int> pqi;
typedef set<int> si;

#define int ll
#define double ld
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rsz resize
#define forn(a,b) for(int a=0;a<b;++a)
#define rep(a,b,c) for(int a=b;a<c;++a)
#define all(x) begin(x), end(x)

const ld PI = 4*atan((ld)1);
const int MOD = 1000000007; //998244353
const ll INF = 1e18;
const int N = 200005;

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

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }



signed main() {ios_base::sync_with_stdio(0);cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	int c = 0;
	int x;
	forn(i, n) {
		cin >> x;
		if (x >= k) c++;
	}
	cout << c << endl;
	
return 0;}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = 0;
		for (int i = 0; i <= N; i++) {
			int target = i;
			int sum = 0;
			while (target != 0) {
				sum += target % 10;
				target /= 10;
			}
			if (sum >= A && sum <= B) {
				ans += i;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

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

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


    int sum = 0;
    if ( a> b){
        sum = sum + a;
        a = a-1;
    } else {
        sum = sum + b;
        b = b-1;
    }
   if ( a> b){
        sum = sum + a;
        a = a-1;
    } else {
        sum = sum + b;
        b = b-1;
    }



    cout << sum << endl;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, Y;
    cin >> N >> Y;

    for(ll i=0; i<=N; i++){
        for(ll j=0; j<=N; j++){
            if(i+j > N) continue;
            ll k = N-i-j;

            if(10000*i + 5000*j + 1000*k == Y){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

// n個までの部分問題、価値を達成する重さ
ll MAX = 100001;
vvll dp(100, vll(MAX, INF));

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll N, W;
    cin >> N >> W;
    vll w(N), v(N);
    rep(i, N){
        cin >> w[i] >> v[i];
    }
    dp[0][v[0]] = w[0];
    dp[0][0] = 0;
    repr(i, 1, N){
        dp[i][0] = 0;
        rep(j, MAX){
            dp[i][j] = dp[i-1][j];
            if(j >= v[i]){
                chmin(dp[i][j], dp[i-1][j-v[i]] + w[i]);
            }
        }
    }
    ll ans = 0;
    rep(i, MAX){
        if(dp[N-1][i] <= W) chmax(ans, i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll A,B,C,K;
  cin >> A >> B >> C >> K;
  ll ans = 0;
  if (A >= K) {
    ans = K;
  } else if (A < K && K <= B) {
    ans = A;
  } else {
    ans = A - (K - A - B);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
long long x,y,ans=0,sum=0;
int main()
{
	cin>>x>>y;
	sum=y/x;
	while (sum>=1)
	{
		sum/=2;
		ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

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

int gcd(int p, int q){
    if(p%q==0)return(q);
    return(gcd(q,p%q));
}

int main(void){
    int k;
    scanf("%d",&k);
    long long int ans=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int n=1;n<=k;n++){
                ans+=gcd(gcd(i,j),n);
            }
        }
    }
    printf("%lld\n",ans);
    return(0);
}

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

int main(){
	int W, H, x, y, r;
	
	cin >> W >> H >> x >> y >> r;
	
	if(x >= r && x <= W - r 
		&& y >= r && y <= H - r){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
ll po(ll a, ll b){
    ll res = 1;
    while(b){
        if(b & 1) res = res * a;
        a = a * a;
        b >>= 1LL;
    }
    return res;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;
    cin >> n;
    ll mxf = 1;
    for(ll i = 2; i <= n; i++){
        for(ll j = 2; po(i, j) <= n; j++){
            ll x = po(i, j);
            if(x <= n){
                mxf = max(mxf, x);
            }
        }
    }
    cout << mxf;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
N=int(input())
M=input()
x=list(M)
cnt=0
a=list()
for i in x:
    a.append(i)
    try:
        if (a[0]=='O' and a[1]=='X') or (a[0]=='X' and a[1]=='O'):
            cnt+=1  
            a=[]
        elif a[1]=='O':
            a=[]
            a.append(i)
        elif a[1]=='X':
            a=[]
            a.append(i)
    except:
        continue
print(cnt)


Measured memory_bytes: 6504
#include <ctype.h>
#include <stdio.h>

int main() {
	static char a[11], b[11], c[11];

	scanf("%s%s%s", a, b, c);
	printf("%c%c%c\n", toupper(a[0]), toupper(b[0]), toupper(c[0]));
	return 0;
}


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

using namespace std;

typedef pair<string,string> pss;
#define size(x) ((int) x.size())

map <pss, int> mp; 

string s, s1, s2;

long long n, mid, sz;

long long ans;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> s;
	sz = (1 << n);
	for (int mask = 0; mask < sz; mask++) {
		s1 = s2 = "";
		for (int i = 0; i < n; i++) {
			if ((mask >> i) & 1)
				s1 += s[i];
			else 
				s2 += s[i];
		} 
		mp[{s1, s2}]++;
	}
	for (int mask = 0; mask < sz; mask++) {
		s1 = s2 = "";
		for (int i = (2 * n) - 1; i >= n; i--) {
			if (mask >> (i - n) & 1) {
				s1 += s[i];
			}
			else
				s2 += s[i];
		}
		ans += mp[{s1, s2}];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 91904
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()

using namespace std;
ll n,m,x,y,mn,cnt;
double a[1005],p[1005];
multiset <int> st;
vector <int> v;
string s,c[10];
const double P = acos(-1.0);
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("collect.in", "r", stdin);
    //freopen("collect.out", "w", stdout);
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]){
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;

ll diff(ll h,  ll w) {
    double ave = h * w / 3;
    ll row = round(ave / w);

    ll a = row * w;
    ll b, c;

    b = (ll)((w/2) * (h - row));
    c = (ll)(((w+1) / 2) * (h-row));

    ll diff_1 = max(a, max(b, c)) - min(a, min(b, c));

    b = (ll)(w * ((h-row)/2));
    c = (ll)(w * ((h-row + 1) /2));

    // cout << a << "," << b << "," << c << endl;
    ll diff_2 = max(a, max(b, c)) - min(a, min(b, c));

    return min(diff_1, diff_2);
}

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

    if (h % 3 ==0 || w % 3 == 0) cout << 0 << endl;
    else {
        cout << min(diff(h, w), diff(w, h)) << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    double r,PI;
    cin >> r;
    PI = 3.141592653589;
    cout <<std ::fixed<< setprecision(8) <<r*r*PI  <<" "<<setprecision(8) <<2*r*PI << endl;

}



Measured memory_bytes: 3272
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Banned K
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N], cs[MAX_N + 1];

/* subroutines */

inline ll cmb2(int ci) { return (ll)ci * (ci - 1) / 2; }

/* main */

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

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

  ll sum = 0;
  for (int i = 1; i <= n; i++) sum += cmb2(cs[i]);

  for (int i = 0; i < n; i++) {
    int ci = cs[as[i]];
    printf("%lld\n", sum - cmb2(ci) + cmb2(ci - 1));
  }
  return 0;
}


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

using namespace std;

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

    cin >> n >> s >> k;

    for (int i=0; i<n; i++) {
        if (s[i] != s[k-1]) s[i] = '*';
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  cin>>s;
  s=s.substr(0,3);
  cout<<s<<endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

set<string> S;
int n;

void solve(string s) {
    S.clear();
    S.insert(s);
    rep(i,s.size()) {
        if(i==0) continue;
        string temp1 = s.substr(0,i);
        string temp2 = s.substr(i,s.size()-i);
        S.insert(temp1+temp2);
        S.insert(temp2+temp1);
        reverse(all(temp1));
        S.insert(temp1+temp2);
        S.insert(temp2+temp1);

        reverse(all(temp2));
        S.insert(temp1+temp2);
        S.insert(temp2+temp1);

        reverse(all(temp1));
        S.insert(temp1+temp2);
        S.insert(temp2+temp1);
    }

    cout<<S.size()<<endl;

}

int main() {
    cin>>n;
    string s;
    rep(i,n) {
        cin>>s;
        solve(s);
    }

    return 0;
}

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

int main(){
    int n,m;
	cin >> n ;
	int a[n], diff[n];
	for(int i=0; i<n; i++)
		cin >> a[i];
	diff[0] = a[0];
	for(int i=1; i<n; i++)
		diff[i] = a[i]-a[i-1];
	int ans = 0;
	for(int i=0; i<n; i++)
		if(diff[i]>0)
			ans += diff[i];
	cout << ans << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void){

    //input
    int N;  scanf("%d",&N);
    int A[N];
    for(int i = 0; i < N; ++i){
        scanf("%d",&A[i]);
        --A[i];                     //配列は0から始まるため
    }
    int B[N];
    for(int i = 0; i < N; ++i){
        scanf("%d",&B[i]);
    }
    int C[N-1];
    for(int i = 0; i< N-1; ++i){
        scanf("%d",&C[i]);
    }
    
    int sum = 0;

    //calc
    
    for(int i=0; i<N; ++i){
        sum += B[A[i]];
        if(i > 0 && A[i] == A[i-1]+1){
            sum += C[A[i-1]];
        }
    }

    printf("%d",sum);
}

Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::num::{NonZeroU32, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Index, IndexMut, Mul, MulAssign, Neg, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
    SubAssign,
};
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, multinomial, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, Num, NumAssignOps, NumOps, One, Pow, Zero};
use permutohedron::Heap;
use proconio::{
    fastout, input, is_stdin_empty,
    marker::{Bytes, Chars, Isize1, Usize1},
};
use rand::random;

pub const MOD10E9_7: usize = 1000000007;
pub const MOD99_: usize = 998244353;
pub const MAX: usize = std::usize::MAX;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 65;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }

    let ans = a.iter().enumerate().filter(|x| x.0 % 2 == 0 && x.1 % 2 == 1).count();
    println!("{}", ans);
}


Measured memory_bytes: 2096
S = list(input())
C = S[2:-1]
if S[0] == "A" and "C" in C and C.count("C") == 1:
    S.remove("A")
    S.remove("C")
    T="".join(S)
    Y=T.lower()
    if T == Y:
        print("AC")
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;
class MainClass
{
	static void Main(string[] args)
	{
		Answer(new ConsoleInput(Console.In, ' '));
	}
	public static void Answer(ConsoleInput cin)
	{
      var n = cin.ReadInt-1;
      var m = cin.ReadInt-1;
      WriteLine(n * m);
	}
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )
#define SQRTI(n) static_cast<uint64_t>(::floor(::sqrt(static_cast<double>(n))))

#ifdef __DEBUG__
template<typename T, typename U>
std::ostream& operator<<(std::ostream &os, const std::pair<T, U> &pair)
{
  os << pair.first << ": " << pair.second;
  return os;
}

template<class ForwardIterator>
std::ostream& _iterator_to_display(
  std::ostream &os, 
  ForwardIterator begin, ForwardIterator end, 
  const std::string &delim = ", "
)
{
  auto itr = begin;
  while (itr != end) {
    os << *itr;
    ++itr;
    if (itr != end) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  _iterator_to_display(os, list.begin(), list.end());
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &vector)
{
  _iterator_to_display(os, vector.begin(), vector.end());
  return os;
}

template<typename T, class C=std::less<T>>
std::ostream& operator<<(std::ostream &os, const std::set<T> &set)
{
  _iterator_to_display(os, set.begin(), set.end());
  return os;
}

template<typename T, typename U, class C=std::less<T>>
std::ostream& operator<<(std::ostream &os, const std::map<T, U> &map)
{
  _iterator_to_display(os, map.begin(), map.end());
  return os;
}
#endif /* __DEBUG__ */

int main(int argc, char **argv)
{
  unsigned N;
  std::cin >> N;
  
  std::vector<unsigned> a(N);
  N_TIMES(n, N) std::cin >> a[n];
  
  unsigned S = std::accumulate(a.begin(), a.end(), static_cast<unsigned>(0));
  
  std::cout << (S - N) << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
s=list(input())
t=list(input())
ls = [[] for _ in range(2)]
for i in range(len(s)):
    if s[i]==t[i]:
        if s[i] in ls[0]:
            index=ls[0].index(s[i])
            if t[i] == ls[1][index]:
                pass
            else:
                print("No")
                exit()

        else:
            if t[i] in ls[1]:
                print("No")
                exit()
            else:
                ls[0].append(s[i])
                ls[1].append(t[i])
    else:
        if s[i] in ls[0]:
            index = ls[0].index(s[i])
            if t[i] == ls[1][index]:
                pass
            else:
                print("No")
                exit()
        else:
            if t[i] in ls[1]:
                print("No")
                exit()
            else:
                ls[0].append(s[i])
                ls[1].append(t[i])
print("Yes")




Measured memory_bytes: 70604
# abc166 C
n, m = map(int, input().split())
lh = [0] + list(map(int, input().split()))
lm = [[] for i in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    lm[a].append(b)
    lm[b].append(a)

ans = 0

for i in range(1, n+1):
    good = True
    for j in lm[i]:
        if lh[i] <= lh[j]:
            good = False

    if good:
        ans += 1

print(ans)


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

using namespace std;

#define fo(i,n) for(int i=0; i<n; i++)
#define Fo(i,k,n) for(int i=k; i<n; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

int n,k;
vi h, dp;

int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin>>n>>k;
    h.resize(n+1);
    dp.resize(n+1, INT_MAX);
    Fo(i,1,n+1)cin>>h[i];
    dp[1]=0;
    Fo(i,2,n+1){
        Fo(j,1,k+1){
            if(i-j < 1)continue;
            // cout<<dp[i-j]<<" "<<abs(h[i]-h[j])<<" "<<i<< " "<<j<<endl;
            dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
s = list(input())

if s[0] == 'R' and s[1] == 'R' and s[2] == 'R':
    print(3)
elif s[0] == 'R' and s[1] == 'R':
    print(2)
elif s[1] == 'R' and s[2] == 'R':
    print(2)
elif s[0] == 'R' or s[1] == 'R' or s[2]=='R':
    print(1)
else:
    print(0)

Measured memory_bytes: 9120
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        list<int> li;
        list<int>::iterator it;
            char str[20];
            int inp;
        while(n--){
            scanf("%s", str);
            if(str[0] == 'i'){
                scanf("%d", &inp);
                li.push_front(inp);
            }else if(str[6] == 'F'){
                li.pop_front();
            }else if(str[6] == 'L'){
                li.pop_back();
            }else if(str[0] == 'd'){
                scanf("%d", &inp);
                for(it = li.begin(); it != li.end(); it++){
                    if(*it == inp){
                         li.erase(it);
                         break;
                    }
                }
            }
        }
        for(it = li.begin(); it != li.end(); it++){
            if(it == li.begin()) cout << *it;
            else cout << ' ' << *it;
        }
        cout << endl;
    }
}



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

int main(){
    int n; cin >> n;
    vector<vector<int> > a(2,vector<int>(n));
    rep(i,2)rep(j,n) cin >> a[i][j];
    int ans = 0;
    for(int k = 0; k < n; k++) {
        int sum = 0;
        for(int i = 0; i <= k; i++) sum += a[0][i];
        for(int i = k; i < n; i++) sum += a[1][i]; 
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
list_w = []
list_k = []
for x in range(10):
    list_w.append(int(input()))
list_w.sort(reverse = True)
for x in range(10):
    list_k.append(int(input()))
list_k.sort(reverse = True)
print(str(sum(list_w[0:3])) +' '+ str(sum(list_k[0:3])))



Measured memory_bytes: 5600
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int input = sc.nextInt();
		int num = input - 1;
		int[][] array = new int[num][];
		for(int i = 0; i < num; i++){
			int[] ar = new int[3];
			for(int j = 0; j < 3; j++){
				ar[j] = sc.nextInt();
			}
			array[i] = ar;
		}

		int[] timeArray = new int[num + 1];
		for(int i = 0;  i < num; i++){
			int time = array[i][0] + array[i][1];
			int j = i;
			while(j + 1 < num){
				if(time < array[j+1][1]){
					time = array[j+1][1];
				}else if(time % array[j+1][2] == 0){

				}else{
					time += array[j+1][2] - (time % array[j+1][2]);
				}
				time += array[j + 1][0];
				j++;
			}
			timeArray[i] = time;
		}
		timeArray[num] = 0;
		for(int i = 0; i < timeArray.length; i++){
			System.out.println(timeArray[i]);
		}
	}

}


Measured memory_bytes: 24948
def main():
    N,K = map(int, input().split())
    S = input()
    flag = S[0]
    count = 0
    A = [1]
    count0 = 0
    if S[0] == "0":
        count0 += 1
    
    for i in range(1,len(S)):
        if S[i] == flag:
            A[count] += 1
        else:
            A.append(1)
            count += 1
            flag = S[i]
            if S[i] == "0":
                count0 += 1
    
    if count0 <= K:
        answer = N
        print(answer)
    else:
        head = 0
        tail = 0
        if S[0] == "0":
            head = sum(A[:2*K])
            if A != []:
                A.pop(0)
        if S[-1] == "0":
            tail = sum(A[::-1][:2*K])
            if A != []:
                A.pop(-1)
        g = min(len(A),2*K+1)
        tmp = sum(A[:g])
        MAX = sum(A[:g])
        s = 0
        while g  < len(A):
            tmp += - A[s] - A[s+1] + A[g] + A[g+1]
            if MAX < tmp:
                MAX = tmp
            s += 2
            g += 2
        print(max(MAX,head,tail))
    
main()

Measured memory_bytes: 46448
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    string s; cin >> s;
    int n = s.size();
    vector<ll> vec(2019, 0);
    int cur = 0;
    int fac = 1;
    vec[0]++;
    rep (i, n) {
        int add = s[n - 1 - i] - '0';
        cur = (cur + (fac * add)) % 2019;
        vec[cur]++;
        fac = (10 * fac) % 2019;
    }
    ll ans = 0;
    rep (i, 2019) ans += vec[i] * (vec[i] - 1) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 3352
#include<stdio.h>
main(){
  int a[5],b[5];

  while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])!=EOF){
    int co[2]={0},i,j;
    scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
  
    for(i=0;i<4;i++){

      if(a[i]==b[i]) co[0]++;

      for(j=0;j<4;j++){
	if(j!=i){

	  if(a[i]==b[j]) co[1]++;

	}
      }
    }
    printf("%d %d\n",co[0],co[1]);
  }
  return 0;
}

Measured memory_bytes: 0
n,m = map(int,input().split())
ans = 0;pel = 0
ansArray = [0] * n
waArray = [0] * n
for i in range(m):
	a,b = map(str,input().split())
	a = int(a)
	if ansArray[a-1] == 0:
		if b == "AC":
			ans += 1
			pel += waArray[a-1]
			ansArray[a-1] = 1
		else:
			waArray[a-1] += 1
print(' '.join(map(str,[ans,pel])))


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

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

const int MX = 200005;
int in[MX], out[MX], k;
vector<int> to[MX];
void dfs(int v, int p=-1) {
  in[v] = k++;
  for (int u : to[v]) {
    if (u == p) continue;
    dfs(u,v);
  }
  out[v] = k;
}

vector<int> vs[MX];

ll c2(ll n) { return n*(n+1)/2;}

int main() {
  int n;
  cin >> n;
  vector<int> c(n);
  rep(i,n) cin >> c[i];
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  dfs(0);
  rep(i,n) vs[c[i]-1].push_back(i);
  ll tot = c2(n);
  BIT<int> d(n);
  rep(i,n) d.add(i,1);
  rep(i,n) {
    ll ans = tot;
    vector<int>& nvs = vs[i];
    sort(nvs.begin(), nvs.end(), [&](int a, int b) {
      return in[a] > in[b];
    });
    vector<P> history;
    for (int v : nvs) {
      int cnt = 1;
      for (int u : to[v]) {
        if (in[u] < in[v]) continue;
        int num = d.sum(in[u], out[u]);
        ans -= c2(num);
        cnt += num;
      }
      d.add(in[v], -cnt);
      history.emplace_back(in[v], cnt);
    }
    ans -= c2(d.sum(0,n));
    for (auto p : history) {
      d.add(p.first, p.second);
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); 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)

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

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

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

int H,W;
bool use[400][400];

pi dfs(int y, int x, vector<string> &f)
{
    pi ret = pi(0,0);
    if (f[y][x]=='#') ret.fi++; else ret.se++;
    use[y][x] = true;
    rep(i,4){
        int ty = y+dy[i];
        int tx = x+dx[i];
        if (!(0<=tx&&tx<W&&0<=ty&&ty<H)) continue;
        if (use[ty][tx]) continue;
        if (f[y][x]==f[ty][tx]) continue;
        auto p = dfs(ty,tx,f);
        ret.fi += p.fi;
        ret.se += p.se;
    }
    return ret;
}

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>H>>W;
    vector<string> f(H);
    rep(i,H) cin>>f[i];
    ll ans=0;
    rep(i,H)rep(j,W)if(!use[i][j]){
        auto p = dfs(i,j,f);
        ans += (ll)p.fi*p.se;
    }
    cout<<ans<<"\n";
    return 0;
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

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

	if(a * b >= c * d)
		cout << a * b << endl;
	else if(a * b < c * d)
		cout << c * d << endl;
	else if(a * b == c * d)
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const int INF=INT_MAX;
const double PI=3.1415926;
int main()
{
    double n;
    cin>>n;
    cout<<fixed<<setprecision(5)<<n*PI*2;
}


Measured memory_bytes: 3772
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
  string s;
  string s0 = "0", s1 = "1";
  cin >> s;
  int n = s.size();
  for(int i = 0; i<n-1; i++){
    if(i%2==0){
      s0 += '1';
      s1 += '0';
    }
    else{
      s0 += '0';
      s1 += '1';
    }
  }
  int cnt0 = 0, cnt1 = 0;
  for(int i = 0; i<n; i++){
    if(s[i] != s0[i]) cnt0++;
    if(s[i] != s1[i]) cnt1++;
  }

  cout << min(cnt1, cnt0) << endl;
  return 0;
}


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

int main()
{
    string S;
    cin >> S;

    int ans = 0;
    int cnt = 0;

    for (int i = 0; i < 3; ++i)
    {
        if (S[i] == 'R')
            cnt++;
        else
        {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

const int MAX_N = 110;
int height, width;
char field[MAX_N][MAX_N];
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};

inline bool VALID_POS(int x, int y) {
    return ( x >= 0 && x < width && y >= 0 && y < height);
}

void dfs(int x, int y, char fruit)
{
    field[y][x] = ' ';

    for (int i = 0; i < 4; ++i) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        // ??°?????????
        if (!VALID_POS(nx, ny) || field[ny][nx] != fruit) continue;
            
        field[ny][nx] = ' ';
        dfs(nx, ny, fruit);
    }  
}


int solve() {
    int ref = 0;

    for (int y = 0; y < height; ++y) {
        for (int x = 0; x < width; ++x) {
            // ??°?????????
            if (field[y][x] == ' ') continue;

            dfs(x, y, field[y][x]);
            ref++;
        }
    }

    return ref;
}


int main()
{
    
    while (cin >> height >> width) {
        if (height == 0 && width == 0) break;

        for (int y = 0; y < height; ++y) {
            for (int x = 0; x < width; ++x) {
                cin >> field[y][x];
            }
        }

        int ans = solve();

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1640
#include <bits/stdc++.h>
using namespace std;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(j, n) for (int j = 0; j < (n); j++)
typedef long long ll;
typedef vector<int> veci;

int main()
{
    int n, d, x;
    cin >> n >> d >> x;
    rep(i,n)
    {
        int t;
        cin >> t;
        for (int j = 0; j*t+1<= d;j++) x++;
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define vbi vector<bool> 
#define mod 1000000007
#define INF 1000000000
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define endl '\n'
#define cnl cout<<endl;
#define frr(i,b) for(ll i=0; i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
ll i,j,k;
void solve()
{
   ll t; cin>>t;
   ll x=pow(t,2);
   cout<<x;
}
signed main(){
   
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Integer[] members = new Integer[n];
    long ans = 0;
    for (int i = 0; i < n; i++) {
      members[i] = sc.nextInt();
    }
    // 木構造で親の分だけ点数を足す
    Arrays.sort(members, Collections.reverseOrder());
    for (int i = 0; i < n; i++) {
      if (i == 0) {continue;}
      ans += members[i / 2];
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 63724
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut ans: usize = 0;
    for i in 1..=n {
        if i % 3 != 0 && i % 5 != 0 {
            ans += i;
        }
    }

    return ans.to_string();
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int n,m,q;
ll ans = 0 ;
vector<int> a(50),b(50),c(50),d(50);


void dfs(vector<int> A){
    if(A.size() == n + 1){
        // calc score
        ll now = 0 ;
        rep(i,q){
            if(A[b[i]] - A[a[i]] == c[i] ) now += d[i];
        }
        ans = max(ans,now);
        return;
    }
    A.push_back(A.back());
    while(A.back() <= m ){
        dfs(A);
        A.back()++;
    }
}
int main(void){
    cin >> n >> m >> q;
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));

    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
const ll mod = 1e9+7;

ll power(ll a,ll b) {
    ll res = 1;
    while(b) {
        if(b&1) {
            res = (res*a)%mod;
        }
        a = (a*a)%mod;
        b >>= 1;
    }
    return res;
}

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    cout << (n*(n-1))/2 + (m*(m-1))/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n;
  int a, b;
  int x, y;
  int i;

  while(1) {
    scanf("%d", &n);
    if(n == 0) break;

    a = 0;
    b = 0;

    for(i = 0; i < n; i++) {
      scanf("%d %d", &x, &y);
      if(x > y) a += x+y;
      else if(x < y) b += x+y;
      else {
	a += x;
	b += y;
      }
    }
    printf("%d %d\n", a, b);
  }

  return 0;
}

Measured memory_bytes: 600
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


fn main(){
    let n: usize = read_as_vec()[0];

    let s = read_as_string().chars().collect::<Vec<char>>();


    for i in 0..n{
        print!("{}{}", s[i], s[i+n+1]);
    }
    println!("");
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
int A[200009];

bool solve(int k){
    stack<pii> stk;
    FOR(i,1,N){
        if(A[i-1]>=A[i]){
            while(stk.size()&&stk.top().first>A[i]) stk.pop();
            if(stk.size()&&stk.top().first==A[i]){
                stk.top().second++;
            }else{
                stk.push({A[i],1});
            }
            while(stk.top().second>=k){
                int d=stk.top().first;
                if(d==1) return false;
                stk.pop();
                if(stk.size()&&stk.top().first==d-1){
                    stk.top().second++;
                }else{
                    stk.push({d-1,1});
                }
            }
        }
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep(i,N) cin>>A[i];
    bool f=true;
    rep(i,N-1) if(A[i]>=A[i+1]) f=false;
    if(f){
        cout1(1)
        return 0;
    }
    
    int lb=1,ub=N,mid;
    while(ub-lb>1){
        mid=(ub+lb)/2;
        if(solve(mid)) ub=mid;
        else lb=mid;
    }
    cout1(ub)
}

Measured memory_bytes: 1152