akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int L = scan.nextInt();
		//math.abs()
		double avg = 0.5 * (2 * L + N - 1);
		int[] apples = new int[N + 1];
		int sum = (int) (0.5 * N * (2 * L + N - 1));
		int min = 10000;
		for (int i = 1; i <=N; i++) {
			apples[i] = L + i - 1;
			if (Math.abs(apples[i]) < Math.abs(min)) {
				min = apples[i];
			}
		}
		System.out.println(sum - min);
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define Unique(v) sort(all(v));v.erase(unique(all(v)),v.end());
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
#define db(x) cerr << #x <<" == "<<x << endl;
#define db2(x,y) cerr<<#x <<" == "<<x<<", "<<#y<<" == "<<y<<endl;
#define db3(x,y,z) cerr << #x<<" == "<<x<<", "<<#y<<" == "<<y<<", "<<#z<<" == "<<z<<endl; 
#define prl cerr<<"called: "<< __LINE__ << endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}


int32_t main(){
  fastio;
  int x;
  cin >> x;
  cout << (x^1)<<endl;
  

  // math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 3648
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

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

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e5 + 10;

int a[N];

bool solve(int n, int b);

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	int lo = 1, hi = n;
	while (lo <= hi) {
		int mid = (lo + hi) / 2;
		if (solve(n, mid)) {
			hi = mid - 1;
		} else {
			lo = mid + 1;
		}
	}
	cout << hi + 1 << endl;
}

bool solve(int n, int b) {
	vector<pii> blocks;
	blocks.pb({0, a[1]});
	for (int i = 2; i <= n; ++i) {
		if (a[i] > a[i - 1]) {
			if (blocks.back().first == 0) {
				blocks.back().second += a[i] - a[i - 1];
			} else {
				blocks.pb({0, a[i] - a[i - 1]});
			}
		} else {
			int len = a[i - 1];
			while (len - blocks.back().second >= a[i]) {
				len -= blocks.back().second;
				blocks.pop_back();
			}
			blocks.back().second -= len - a[i];
			len = a[i];
			if (blocks.size() == 1 and blocks.back().first == b - 1) {
				return false;
			}
			int zeroes = 0;
			while (blocks.back().first == b - 1) {
				zeroes += blocks.back().second;
				blocks.pop_back();
			}
			int k = blocks.size();
			if (blocks[k - 1].second == 1) {
				++blocks[k - 1].first;
				if (k >= 2 and blocks[k - 1].first == blocks[k - 2].first) {
					blocks[k - 2].second += 1;
					blocks.pop_back();
				}
			} else {
				--blocks[k - 1].second;
				blocks.pb({blocks[k - 1].first + 1, 1});
			}
			if (zeroes) {
				blocks.pb({0, zeroes});
			}
		}
	}
	return true;
}

Measured memory_bytes: 1152
import math
num1=0                                          #長方形の数                                                 
num2=0                                          #ひし形の数
while True:
    try:
        a,b,c=list(map(int, input().split(",")))
    except:
        break
    
    if pow(a,2)+pow(b,2)==pow(c,2):
        num1+=1
    elif a==b and a+b>c:
        num2+=1

print(num1)
print(num2)



Measured memory_bytes: 5660
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

struct edge {
    edge(int from_, int to_, ll cost_) : from(from_), to(to_), cost(cost_){}
    edge() : from(0), to(0), cost(0) {}
    int from, to;
    ll cost;
};

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, M, P;
    cin >> N >> M >> P;
    vector<edge> Edges(M);
    for (int m = 0; m < M; ++m) {
        int A, B; ll C;
        cin >> A >> B >> C;
        A--; B--;
        Edges[m] = edge(A, B, P-C);
    }
    
    vector<ll> d(N, INFLL);
    d[0] = 0;
    bool bInf = false;
    for (int i = 0; i < 2*N; ++i) {
        for (const auto& e : Edges) {
            if (d[e.from] != INFLL && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (i >= N && e.to == N-1) bInf = true;
            }
        }
    }
    
    if (bInf) {
        cout << -1 << endl;
    } else {
        cout << max(0LL, -d[N-1]) << endl;
    }

    return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-

def get_input() -> str:
    """
    標準入力を取得する.

    Returns:\n
        str: 標準入力
    """
    S = input()

    return S


def main(S: str) -> None:
    """
    メイン処理.

    Args:\n
        S (str): 文字列(1 <= |S| <= 1000, 英子文字のみ)
    """
    # 求解処理
    ans = S
    if S[-1] == "s":
        ans += "es"
    else:
        ans += "s"

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    S = get_input()

    # メイン処理
    main(S)


Measured memory_bytes: 9020
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;



int main() {
	int n, k;
	cin >> n >> k;
	int r, s, p;
	cin >> r >> s >> p;
	string data;
	cin >> data;
	vector<char> ans(n);
	i64 point = 0;
	ff(i, 0, k) {
		if (data[i] == 'r') {
			ans[i] = 'p';
			point += p;
		}
		if (data[i] == 's') {
			ans[i] = 'r';
			point += r;
		}
		if (data[i] == 'p') {
			ans[i] = 's';
			point += s;
		}
	}
	ff(i, k, n) {
		if (data[i] == 'r') {
			if (ans[i - k] != 'p') {
				ans[i] = 'p';
				point += p;
			}
			else {
				ans[i] = 'o';
			}
		}
		if (data[i] == 's') {
			if (ans[i - k] != 'r') {
				ans[i] = 'r';
				point += r;
			}
			else {
				ans[i] = 'o';
			}
		}
		if (data[i] == 'p') {
			if (ans[i - k] != 's') {
				ans[i] = 's';
				point += s;
			}
			else {
				ans[i] = 'o';
			}
		}
	}
	cout << point << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>
#define endl "\n"
typedef long long int ll;
typedef unsigned long long int ull;
typedef float fl;
typedef short int si;
using namespace std;
void solve()
{
    int n; cin >> n;
    ll a[n]; int ans=0;
    for (int i=0;i<n;++i) cin >> a[i];
    for (int i=0;i<n;++i){
        for (int j=i+1;j<n;++j){
            for (int k=j+1;k<n;++k){
                if (a[k]!=a[i]&&a[j]!=a[i]&&a[k]!=a[j]){
                    if (a[i]+a[j]>a[k]&&a[k]+a[j]>a[i]&&a[i]+a[k]>a[j]) ++ans;
                }
            }
        }
    }
    cout << ans;
    return;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    solve(); return 0;
}


Measured memory_bytes: 3620
//=======================//
// coder: Andy - Tohrumi //
//=======================//

#include <bits/stdc++.h>

using namespace std;

#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)

int pres[100005], pret[100005];

signed main() {
	fastio;
	string s, t; cin >> s >> t;
	int n = s.length(), m = t.length();
	rep(i, 0, n) pres[i + 1] = pres[i] + ((s[i] == 'A') ? 1 : -1);
	rep(i, 0, n) pret[i + 1] = pret[i] + ((t[i] == 'A') ? 1 : -1);
	int q; cin >> q;
	while(q--) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		int x = pres[b] - pres[a - 1];
		int y = pret[d] - pret[c - 1];
		x += 300000; x %= 3;
		y += 300000; y %= 3;
		if(x == y) cout << "YES\n";
		else cout << "NO\n";
	}
}


Measured memory_bytes: 4528
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int x = scan.nextInt();
        int y = scan.nextInt();

        x--;
        y--;

        int[] t = new int[n];
        for (int j = 0; j < n; j++) {

            Queue<Integer> que = new LinkedList<>();
            int[] dis = new int[n];

            Arrays.fill(dis,Integer.MAX_VALUE);

            dis[j] = 0;
            que.add(j);

            while (!que.isEmpty()){
                Integer in = que.poll();
                int d = dis[in];
                if(in > 0 && add(in-1,d+1,dis)){
                    que.add(in-1);
                }
                if(in < n-1 && add(in+1,d+1,dis)) {
                    que.add(in + 1);
                }
                if(in == x && add(y,d+1,dis)){
                    que.add(y);
                }
                if(in == y && add(x,d+1,dis)){
                    que.add(x);
                }
            }

            for (int i = 0; i < t.length; i++) {
                t[dis[i]]++;
            }
        }

        for (int i = 1; i < t.length; i++) {
            System.out.println(t[i]/2);
        }
    }

    private static boolean add(int i, int d, int[] dis) {
        if(dis[i] != Integer.MAX_VALUE) return false;
        dis[i] = d;
        return true;
    }
}


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

signed main(){

  string s,t;
  cin>>s;
  t = s;
  vector<int> alp(26);
  for(auto c:s)alp[c-'a']++;

  string ans = "zzzzzzzzzzzzzzzzzzzzzzzzzzz";
  auto chmin = [](auto& a,auto b){if(a>b)a=b;};
  while(1){
    for(int i=0;i<26;++i)if(alp[i]==0){
      string tmp = s;
      tmp += ('a'+i);
      if(t<tmp){
        chmin(ans,tmp);
      }
    }
    if(s.empty())break;
    alp[s.back()-'a']--;
    s.pop_back();
  }
  cout<<(ans=="zzzzzzzzzzzzzzzzzzzzzzzzzzz"?"-1":ans)<<endl;
  
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

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

void solve() {
    ll A, B, C, D; scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
    if(A < B) {
        puts("No");
        return;
    }

    ll q = A % B, g = gcd(B, D);
    q %= g;
    if(q <= min(C, B-D-1)) {
        puts("No");
        return;
    }
    
    // C < q+kg < B -> No
    // C-q < kg < B-q -> No

    // (C-q)/g < k
    ll mik = (C < q ? 0 : (C-q)%g ? (C-q+g-1)/g : (C-q)/g+1);
    // k < (B-q)/g
    ll mak = ((B-q)%g ? (B-q)/g : (B-q)/g-1);
    if(mak - mik + 1 > 0) {
        puts("No");
    }
    else {
        puts("Yes");
    }
}

int main() {
    int T; scanf("%d", &T);
    while(T--) solve();
}


Measured memory_bytes: 256
import numpy as np

li = input().split()
N = int(li[0])
L = int(li[1])
apple = []

for i in range(N):
  apple.append(L+i)

if sum(apple) >= 0:
	m = min(np.abs(apple))
else:
	m = -min(np.abs(apple))

ans = sum(apple) - m
print(ans)

Measured memory_bytes: 12508
x, y = map(int, input().split())
diff = abs(abs(x)-abs(y))
 
if abs(x) < abs(y):
  if x < 0:
    diff += 1
  if y < 0:
    diff += 1
else:
  if x > 0:
    diff += 1
  if y > 0:
    diff += 1
print(diff)

Measured memory_bytes: 38384
// Last Update:2017-11-12 22:34:39
// author:sjy
#include<bits/stdc++.h>
using namespace std;
int ans[2005];
int main(void)
{
    int n,m,k;
    cin>>n>>m>>k;
    for(int i = 0;i < n;i++)
    {
        cin>>ans[i];
    }
    int maxx = abs(ans[n-1] - k);
    if(n >= 2)
    {
        maxx = max(maxx,abs(ans[n-1] - ans[n-2]));    
    }
    cout<<maxx<<endl;
    return 0;
}

Measured memory_bytes: 256
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())

n,m,k=sep()
a=lis()
b=lis()
from bisect import bisect_right
a_c=[a[0]]
b_c=[b[0]]
for i in range(1,n):
    a_c.append(a_c[-1]+ a[i])
for i in range(1,m):
    b_c.append(b_c[-1] + b[i])

m=-1
m=max(m,bisect_right(b_c,k))
for i in range(n):
    if a_c[i]<=k:
        t=k-a_c[i]
        t2=bisect_right(b_c,t)
        m=max(i+1+t2,m)
    else:
        break
print(max(0,m))













Measured memory_bytes: 141412
#include <stdio.h>

int main()
{
  int W, H, x, y, r;

  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if ((x + r <= W) && (x - r >= 0)
      && (y + r <= H) && (y - r >=0)) {
	printf("Yes\n");
  }  else {
	printf("No\n");
  }

  return 0;
}
	


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

int GetDigit(int n)
{
  int digit = 0;
  while (true)
  {
    if (n == 0)
    {
      break;
    }
    n = n / 10;
    digit++;
  }
  return digit;
}

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

  int ans = 0;
  for (int i = 1; i <= N; i++)
  {
    if (GetDigit(i) % 2 == 1)
    {
      ans++;
    }
  }

  cout << ans << endl;
}

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

int main(){
    int h,w; cin >> h >> w;
    vector<string> c(h);
    for(int i = 0; i < h; i++) {
        cin >> c[i];
    }
    for(int i = 0; i < h; i++) {
        cout << c[i] << endl;
        cout << c[i] << endl;
    }  
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI 3.1415926535897
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N;
int p[20];


signed main(){
	cin >> N;
	rep(i, 0, N) cin >> p[i];

	sort(RNG(p, 0, N));

	int ans = 0;
	rep(i, 0, N-1) ans += p[i];
	ans += p[N-1]/2;

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define read(x) scanf("%d",&x)
int n;
int a[2005];
ll ans=0;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	REP(i,n) cin>>a[i];
	sort(a+1,a+n+1);
	for (int i=1;i<n;++i){
		for (int j=i+1;j<=n;++j){
			int x=a[i],y=a[j];
			ans+=(lower_bound(a+1,a+n+1,x+y)-1)-upper_bound(a+1,a+n+1,y-x)+1;
			if (x>y-x) --ans;
			if (y>y-x) --ans;
		}
	}
	cout<<ans/3;
	return 0;
}

Measured memory_bytes: 256
n, x, y = gets.split.map &:to_i

#result = (n-1).downto(1).to_a
#result[0] += 1
#result[y - x - 1] -= 1

result = Array.new(n).map{ Array.new(n) }
(0 ... n).each{ |i|
	(i + 1 ... n).each{ |j|
		result[i][j] = j - i
	}
}

# ショートカット路を含む長さ
(n - 1).downto(1){ |i|
	# 左端点から先の自由度
	(0 .. i - 1).each{ |j|
		# 左の左
		ll = x - j - 1
		# 左の右
		lr = x + j - 1
		#右の左
		rl = y - (i - j - 1) - 1
		#右の右
		rr = y + (i - j - 1) - 1
		
		if ll >= 0 && rl >= 0 then
			if rl - ll > i then
				result[ll][rl] = i
			end
		end

		if ll >= 0 && rr < n then
			if rr - ll > i then
				result[ll][rr] = i
			end
		end

		if lr < n && rl >= 0 then
			if rl - lr > i then
				result[lr][rl] = i
			end
		end

		if lr < n && rr < n then
			if rr - lr > i then
				result[lr][rr] = i
			end
		end
	}
}

count = Array.new(n, 0)

result.each{ |r|
	r.each{ |rr|
		if rr != nil then
			count[rr] += 1
		end
	}
}

puts count[1..-1].join("\n")


Measured memory_bytes: 33148
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

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

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	long double r; cin >> r;
	cout << fixed << setprecision(15) ;
	cout << 2 * PI*r;

	return 0;
}

Measured memory_bytes: 3228
import Foundation
func toTuple<T>(_ args: [T]) -> (T, T) { (args[0], args[1]) }
func toTuple<T>(_ args: [T]) -> (T, T, T) { (args[0], args[1], args[2]) }
func toTuple<T>(_ args: [T]) -> (T, T, T, T) { (args[0], args[1], args[2], args[3]) }
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }
func readDoubles() -> [Double] { readLine()!.split(separator: " ").map { Double($0)! } }
func readStrings() -> [String] { readLine()!.split(separator: " ").map { String($0) } }

let (A, B) = toTuple(readStrings())
let a = Int(A)!
let bSplit = B.split(separator: ".")
let b = Int(String(bSplit[0]+bSplit[1]))!
print(a * b / 100)

Measured memory_bytes: 13192
#include <iostream>
using namespace std;
typedef long long ll;
ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  int ans[n][n];
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      ans[i][j]=0;
    }
  }
  int k=0;
  for(int i=0;i<20;i++){
    if(n&(1<<i)) k=i;
  }
  for(int i=0;i<=k;i++){
    for(int x=0;x<n-1;x++){
      for(int y=x+1;y<n;y++){
        if(ans[x][y]==0){
          if((x&(1<<i))!=(y&(1<<i))){
            ans[x][y]=i+1;
          }
        }
      }
    }
  }
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      cout << ans[i][j] << ' ';
    }
    cout << endl;
  }
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

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

int main(){
    int n, k;
    cin >> n >> k;
    int l[n];
    rep(i, n) cin >> l[i];
    sort(l, l + n, greater<int>());
    int ans = 0;
    rep(i, k) ans += l[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int m, n, h, i, k;
    boolean[] a;
    
    for(;;){
      n = sc.nextInt(); m = sc.nextInt();
      if(n == 0 && m == 0)break;
      a = new boolean[n];

      h = n;
      for(k = -1;h-- > 0;a[k % n] = true)for(i = 0;i < m;i++)if(a[++k % n])i--;
      out.println((k % n) + 1);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 19312
#include <iostream>
#include <string>

using namespace std;

int main(void)
{	

	
	while (true)
	{   
		string sub = "";
		cin >> sub;
		int num, sh;
		if (sub == "-")
			break;
		cin >> num;
		
		for (int i = 0; i < num; i++)
		{
			cin >> sh;
			string t = sub.substr(sh);
			t += sub.substr(0,sh);
			sub = t;

		}

		cout << sub << endl;
	}

}

Measured memory_bytes: 1216
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define lld long long
#define pi pair<lld,lld>
#define mod 1000000007
#define N 2000005
#define pb push_back
lld fact[N],ifact[N];
struct node
{
    vector<lld> v;
    vector<lld> s;
}; 
lld expo(lld a,lld b)
{
    if(b==0) return 1; if(b==1) return a%mod;
    lld z=expo(a,b/2);
    z=(z%mod*z%mod)%mod;
    if(b%2) z=(z*a)%mod;
    return z;
}
lld ncr(lld n,lld r)
{
    if(r>n) return 0;
    if(r==n) return 1;
    lld mm=fact[n]*ifact[n-r]%mod;
    mm=mm*ifact[r]%mod;
    return mm;
}
void pre(){
    fact[0] = 1;
    ifact[0] = 1;
    rep(i,1,N){
        fact[i] = i;
        fact[i] *= fact[i-1];
        fact[i] %= mod;;
        ifact[i] = expo(fact[i],mod - 2);
    }
}
vector < int > z_function ( string s ) {
    int n = (int)s.length();
    vector<int> z(n);
    for (int i = 1,l=0,r=0;i<n;++i){
        if (i<=r)
            z[i] = min(r-i+1,z[i-l]);
        while(i+z[i]<n&&s[z[i]]==s[i+z[i]])
            ++z[i];
        if(i+z[i]-1>r)
            l=i,r=i+z[i]-1;
    }
    return z ;
}

lld max(lld a,lld b){return a>b?a:b;}
void build(node tree[],lld a[],int st,int en,int node)
{
    if(en<st) return;
    if(st==en)
    {
        tree[node].v.pb(a[st]);
        tree[node].s.pb(a[st]);
        return;
    }
    int mid=(st+en)/2;
    build(tree,a,st,mid,2*node);
    build(tree,a,mid+1,en,2*node+1);
    tree[node].v.resize(tree[2*node].v.size() + tree[2*node+1].v.size());
    merge(tree[2*node].v.begin(),tree[2*node].v.end(),tree[2*node+1].v.begin(),tree[2*node+1].v.end(),tree[node].v.begin());
    tree[node].s.resize(tree[node].v.size());
    tree[node].s[0]=tree[node].v[0];
    for(int k=1;k<tree[node].v.size();k++)
    {
        tree[node].s[k]=tree[node].s[k-1]+tree[node].v[k];
    }

}

lld query(node tree[],int st,int en,int l,int r,int node,lld x)
{
    if(st>en||st>r||en<l) return 0;
    if(st>=l&&en<=r)
    {
    int j=lower_bound(tree[node].v.begin(),tree[node].v.end(),x)-tree[node].v.begin();
    if(j==tree[node].v.size()) return tree[node].s[tree[node].s.size()-1];
    if(tree[node].v[j]!=x) j--;
    if(j>=0) return tree[node].s[j];
    return 0;
    }
    int mid=(st+en)/2; lld xx,yy; xx=yy=0;
    xx= query(tree,st,mid,l,r,2*node,x); 
    yy=query(tree,mid+1,en,l,r,2*node+1,x);
    return xx+yy;
}

int main()
{
   // pre();
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // freopen("/home/ankit/input_10.txt","r",stdin);
    // freopen("/home/ankit/out10.txt","w",stdout);
    int n; cin>>n;
    string s; cin>>s;
    if(n%2)
    {
      printf("No\n");
      return 0;
    }
    int f=0;
    for(int i=n/2;i<n;++i)
      if(s[i]!=s[i-n/2])f=1;
    if(f)printf("No\n");
    else printf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0) break;
            for(int i = 0; i < H; i++) {
                for(int j = 0; j < W; j++) {
                    if((i + j) % 2 == 0) System.out.print("#");
                    else System.out.print(".");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 34604
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(long i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main()
{
    long d, g;
    cin >> d >> g;
    g /= 100;
    vector<pair<long, long>> pc(d);
    rep(i, d) {
        long p, c;
        cin >> p >> c;
        c /= 100;
        pc[i] = make_pair(p, c);
    }

    long ans = 10000;
    rep(i, (1 << d)) {
        long sum = 0, num = 0, resmax = 0;

        rep(j, d) {
            if (i & (1 << j)) {
                sum = sum + pc[j].first * (j + 1) + pc[j].second;
                num += pc[j].first;
            }
            else {
                resmax = j;
            }
        }

        if (sum < g) {
            long temp = (g - sum - 1) / (resmax + 1) + 1;
            if (temp >= pc[resmax].first) {
                continue;
            }
            else {
                num += temp;
            }
        }

        ans = min(ans, num);
    }

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

Measured memory_bytes: 256
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc147_a.cpp
 * time   : Sat May  2 18:47:17 2020
 * quest  : A - Blackjack
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  cout << ((a1 + a2 + a3) >= 22 ? "bust\n" : "win\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[100005];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    
    int current_botan = 1;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(current_botan == 2){
            cout << ans << endl;
            return 0;
        }

        current_botan = a[current_botan];
        ans++;
    }

    cout << -1 << endl;

}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
	long nDelCnt = 0;
	long nCnt;
	cin >> nCnt;
	long arr[100001];
	memset(arr, 0, sizeof(arr));

	// 入力値を配列に格納。
	// 但し、数列の最大数が100000なのでそれより大きな値を入力されても
	// 数列が正しくならないので削除対象に加算する。
	long lnMax = 0;
	for (long i = 0; i < nCnt; i++)
	{
		long lnTmpVal;
		cin >> lnTmpVal;
		if (100000 < lnTmpVal)
		{
			nDelCnt++;
			continue;
		}
		arr[lnTmpVal]++;
		if (lnTmpVal > lnMax)
			lnMax = lnTmpVal;
	}

	// 入力された個数と、数値の値が一致するかチェック
	for (long i = 1; i <= lnMax; i++)
	{
		if (0 > arr[i]-i)			// 必要数に足りないので、入力されたもの全消し
			nDelCnt = nDelCnt + arr[i];
		else if (0 < arr[i] - i)	// 余分な個数のみ消す
			nDelCnt = nDelCnt + arr[i] - i;
	}
	cout << nDelCnt;
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
    char a[10];
    char b[10];
    int count=0;

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

    for(int i=0;i<3;i++)
    {
        if(a[i]==b[i])
        count++;
    }

    printf("%d",count);
}



Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
//typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#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 reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define P pair<int,int>

int main() {
	string S;
	getline(cin, S);
	rep(i, S.size()) {
		if (S[i] != ' '&&S[i]!='.') {
			S[i] = char(S[i] + ('A' - 'a'));
		}
	}
	cout << S << endl;
}


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

int main()
{
  int num_employee;
  cin >> num_employee;
  vector<int> employees(num_employee);
  for (int i = 0; i < num_employee - 1; i++)
  {
    int num_bos;
    cin >> num_bos;
    employees.at(num_bos - 1)++;
  }
  for (auto employee : employees)
  {
    cout << employee << endl;
  }
}


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


int main() {
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	int cnt = 1;
	char now = S[0];
	for (int i = 1; i < S.length(); i++) {
		if (now != S[i]) {
			now = S[i];
			cnt++;
		}
	}
	int final_gnum = min(N - cnt + K * 2, N -1);
	cout << final_gnum << endl;
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  if (a > b) {
    ans += a;
    a--;
  } else {
    ans += b;
    b--;
  }
  ans += max(a, b);
  cout << ans << endl;
}

Measured memory_bytes: 256
import math
n = int(input())
x = n/1.08
x1, x2 = math.floor( x ), math.ceil( x )

if n == math.floor( x1 * 1.08 ) :
  print(x1)
elif n == math.floor( x2 * 1.08 ):
  print(x2)
else:
  print(':(')

Measured memory_bytes: 9036
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
using namespace std;

int main() {
	long long a, b, c, old_a, old_b, old_c;
	cin >> a >> b >> c;
	int count = 0;
	if (a == b&&b == c) {
		if (a % 2 == 0) {
			cout << -1 << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	else {
		while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
			old_a = a; old_b = b; old_c = c;
			a = (old_b + old_c) / 2;
			b = (old_a + old_c) / 2;
			c = (old_a + old_b) / 2;
			count++;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[19];
	cin>>s;
	for(int i=0;i<19;i++)
	{
		if(i==5 || i==13){
			cout<<" ";
		}
		else{
		cout<<s[i];
		}
	}
	return 0;
}

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef vector<int> V;
namespace _DSU{
    int cnt=0;
    int mem[2][212345];
    int* get(){
        return mem[cnt++];
    }
}
class UF{
public:
    int *par,*rank;
    int find(int x){
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
    }
    UF(int n,int *par,int *rank) :par(par),rank(rank){
	REP(i,n)par[i] = i,rank[i] = 0;
    }
    UF(int n):UF(n,_DSU::get(),_DSU::get()){}
    bool unite(int x, int y){
	x = find(x);y = find(y);
	if (x == y)return false;
	if (rank[x] < rank[y]) par[x] = y;
	else{
	    par[y] = x;
	    if (rank[x] == rank[y])rank[x]++;
	}
	return true;
    }
    bool same(int x, int y){
	return find(x) == find(y);
    }
};
int main(){
    int N;
    cin>>N;
    vector<int> a(N),b(N);
    cin>>a>>b;
    int x=0;
    REP(i,N)x^=a[i];
    map<int,int> cnt;
    REP(i,N)cnt[a[i]]++;
    cnt[x]++;
    REP(i,N)cnt[b[i]]--;
    for(auto &it:cnt){
        if(it.se<0){
            cout<<-1<<endl;
            return 0;
        }
        if(it.se>0)
            b.pb(it.fi);
    }
    a.pb(x);
    reverse(ALL(a));
    reverse(ALL(b));
    

    x=0;
    for(auto &it:cnt)it.se=x++;
    for(auto &it:a)it=cnt[it];
    for(auto &it:b)it=cnt[it];
    //REP(i,N+1)cout<<a[i]<<" ";cout<<endl;
    //REP(i,N+1)cout<<b[i]<<" ";cout<<endl;

    UF uf(x);
    REP(i,N+1)if(a[i]!=b[i])uf.unite(a[i],b[i]);
    vector<int> CC(x,0);
    REP(i,N+1)if(a[i]!=b[i])CC[uf.find(a[i])]++;

    if(a[0]!=b[0]){
        int res=-2;
        REP(i,x)if(CC[i])res+=CC[i]+1;
        cout<<res<<endl;
    }
    else{

        int res=0;
        FOR(i,1,N+1)if(a[i]!=b[i]&&a[0]==b[i])res=-1;
        REP(i,x)if(CC[i])res+=CC[i]+1;
        cout<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 6896
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;
//obj;
class binary{
public:
    bool isOK(int index, int key,vi a) {
    if (a[index] >= key) return true;
    else return false;
}
int binary_search(int key,vi a) {
   
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key,a)) ok = mid;
        else ng = mid;
    }
    return ok;
}
}obj;

int main(){
int n;cin>>n;
for(int i=1;i<=n;i++){
    int flag=0;
    for(int x=1;x<n;x++){
        if(x*x>i)break;
        for(int y=1;y<n;y++){
            if(y*y>i)break;
            for(int z=1;z<n;z++){
                if(z*z>i)break;
                ll sum=x*x+y*y+z*z+x*y+x*z+y*z;
                if(sum>i)break;
                if(sum==i)flag++;
                
            }
        }
    }
cout<<flag<<endl;
}
 }


Measured memory_bytes: 3432
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <iterator>
#include <algorithm>
#define RANGELOOP(b,e) for(int i=b; i<e; i++)
#define LOOP(e) for(int i=0; i<e; i++)
#define FOREACH(e,array) for(const auto& e:array)

int main() {
    char S[100];
    std::cin >> S;
    
    int len = 0, max_len = 0;
    FOREACH(c, S) {
        if (c=='A'||c=='C'||c=='G'||c=='T') {
            len++;
        } else {
            max_len = std::max(len, max_len);
            len = 0;
        }
    }
    std::cout << max_len;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>
#include<tuple>
#include<numeric>
#include<cassert>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<int,ll>;
using Pd = pair<double,double>;
using T = tuple<double,double,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N = 8003;
const ll lmod = 1e9+7;

int cnt[2][MAX_N];
bool dp[4][MAX_N];

int main(){
  string S; int N,x,y,a;
  cin >> S >> x >> y ;
  N = S.length();
  S = S + "T";
  a = 0;
  while(S[a]=='F') a++;
  x -= a;
  fill(dp[0],dp[0]+MAX_N*4,false);
  int cnt = 0, flag = 0;
  dp[0][0] = dp[1][0] = dp[2][0] = dp[3][0] = true;
  int xprev = 0 ,xnow = 1 ,yprev = 2 ,ynow = 3;
  REP(i,a,N+1){
    if(S[i]=='F') cnt++;
    else{
      if(cnt!=0){
        int now,prev;
        if(!flag) prev = xprev, now = xnow, swap(xprev,xnow);
        else prev = yprev, now = ynow, swap(yprev,ynow);
        fill(dp[now],dp[now]+N,false);
        rep(i,N+1){
          if(i+cnt<MAX_N) dp[now][i+cnt] |= dp[prev][i];
          dp[now][abs(i-cnt)] |= dp[prev][i];
          // if(dp[now][i+cnt]) cout << "flag = " << flag << ", i+cnt = " << i+cnt << endl;
          // if(dp[now][abs(i-cnt)]) cout << "flag = " << flag << ", i-cnt = " << i-cnt << endl;
        }
      }
      cnt = 0;
      (flag += 1) %= 2;
    }
  }
  cout << (((dp[xprev][abs(x)] && dp[yprev][abs(y)])) ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200010
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int nc2(int n){
    return n*(n-1)/2;
}
int n;
int a[N];
int cnt[N]={0};
signed main()
{
    
    speed
    cin>>n;
    rep(i,1,n){
        cin>>a[i];
        cnt[a[i]]+=1;
    }
    int ans=0;
    rep(i,1,n){
        ans+=nc2(cnt[i]);
    }
    rep(i,1,n){
        cout<<ans-nc2(cnt[a[i]])+nc2(cnt[a[i]]-1)<<endl;
    }

    
    


    return 0;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int cnt[SIZE] = {};
    for( int i = 0; i < n; ++i ) {
        int a;
        cin >> a;
        ++cnt[a];

    }

    int res = 0;
    for( int i = 1; i < SIZE; ++i ) {
        res += max( 0, cnt[i] - 1 );

    }

    if( res % 2 ) ++res;
    cout << n - res << endl;

    return 0;
}


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

#define int long long

using namespace std;

const int maxn = 2e5 + 10;
int h[maxn], a[maxn], ans, n;
vector<pair<int, int>> v;

struct fenwick
{
    vector<int> bit;
    int n;

    fenwick(int n) : n(n) { bit.assign(n, 0); }

    void add(int idx, int val)
    {
        for (; idx < n; idx = idx | (idx + 1))
            bit[idx] = max(bit[idx], val);
    }

    int get(int r)
    {
        int res = 0;
        for (; ~r; r = (r & (r + 1)) - 1)
            res = max(res, bit[r]);
        return res;
    }
};

signed main()
{
    ios::sync_with_stdio(false);
    cin >> n;

    fenwick now(n);
    for (int i = 0; i < n; i++)
        cin >> h[i], v.push_back({h[i], i});
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(v.begin(), v.end());

    for (auto u : v)
    {
        int x = now.get(u.second) + a[u.second];
        ans = max(ans, x);
        now.add(u.second, x);
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 8944
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, atan2
from operator import mul
from functools import reduce
sys.setrecursionlimit(10**8)

INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
L = []
for i in range(n):
    x, y = LI()
    L += [(atan2(y, x), x, y)]


L.sort()
L += L
cs = [(0, 0)]
for _, x, y in L:
    cs += [(cs[-1][0] + x, cs[-1][1] + y)]



ans = 0
for i in range(n):
    for j in range(i + 1, i + n + 1):
        x1, x2 = cs[i][0], cs[j][0]
        y1, y2 = cs[i][1], cs[j][1]
        ans = max(ans, (x2 - x1) ** 2 + (y2 - y1) ** 2)


print(ans ** 0.5)

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

int main() {
    int n,k,i,j,l=0;
    cin>>n>>k;
    int a[n],dp[n][k+1];
    for(i=0;i<n;i++){
        cin>>a[i]; dp[i][0]=0;
    }
    for(i=0;i<=k;i++){
        dp[0][i]=i/a[0];           
    }
    for(i=1;i<n;i++){
         for(j=1;j<=k;j++){
             if(a[i]>j)
                dp[i][j]=dp[i-1][j];
                 else{
                     if(dp[i][j-a[i]]%2==0)
                     dp[i][j]=3;
                     else{ l=i-1;dp[i][j]=2;
                         while(l>=0){
                             if(dp[i][j-a[l]]%2==0){
                                 dp[i][j]=3;break;
                             }
                             l--;
                         }
                     }
                 }
             }
        }
        
    if(dp[n-1][k]%2)
    cout<<"First"<<endl;
    else
    cout<<"Second"<<endl;
    
    return 0;
}

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

int main() {
  int N;
  string s , t;
  cin >> N >> s >> t;
  int smallest = 2 * N;
  for (int k = 1; k <= N; k++){
    bool ok = true;
    for(int i = 0; i < k; i++){
      if(s.at(N - k + i) != t.at(i)){
        ok = false;
      }
    }
    if(ok){
      smallest = N * 2 - k;
    }
  }
  cout << smallest << endl;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
  input! {
    _N: usize,
    S: String
  }
  
  let mut rs: Vec<usize> = vec![];
  let mut gs: Vec<usize> = vec![];
  let mut bs: Vec<usize> = vec![];
  
  for (i, c) in S.chars().enumerate() {
    match c {
      'R' => rs.push(i+1),
      'G' => gs.push(i+1),
      'B' => bs.push(i+1),
      _ => unreachable!()
    }
  }
  rs.reverse();
  gs.reverse();
  bs.reverse();
  
  let mut result = 0;
  result += culc(&mut rs, &mut gs, &mut bs);
  result += culc(&mut rs, &mut bs, &mut gs);
  result += culc(&mut bs, &mut rs, &mut gs);
  result += culc(&mut bs, &mut gs, &mut rs);
  result += culc(&mut gs, &mut rs, &mut bs);
  result += culc(&mut gs, &mut bs, &mut rs);
  
  println!("{}", result);
}

fn culc(r: &mut Vec<usize>, g: &mut Vec<usize>, b: &mut Vec<usize>) -> usize {
  let mut result = 0;
  for i in r.iter() {
    for j in g.iter() {
      if j < i { break }
      for k in b.iter() {
        if k < j { break }
        if i + k != j * 2 {
          result += 1;
        }
      }
    }
  }
  result
}


Measured memory_bytes: 2208
x,k,d=map(int,input().split())
x1=abs(x)
if x1<=k*d:
    c=x1//d
    if x1-c*d<0:
        if (k-c)%2==0:print(abs(x1-d*c))
        else:print(abs(x1-d*c)+d)
    else:
        if (k-c)%2==0:print(abs(x1-d*c))
        else:print(abs(abs(x1-d*c)-d))
else:print(x1-k*d)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vstr s(n);
  ll ans=0;
  ll r=0;
  ll l=0;
  ll rl=0;
  rep(i,n){
    cin>>s[i];
    for(int j=0;j<sz(s[i])-1;j++){
      if(s[i][j]=='A'&&s[i][j+1]=='B') ans++;
    }      
    if(s[i][0]=='B'&&s[i][sz(s[i])-1]=='A'){
      rl++;
    }
    else if(s[i][sz(s[i])-1]=='A'){
      r++;
    }
    else if(s[i][0]=='B'){
      l++;
    }
  }
  if(rl>0){
    ans+=rl-1;
    rl=1;
  }
  if(r>0&&l>0&&rl==1){
    ans+=2;
    r--;
    l--;
    rl--;
  }
  
    ans+=min(r,l);
    r-=min(r,l);
    l-=min(r,l);
  
  if(r>0||l>0){
    if(rl>0){
      ans++;
    }
  }
  COUT(ans);
}


Measured memory_bytes: 768