akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1e9 + 7

bool visited[50][50];

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

    int m,n;

    cin >> m >> n;

    vector<string> s(m);

    for(int i = 0;i < m;i++) cin >> s[i];

    queue<pair<int,int> > q;

    for(int i = 0;i < m;i++) for(int j = 0;j < n;j++)
    {
        if(s[i][j]=='.') continue;
        if(visited[i][j]) continue;
        q.push({i,j});
        visited[i][j] = true;
        int cnt = 0;
        while(!q.empty())
        {
            int x = q.front().first,y = q.front().second;
            q.pop();
            cnt++;
            for(int k = -1;k <= 1;k++) for(int l = -1;l <= 1;l++)
            {
                if(k==0 and l==0) continue;
                if(k!=0 and l!=0) continue;
                int ai = k+x,aj = l+y;
                if(ai<0 or ai>=m or aj<0 or aj>=n) continue;
                if(visited[ai][aj]) continue;
                if(s[ai][aj]=='.') continue;
                visited[ai][aj] = true;
                q.push({ai,aj});
            }
        }
        //cout << i << ' ' << j << ' ' << cnt << endl;
        if(cnt==1){ cout << "No"; return 0; }
    }

    cout << "Yes";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,M;
int par[100005];
int rank_[100005];
void init_uf(int n){
for(int i=0;i<n;i++){
par[i]=i;
  rank_[i]=0;
}
}
int find(int x){
if(par[x]==x)
  return x;
  else
    return find(par[x]);
}
void unite(int x,int y){
x=find(x);y=find(y);
  if(x==y)
    return;
  else if(rank_[x]<rank_[y])
    par[x]=y;
  else{
  par[y]=x;
    if(rank_[x]==rank_[y])rank_[x]++;
  }
}
bool same(int x,int y){
return find(x)==find(y);
}
int main(){
cin>>N>>M;init_uf(N);
  map<int,int>m;
  for(int i=0;i<N;i++){
int p;cin>>p;p--;
    m[p]=i;
  }for(int i=0;i<M;i++){
int x,y;cin>>x>>y;x--;y--;
    unite(x,y);
  }int ans=0;
  for(int i=0;i<N;i++){
  if(same(i,m.at(i)))ans++;
  }cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 9004
import collections
n=int(input())

A=list(map(int,input().split()))

a=collections.Counter(A)

X=sorted(a.items(), key=lambda x:x[0])

K=[]
V=[]

RES=[]
for i in range(len(X)):
    K.append(X[i][0])
    V.append(X[i][1])

if len(X)>=3:
    for j in range(1,len(X)-1):
        res=V[j]
        if K[j]-1==K[j-1]:
            res+=V[j-1]
        if K[j]+1==K[j+1]:
            res+=V[j+1]
        RES.append(res)
elif len(X)==2:
    if K[0]+1==K[1]:
        RES.append(V[0]+V[1])
    else:
        RES.append(max(V))
else:
    RES.append(V[0])        

print(max(RES))
        

Measured memory_bytes: 16728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pa;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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

int main()
{   
    ll n,m; cin >> n >> m;
    ll res = (n-m)*100+1900*m;
    cout << res * pow(2,m) << endl;
}
    

Measured memory_bytes: 512
n,m,x,y = list(map(int,input().split()))
x_city = list(map(int,input().split()))
y_city = list(map(int,input().split()))
x_city.sort()
y_city.sort()
for i in range(x+1, y+1):
  if x_city[-1] < i and i <= y_city[0]:
    print('No War')
    quit()
  else:
    pass
print('War')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

const int maxN =  400, BASE = 1e9 + 7;
const long long oo = 10000000000000ll;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define LL long long
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define PINT pair < int, int >
#define BIT(x, i) ((x >> i) & 1)
#define NUM_SET_BIT __builtin_popcountll

struct cmp {
    bool operator () (pair < int, LL > a, pair < int, LL > b) {
        return b.S < a.S;
    }
};

priority_queue < pair < int, LL >, vector < pair < int, LL > >, cmp > heap;

int n, c[maxN][maxN], a[maxN][maxN], check[maxN];
vector < pair < int, PINT > > e;
vector < PINT > adj[maxN];
LL res, d[maxN];

LL dijkstra(int s, int t) {
    FORU(i, 1, n) d[i] = oo, check[i] = 0;
    while (!heap.empty()) heap.pop();
    d[s] = 0; heap.push(MP(s, d[s]));

    while (!heap.empty()) {
        auto p = heap.top(); heap.pop();
        while (check[p.F] && !heap.empty()) {
            p = heap.top();
            heap.pop();
        }
        if (check[p.F]) break;

        int u = p.F;
        if (u == t) return d[t];
        REPU(i, adj[u].size()) {
            int v = adj[u][i].F;
            int w = adj[u][i].S;
            if (d[v] > d[u] + w) {
                d[v] = d[u] + w;
                heap.push(MP(v, d[v]));
            }
        }
    }

    return (d[t] == oo) ? -1 : d[t];
}

int main() {
    cin >> n;
    FORU(i, 1, n)
        FORU(j, 1, n) {
            int x; scanf("%d", &x);
            if (j <= i) continue;
            e.PB({x, MP(i, j)});
        }

    sort(e.begin(), e.end());

    for (auto p : e) {
        int u = p.S.F;
        int v = p.S.S;
        int w = p.F;
        int len = dijkstra(u, v);
        if ((len != -1 && len < w) || (len > w && c[u][v])) {
            cout << -1;
            return 0;
        }
        if (len != w) {
            c[u][v] = c[v][u] = w;
            res += w;
            adj[u].PB(MP(v, w));
            adj[v].PB(MP(u, w));
        }
    }

    cout << res;
}


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

int h, n;
vector<int> b;

int dp[101010][10];

int dfs(int i = 1, int bit = 0) {
  if (i == h) {
    return 0;
  }
  bit |= b[i];

  int &ret = dp[i][bit];
  if (~ret)
    return ret;

  ret = 0;
  if (bit == 0)
    ret = max(ret, dfs(i + 1, 0b111) + 2);
  if ((bit & (0b100)) == 0)
    ret = max(ret, dfs(i + 1, 0b110) + 1);
  if ((bit & (0b010)) == 0)
    ret = max(ret, dfs(i + 1, 0b111) + 1);
  if ((bit & (0b001)) == 0)
    ret = max(ret, dfs(i + 1, 0b011) + 1);
  ret = max(ret, dfs(i + 1, 0));

  return ret;
}

int main() {
  memset(dp, -1, sizeof(dp));
  cin >> h >> n;

  int ei[4] = {0b100, 0b110, 0b011, 0b001};
  b.assign(h + 1, 0);
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    b[y + 1] |= ei[x];
    b[y] |= ei[x];
  }

  cout << dfs() << endl;
}


Measured memory_bytes: 7552
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N, A, B;
    scan(N, A, B);
    A -= B;
    auto H = lreads(N);
    long ok = 10 ^^ 9 + 100;
    long ng = 0;
    bool eval(long x)
    {
        long cnt;
        foreach (i; 0 .. N)
        {
            if (B * x < H[i])
            {
                cnt += (H[i] - B * x + A - 1) / A;
            }
            if (x < cnt)
                return false;
        }
        return true;
    }

    while (1 < ok - ng)
    {
        long m = (ok + ng) / 2;
        if (eval(m))
        {
            ok = m;
        }
        else
        {
            ng = m;
        }
    }
    writeln(ok);
}


Measured memory_bytes: 5340
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def count_bits(N):
    T = 0
    while N != 0:
        T += N & 1
        N >>= 1
    return T


def solve():
    """
    OPT[i][j] - number of pairs for first i man, with mask j=0011..01

    OPT[i+1][j|k] += OPT[i][j] k has exactly one bit set j|k != j and i+1 is compatible with k-th woman

    """
    N = read_int()
    modulo = 10**9+7
    A = []
    for _ in range(N):
        A.append(read_ints())
    dp = [0]*(2**N)
    dp[0] = 1
    for mask in range(2**N-1):
        a = count_bits(mask)
        for b in range(N):
            if A[a][b] and mask&(1<<b) == 0:
                dp[mask|(1<<b)] = (dp[mask|(1<<b)]+dp[mask])%modulo
    return dp[-1]


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 57580
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String str = br.readLine();
	    StringBuilder sb = new StringBuilder(str);

	    int q = Integer.parseInt(br.readLine());

	    StringBuilder result = new StringBuilder();
	    for (int i = 0; i < q; i++) {
	    	String[] line = br.readLine().split(" ");

	    	String order = line[0];
	    	int a = Integer.parseInt(line[1]);
	    	int b = Integer.parseInt(line[2]) + 1;

	    	String p = "";
	    	if (line.length > 3) p = line[3];

	    	if ("replace".equals(order)) {
	    		sb.replace(a, b, p).toString();
	    	}

	    	if ("reverse".equals(order)) {
	    		StringBuilder temp = new StringBuilder(sb.substring(a, b));
	    		sb.replace(a, b, temp.reverse().toString()).toString();
	    	}

	    	if ("print".equals(order)) {
		    	result.append(sb.substring(a, b)).append("\n");
	    	}
 	    }
	    System.out.print(result.toString());
	}
}

Measured memory_bytes: 24620
a, b = map(int, input().split())


def factorization_in_prime_number(x):
    prime_factor = []
    if x % 2 == 0:
        prime_factor.append(2)
    while x % 2 == 0:
        x //= 2
    m = int(x**.5) + 1
    for i in range(3, m, 2):
        if x % i == 0:
            prime_factor.append(i)
        while x % i == 0:
            x //= i
    if x != 1:
        prime_factor.append(x)
    return prime_factor


a_factor = factorization_in_prime_number(a)
b_factor = factorization_in_prime_number(b)
ans = len(set(a_factor) & set(b_factor)) + 1
print(ans)


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

int main(void)
{
	char str[12];
	while (scanf("%s", str) != EOF){
		if ((str[0] != 's') && ((str[0] == str[1] && str[1] == str[2]) || (str[0] == str[3] && str[3] == str[6]) || (str[0] == str[4] && str[4] == str[8]))){
			cout << str[0] << endl;
		}
		else if ((str[4] != 's') && ((str[3] == str[4] && str[4] == str[5]) || (str[1] == str[4] && str[4] == str[7]) || (str[0] == str[4] && str[4] == str[8]) || (str[2] == str[4] && str[4] == str[6]))){
			cout << str[4] << endl;
		}
		else if ((str[8] != 's') && ((str[6] == str[7] && str[7] == str[8]) || (str[2] == str[5] && str[5] == str[8]))){
			cout << str[8] << endl;
		}
		else puts("d");
	}
	
	return (0);
}

Measured memory_bytes: 0
n,m=map(int, input().split())
l = [None]*n
msg=''
for _ in range(m):
    s, c = input().split()
    index = int(s)-1
    if l[index] is None:
        l[index] = c
    else:
        if l[index] == c:
            continue
        else:
            msg=-1
            break
if l[0] is None and len(l) != 1:
    l[0]='1'
l = list(map(lambda x: '0' if x is None else x, l))
if msg == -1:
    print(msg)
elif l[0] == '0' and len(l) != 1:
    print(-1)
else:
    print(msg.join(l))



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int l=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
	if(s[i]=='x')
	l++;
	if(l>7)
	cout<<"NO";
	else
	cout<<"YES";
	return 0;
}

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

int main() {
  int X;
  cin>>X;
  if(X>=30){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

int main()
{
	int n, m;
	long x[1000], y[1000];

	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> x[i] >> y[i];

	int c = abs(x[0] + y[0]) % 2;
	bool f = 1;

	for (int i = 0; i < n; i++) {
		if (abs(x[i] + y[i]) % 2 != c) {
			cout << -1 << endl;
			f = 0;
			break;
		}
	}

	if (f) {
		long long d[32];

		m = 31;
		if(c % 2 == 0)
			m++;

		cout << m << endl;

		for (int i = 0; i < m - 1; i++) {
			d[i] = 1ull << (30 - i);
			cout << d[i] << " ";
		}

		d[m - 1] = 1;
		cout << d[m - 1] << endl;

		for (int i = 0; i < n; i++) {
			if (c % 2 == 0) {
				x[i]--;
				m = 31;
			}

			long long u = x[i] + y[i], v = x[i] - y[i], s = 0, t = 0;

			for (int j = 0; j < m; j++) {
				if (u > s && v < t) {
					cout << "U";
					s += d[j];
					t -= d[j];
				}
				else if (u < s && v < t) {
					cout << "L";
					s -= d[j];
					t -= d[j];
				}
				else if (u < s && v > t) {
					cout << "D";
					s -= d[j];
					t += d[j];
				}
				else {
					cout << "R";
					s += d[j];
					t += d[j];
				}
			}

			if (c % 2 == 0)
				cout << "R";

			cout << endl;
		}
	}

	return 0;
}

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

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

using namespace std;
using lint=long long;

int main(){
	lint a,b,n; cin>>a>>b>>n;
	lint x=min(n,b-1);
	printf("%lld\n",(a*x)/b-a*(x/b));
	return 0;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    string s, t;
    cin >> s >> t;
    map<char, Int> mp;
    Int n = s.size(); 
    Int m = t.size();
    for (Int i = 0; i < n; i++) {
        mp[s[i]]++;
    }
    for (Int i = 0; i < m; i++) {
        if (mp[t[i]] == 0) {
            dump(-1);
            return 0;
        }
    }
    vector<vector<Int>> nxt(n, vector<Int>(26, INF));
    for (Int i = 2 * n - 1; i >= 0; i--) {
        for (Int j = 0; j < 26; j++) {
            if (s[i % n] == 'a' + j) {
                nxt[(i - 1 + n) % n][j] = 1;
            }
        }
    }
    for (Int i = 2 * n - 1; i >= 0; i--) {
        for (Int j = 0; j < 26; j++) {
            nxt[(i - 1 + n) % n][j] = min(nxt[(i - 1 + n) % n][j], nxt[i % n][j] + 1);
        }
    }
    Int res = 1;
    Int cur = 0;
    for (Int i = 0; i < m; i++) {
        if (i == 0 and t[0] == s[0]) continue;
        res += nxt[cur][t[i] - 'a'];
        cur += nxt[cur][t[i] - 'a'];
        cur %= n;
    }
    dump(res);
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    int n; cin >> n;
    
    vector<int> a(n+1),b(n);
    REP(i,n+1) cin >> a[i];
    REP(i,n) cin >> b[i];

    ll ans = 0;
    REP(i,n) {
        ans += min(a[i],b[i]);
        b[i] = max(0,b[i]-a[i]);
        ans += min(b[i],a[i+1]);
        a[i+1] = max(0,a[i+1] - b[i]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var (
		k, s, num int
	)
	fmt.Scan(&k, &s)
	for x := 0; x <= k; x++ {
		for y := 0; y <= k; y++ {
			z := s - x - y
			if 0 <= z && z <= k {
				num++
			}
		}
	}
	fmt.Println(num)
}


Measured memory_bytes: 1784
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

int main(){
  int N, K, T, U, V, L;
  cin >> N >> K >> T >> U >> V >> L;
  vector<int> D(N);
  REP(i, N) cin >> D[i];


  double res = 0;
  double pos = 0;
  int carrot = 0;
  int i = 0;
  while(i < N){
    // move to a next carrot
    res += (D[i] - pos) / U;
    pos = D[i++];
    carrot++;

    while(carrot > 0){
      // eat carrot
      // cout << pos << " " << res << endl;      
      carrot--;
      double next = min(pos + T * V, (double)L);;

      while(i < N && D[i] < next){
        carrot++;
        i++;
      }

      if(carrot > K){
        carrot = K + 1;
        res += (D[i-1] - pos) / V;
        pos =  D[i-1];
      }else{
        res += (next - pos) / V;
        pos = next;
      }
    }
    assert(carrot == 0);
  }
  cout << fixed << setprecision(20) << res + (L - pos) / U << endl;
  
  return 0;
}

Measured memory_bytes: 1268
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
bool is_all_c(char c, string s){
		REP(i, s.length())
				if(s[i] != c)  return false;
		return true;
}

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	string S;  cin >> S;
	int ans = INF;
	for(char c = 'a' ; c <= 'z' ; c++){

			string s = S;  int keep = 0;
			while(!(is_all_c(c, s))){

							REP(i, s.length() - 1)
								if(s[i] == c || s[i + 1] == c)  s[i] = c;
					
							s.pop_back();
							keep += 1;
			}
			ans = min(ans, keep);
	}


	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
using ll = long long;
using namespace std;
int main(){
    int n;
    cin>>n;
    rep(i,n+1){
        int ans = floor(i*1.08);
        if(ans==n){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
}

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

int main() {
  int N,A,B,C,D,i,cn=0;
  char p='.';
  string S,s1,s2;
  cin >> N >> A >> B >> C >> D >> S;
  s1 = S.substr(A, C-A+1);
  s2 = S.substr(B, D-B+1);
  
  for(char c : s1) {
    if(c=='#' && p==c) {
      cout << "No" << endl;
      return 0;
    }
    p=c;
  }
  p='.';
  for(char c : s2) {
    if(c=='#' && p==c) {
      cout << "No" << endl;
      return 0;
    }
    p=c;
  }
  
  if(C>D) {
    for(i=B-2; i<D+1; i++) {
      char c=S.at(i);
      if(c=='.')
        cn++;
      else
        cn=0;
      if(cn==3)
        break;
    }
    if(i==D+1) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
}

Measured memory_bytes: 772
# -*- coding: utf-8 -*-
s = int(input())

dp = [s]

i=2
a_1=s
while(True):
    if a_1 % 2==0:
        index = a_1 /2
    else:
        index = 3 * a_1 + 1
    if int(index) in dp:
        break
    else:
        dp.append(int(index))
        a_1 = int(index)
        i+=1

print(i)

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

using namespace std;

void Main() {
    string N;
    cin >> N;

    bool has9 = false;
    if (N[0] == '9' || N[1] == '9') {
        has9 = true;
    }
    cout << (has9 ? "Yes" : "No") << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3624
# E - Crested Ibis vs Monster
def main():
    INF = 1 << 30

    H, N, *AB = map(int, open(0).read().split())
    dp = [INF] * (H + 10001)  # dp[i] := min magic points to decrease monster's health by i
    dp[0] = 0
    for i in range(H):
        for a, b in zip(*[iter(AB)] * 2):
            dp[i + a] = min(dp[i + a], dp[i] + b)
    print(min(dp[H:]))


if __name__ == "__main__":
    main()


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

int main(){
  int n;
  std::cin >> n;
  string s;
  int count = 0;
  std::cin >> s;
  rep(i, n - 2){
    if(s.at(i) == 'A'){
      if (s.at(i+1) == 'B') {
        if (s.at(i+2) == 'C') {
          count++;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}

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


int main(void){
  int n, i, j;
  double v[1000];
  double sum = 0, temp = 0;
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> v[i];
  }
  for(i = 0; i < n; i++){
    for(j = i; j < n; j++){
      if(v[i] < v[j]){
        temp = v[i];
        v[i] = v[j];
        v[j] = temp;
      }
    }
  }
  sum = sum + v[n-1];
  for(i = n-2; 0 <= i; i--){
    sum = (sum + v[i])/2;
  }
  cout << sum;
  return 0;
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  map<string, int> cnt;
  int ans = 0;
  for ( int i = 0; i < N; i++ ) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ans += cnt[s];
    cnt[s]++;
  }

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


Measured memory_bytes: 11264
#include<stdio.h>

int main(void) {
  char s[4];
  int i = 0,sum = 700;
  for (i = 0;i < 3;++i) {
    scanf("%s",&s[i]);
  }
  for (i = 0;i < 3;++i) {
    if(s[i] == 'o') {
      sum += 100;
    }
  }
  printf("%d",sum);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void){
  int n,x,l[101];
  int i, count = 1, length = 0;
  
  scanf("%d %d",&n,&x);
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
    length += l[i];
    if(length<=x){
      count += 1;
    }
    else{
      break;
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main ()
{
	long int K, S, C=0;
	while (scanf("%d%d", &K, &S)!=EOF)
	{
		C=0, C=0;
		for (int i=0;i<=K;i++)
		{
			for(int j=0;j<=K;j++)
			{
				if(i+j+K>=S&&i+j<=S)
					C++;	
			} 
		}
		cout<<C<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b,c;
  cin>>a>>b>>c;
  int m = max({a,b,c});
  cout <<  a + b + c + m * 9 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int D;
  cin >> D;
  vector<int> c(26);
  for (auto &it : c)
    cin >> it;
  vector<vector<ll>> s(D, vector<ll>(26));
  for (int i = 0; i < D; i++)
  {
    for (int j = 0; j < 26; j++)
    {
      cin >> s[i][j];
    }
  }

  vector<ll> last(26, 0);

  vector<ll> t(D);
  for (auto &it : t)
  {
    cin >> it;
    it--;
  }
  ll score = 0;
  for (int i = 0; i < D; i++)
  {
    last[t[i]] = i + 1;
    score += s[i][t[i]];
    for (int j = 0; j < 26; j++)
    {
      score -= c[j] * ((i + 1) - last[j]);
    }
    cout << score << endl;
  }
  return 0;
}


Measured memory_bytes: 3704
n, a, b = map(int, input().split())
s = str(input())
i = 0
ab = a + b
pas, bn = 0, 0
while i < n:
    if (s[i] == 'a' and pas < ab):
        print('Yes')
        pas += 1
    elif (s[i] == 'b' and pas < ab and bn < b):
        print('Yes')
        pas += 1
        bn += 1
    else:
        print('No')
    i += 1


Measured memory_bytes: 4040
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
int  main()
{
    
    ll a1 , a2 , b1 ,b2 ; 
    cin>>a1>> b1 >>a2>>b2 ; 
    if(a1<0 )
    {
        cout<< "No" ;
        return 0 ; 
    }else if ( a2<0)
    {
        cout<<"Yes" ;
        return  0 ; 
    }
    
    
    while( a1>0  && a2>0 )
    {
        a2-= b1 ; 
        if(a2<=0)
        break ; 
        a1 -= b2 ; 
        

    }
    
    if(a2<=0)
    cout<<"Yes" ;
    else
    cout<<"No " ;
}

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

int main() {
    int A , B ;
    cin >> A >> B ; // 1 ≤ A,B ≤ 3
    if (A == 1 && B == 2 || A == 2 && B == 1) cout << "3" << endl ;
    if (A == 2 && B == 3 || A == 3 && B == 2) cout << "1" << endl ;
    if (A == 3 && B == 1 || A == 1 && B == 3) cout << "2" << endl ;
	return 0;
}

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

int main() {
    int N, i;
    cin >> N >> i;
    cout << N - i + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad

main :: IO ()
main = do
  [n, a, b] <- getInts
  ss <- getLine
  let ans = solve a b ss
  mapM_ putStrLn ans
  
getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: Int -> Int -> String -> [String]
solve a b ss = go ss 0 0 
  where
    go [] _ _ = []
    go (c:cs) a' b'
      | a' + b' >= a + b = "No" : go cs a' b'
      | c == 'a' = "Yes" : go cs (a'+1) b'
      | c == 'b' &&
        b' < b = "Yes" : go cs a' (b' + 1)
      | otherwise = "No" : go cs a' b'


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	priority_queue<int> Q,P;
	REP(i,1<<N){
		Q.push(in());
	}
	
	P.push(Q.top());
	Q.pop();
	
	for(int i=0;i<N;i++){
		vector<int> NP,NQ;
		while(!P.empty()){
			auto S = P.top();
			P.pop();
			NP.push_back(S);
			while(!Q.empty()){
				auto V = Q.top();
				Q.pop();
				if(S>V){
					NP.push_back(V);
					break;
				}
				else{
					NQ.push_back(V);
				}
			}
			
		}
		for(auto& x:NP) P.push(x);
		for(auto& x:NQ) Q.push(x);
	}
	
	out(P.size()==(1<<N) ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
string S;
ll K;

bool allsame(string T) {
    for(int i = 0; i < T.size(); i++) {
        if(T[i] != T[0]) return false;
    }
    return true;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> S >> K;
    if(allsame(S)) {
        ll tmp = S.size() * K;
        cout << (tmp) / 2 << endl;
        return 0;
    }
    vector<ll> v;
    for(int i = 0; i < S.size(); i++) {
        if(i == 0 || S[i] != S[i-1]) v.push_back(0);
        v.back()++;
    }
    if(S[0] == S.back()) {
        ll ans = 0;
        for(int i = 1; i + 1 < v.size(); i++) {
            ans += K * ((v[i]) / 2);
        }
        ll tmp = v[0] + v.back();
        ans += (K - 1) * ((tmp) / 2);
        ans += (v[0]) / 2;
        ans += (v.back()) / 2;
        cout << ans << endl;
    } else {
        ll ans = 0;
        for(int i = 0; i < v.size(); i++) {
            ans += K * ((v[i]) / 2);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=sorted(list(map(int,input().split())))
b=list(map(int,input().split()))
c=sorted(list(map(int,input().split())))
import bisect
ans=0
for i in range(n):
    inda=bisect.bisect_left(a,b[i])
    indc=bisect.bisect_right(c,b[i])
    ans += inda*(n-indc)
print(ans)

Measured memory_bytes: 29440
n = gets.to_i
a = gets.split.map(&:to_i)
bef = a[0]
sum = 0
(n - 1).times do |i|
  if a[i+1] < bef
    sum += bef - a[i+1]
  else
    bef = a[i+1]
  end
end
puts sum

Measured memory_bytes: 28088
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>

using namespace std;

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

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

	long long dp[n][n];
	for(int i=0; i<n; i++) {
		dp[i][i] = a[i];
	}
	for(int len=2; len<=n; len++) {
		for(int i=0,j=i+len-1; j<n; i++,j++) {
			dp[i][j] = max(a[j]-dp[i][j-1], a[i]-dp[i+1][j]);
		}
	}
	printf("%lld\n", dp[0][n-1]);
    return 0;
}

Measured memory_bytes: 70400
#include <iostream>
int main() {
	int N, A, B, C, D, x,y;
	std::cin >> N >> A >> B >> C >> D;
	if (N%A >= 1) {
		x = N / A + 1;
	}
	else {
		x = N / A;
	}
	if (N%C >= 1) {
		y = N/ C+ 1;
	}
	else {
		y = N / C;
	}
	
	if (x*B < y*D) {
		std::cout << x * B << std::endl;
	}
	if (x*B >= y*D) {
		std::cout << y * D << std::endl;
	}
}




Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}

typedef pair<double,double> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 100005;
const double PI = 3.14159265358979323846;

P rot(P x, double th)
{
    return P(x.fi*cos(th)-x.se*sin(th), x.fi*sin(th)+x.se*cos(th));
}

double dir(P p, P q)
{
    return sqrt((p.fi-q.fi)*(p.fi-q.fi)+(p.se-q.se)*(p.se-q.se));
}

double solve(P p, P q, P r)
{
    q.fi -= p.fi, q.se -= p.se, r.fi -= p.fi, r.se -= p.se;
    p = P(0.0, 0.0);
    double th;
    if(abs(q.fi) < EPS){
        if(q.se > 0){
            th = - PI / 2.0;
        }else{
            th = PI / 2.0;
        }
    }else{
        th = -atan(q.se/q.fi);
    }
    q = rot(q, th), r = rot(r, th);
    return abs(q.fi)*abs(r.se)/(dir(p,q)+dir(q,r)+dir(r,p)+2*abs(r.se));
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    P p, q, r;
    cin >> p.fi >> p.se;
    cin >> q.fi >> q.se;
    cin >> r.fi >> r.se;
    printf("%.12lf\n", max({solve(p,q,r),solve(q,r,p),solve(r,p,q)}));
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    map<int,int>mp;
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            n/=i;
            mp[i]++;
        }
    }
    if(n>1)mp[n]++;
    int ans=0;
    for(P p:mp){
        for(int j=1;;j++){
            if(j*(j+1)/2<=p.se)continue;
            ans+=j-1;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 1000
#define BIGN (ll)(pow(10, 9) + 7)
using namespace std;
int main() {
  ll p = 1;
  ll n;
  cin >> n;
  for (ll i = 0; i < n; i++) {
    p *= (i + 1);
    p %= BIGN;
  }
  cout << p << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int A,B;
    private void solve() {
        A = nextInt();
        B = nextInt();

        int ans = 0;
        if (A >= 13) {
            ans = B;
        } else if (A >= 6) {
            ans = B / 2;
        }

        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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


Measured memory_bytes: 21588
from collections import Counter

a, b, ab, x, y = map(int, input().split())

if a+b >= ab*2:
    if x < y:
        less, more = x, y
        cost_l, cost_m = a, b
    else:
        less, more = y, x
        cost_l, cost_m = b, a
    
    cost = less*ab*2
    more -= less
    less = 0

    if cost_m < ab * 2:
        cost += more*cost_m
    else:
        cost += more*ab*2

    print(cost)
else:
    print(a*x+b*y)

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

const int P = (int)1e9 + 7;

void add(int &x, const int &y) {
    if ((x += y) >= P)
        x -= P;
}

int d[2][2], D[2][2];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    d[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        memset(D, 0, sizeof(D));
        for (int x = 0; x < 2; ++x) {
            for (int y = 0; y < 2; ++y) {
                add(D[x | 1][y], d[x][y]);
                add(D[x][y | 1], d[x][y]);
                add(D[x][y], (long long)d[x][y] * 8 % P);
            }
        }
        memcpy(d, D, sizeof(d));
    }
    cout << d[1][1];
    return 0;
}


Measured memory_bytes: 3684
#include<iostream>
#include<memory.h>
#include<stdio.h>
#include<algorithm>
using namespace std;

int n;
int a[100005];
int maxnum,minnum;
int ans1[100005];
int ans2[100005];

int main(){
    //cin>>n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        //cin>>a[i];
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    minnum=a[0];
    maxnum=a[n-1];
    for(int i=1;i<n-1;i++){
        if(a[i]<0){
            ans1[i]=maxnum;
            ans2[i]=a[i];
            maxnum-=a[i];
        }
        else{
            ans1[i]=minnum;
            ans2[i]=a[i];
            minnum-=a[i];
        }
    }
    cout<<maxnum-minnum<<endl;
    for(int i=1;i<n-1;i++){
        //cout<<ans1[i]<<" "<<ans2[i]<<endl;
        printf("%d %d\n",ans1[i],ans2[i]);
    }
    //cout<<maxnum<<" "<<minnum<<endl;
    printf("%d %d\n",maxnum,minnum);
    return 0;
}


Measured memory_bytes: 3072
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var l1 = ReadIntArray();
        var X = ReadIntArray();
        int N = l1[0];


        var result = long.MaxValue;
        for (int p = 1; p <= 100; p++)
        {
            long total = 0;
            for (int n = 0; n < N; n++)
            {
                total += ((X[n] - p) * (X[n] - p));
            }
            if (total < result)
            {
                result = total;
            }
        }

        Console.WriteLine(result);
    }

    static string[] ReadStringArray()
    {
        return Console.ReadLine().Trim().Split(' ');
    }

    static int[] ReadIntArray()
    {
        return ReadStringArray().Select(_ => int.Parse(_)).ToArray();
    }

    static long[] ReadLongArray()
    {
        return ReadStringArray().Select(_ => long.Parse(_)).ToArray();
    }
}
 


Measured memory_bytes: 13268
/*
Author : N_o_o_B
Created : April 19 2020 17:32:51 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;
const ld PI = acos(-1);
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int r;
    cin >> r;
    cout << 2*PI*r << endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 3800
h_max, w_max   = gets.split.map(&:to_i)
h_size, w_size = gets.split.map(&:to_i)

# 白色マス         - 塗りつぶす行     - 塗りつぶす列     + 塗りつぶす行列の共通部分
p (h_max * w_max)  - (h_size * w_max) - (w_size * h_max) + (h_size * w_size)

Measured memory_bytes: 1788
#include <iostream>
#include <string>
using namespace std;
bool kaibun(string);
int main(){
	string str;
	int n;
	cin >> str;
	if(!kaibun(str)){
		cout << "No";
		return 0;
	}
	n = str.size();
	if(!kaibun(str.substr(0,(n - 1)/2))){
		cout << "No";
		return 0;
	}
	if(!kaibun(str.substr((n + 3)/2 - 1,n - (n + 3)/2 + 1))){
		cout << "No";
		return 0;
	}
	cout << "Yes";
	return 0;



	return 0;
}

bool kaibun(string str){
	int size = str.size();
	string gyaku;
	for(int i = 0;i <= size - 1;i++){
		gyaku.push_back( str[size - 1 - i]);
	}
	if(gyaku == str){
		return 1;
	}
	return 0;

}


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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        int count = 0, start = 1, end = start + 1, sum = (n > 2) ? start + end : 0;
        while (sum > 0) {
            if (sum < n && end * 2 <= n) {
                sum += ++end;
            } else {
                if (sum == n) {
                    count++;
                }
                sum -= start++;
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 0
#include <stdio.h>

unsigned long long x;

int main(int argc, char const *argv[]) {
	unsigned long long digit = 1;
	int min;

	scanf("%llu", &x);

	for (digit = 1, min = 1000; x / digit > 99; digit *= 10) {
		int n = x / digit % 1000;

		int abs = n - 753;

		abs = abs > 0 ? abs : -abs;

		min = abs < min ? abs : min;
	}

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

	return 0;
}


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

int main()
{
	int A, B;
	cin >> A >> B;
	
	int sum = 0;
	
	for (int i = 0; i < 2; i++) {
		if (A > B) {
			sum += A;
			A--;
		} else {
			sum += B;
			B--;
		}
	}
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define y1 my_y1
#define fi first
#define se second
#define lcm mylcm
 
using namespace std;
 
const ll mod = 998244353;
const ll inf = 2e9;
const int N = 1e5 + 5;

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

int main () {
	//freopen("a.out", "w", stdout);
    cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
		dp[i] = inf;
	}
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	for (int i = 3; i <= n; i++) {
		dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
	}
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 1792