akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
///////////////////////////////////////////////////////
int n,ans=1;
cin >> n;
int d[n];
for(int i=0;i<n;i++){
	cin >> d[i];
}

sort(d,d+n);

for(int i=0;i<n-1;i++){
	if(d[i]!=d[i+1]){
		ans++;
	}
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
typedef pair<ll,ll> P;
const ll MOD=1e9+7;
ll X,Y;
ll A(ll x)
{
    ll re=1;
    for(ll i=1;i<=x;i++)
        re*=i,re%=MOD;
    return re;
}
ll ksm(ll x,ll y)
{
    ll re=1;
    while(y)
    {
        if(y&1) re=(ll)re*x%MOD;
        x=(ll)x*x%MOD;
        y>>=1;
    }
    return re;
}
ll inv(ll x)
{
    return ksm(x,MOD-2);
}
int main()
{
    cin>>X>>Y;
    if((2*X-Y)%3!=0)
        return printf("0\n")*0;
    ll n=(2*X-Y)/3,m=X-2*n;
    //printf("%d %d\n",n,m);
    if(n<0 || m<0)
        return printf("0\n")*0;
    printf("%lld\n",(ll)A(m+n)*inv(A(m))%MOD*inv(A(n))%MOD);
    return 0;
}


Measured memory_bytes: 256
class Node:
    def __init__(self):
        self.parent = -1
        self.left = -1
        self.right = -1

#ノードの深さを求める関数
def getdepth(node,node_id):
    d = 0
    while node[node_id].parent != -1:
        node_id = node[node_id].parent
        d += 1
    return d

#子のリストを求める関数
def getchild(node,node_id):
    if node[node_id].left == -1:
        return []
    ret = [node[node_id].left]
    while node[ret[-1]].right != -1:
        ret.append(node[ret[-1]].right)
    return ret

N = int(input())
nodes = [Node() for i in range(N)]

#入力を木構造に入力する
for i in range(N):
    n,k,*child = map(int,input().split())
    if k != 0:
        nodes[n].left = child[0]
        for j in range(len(child)):
            nodes[child[j]].parent = n
            if j != len(child)-1:
                nodes[child[j]].right = child[j+1]

for i in range(N):
    depth = getdepth(nodes,i)
    children = getchild(nodes,i)
    if nodes[i].parent == -1:
        node_type = 'root'
    elif nodes[i].left == -1:
        node_type = 'leaf'
    else:
        node_type = 'internal node'
    print('node {}: parent = {}, depth = {}, {}, {}'.format(i,nodes[i].parent, depth, node_type, children))



Measured memory_bytes: 33652
k, n = map(int, input().split())
mid = k / 2
a = [int(i) for i in input().split()]
max_diff = a[0]  + (k - a[-1])
for i in range(n - 1):
  diff = a[i + 1] - a[i]
  if diff > max_diff:
    max_diff = diff
print(k - max_diff)

Measured memory_bytes: 26436
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7
EPS = 1e-6
KETA = 10**7


def main():
    H, W, K = MAP()
    x1, y1, x2, y2 = LIST()
    c = [[-1] + [0 if c == "." else -1 for c in input()] + [-1]
         for i in range(H)]
    c = [[-1] * (W + 2)] + c + [[-1] * (W + 2)]
    c[x1][y1] = 0

    # 0123: 上下左右
    stack = [((x1 * KETA + y1) << 2) + 0, ((x1 * KETA + y1) << 2) + 1,
             ((x1 * KETA + y1) << 2) + 2, ((x1 * KETA + y1) << 2) + 3]
    DX = (1, 0, -1, 0)
    DY = (0, 1, 0, -1)
    head = 0
    while head < len(stack):
        b = stack[head]
        head += 1
        d = b % 4
        x, y = divmod(b >> 2, KETA)
        flag = True
        a = c[x][y] + 1
        for k in range(1, K + 1):
            xx, yy = x + k * DX[d], y + k * DY[d]
            if c[xx][yy] == 0:
                stack.append(((xx * KETA + yy) << 2) + (d - 1) % 4)
                stack.append(((xx * KETA + yy) << 2) + (d + 1) % 4)
                c[xx][yy] = a
            elif c[xx][yy] != a:
                flag = False
                break
        if flag:
            stack.append(((xx * KETA + yy) << 2) + d)
        if c[x2][y2] > 0:
            print(c[x2][y2])
            return

    print(-1)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 163756
import std.stdio, std.string, std.conv, std.range, std.algorithm;
void main() {
	long n, m, l;
	"%d %d %d\n".readf(&n, &m, &l);
	long[][] a, b;
	foreach (_n; 0..n) a ~= readln.split.to!(long[]);
	foreach (_m; 0..m) b ~= readln.split.to!(long[]);
	foreach (_a; a) {
		long[] c = [];
		foreach (_l; 0..l) c ~= iota(m).map!(_m => _a[_m] * b[_m][_l]).sum;
		c.to!(string[]).join(" ").writeln;
	}
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> P;

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

  vector<int> A(N);

  rep(i, N) cin >> A.at(i);
  sort(begin(A), end(A));

  int sum = 0;
  rep(i, K){
    sum += A.at(i);
  }

  cout << sum << endl;
}


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

int main()
{
 int a,b,n;
 while(cin>>n, n)
 {
  int x=0, y=0;
 while(n--)
 {
   cin>>a>>b;
   if(a<b) {y+=a+b;}
   else if(a>b) {x+=a+b;}
   else {x+=a; y+=b;}
  }

 cout<<x<<" "<<y<<endl;
}
}
 
 
   
  

Measured memory_bytes: 1160
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <deque>
#include <math.h>
#include <map>
#include <bitset>
#include <queue>
#include <list>
#include <utility>

//#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using p = pair<int, int>;
using Graph = vector<vector<int>>;
#define rep(i,n)  for(int i = 0; i < n ; i++)
int dx[4]{ -1,0,1,0 };
int dy[4]{ 0,1,0,-1 };

int main()
{
    long X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;

    vector<long> qA(A);
    vector<long> qB(B);
    vector<long> qC(C);

    rep(i, A) {
        cin >> qA[i];
    }
    rep(i, B) {
        cin >> qB[i];
    }
    rep(i, C) {
        cin >> qC[i];
    }
    sort(qA.begin(),qA.end());
    sort(qB.begin(),qB.end());
    sort(qC.begin(),qC.end());
    reverse(qA.begin(), qA.end());
    reverse(qB.begin(), qB.end());
    reverse(qC.begin(), qC.end());
    vector<long> d;
    rep(i, X) {
        d.push_back(qA[i]);
    }
    rep(i, Y) {
        d.push_back(qB[i]);
    }
    rep(i, C) {
        d.push_back(qC[i]);
    }
    sort(d.begin(), d.end());
    reverse(d.begin(), d.end());
    ll ans = 0;;
    for (int i = 0; i < X+Y; i++)
    {
        ans += d[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 8688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if (a.equals("H")) {
			if (b.equals("H")) {
				System.out.println("H");
			} else {
				System.out.println("D");
			}
		} else {
			if (b.equals("H")) {
				System.out.println("D");
			} else {
				System.out.println("H");
			}
		}
	}

}

Measured memory_bytes: 19924
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int count = Math.min(B / A, C);

		System.out.println(count);

	}
}

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

#define loop(i, x, y) for (i = x; i < y; i++)
#define loopr(i, x, y) for (i = x; i > y; i--)

//use *it instead of it
#define vloop(it, x) for (auto it = x.begin(); it != x.end(); it++)
#define vloopr(it, x) for (auto it = x.end() - 1; it != x.begin() - 1; it--)

#define yes printf("YES\n")
#define no printf("NO\n")
#define pb push_back
#define mp make_pair

#define debug(x) cerr << #x << ":" << x << endl
#define yo cerr << "yo" << endl

typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;

const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;

#define test(t) \
    ll t;       \
    cin >> t;   \
    while (t--)

//use double
#define precision(x)       \
    cout.setf(ios::fixed); \
    cout << setprecision(10) << x << endl;

// ll gcd(ll x_f, ll y_f)
// {
//     if (x_f == 0)
//         return y_f;
//     return gcd(y_f % x_f, x_f);
// }

ll power(ll x_f, ll y_f, ll m_f)
{
    ll res_f = 1;

    x_f = x_f % m_f;
    while (y_f)
    {
        if (y_f & 1)
            res_f = (res_f * x_f) % m_f;
        y_f = y_f >> 1;
        x_f = (x_f * x_f) % m_f;
    }
    return res_f;
}

// ll less(ll x_f, ll y_f)
// {
//     return (x_f > y_f) ? y_f : x_f;
// }
// ll more(ll x_f, ll y_f)
// {
//     return (x_f < y_f) ? y_f : x_f;
// }

ll fac(ll x_f)
{
    ll fac_f = 1;
    for (ll i = 1; i <= x_f; i++)
    {
        fac_f *= i;
        fac_f = fac_f % MOD;
    }
    return fac_f;
}

bool composite[1000007] = {false};
ll seive(ll x)
{
    composite[0] = true;
    composite[1] = true;
    for (ll i = 2; i <= x; i++)
    {
        if (!composite[i])
        {
            for (ll j = 2 * i; j <= x; j += i)
            {
                composite[j] = true;
            }
        }
    }
}

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

    ll n;
    cin >> n;

    ll all = power(10, n, MOD);
    ll wo = power(9, n, MOD);
    ll wb = power(8, n, MOD);

    ll ans = (all - (2 * wo) + wb) % MOD;
    if (ans < 0)
        ans = ans + MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    a=ord('a')
    S=list(map(lambda s:ord(s)-a,input()))
    N=len(S)
    for k in range(26):
        SUM=[0]*(N+1)
        for i in range(N):
            SUM[i+1]=SUM[i]+(S[i]==k)
        T=[2*x-i for i,x in enumerate(SUM)]
        m=T[0]
        mi=0
        for i in range(2,N+1):
            if T[i]>m:
                print(mi+1,i)
                exit()
            if m>T[i-1]:
                m=T[i-1]
                mi=i-1
    print(-1,-1)
        
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 88568
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var h = new HashSet<String>();
		for(int i=0;i<N;i++){
			if(h.Contains(S[i])){
				Console.WriteLine("No");
				return;
			}
			if(i > 0){
				char last = S[i - 1][S[i - 1].Length - 1];
				char first = S[i][0];
				if(last != first){
					Console.WriteLine("No");
					return;
				}
			}
			h.Add(S[i]);
		}
		Console.WriteLine("Yes");
	}
	int N;
	String[] S;
	public Sol(){
		N = ri();
		S = new String[N];
		for(int i=0;i<N;i++) S[i] = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13280
import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
g=[[] for _ in range(n)]
indeg=[0]*n
touch=[0]*n
for _ in range(m):
    l,r,d=map(int,input().split())
    l-=1
    r-=1
    touch[l]=1
    touch[r]=1
    g[l].append((r,d))
    indeg[r]+=1
if m==0:
    print('Yes')
    exit()
entered=False
for i in range(n):
    if indeg[i]==0 and touch[i]==1:
        vis=[False]*n
        entered=True
        dist=[-1]*n
        dist[i]=0
        def dfs(u):
            vis[u]=1
            for v,wt in g[u]:
                if dist[v]==-1:
                    dist[v]=dist[u]+wt
                elif dist[v]!=dist[u]+wt:
                    print('No')
                    exit()
                if vis[v]==False:
                    dfs(v)
        dfs(i)

if entered==False:
    print('No')
else:
    print('Yes')



Measured memory_bytes: 122000
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,c;
	cin>>a>>b>>c;
	ll sum=a+b+c;
if(a%2==1||b%2==1||c%2==1)cout<<0<<endl;
	else if(a==b&&b==c)cout<<-1<<endl;
	else{
		int cnt=0;
		while(1){
			if(a%2==1||b%2==1||c%2==1)break;
			a=(sum-a)/2;
			b=(sum-b)/2;
			c=(sum-c)/2;
			cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
/*Saurav Paul*/
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define boost		          ios_base::sync_with_stdio(0);
#define eb                    emplace_back
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1e9+7
#define itoc(c)               ((char)(((int)'0')+c))
#define ctoi(c)               ((int)(((int)c)-'0'))
#define all(p)                p.begin(),p.end()
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define scn2(num,num2)        scanf("%lld%lld",&num,&num2);
using namespace std;

const int nax = 2000+1;
char s[nax][nax];
int dp[nax][nax];
int h , w;
int main()
{
	
	scanf("%d%d",&h,&w);
	for(int i =0 ; i < h ; i++)
		scanf("%s",s[i]);
	
	int maxi = 0;
	for (int i = 0 ; i < h ; i++){
		for(int j= 0 ; j < w ; j++){					
			if(s[i][j]=='#')
				continue ;
			int cnt = 0,st= j;
			while(j < w){
				if(s[i][j]=='#')
					break;
				cnt++;
				j++;
			}
			for(st=st ; st < j ; st ++)
				dp[i][st] +=cnt ;
		}
	}

	for (int i = 0 ; i < w ; i++){
		for(int j= 0 ; j < h ; j++){	

			if(s[j][i]=='#')
				continue ;
			int cnt = 0,st= j;
			while(j < h){
				if(s[j][i]=='#')
					break;
				cnt++;
				j++;
			}
			for(st=st ; st < j ; st ++)
				dp[st][i] +=cnt ;
		}
	}

	for(int i = 0 ; i < h ; i++)
		for(int j = 0 ; j < w ; j++)
			maxi = max(maxi, (int)dp[i][j]);

	printf("%d\n",maxi-1);
    return 0;
}


Measured memory_bytes: 19840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll ZERO = 0;
const ll INF = 1e14;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;

int main() {
    string S,T;
    cin >> S >> T;
    cout << T << S << endl;
}

Measured memory_bytes: 256
import sys

def cmb(n, r, mod):#コンビネーションの高速計算　
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


input=sys.stdin.readline
write=sys.stdout.write

N=int(input())
hen={i:[] for i in range(1,N+1)}
for i in range(0,N-1):
    a,b=map(int,input().split())
    hen[a].append(b)
    hen[b].append(a)

parent={i:-1 for i in range(1,N+1)}
parent[1]=0
q=[]
q.append(1)
sub=[]
while q!=[]:
    while q!=[]:
        x=q.pop()
        for p in hen[x]:
            if parent[p]==-1:
                parent[p]=x
                sub.append(p)
        #何らかの操作
        #ここでsubキューに次に使うものを格納
        if q==[]:
            q=sub
            sub=[]
            break

ans={i:1 for i in range(1,N+1)}
subtreesize={i:1 for i in range(1,N+1)}
flag={i:0 for i in range(0,N+1)}
q=[]
for i in range(1,N+1):
    if i!=1 and len(hen[i])==1:
        q.append(i)


sub=[]
while q!=[]:
    while q!=[]:
        x=q.pop()
        p=parent[x]
        if p!=1:
            ans[p]=(ans[p]*ans[x]*g2[subtreesize[x]])%mod
            subtreesize[p]+=subtreesize[x]
            flag[p]+=1
            if flag[p]==len(hen[p])-1:
                ans[p]=(ans[p]*g1[subtreesize[p]-1])%mod
                sub.append(p)
        else:
            subtreesize[1]+=subtreesize[x]
            ans[1]=(ans[1]*ans[x]*g2[subtreesize[x]])%mod
            flag[1]+=1
            if flag[1]==len(hen[1]):
                ans[1]=(ans[1]*g1[subtreesize[1]-1])%mod
        #何らかの操作
        #ここでsubキューに次に使うものを格納
        if q==[]:
            q=sub
            sub=[]
            break

q=[1]
flag2={i:0 for i in range(1,N+1)}
flag2[1]=1
sub=[]
while q!=[]:
    while q!=[]:
        x=q.pop()
        for p in hen[x]:
            if flag2[p]==0:
                if len(hen[p])!=1:
                    ans[p]=(ans[x]*pow(N-subtreesize[p],mod-2,mod)*g1[subtreesize[p]]*g2[subtreesize[p]-1])%mod
                    flag2[p]=1
                    sub.append(p)
                else:
                    ans[p]=(ans[x]*pow(N-1,mod-2,mod))%mod

        #何らかの操作
        #ここでsubキューに次に使うものを格納
        if q==[]:
            q=sub
            sub=[]
            break

for i in range(1,N+1):
    write(str(ans[i])+"\n")

Measured memory_bytes: 169136
N = int(input())
a = list(map(int, input().split()))
s = a[:1]
t = a[1:]
x = sum(s)
y = sum(t)
if x==y:
  ans = 0
else:
  ans = abs(x-y)

for i in range(1,N-1):
  x += a[i]
  y -= a[i]
  if x==y:
    ans = 0
    break
  elif abs(x-y)<ans:
    ans = abs(x-y)
print(ans)

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

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

   vector<long long> A(N);
   for (long long i = 0; i < N; i++)
      cin >> A.at(i);
   
   long long count = 0;
   long long sum = 0;
   for (long long i = 0; i < N; i++)
   {
      if (A.at(i) <= 0)
      {
         count++;
         A.at(i) *= -1;
      }
      sum += A.at(i);
   }
   
   sort(A.begin(), A.end());

   if (count % 2 == 0)
      cout << sum << endl;
   else
      cout << sum - (2 * A.at(0)) << endl;
}


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

int main()
{
    int i,n;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }for(i=0;i<(n-1);i++)
    {
        if(a[i]>=a[i+1])
        {
            if(a[i-1]==a[i]) continue;
            else a[i]--;
        }
    }for(i=0;i<(n-1);i++)
    {
        if(a[i]>a[i+1]) {printf("No");return 0; }
    }
    printf("Yes");
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i = 0; i < 10000; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a == 0 && b == 0) {
				break;
			} else {
				if(a < b) {
					System.out.println(a + " " + b);
				} else {
					System.out.println(b + " " + a);
				}
			}
		}
	}
}

Measured memory_bytes: 35684
N, M = map(int, input().split())

k = [0] * M
s = [0] * M


for m in range(M):
    line = list(map(int, input().split()))
    k[m] = line[0]
    
    s[m] = [line[l] - 1 for l in range(1, k[m] + 1)]

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

ans = 0
for i in range(2 ** N):
    tmp = [(i >> t) & 1 for t in range(N)]
    need = [sum([tmp[i] for i in l]) % 2 for l in s]
    if need == p:
        ans += 1
print(ans)

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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

ll cnt_a[45], cnt_b[45];

ll bit(ll x, ll j){
  return (x >> j) & 1;
}

void calc(ll x, ll cnt[]){
  for (ll j = 40; j >= 0; --j){
    ll cur = 0;
    ll X = (x >> (j + 1)), Y = x - ( (X << (j + 1)) + (1ll << j) );
    if (j == 0){
      cnt[j] = X + bit(x, j);
    }
    if (bit(x, j) == 0){
      cnt[j] = X * (1ll << j);
    } else {
      cnt[j] = X * (1ll << j) + Y + 1;
    }
  }

}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);
//  freopen(Task".out", "w", stdout);
  ll a, b; cin >> a >> b;
  calc(a - 1, cnt_a); calc(b, cnt_b);
  ll ans = 0;
  for (ll j = 40; j >= 0; --j){
    cnt_b[j] -= cnt_a[j];
    if (cnt_b[j] & 1) ans = ans | (1ll << j);
  }
  cout << ans;
return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <complex>
using namespace std;

#define x real()
#define y imag()
typedef complex<double> Point;

Point circumscribed_Circle_Center(Point a, Point b, Point c){
  double A = a.x - b.x;
  double B = a.y - b.y;
  double C = -1.0 * (a.x*a.x - b.x*b.x + a.y*a.y - b.y*b.y);
  double D = a.x - c.x;
  double E = a.y - c.y;
  double F = -1 * (a.x*a.x - c.x*c.x + a.y*a.y - c.y*c.y);

  double L = (C*E - B*F) / (E*A - B*D);
  double M = (D*C - A*F) / (D*B - E*A);
  double xp = L / -2.0;
  double yp = M / -2.0;
  return (Point(xp, yp));
}

double circumscribed_Circle_Radius(Point a, Point c){
  double L = c.x * -2.0;
  double M = c.y * -2.0;
  double N = -1 * (a.x*a.x + a.y*a.y + L*a.x + M*a.y);
  double r = sqrt(L*L + M*M - 4*N) / 2.0;
  return r;
}

int main(){
  int n;
  Point a, b, c;
  cin >> n;
  while(n--){
    cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y;
    Point C = circumscribed_Circle_Center(a, b, c);
    double r = circumscribed_Circle_Radius(a, C);
    printf("%.3f %.3f %.3f\n", C.x, C.y, r);
  }
  return 0;
}

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

int main()
{
  int n, a, b, ct = 0, t;

  cin >> n >> a >> b;
  for (int i = 0; i < n; i++){
    cin >> t;
    if (!(a <= t && t < b))  ct++;
  }

  cout << ct << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int H, W, i, j,answer=0;
	char s[60][60] = { 0 };
	cin >> H >> W;
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			cin >> s[i][j];
		}
	}
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			if (s[i][j] == '#') {
				if (s[i - 1][j] != '#'&&s[i + 1][j] != '#'&&s[i][j - 1] != '#'&&s[i][j + 1] != '#') {
					answer++;
				}
			}
		}
	}
	if (answer == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,x,y,z;
    cin>>a>>b;
    x=a+b;
    y=a-b;
    z=a*b;
    if(x>=y && x>=z)
    {
        cout<<x<<endl;
    }
    else if(y>=x && y>=z)
    {
        cout<<y<<endl;
    }
    else
    {
        cout<<z<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
n, m = [ int(v) for v in input().split() ]
node_list = []
for i in range(m):
    a, b, c = [ int(v) for v in input().split() ]
    node_list.append((a-1,b-1,-c))
distance_list = [ 10**15 for i in range(n) ]
parent_list = [ -1 for i in range(n) ]

distance_list[0] = 0
parent_list[0] = -1



for i in range(n-1):
    new_distanece_list = distance_list
    for j in node_list:
        a, b, c = j
        if distance_list[a] != 10**15:
            if new_distanece_list[b] > distance_list[a] + c:
                new_distanece_list[b] = distance_list[a] + c
                parent_list[b] = a
                change_log = 1
    distance_list = new_distanece_list
distance_list_1 = [ i for i in distance_list]

for i in range(n):
    new_distanece_list = distance_list
    for j in node_list:
        a, b, c = j
        if distance_list[a] != 10**15:
            if new_distanece_list[b] > distance_list[a] + c:
                new_distanece_list[b] = distance_list[a] + c
                parent_list[b] = a
                change_log = 1
    distance_list = new_distanece_list
distance_list_2 = distance_list



if distance_list_1[-1] == distance_list_2[-1]:
    print(-distance_list_1[-1])
else:
    print("inf")

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int X;
    cin >> X;
    int max=0;
    if(X==1){
        cout << 1 << endl;
        return 0;
    }
    for(int i=1; i<=X; i++){
        for(int j=2; j<=X; j++){
            int t=pow(i,j);
            if(t>X){
                break;
            }
            if(t>max){
                max=t;
            }
        }
    }
    cout << max << endl;
}

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

int main(){
    int N;
    int X[200000];
    int Y[200000];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> X[i];
        Y[i] = X[i];
    }
    sort(Y, Y+N);
    int l = Y[N/2 - 1];
    int g = Y[N/2];
    for(int i=0;i<N;i++){
        if(X[i] <= l){
            cout << g << endl;
        }else{
            cout << l << endl;
        }
    }
}


Measured memory_bytes: 3712
s = list(map(int, input()))

a = [i%2 for i in range(len(s))]
b = [(i+1)%2 for i in range(len(s))]

a_sum = sum(abs(x-y) for x, y in zip(s, a))
b_sum = sum(abs(x-y) for x, y in zip(s, b))
print(min(a_sum, b_sum))


Measured memory_bytes: 11552
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <stack>
#include <tuple>
#include <queue>
#include <functional>

using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;

int main()
{
    int day, numType;
    cin >> day >> numType;
    vector<int> cakes(numType);
    for (int i = 0; i < numType; i++) cin >> cakes[i];
    if (cakes.size() == 1)
    {
        cout << cakes[0] - 1 << endl;
        return 0;
    }
    while(true)
    {
        sort(cakes.begin(), cakes.end(), greater<int>{});
        if (cakes[1] == 0) break;
        cakes[0] -= cakes[1];
        cakes[1] = 0;
    }
    if (cakes[0] == 0) cout << 0 << endl;
    else cout << cakes[0] - 1 << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();

    sc.close();

    HashMap<Integer, Integer> hashMap = new HashMap<>();

    for (int i = 1; i <= N; i++) {
  
      // 各桁の合計を出す
      String s = String.valueOf(i);

      String[] S = s.split("");
    
      int sum = 0;
    
      for (int j = 0; j < S.length; j++) {
        sum += Integer.valueOf(S[j]);
      }

      hashMap.put(i,sum);
    
    }

    int sum = 0;

    for (Map.Entry<Integer, Integer> map : hashMap.entrySet()) {

      if (A <= map.getValue() && map.getValue() <= B){
        sum += map.getKey();
      }
      
    }

    System.out.println(sum);

  }

}

Measured memory_bytes: 33748
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)


int main() {
	i64 x;
	cin >> x;
	i64 ans = 0;
	ans = (x / 11)*2;
	x %= 11;
	if (x > 6) {
		ans++;
	}
	if (x > 0) {
		ans++;
	}
	cout <<ans << endl;
	return 0;
}

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

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

typedef long long ll;
typedef pair<int, int> P;
typedef map<int, int> MP;

#define INF 1e9

int main(int, char**)
{
  int n, k;
  cin >> n >> k;

  vector<int> a(n);
  int l = 1, r = 0, mid;
  rep(i,n) {
    cin >> a[i];
    r = max(r,a[i]);
  }

  while (r > l) {
    mid = (l+r)/2;
    int cnt = 0;
    rep(i,n) {
      cnt+=(a[i]+mid-1)/mid-1;
    }
    if (cnt <= k) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }

  cout << l << endl;

  return 0;
}


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

int my_abs(int a){
    if(a < 0){
        a *= -1;
    }
    return a;
}

int main() {

    int a,b,c,d;

    cin >> a >> b >> c >> d;

    if(my_abs(a-c) > d && (my_abs(a-b) > d || my_abs(b-c) > d)){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
from sys import stdin
from bisect import bisect_right, bisect_left


def input():
    return stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    A.sort()
    B.sort()
    C.sort()

    ans = 0
    i, j = 0, 0
    for b in B:
        i = bisect_left(A, b, lo=i)
        j = bisect_right(C, b, lo=j)
        ans += i * (N - j)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22720
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<double,int> pint;
typedef long long ll;
const int inf   = 1<<29;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int n,m;cin>>n>>m;
  cout<<n*n-m<<endl;
  return 0;
  } 


Measured memory_bytes: 256
a = list(input())

ans1 = 0
ans2 = 0

for i in range(len(a)):
		if a[i] == 'A':
			ans1 = i
			break
for j in reversed(range(len(a))):
		if a[j] == 'Z':
			ans2 = j
			break

print(ans2 - ans1 +1)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll a,b,c;cin >>a>>b>>c;
    ll ans=0;
    while(1) {
        if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)break;
        if(a==b&&b==c){
            ans=-1;
            break;
        }
        int na=a,nb=b,nc=c;
        a=(nb+nc)/2;
        b=(na+nc)/2;
        c=(na+nb)/2;
        ans++;
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 3640
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7),n;
	static long cf = 998244353;
    static final int MAX = (int) 1e6;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static int col = 20;
    public static long[] Bit;
    public static long[] fac,inv;
    public  static int[] prime; 
    public static long[] dp;
	public static FastReader sc = new FastReader();
	public static void main(String[] args) {
	//	Scanner sc = new Scanner(System.in);
 
		int a = sc.nextInt() + sc.nextInt() + sc.nextInt();
		if(a >= 22) out.print("bust");
		else
		out.print("win");
		out.close();
	}
	
	
}

Measured memory_bytes: 21204
n = int(input())
x = list(map(int, input().split()))
a = min(x)
b = max(x)
ans  = 10**9

for i in range(a, b+1):
    s = 0
    for j in x:
        s += (j-i)**2

    ans = min(ans, s)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<stdio.h>

#define PI 3.141592654
#define DEG_TO_RAD(theta) degToRad(theta)
#define RAD_TO_DEG(theta) radToDeg(theta)

struct POINT{
	double x;
	double y;
};

double degToRad( double theta )
{
	return PI/180.0 * theta;
}

double radToDeg( double theta )
{
	return 180.0/PI * theta;
}

double getTheta( const POINT& p )
{
	double theta = RAD_TO_DEG( atan( p.y/p.x ) );

	if( p.x <= 0 && p.y >= 0 ){
		theta += 180.0;
	}
	else if( p.x <= 0 && p.y <= 0 ){
		theta += 180.0;
	}
	else if( p.x >= 0 && p.y <= 0 ){
		theta += 360.0;
	}

	return theta;
}

int main(void)
{
	int n;
	double theta;
	POINT p;

	while(1){
		p.x = 1.0;
		p.y = 0.0;
		theta = 0.0;

		std::cin >> n;
		if( n == -1 ){
			break;
		}
		if( n < 2 || n > 1000 ){
			continue;
		}
		for( int i = 0 ; i < n-1 ; i++ ){
			theta += 90;
			p.x += cos( DEG_TO_RAD(theta) );
			p.y += sin( DEG_TO_RAD(theta) );
			theta = getTheta(p);
		}
		printf( "%.2f\n%.2f\n", p.x, p.y );
	}

	return 0;
}

Measured memory_bytes: 1276
import math
N = int(input())
lim = math.floor(math.sqrt(N))
f_min = len(str(N))
for i in range(1, lim + 1):
  if N % i == 0:
    B = int(N / i)
    if len(str(B)) < f_min:
      f_min = len(str(B))
print(f_min)


Measured memory_bytes: 8984
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define REPEACH(i,k) for(auto& i:k)
#define FOR(a, b) for (ll i = a; i < b + 1; i++)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;

signed main(){
  string s;
  cin >> s;
  REP(i,s.size()){
    if(i%2==0){
      if(s[i]=='R'||s[i]=='U'||s[i]=='D'){
        continue;
      }
      else{
        cout << "No" << endl;
        return 0;
      }
    }
    else{
      if(s[i]=='L'||s[i]=='U'||s[i]=='D'){
        continue;
      }
      else{
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    char a; cin >> a;
    if ('a' <= a && a <= 'z') {
        cout << 'a' << endl;
    }
    else {
        cout << 'A' << endl;
    }
}


Measured memory_bytes: 3592
import sys
input = sys.stdin.readline
T = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

p = (a[0] - b[0]) * T[0]
q = (a[1] - b[1]) * T[1]

if p > 0:
  p *= -1
  q *= -1
if p + q < 0:
  print(0)
elif p + q > 0:
  print(-p // (p + q) * 2 + ((-p % (p + q)) > 0))
else:
  print("infinity")

Measured memory_bytes: 38384
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int t,n,c[3][10001],yn[40001]; char cyn[40001];
	int nc[4][3][3]={
		{{0,2,4},{2,0,2},{4,2,0}},
		{{2,2,4},{2,2,4},{4,4,6}},
		{{6,4,4},{4,2,2},{4,2,2}},
		{{6,4,4},{4,4,4},{4,4,4}}
	};
	cin>>t;rep(ct,t){
		cin>>n>>cyn; rep(i,4*n)yn[i]=cyn[i]=='Y';
		rep(i,3)rep(j,n+1)c[i][j]=1<<20;
		c[0][0]=!yn[2*n]?!yn[0]?0:3:7;
		c[1][0]=yn[2*n]?5:3;c[2][0]=5;
		rep(i,n)rep(j,3)rep(k,3){
			int book;
			if(i==n-1)book=yn[2*i+1]+yn[2*i+1+2*n]*2;
			else book=(yn[2*i+1]||yn[2*i+2])+(yn[2*i+1+2*n]||yn[2*i+2+2*n])*2;
			c[k][i+1]=min(c[k][i+1],c[j][i]+nc[book][j][k]);
		}
		cout<<c[0][n]/2+n<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
int main(){
    ll n, m; cin >> n >> m;
    string s, t; cin >> s >> t;
    bool flag = true;
    for(int i = 0; i < gcd(n, m); i++){
        //cout << s[i * (n / gcd(n, m))] << " " << t[i * (m / gcd(n, m))] << endl;
        if(s[i * (n / gcd(n, m))] != t[i * (m / gcd(n, m))])flag = false;
    }
    if(flag) cout << lcm(n, m) << endl;
    else cout << -1 << endl;

}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  cout lfs (n+1)/2/(ld)n<<endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
Map = [list(map(int, input().split())) for i in range(N)]

ans = sum([sum(Map[i]) for i in range(N)])

for k in range(N):
    for i in range(N):
        for j in range(N):
            if Map[i][k] + Map[k][j] < Map[i][j]:
                print(-1)
                exit()

for i in range(N):
    for j in range(N):
        for k in range(N):
            if i == k or j == k:
                continue
            if Map[i][k] + Map[k][j] == Map[i][j]:
                ans -= Map[i][j]
                break

print(ans//2)

Measured memory_bytes: 44764
import java.util.*;

public class Main{

    private static int m;
    private static int n;;
    private static int max;
    private static int q;
    private static int[] a;
    private static int[] b;
    private static int[] c;
    private static int[] d;

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        m = sc.nextInt();
        q = sc.nextInt();

        a = new int[q];
        b = new int[q];
        c = new int[q];
        d = new int[q];

        for(int i = 0; i < q; i++){
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }

        int[] A = new int[n];
        Arrays.fill(A, 1);
        max = 0;
        array(A, n - 1);

        System.out.println(max);

    }

    static void array(int[] A, int x){
        if(-1 == x){
            //System.out.println(Arrays.toString(A));
            if(judge(A)){
                int point = 0;
                for(int i = 0; i < q; i++){
                    if(A[b[i]] - A[a[i]] == c[i]){
                        point += d[i];
                    }
                }
                max = Math.max(max, point);
                //System.out.println(point);

            }

            return;
        }


        if(x == n - 1){
            for(int i = 1; i <= m; i++){
                A[x] = i;
                array(A, x - 1);
            }

        }else{
            for(int i = A[x + 1]; i > 0; i--){
                A[x] = i;
                array(A, x - 1);
            }
        }

    }

    static boolean judge(int[] A){
        int n = A[0];
        for(int i = 1; i < A.length; i++){
            if(n <= A[i]){
                n = A[i];
            }else{
                return false;
            }
        }
        return true;
    }

}


Measured memory_bytes: 38276
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys

N = int(input())
ret = 0
pat = [0,0,0,0]
## pat:=[--, B-, -A, BA]

for _ in range(N):
  s = str(input())
  ret += s.count("AB")
  p = 0
  if s[0]=='B':
    p += 1
  if s[-1]=='A':
    p += 2
  pat[p] += 1

ret += max(0, pat[3]-1)
if pat[1]>0 and pat[3]>0:
  ret += 1
  pat[1]-=1
if pat[2]>0 and pat[3]>0:
  ret += 1
  pat[2]-=1
ret += min(pat[1],pat[2])

print(ret)

Measured memory_bytes: 44264
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;
        Solver s = new Solver();
        for (int i = 1; i <= t; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }

}

class Solver {
    void solve(int test, InputReader in, PrintWriter out) throws IOException {
        long n = in.nextLong();
        long m = in.nextLong();
        long low = 0, high = (long) 1e15;
        long ans = 0;
        while (low <= high) {
            long mid = (low + high) / 2;
            if (can(mid, n, m)) {
                ans = mid;
                low = mid + 1;
            } else {
                high = mid - 1;
            }
        }
        out.println(ans);
    }

    private boolean can(long groups, long s, long c) {
        long rc = groups * 2;
        if (s >= groups && c >= rc) return true;
        if (c < rc) return false;
        long mr = groups - s;
        c -= 2 * mr;
        s += mr;
        return s >= groups && c >= rc;
    }
}

class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
        st = null;
    }

    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {
        return br.readLine();
    }

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

Measured memory_bytes: 21460
# coding: utf-8
import math
a,b,h,m = [int(x) for x in input().split()]
a_arg = math.pi*(h+m/60)/6
b_arg = math.pi*m/30
l_arg = 0
s_arg = 0
if a_arg >= b_arg:
    c2 = a**2 + b**2 - 2*a*b*math.cos(a_arg-b_arg)
else:
    c2 = a**2 + b**2 - 2*a*b*math.cos(b_arg-a_arg)
print(c2**0.5)

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

int main(){
  int n;
  cin >> n;
  int x[n], y[n];
  for(int i=0; i<n; ++i) cin >> x[i] >> y[i];
  
  double temp = 0.0;
  for(int i=0; i<n; ++i){
    for(int j=0; j<n; ++j){
      if(i != j){
        temp += sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
      }
    }
  }
  
  double res = temp / n;
  cout << setprecision(20) << res << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  long long ans = 1000;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] < a[i + 1]) {
      ans += (ans / a[i]) * (a[i + 1] - a[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
#define log loga
// std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// int myRand(int R) {
// 	int val=rng() % R;
//       assert(val>=0);
//       return val;
// }
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int32_t MOD=MOD1;

int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
          int cnt[4]={0};
          int n;
          cin>>n;
          rep(i,0,n)
          {
                string s;
                cin>>s;
                if(s=="AC")
                cnt[0]++;
                else if(s=="WA")
                cnt[1]++;
                else if(s=="TLE")
                cnt[2]++;
                else
                cnt[3]++;
          }

           int cur=0; 
          for(auto it:{"AC","WA","TLE","RE"})
          {
               cout<<it<<" x "<<cnt[cur++]<<endl;
          }
      }
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 3656