akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

string S;

int main() {
    cin >> S;

    rep(i, S.size()) {
        cout << "x";
    }
    cout << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var A, B, i, ans int
  fmt.Scan(&A, &B)
  for i < B {
    if B == 1{
      break
    }
    if i + A < B {
      i += A-1
    } else {
      i += A
    }
    ans++
  }
  fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int L[N];
  for(int i = 0; i < N; i++){
  	cin >> L[i];
  }
  sort(L,L+N);
  int a = 0;
  for(int j = 0;j < N-1; j++){
  	a += L[j];
  }
  if(L[N-1] < a){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = tuple(map(lambda n: int(n) - 1, input().split()))

visited = [0] * n
next_town = 0
order = []

while True:
    if visited[next_town]:
        break
    order.append(next_town)
    visited[next_town] = 1
    next_town = a[next_town]

first_loop = len(order)
offset = order.index(next_town)
second_loop = first_loop - offset

if k < first_loop:
    print(order[k] + 1)
else:
    print(order[offset + (k - first_loop) % second_loop] + 1)


Measured memory_bytes: 32364
n = int(input())
def check(s):
    if int(s) > n:
        return 0
    if all(s.count(i)>0 for i in '753'):
        count = 1
    else:
        count = 0
    for i in '753':
        count += check(s+i)
    return count
print(check('0'))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
int n,a[10005],t1=0,ans=0,t2=0;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
	scanf("%d",&a[i]);
	if (a[i]%2==0){
	t1=2;t2=0;
	while (a[i]%t1==0){
		t1*=2;
		t2++;
	}
	ans+=t2;
	}
}
printf("%d",ans);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1155&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

int rec(int& i,const string& s){
    int ret = 0;
    if(s[i] >= '0' && s[i] <= '3'){
        ret = s[i] - '0';
        i++;
    }else if(s[i] == '-'){
        i++;
        int tmp = rec(i,s);
        if(tmp == 0) ret = 2;
        if(tmp == 1) ret = 1;
        if(tmp == 2) ret = 0;
    }else if(s[i] == '('){
        i++;
        int l = rec(i,s);
        char c = s[i];
        i++;
        int r = rec(i,s);
        i++;
        if(c == '+') ret = max(l,r);
        if(c == '*') ret = min(l,r);
    }
    return ret;
}
int solve(const string& s){
    int res = 0;
    string tmp;
    for(int P = 0; P < 3; P++){
        for(int Q = 0; Q < 3; Q++){
            for(int R = 0; R < 3; R++){
                tmp = s;
                char p = '0'+P;
                char q = '0'+Q;
                char r = '0'+R;
                replace(tmp.begin(),tmp.end(),'P',p);
                replace(tmp.begin(),tmp.end(),'Q',q);
                replace(tmp.begin(),tmp.end(),'R',r);
                int i = 0;
                if(rec(i,tmp) == 2) res++;
            }
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s;
    while(cin >> s){
        if(s == ".") break;
        cout << solve(s) << endl;
    }
    return 0;
}



Measured memory_bytes: 3192
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define MIN(a,b) ((a) < (b) ? (a) : (b))

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  char *s = (char *) calloc (n + 1, sizeof (char));
  scanf ("%s", s);
  i32 w = 0;
  for (i32 i = 0; i < n; ++i) {
    if (s[i] == '.') {
      w++;
    }
  }
  i32 min = MIN(n - w, w);
  i32 b = 0;
  for (i32 i = 0; i < n; ++i) {
    if (s[i] == '.') {
      w--;
    } else {
      b++;
    }
    min = MIN(min, b + w);
  }
  printf ("%" PRIi32 "\n", min);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
#define iof ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pi 3.1415926535897
const ll mod =1000000007;
#define inf 100000
using namespace std;

int main()
{

    ll n,q;cin>>n>>q;
    string s; cin>>s;
    ll arr[n];
    arr[0]=0;
    for(ll i=1;i<n;i++)
    {
        if(s[i]=='C' and s[i-1]=='A')
            arr[i]=arr[i-1]+1;
        else
            arr[i]=arr[i-1];
    }
    while(q--)
    {
        ll l,r; cin>>l>>r;
        l--,r--;

        cout<<arr[r]-arr[l]<<endl;
    }
}



Measured memory_bytes: 1920
#include <stdio.h>
int main(){
  int a,b,i,j,s;
  scanf("%d%d",&a,&b);
  for(i=1;i<499500;i++){
    s=0;
    a++;
    b++;
    for(j=1;j<1000;j++){
      s+=j;
      if(a==s&&b==s+j+1)printf("%d",i);
    }
  }
  return 0;
}

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

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

int H, W;
vector<string> S;

bool solve() {
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (S[i][j] == '.') continue;
      for (int k = 0; k < 4; ++k) {
        if (0 <= i + dy[k] && i + dy[k] < H && 0 <= j + dx[k] && j + dx[k] < W) {
          if (S[i + dy[k]][j + dx[k]] == '#') k = 4;
        }
        if (k == 3) return false;
      }
    }
  }
  return true;
}

int main() {
  cin >> H >> W;
  S.resize(H); for (int i = 0; i < H; ++i) cin >> S[i];
  cout << ((solve()) ? "Yes" : "No") << endl;
  return 0;
}


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

#define FOR(i, a, n) for(int i = a; i < n; ++i)
#define ll long long
#define sc(a) scanf("%d", &a);
#define scl(a) scanf("%lld", &a);

int main() {
//#ifndef ONLINE_JUDGE
//	freopen("in", "r", stdin);
//	freopen("out", "w", stdout);
//#endif
	
	int n, k; sc(n); sc(k);

	vector<int> v(n);

	FOR(i, 0, n) { sc(v[i]); }

	sort(v.begin(), v.end());
	int ans = 0;
	FOR(i, 0, k) {
		ans += v[i];
	}
 	
	printf("%d\n", ans);
	
	return 0;
}


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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble
    int n,k;
    cin>>n>>k;
    map<int,int> mp;
    for(int i=0;i<k;i++){
        int x;
        cin>>x;
        for(int j=0;j<x;j++){
            int a;
            cin>>a;
            mp[a]++;
        }
    }
    cout<<n-_sz(mp)<<nl;
    return 0;
}


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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 128;
const int oo = 0x3f3f3f3f;
int dist[N][N];
using ii = pair<int, int>;
int g[N][N];

vector<ii> delta = { {0,1}, {1,0} };

int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char c; cin >> c;
            g[i][j] = c == '.' ? 0 : 1;
        }
    }

    debug(
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++)
                cout << g[i][j] << ' ';
            cout << endl;
        }
    )

    using triple = tuple<int, int, int>;
    priority_queue<triple, vector<triple>, greater<triple>> pq;
    pq.emplace(0, 0, 0);
    memset(dist, oo, sizeof(dist));
    dist[0][0] = g[0][0];

    while (!pq.empty()) {
        int d, y, x;
        tie(d, y, x)= pq.top(); pq.pop();

        if (d > dist[y][x]) continue;

        for (auto& _delta : delta) {
            int dy, dx;
            tie(dx, dy) = _delta;
            if (x+dx < 0 || x+dx >= w || y+dy < 0 || y+dy >= h)
                continue;
            int cost = g[y+dy][x+dx] == 1 && g[y][x] == 0 ? 1 : 0;
            if (dist[y+dy][x+dx] > dist[y][x] + cost) {
                debugf("Relaxed %d,%d\n", y+dy, x+dx);
                dist[y+dy][x+dx] = dist[y][x] + cost;
                pq.emplace(dist[y+dy][x+dx], y+dy, x+dx);
            }
        }
    }

    cout << dist[h-1][w-1] << endl;

    return 0;
%>

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 200005 ;
using namespace std ;

int X, n, a[N] ;
struct poi {
	int l, r, L, R, b ;
} f[N], g ;

void add(poi a, poi &b, int x) {
	if (a.L + x >= X) {
		b.l = 0, b.r = 0, b.b = b.L = b.R = X ;
		return ;
	}
	b.l = a.l, b.L = a.L + x ;
	b.b = a.b + x ;
	if (a.R + x <= X) {
		b.r = a.r, b.R = a.R + x ;
		return ;
	}
	b.r = X - (a.b + x) ;
	b.R = X ;
}

void del(poi a, poi &b, int x) {
	if (a.R - x <= 0) {
		b.l = b.r = X, b.b = - X, b.L = b.R = 0 ;
		return ;
	}
	b.r = a.r, b.R = a.R - x ;
	b.b = a.b - x ;
	if (a.L - x >= 0) {
		b.l = a.l, b.L = a.L - x ;
		return ;
	}
	b.l = - (a.b - x) ;
	b.L = 0 ;
}

int main() {
	//freopen("a.in", "r", stdin) ;
	scanf("%d%d", &X, &n) ;
	f[0].l = 0, f[0].r = X, f[0].b = 0, f[0].L = 0, f[0].R = X ;
	a[0] = 0 ; 
	rep(i, 1, n) {
		scanf("%d", &a[i]) ;
		if (i & 1) del(f[i - 1], f[i], a[i] - a[i - 1]) ; else
		  add(f[i - 1], f[i], a[i] - a[i - 1]) ;
	//	printf("%d: %d -> l=%d r=%d L=%d R=%d b=%d\n", i, a[i], f[i].l, f[i].r, f[i].L, f[i].R, f[i].b) ;
	}
	int m, x, y ;
	scanf("%d", &m) ;
	rep(i, 1, m) {
		scanf("%d%d", &x, &y) ;
		int l = 0, r = n, res = l ;
		for ( ; l <= r ; ) {
			int mid = (l + r) / 2 ;
			if (a[mid] <= x) res = mid, l = mid + 1 ;
				else r = mid - 1 ;
		}
		if (res & 1) add(f[res], g, x - a[res]) ;
			else del(f[res], g, x - a[res]) ;
		if (y < g.l) printf("%d\n", g.L) ; else
		  if (y > g.r) printf("%d\n", g.R) ; else 
			printf("%d\n", y + g.b) ;
	}
	return 0 ; 
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
int main()
{
	int n,x;
	int Max=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		m[x]=1;
		if(x>Max){
			Max=x;
		}
	}
	map<int,int>::iterator it,it2;
	it=m.lower_bound(Max/2);
	it2=it;
	it2--;
	int r;
	int c,d;
	c=min(Max-it->first,it->first);
	d=min(Max-it2->first,it2->first);
	if(c>d){
		r=it->first;
	}else{
		r=it2->first;
	}
	printf("%d %d",Max,r);
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

int n;
long A[100000];

vector<int> primes;
map<long, long> squared;
set<long> cubed;
map<long, long> factorize(long n) {
  map<long, long> ret;
  for (int p : primes) {
    int cnt = 0;
    while (n % p == 0) {
      ++cnt;
      if (cnt == 3) cnt = 0;
      n /= p;
    }
    if (cnt > 0) {
      ret[p] = cnt;
    }
  }
  
  if (n == 1) return ret;
  if (squared.count(n)) {
    long p = squared[n];
    ret[p] = 2;
  } else {
    ret[n] = 1;
  }
  return ret;
}

bool is_prime(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) return false;
  }
  return true;
}

void pre() {
  for (long i = 1; i < 100000; ++i) {
    squared[i * i] = i;
    cubed.insert(i * i * i);
  }
  
  for (int i = 2; i < 2155; ++i) {
    if (is_prime(i)) primes.push_back(i);
  }
}

map<long, long> anti(const map<long, long>& mp) {
  map<long, long> ret;
  for (auto&& p : mp) {
    ret[p.first] = 3 - p.second;
  }
  return ret;
}

map<map<long, long>, int> mp;
int main() {
  pre();
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> A[i];
  
  bool cube_exists = false;
  for (int i = 0; i < n; ++i) {
    if (cubed.count(A[i])) {
      cube_exists = true; 
      continue;
    }
    ++mp[factorize(A[i])];
  }
  
  int sum = 2 * cube_exists;
  for (auto&& p : mp) {
    auto rev = anti(p.first);
    
    auto it = mp.find(rev);
    if (it == mp.end()) {
      sum += 2 * p.second;
    } else {
      sum += max(it->second, p.second);
    }
  }
  cout << sum / 2 << endl;
}


Measured memory_bytes: 40960
import java.util.*;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
      //整数の入力
      Scanner sc = new Scanner(System.in);
      int x = Integer.parseInt(sc.next());
      int y = Integer.parseInt(sc.next());
      int z = Integer.parseInt(sc.next());
      int work;

      work = x;
      x = y;
      y = work;

      work = x;
      x = z;
      z = work;

      System.out.print(x);
      System.out.print(" ");
      System.out.print(y);
      System.out.print(" ");
      System.out.print(z);
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
long long n,a,b,k,f[300001];
long long pow(long long a, long long b, long long MOD)
{
 long long x=1,y=a; 
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD; 
 	b /= 2;
 	}
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
long long InverseEuler(long long n, long long MOD)
{
 return pow(n,MOD-2,MOD);
}
 
long long C(long long n, long long r, long long MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
int main(){
	cin>>n>>a>>b>>k;
	f[0]=1;
	for(int i=1;i<=300000;i++){
		f[i]=(f[i-1]*i)%mod;
	}
	long long ans=0;
	for(int i=0;i<=n;i++){
		if((k-(i*a))<0){
			break;
		}
		else{
			if((k-i*a)/b<=n&&(k-(i*a))%b==0){
				ans+=C(n,i,mod)*C(n,(k-i*a)/b,mod);
				ans%=mod;
			}
		}
	}
	cout<<ans;
}

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

int main()
{
    long long a,b;
    long long v,w,t;

    cin >> a >> v >> b >>w >>t;

    if(v <= w)
    {
        cout << "NO" << endl;
    }
    else
    {
        if((v - w) * t >= (a > b ? a - b : b - a))
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
        
    }
    
}


Measured memory_bytes: 3624
//こんなの思いつきません。
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#define int long long
using namespace std;

string a;
int cnt[26][200001];

signed main()
{
	cin >> a;
	int n = a.length();
	
	for (int i = 0; i < n; i++) {
		cnt[a[i] - 'a'][i + 1]++;
	}
	for (int i = 0; i < 26; i++) {
		for (int j = 1; j <= n; j++) {
			cnt[i][j] += cnt[i][j - 1];
		}
	}
	
	int ng = 0;
	for (int i = 0; i < n; i++) {
		ng += cnt[a[i] - 'a'][n] - cnt[a[i] - 'a'][i + 1];
	}
	cout << 1 + n * (n - 1) / 2 - ng << endl;
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=2019;


int main(){
    int x; cin >> x;
    if(400 <= x && x <= 599) cout << 8 << endl;
    else if(x <= 799) cout << 7 << endl;
    else if(x <= 999) cout << 6 << endl;
    else if(x <= 1199) cout << 5 << endl;
    else if(x <= 1399) cout << 4 << endl;
    else if(x <= 1599) cout << 3 << endl;
    else if(x <= 1799) cout << 2 << endl;
    else if(x <= 1999) cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3584
def solution
  n, yen = gets.chomp.split(' ').map(&:to_i)
  (0..n).each do |x|
    (0..(n - x)).each do |y|
      z = n - x - y
      return "#{x} #{y} #{z}" if ((x * 10_000) + (y * 5_000) + (z * 1_000) == yen)
    end
  end
  '-1 -1 -1'
end

puts solution


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

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

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

int main() {
    int n, a[MAXN], m, b[MAXN], mid;

    cin >> n;

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

    for (int i=n; i>=1; --i) {
        int sum = 0;
        for (int j=2*i; j<=n; j+=i) {
            sum ^= b[j];
        }
        b[i] = sum^a[i];
    }

    vector<int> ans;
    for (int i=1; i<=n; i++) {
        if (b[i]) ans.push_back(i);
    }
    cout << ans.size() << endl;
    for(int i=0; i<ans.size(); ++i) {
        cout << ans[i];
        if (i+1 != ans.size()) cout << " ";
    }

    cout << endl;
}


Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int N; cin >> N;
    vector<int> H(N); for(int i=0; i<N; i++) cin >> H[i];
    int max=0;
    int cnt=0;
    for(int i=0; i<N; i++){
        if(max<=H[i]){
            cnt++;
            max = H[i];
        }
    }
    cout << cnt << endl;
}

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

int main(void)
{
    int room[4][3][10];
    int b,f,r,v;
    int x,y,z,i,j,n;
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(z=0;z<10;z++){
                room[i][j][z] = 0;
            }
        }
    }
    cin >> n;
    for(i=0;i<n;i++){
        cin >>b>>f>>r>>v;
        room[b-1][f-1][r-1]+=v;
    }
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(z=0;z<10;z++){
                printf(" %d",room[i][j][z]);
            }
            cout <<endl;
        }
        if(i!=3) {
            for (int k = 0; k < 20; k++) {
                printf("#");
                if (k == 19) printf("\n");
            }
        }
    }




    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;

void distance1(vector<int> x, vector<int> y)
{
	double sum = 0;
	int n = x.size();
	for(int i = 0; i < n; i++){
		sum += abs(x[i] - y[i]);
	} 
	cout << sum << endl;
}
void distance2(vector<int> x, vector<int> y)
{
	double dd = 0;
	int n = x.size();
	for(int i = 0; i < n; i++){
		dd += pow(abs(x[i] - y[i]), 2);
	}
	double d = sqrt(dd);
	cout << d << endl;
}
void distance3(vector<int> x, vector<int> y)
{
	double ddd = 0;
	int n = x.size();
	for(int i = 0; i < n; i++){
		ddd += pow(abs(x[i] - y[i]), 3);
	}
	double d = cbrt(ddd);
	cout << d << endl;
}
void distanceX(vector<int> x, vector<int> y)
{
	double max = 0;
	int n = x.size();
	for(int i = 0; i < n; i++){
		if(abs(x[i] - y[i]) > max){
			max = abs(x[i] - y[i]);
		}
	}
	cout << max << endl;
}
int main(void)
{	
	cout << fixed << setprecision(5);//?¨????

	int n;
	cin >> n;
	
	vector<int> x(n);
	vector<int> y(n);
	
	for(int i = 0; i < n; i++){
		cin >> x[i];
	}
	for(int i = 0; i < n; i++){
		cin >> y[i];
	}
	
	distance1(x, y);
	distance2(x, y);
	distance3(x, y);
	distanceX(x, y);

	return 0;
}

Measured memory_bytes: 3388
/**
 *
 * Contest - Problema X: Nome (link)
 *
 * Abridge version.
 *
 * Solution: text
 */
#include <iostream>

#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstring>
#include <algorithm>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : (vec)) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }
#define LOGA2(arr, N, M, sep) { cerr << #arr << " =\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cerr << (arr)[i][j] << " "; cerr << endl; } cerr << (sep); }

#define REP(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

const int MAX { 2000010 };
const ll oo { 1LL << 62 };
const int MOD { 1000000007 };

void solve(int N, int I)
{
    auto ans = N - I + 1;
    cout << ans << endl;
}

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

    int N, I;
    cin >> N >> I;

    solve(N, I);

    return 0;
}
	

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

int main()
{
    long long x,k,d;
    cin>>x>>k>>d;
    int flag=1;
    if(x<0)
    {
        flag=-1;
        x=-x;
    }
    long long xx=x/d;
    if(k<=xx)
    {
        cout<<abs(flag*(x-d*k));
    }
    else
    {
        long long kk=k-xx;
        if(kk%2==0)
        {
            cout<<abs(flag*(x-xx*d));
        }
        else
        {
            cout<<abs(flag*(x-(xx+1)*d));
        }
    }
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

vector<ll> divisor(ll x){
    vector<ll> res;
    for(int i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(x/i!=i) res.push_back(x/i);
        }
    }
    SORT(res);
    return res;
}

int main() {
    ll n, t[MAX_N], ma = 0, ans = 0;
    cin >> n;
    REP(i,n){
        cin >> t[i];
        ma = max(ma, t[i]);
    }
    vector<ll> ls = divisor(ma);
    REP(i,n){
        ans += *lower_bound(ALL(ls),t[i]) - t[i];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3904
import scala.io.StdIn.readLine

object Main {
  def main(args: Array[String]) {
    def printChessBoard: Unit ={
      val Array(a, b) = readLine().split(" ").map(_.toInt)
      if(a != 0 || b != 0) {
        for(j <- 0 until a) {
          var i = 0
          if(j % 2 == 0) {
            while (i < b) {
              if(i % 2 == 0) print("#") else print(".")
              i += 1
            }
          } else {
            while (i < b) {
              if(i % 2 == 0) print(".") else print("#")
              i += 1
            }
          }
          print("\n")
        }

        println()
        printChessBoard
      }
    }

    printChessBoard
  }
}

Measured memory_bytes: 49000
class Point:
	def __init__(self, x, y):
		self.x = x
		self.y = y

	def getDistance(self, to):
		return abs(self.x - to.x) + abs(self.y - to.y)

	def __repr__(self):
		return "({0}, {1})".format(self.x, self.y)

N, M = [int(x) for x in input().split(" ")]

a = []
c = []
for _ in range(N):
	x, y = [int(p) for p in input().split(" ")]
	a.append(Point(x, y))

for _ in range(M):
	x, y = [int(p) for p in input().split(" ")]
	c.append(Point(x, y))

for a_i in a:
	min_d = 250000000
	min_i = 0
	for i in range(len(c)):
		d = a_i.getDistance(c[i])
		if d < min_d:
			min_d = d
			min_i = i
	print(min_i + 1)


Measured memory_bytes: 3064
<?php

fscanf(STDIN, "%d", $N);

$map = explode(" ", trim(fgets(STDIN)));
$ans = PHP_INT_MAX;
for($i=1; $i<=100; $i++){
    $temp = 0;

    foreach ($map as $item){
        $temp += pow($item - $i, 2);
    }
    $ans = min($ans, $temp);
}
echo $ans;

Measured memory_bytes: 4604
N = int(input())

AC,WA,TLE,RE = 0,0,0,0

for i in range(N):
    S = input()
    if(S == 'AC'):
        AC += 1
    if(S == 'WA'):
        WA += 1
    if(S == 'TLE'):
        TLE += 1
    if(S == 'RE'):
        RE += 1

print('AC x {}'.format(AC))
print('WA x {}'.format(WA))                    
print('TLE x {}'.format(TLE))
print('RE x {}'.format(RE))


Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
 
using lnt = long long;
using Real = long double;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)
 
#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)
 
constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;
 
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}
 
using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

lnt prefix[2000], overall[2000];

int main(){
	summon_tourist;

	lnt N, K, A[2000]; cin >> N >> K;
	REP(i, N) cin >> A[i];
	REP(i, N){
		REP(j, i){
			if(A[i] < A[j]) prefix[i]++;
		}
		REP(j, N){
			if(A[i] < A[j]) overall[i]++;
		}
	}
	lnt ans = 0;
	lnt origK = K;
	K = K*(K-1)/2 % MOD;
	REP(i, N){
		ans += ((K*overall[i]) % MOD) + (origK*prefix[i]%MOD);
		ans %= MOD;
	}
	cout << ans << ln;
}

Measured memory_bytes: 3668
n = int(input())
aas = list(map(int, input().split()))
ms = [-1]*n
ms[0] = 0
for i in range(1,n):
    ms[i] = (aas[i-1] - ms[i-1]/2) * 2
ms[0] = int((ms[0] + (aas[n-1] - ms[n-1]/2) * 2) / 2)
for i in range(1,n):
    ms[i] = int((aas[i-1] - ms[i-1]/2) * 2)
print(*ms)

Measured memory_bytes: 91068
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>

bool check(
    const std::vector<std::string> &A, const std::vector<std::string> &B,
    size_t i, size_t j
) {
    size_t N=A.size(), M=B.size();

    for (size_t u=0; u<M; ++u)
        for (size_t v=0; v<M; ++v) {
            if (A.size() <= u+i || A[u+i].length() <= v+j ||
                B.size() <= u || B[u].length() <= v) continue;

            if (A[u+i][v+j] != B[u][v])
                return false;
        }

    return true;
}

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

    std::vector<std::string> A(N), B(M);

    for (size_t i=0; i<N; ++i) {
        char buf[64];
        scanf("%s", buf);
        A[i] = buf;
    }

    for (size_t i=0; i<M; ++i) {
        char buf[64];
        scanf("%s", buf);
        B[i] = buf;
    }

    for (size_t i=0; i+M<=N; ++i)
        for (size_t j=0; j+M<=N; ++j)
            if (check(A, B, i, j))
                return !printf("Yes\n");

    printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9;
const ll mod=998244353;
//Binary Indexed Tree
vector<ll>bit(1000010);
ll n;
ll sum(ll i){
    ll s=0;
    while(i>0){
        s+=bit[i];
        i=i&(i-1);
    }
    return s;
}
void add(ll i,ll a){
    while(i<=n){
        bit[i]+=a;
        i+=i&-i;
    }
}
//Binary Indexes Tree
vector<ll>bit2(1000010);
ll sum2(ll i){
    ll s=0;
    while(i>0){
        s+=bit2[i];
        i=i&(i-1);
    }
    return s;
}
void add2(ll i,ll a){
    while(i<=n){
        bit2[i]+=a;
        i+=i&-i;
    }
}
vector<ll>a(200010);
vector<ll>b(200010);
map<ll,ll>ma2;
ll f(ll i){
    return sum(n)-sum(i)-(sum2(n)-sum2(i))*ma2[i]+ma2[i]*sum2(i-1)-sum(i-1);
}
signed main(){
    ll q;cin>>q;
    n=q+1;
    vector<ll>query(q+1);
    set<ll>st;
    map<ll,ll>ma;
    rep(i,q){
        ll d;cin>>d;
        query[i]=d-1;
        if(d==1){
            ll A,B;cin>>A>>B;
            b[i]=B;
            st.insert(A);
            a[i]=A;
        }
        if(i)b[i]+=b[i-1];
    }
    ll idx=1;
    for(auto e:st){
        ma[e]=idx;
        ma2[idx]=e;
        idx++;
    }
    ll m=0;
    rep(i,q){
        if(!query[i]){
            m++;
            add2(ma[a[i]],1);
            add(ma[a[i]],a[i]);
        }else{
            if(m%2==0){
                ll l=0,r=n;
                while(r-l>1){
                    ll mid=(r+l)/2;
                    if(sum2(mid)>=m/2){
                        r=mid;
                    }else{
                        l=mid;
                    }
                }
                ll mi=f(r)+b[i];
                ll mii=r;
                //cout<<mii<<endl;
                l=0,r=n;
                while(r-l>1){
                    ll mid=(r+l)/2;
                    if(sum2(mid)>=m/2+1){
                        r=mid;
                    }else{
                        l=mid;
                    }
                }
                if(f(r)+b[i]<mi){
                    mi=f(r)+b[i],mii=r;
                }
                //cout<<mii<<endl;
                cout<<ma2[mii]<<' '<<mi<<endl;
            }else{
                ll l=0,r=n;
                while(r-l>1){
                    ll mid=(r+l)/2;
                    if(sum2(mid)>=m/2+1){
                        r=mid;
                    }else{
                        l=mid;
                    }
                }
                //cout<<i<<' '<<sum(n)<<' '<<sum(r)<<' '<<m<<endl;
                cout<<ma2[r]<<' '<<f(r)+b[i]<<endl;
            }
        }
    }
}

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

chessrow :: Int -> Int -> String
chessrow h 0 = []
chessrow h x = chessrow h (x - 1) ++ [p]
  where p = if even (h + x) then '#' else '.' 

chessboard :: Int -> Int -> String
chessboard 0 w = []
chessboard h w = chessboard (h - 1) w ++ chessrow h w ++ ['\n']
  
main = do
  [h, w] <- map (\x -> read x :: Int) . words <$> getLine
  when (h /= 0 || w /= 0) $ putStr (chessboard h w) >> putChar '\n' >> main

Measured memory_bytes: 5508
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <stack>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define INF (1<<29)

const int limit =50;

int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v){
	visited[v] = true;
	rep(vv, n){
		if(graph[v][vv]==false) continue;

		if(visited[vv] == true) continue;
		dfs(vv);
	}
}

int main()
{
	cin >> n >> m;

	rep(i, m){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;

		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
		
	int ans =0;

	rep(i, m){
		graph[a[i]][b[i]] = graph[b[i]][a[i]]=false;

		rep(j, n) visited[j] = false;

		dfs(0);

		rep(j, n){
			if(visited[j] == false){
				ans++;
				break;
			}
		}
		graph[a[i]][b[i]] = graph[b[i]][a[i]]=true;
	}

	cout << ans;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n<1000){
    cout<<"ABC"<<endl;
  }else{
    cout<<"ABD"<<endl;
  }
  return 0;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)

int main()
{
  //input
  inputInt(N);
  inputIntArray(a,N);
  
  //main
  long sum = 0;
  fN(i,N) sum += a[i];
  sum /= 2;//ans[0]~ans[N-1]の和
  
  long rest = 0;
  for(int i=1; i<N; i+=2) rest += a[i];//ans[1]~ans[N-1]の和
  
  int ans[N] = {0};
  
  ans[0] = sum - rest;
  fSE(i,0,N-2) ans[i+1] = a[i] - ans[i];
  fN(i,N) ans[i] *= 2;
  
  // 出力
  fN(i,N) output(ans[i]);
    
  return 0;
}

Measured memory_bytes: 2048
from collections import deque

if __name__ == '__main__':
    s = input()
    q = int(input())
    hanten_flag = 0

    d_mae = deque()
    d_ushiro = deque()

    for i in range(q):
        query = input().split(" ")
        if query[0] == "1":
            hanten_flag = (hanten_flag + 1) % 2
        else:
            if query[1] == "1":
                if hanten_flag == 0:
                    d_mae.appendleft(query[2])
                else:
                    d_ushiro.append(query[2])
            else:
                if hanten_flag == 0:
                    d_ushiro.append(query[2])
                else:
                    d_mae.appendleft(query[2])

    if hanten_flag == 0:
        print("".join(list(d_mae)) + s + "".join(list(d_ushiro)))

    else:
        print("".join(reversed(list(d_ushiro))) + s[::-1] + "".join(reversed(list(d_mae))))

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

int sum_Digits(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int N, min = 10e5;
  cin >> N;
  rep(a, N){
    int b = N - a;
    int tmp = sum_Digits(a) + sum_Digits(b);
    if(min > tmp){
      min = tmp;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
$<.each do |l|
  p, q = l.split.map(&:to_i)
  i, rs = 0, { p => 0 }
  loop do
    i += 1
    x, p = (p * 10).divmod q
    print x
    if p.zero?
      puts
      break
    end
    if rs.key?(p)
      puts
      puts ' ' * rs[p] + ?^ * (i - rs[p])
      break
    end
    rs[p] = i
  end
end

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

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

  if(a==b and b==c){
    cout << 1 << endl;
  }
  if(a==b and b!=c or b==c and c!=a or c==a and a!=b){
    cout << 2 << endl;
  }
  if(a!=b and b!=c and c!=a){
    cout << 3 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    // Your code here!
    int i, j;
    string s, ans = "Yes";
    cin >> i >> s;
    if(i % 2==1){
        ans = "No";
    }
    for(j=0; j<i/2; j++){
        if(s[j] != s[j + i/2]){
            ans = "No";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionB
    {
        //https://atcoder.jp/contests/abc169/tasks/abc169_b
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            
            long result = 1;

            var limit = (long)Math.Pow(10, 18);

            foreach(long c in inputLongArray)
            {
                if (c == 0)
                {
                    result = 0;
                    break;
                }

                if (c <= limit / result)
                {
                    result *= c;
                }
                else
                {
                    result = -1;
                }

            }

            Console.WriteLine(result);
            

            Console.Out.Flush();
        }
    }
}


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

int main(){
  int n;
  int s;
  int cnt = 0;

  scanf("%d %d", &n, &s);

  while(n > 0){
    cnt++;
    n -= s;
  }

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

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

ll a,b,c;

char katsute(char d){
  if(d=='r')return 'p';
  else if(d=='s')return 'r';
  else return 's';
}

ll tokuten(char d){
  if(d=='r')return c;
  else if(d=='s')return a;
  else return b;
}

int main(){

  ll n,k;
  string t;
  cin >> n >> k >> a >> b >>c >> t;

  string u=t;
  for(ll i=0;i<n;i++){
    u[i]='.';
  }

  ll s=0;

  for(ll i=0;i<k;i++){
    u[i]=katsute(t[i]);
    s+=tokuten(t[i]);
  }

  //cout << u[0] << " " << u[1] << endl;


  for(ll i=k;i<n;i++){
    if(t[i]==t[i-k]){
      if(u[i-k]=='a'){
        u[i]=katsute(t[i]);
        s+=tokuten(t[i]);
      }
      else{
        u[i]='a';
      }
    }
    else{
      u[i]=katsute(t[i]);
      s+=tokuten(t[i]);
    }
  }

  //for(ll i=0;i<n;i++)cout << u[i];

  cout << s << endl;

}

Measured memory_bytes: 3820
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a,b = map(int,input().split())

g = gcd(a,b)
f = factorization(g)
ans = 1

for i,j in f:
  if i == 1:
    continue
  ans += 1

print(ans)

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

ll gao(ll x, ll y) {
    if (x <= y) {
        return y - x;
    } else {
        return 2 + x - y;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x, y;
    cin >> x >> y;
    ll ans;
    ans = min(min(gao(x, y), gao(-x, y) + 1),
              min(gao(x, -y) + 1, gao(-x, -y) + 2));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
def main():
    S = input()
    # BC -> D に変換
    #     ABCACCBABCBCAABCB -> ADACCBADDAADB
    # 後ろから順にみてDからスタートしてB/Cが出てきたら区切る
    #     AD (ACCB) ADDAAD (B)
    # 各セクションでAの右側にあるDの数を足し合わせる
    #     1 + 3 + 1 + 1 = 6
    T = list()
    for ch in S:
        if len(T) > 0 and T[-1] == 'B' and ch == 'C':
            T[-1] = 'D'
            continue
        T.append(ch)
    T.reverse()
    ans, cnt_d = 0, 0
    for ch in T:
        if ch == 'A':
            ans += cnt_d
        elif ch in ['B', 'C']:
            cnt_d = 0
        else:  # ch == 'D'
            cnt_d += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 10692
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();                                                                         //半径r
        System.out.println(String.format("%.6f",r*r*Math.PI)+" "+String.format("%.6f",2*r*Math.PI));        //print(面積 円周の長さ)
    }
}


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

int main() {
    int k, s;
    cin >> k >> s;
    int count = 0;
    for (int x=0; x<=k; x++) {
        for (int y=0; y<=k; y++) {
            int z = s - x - y;
            if (z >= 0 && z <= k) count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
fn main() {
    proconio::input! {
        k: usize,
        s: proconio::marker::Chars,
    }
    if s.len() <= k {
        println!("{}", s.iter().map(|c| c.to_string()).collect::<String>());
    } else {
        let mut v = "".to_string();
        for i in 0..k {
            v += &format!("{}", s[i]);
        }
        v += "...";
        println!("{}", v);
    }
}


Measured memory_bytes: 2200
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = int(input())

num = 0
for i in range(1,N+1):
    if i % 2 == 1:
        num += 1

print(num/N)


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

int main(){
    int n, m, i, a;
    cin >> n >> m;
    for(i=0;i<m;i++){
        cin >>a ;
        n -=a;
    }
    if(n>=0) cout<< n;
    else cout << -1;
}


Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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 main(){
   int n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--, b--, c--, d--;
   string s; cin >> s;
    bool renzoku = false;
    rept(i, min(a, b), max(c, d)){
        if(s[i]=='#' && s[i+1] == '#')renzoku = true;
    }
    if(renzoku)cout << "No" << ln;
    else if(c<d)cout << "Yes" << ln;
    else{
        bool three = false;
        rept(i, b, d+1){
            if(s[i]=='.' && s[i+1] == '.' && s[i-1] == '.')three = true;
        }
        if(three)cout << "Yes" << ln;
        else cout << "No" << ln;
    }
}


Measured memory_bytes: 3752
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;

const int BUCKET_SIZE = 512;
const int MAXN = 200010;

int N, K, T;
int node[MAXN], invalid_node[MAXN];
int bucket[BUCKET_SIZE], cons[BUCKET_SIZE], invalid_bucket[BUCKET_SIZE];

void lazy_update(int i) {
  int sl = i*BUCKET_SIZE, sr = sl + BUCKET_SIZE;
  // 区間更新値があれば適用
  if(cons[i] > 0) {
    // i: index for bucket
    // k: index for node
    for(int k=sl; k<sr; k++) {
      if(bucket[i] - cons[i] != node[k]) {
	invalid_node[k] = true;
      }
      else {
	node[k] = bucket[i];
      }
    }
    cons[i] = 0;
  }
}

void update(int l, int r, int x) {
  for(int i=0; i<BUCKET_SIZE; i++) {
    int sl = i*BUCKET_SIZE, sr = sl + BUCKET_SIZE;
    if(r <= sl or sr <= l) continue;
    if(l <= sl and sr <= r) {
      if(cons[i] > 0) {
	// 区間更新されるような値が以前に存在
	if(x - bucket[i] != 1) {
	  invalid_bucket[i] = true;
	}
	else {
	  bucket[i] = x;
	  cons[i]++;
	}
      }
      else {
	// 区間更新値がはじめてきた
	bucket[i] = x;
	cons[i] = 1;
      }
    }
    else {
      lazy_update(i);
      for(int k=max(l,sl); k<min(r,sr); k++) {
	if(x - node[k] != 1) {
	  invalid_node[k] = true;
	}
	else {
	  node[k] = x;
	}
      }
    }
  }
}

bool is_valid_node(int node_id) {
  int bucket_id = node_id / BUCKET_SIZE;
  lazy_update(bucket_id);
  if(invalid_bucket[bucket_id]) return false;
  if(invalid_node[node_id]) return false;
  return node[node_id] == K;
}

int main() {
  cin >> N >> K >> T;
  for(int i=0; i<T; i++) {
    int l, r, x; cin >> l >> r >> x; l--;
    update(l, r, x);
  }
  int ans = 0;
  for(int i=0; i<N; i++) {
    ans += is_valid_node(i);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4648
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

int DP[33][33][33][33];
int rem[33][33][33][33];
int S_[40][40];

int h, w, s;

int S(int y, int x){
	if(y < 0 || x < 0 || y >= h || x >= w){
		return 0;
	}
	return S_[y][x];
}

int main(){
	while(true){
		cin >> h >> w >> s;
		if(h == 0){
			break;
		}
		for(int i = 0; i < 40; i++){
			for(int j = 0; j < 40; j++){
				S_[i][j] = 0;
			}
		}
		int u[40][40] = {};
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> u[i][j];
				S_[i][j] = u[i][j];
			}
		}
		for(int i = 1; i < 40; i++){
			for(int j = 0; j < 40; j++){
				S_[i][j] += S_[i - 1][j];
			}
		}
		for(int i = 0; i < 40; i++){
			for(int j = 1; j < 40; j++){
				S_[i][j] += S_[i][j - 1];
			}
		}
		int th = S_[39][39] - s;
		for(int i = 0; i < w; i++)for(int l = 0; l < h; l++)
		for(int j = 0; j < h; j++)for(int k = 0; k < w; k++){
			DP[i][j][k][l] = 0;
			rem[i][j][k][l] = 0;
			if(i <= k && j <= l){
				int hoge = S(l, k) - S(l, i - 1) - S(j - 1, k) + S(j - 1, i - 1);
				if(hoge >= th){
					DP[i][j][k][l] = 1;
					rem[i][j][k][l] = hoge - th;
				}
			}
		}
		for(int dx = 0; dx < w; dx++)for(int dy = 0; dy < h; dy++)
		for(int sx = 0; sx + dx < w; sx++)for(int sy = 0; sy + dy < h; sy++){
			int gx = sx + dx;
			int gy = sy + dy;
			for(int px = sx; px < gx; px++){
				int ret = DP[sx][sy][px][gy] + DP[px + 1][sy][gx][gy];
				int ret2 = min(rem[sx][sy][px][gy], rem[px + 1][sy][gx][gy]);
				
				if(DP[sx][sy][gx][gy] < ret){
					DP[sx][sy][gx][gy] = ret;
					rem[sx][sy][gx][gy] = ret2;
				}else if(DP[sx][sy][gx][gy] == ret){
					rem[sx][sy][gx][gy] = max(rem[sx][sy][gx][gy], ret2);
				}
			}
			for(int py = sy; py < gy; py++){
				int ret = DP[sx][sy][gx][py] + DP[sx][py + 1][gx][gy];
				int ret2 = min(rem[sx][sy][gx][py], rem[sx][py + 1][gx][gy]);
				
				if(DP[sx][sy][gx][gy] < ret){
					DP[sx][sy][gx][gy] = ret;
					rem[sx][sy][gx][gy] = ret2;
				}else if(DP[sx][sy][gx][gy] == ret){
					rem[sx][sy][gx][gy] = max(rem[sx][sy][gx][gy], ret2);
				}
			}
		}
		cout << DP[0][0][w - 1][h - 1] << " " << rem[0][0][w - 1][h - 1] << endl;
	}
	return 0;
}




Measured memory_bytes: 12064