akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

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

int main() {
	
	long long int n;
	cin >> n;
	long long int t=0,a = 0, b = n, c = n;
	int x = 0;
	int r = 0;
	while (b) {
		//if (b % 10 != 9)continue;
		x++;
		t += b % 10;
		if (b / 10 == 0)r = b;
		b /= 10;
	}
	a = max(t, a);;
	t = 0;
	t = r + (x - 1) * 9 - 1;
	
	cout << max(t, a) << endl;
	

	return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var (
    a string
    n int
  )
  fmt.Scan(&a)
  if a[0] == '1' {
    n++
  }
  if a[1] == '1' {
    n++
  }
  if a[2] == '1' {
    n++
  }
  fmt.Println(n)
}

Measured memory_bytes: 512
#include <stdio.h>

int main() {
  char c;
  while(scanf("%c", &c) != -1) printf("%c", c + (
    (c >= 0x61 && c <= 0x7a) ? -0x20 :
    (c >= 0x41 && c <= 0x5a) ? 0x20 :
    0
  ));
  return 0;
}

Measured memory_bytes: 524
#include <iostream>
using namespace std;
int main(void){
   int a,b,c,x,C,n=0;
   cin >> a;
   cin >> b;
   cin >> c;
   for(int x=a;x<=b;x++){
       C=c%x;
       if(C==0){
           n=n+1;
       }
   }
   cout << n <<endl;
}


Measured memory_bytes: 3104
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < n; ++i)

char s[3001];
int n, m, mx[3001], mn[3001], md = 1e9 + 7, x[3001], an[3001][3001];

int main() {
	scanf("%d%d%s", &n, &m, s);
	f(i, 0, n)mx[i + 1] = mn[i + 1] = x[i + 1] = x[i] + (s[i] == '1');
	int L = 0;
	while (m--) {
		int l, r;
		scanf("%d%d", &l, &r);
		if (r <= L)continue;
		int a = mn[l - 1], b = mx[l - 1];
		int z = x[r] - b;
		f(i, l, r + 1) {
			if (z >= i - l + 1)mx[i] = 1 + mx[i - 1];
			else mx[i] = mx[i - 1];
		}
		z = r - l + 1 - (x[r] - a);
		f(i, l, r + 1) {
			if (z >= i - l + 1)mn[i] = mn[i - 1];
			else mn[i] = mn[i - 1] + 1;
		}
		L = r;
	}
	an[0][0] = 1;
	f(i, 0, n) {
		int a = mn[i], b = mx[i];
		f(j, a, b + 1) {
			if (j >= mn[i + 1] && j <= mx[i + 1]) {
				an[i + 1][j] += an[i][j];
				if (an[i + 1][j] >= md)an[i + 1][j] -= md;
			}
			if (j + 1 >= mn[j + 1] && j + 1 <= mx[i + 1]) {
				an[i + 1][j + 1] += an[i][j];
				if (an[i + 1][j + 1] >= md)an[i + 1][j + 1] -= md;
			}
		}
	}
	printf("%d\n", an[n][x[n]]);
}

Measured memory_bytes: 12544
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


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

} 

Measured memory_bytes: 3520
#include <stdio.h>
#include <math.h>

int main(void) {
	double x1, y1, x2, y2,q;

	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	q = pow(x2 - x1,2)+pow(y2-y1,2);
	q = sqrt(q);
	printf("%f", q);
	return 0;
}


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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;
ll a[NMAX],sum[NMAX];
int main(int argc, char const *argv[])
{
	int n;
	scanf("%d",&n);
	for(register int i = 1;i <= n;i++)
		scanf("%d",a+i);
	sum[n+1] = 0;
	for(register int i = n;i >= 1;--i)
		sum[i] = (sum[i+1] + a[i])%MOD;

	ll ans = 0;
	for(register int i = 1;i < n;i++)
		ans = (ans + a[i] * sum[i+1] % MOD)%MOD;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6932
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
# UnionFind
class UnionFind():
    def __init__(self, n):
        self.nodes=[-1] * n  # nodes[x]: 負なら、絶対値が木の要素数

    def get_root(self, x):
        # nodes[x]が負ならxが根
        if self.nodes[x] < 0:
            return x
        # 根に直接つなぎ直しつつ、親を再帰的に探す
        else:
            self.nodes[x]=self.get_root(self.nodes[x])
            return self.nodes[x]

    def unite(self, x, y):
        root_x=self.get_root(x)
        root_y=self.get_root(y)
        # 根が同じなら変わらない
        # if root_x == root_y:
        # pass
        if root_x != root_y:
            # 大きい木の方につないだほうが計算量が減る
            if self.nodes[root_x] < self.nodes[root_y]:
                big_root=root_x
                small_root=root_y
            else:
                small_root=root_x
                big_root=root_y
            self.nodes[big_root] += self.nodes[small_root]
            self.nodes[small_root]=big_root


def main():
    N,M = MI()
    uf=UnionFind(N)
    get_root, unite, nodes=uf.get_root, uf.unite, uf.nodes

    for _ in range(M):
        A,B = MI()
        unite(A-1,B-1)

    ans = 0
    for i in range(N):
        ans = max(ans, -nodes[get_root(i)])
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 15064
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int n, kkt; scanf("%d %d", &n, &kkt);
	int sq = sqrt(n);
	int sz = (n + sq - 1) / sq;
	vector<int> a(n);
	vector<int> b(sz);
	while (kkt--) {
		int t, x, y; scanf("%d %d %d", &t, &x, &y);
		if (t == 0) {
			x--;
			a[x] += y;
			b[x / sq] += y;
		}
		else {
			x--;
			int res = 0;
			while (x < y and x % sq != 0) res += a[x++];
			while (x < y and y % sq != 0) res += a[--y];
			while (x < y) res += b[x / sq], x += sq;
			printf("%d\n", res);
		}
	}
	return 0;
}


Measured memory_bytes: 3348
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int n,k;
ll A[100010];

bool f(ll p){
	ll temp=p;
	int x=0;
	for(int i =0;i<k;i++){
		while(temp>=A[x]){
			temp-=A[x];
			x++;
		}
		temp=p;
	}
	if(x>=n) return true;
	else return false;
}

ll binary_find(ll left,ll right){
	ll mid;
	while(left+1<right){
		mid=(left+right)/2;
		if(f(mid)) right=mid;
		else left=mid;
	}
	return right;
}

int main(){
	ll p,sum;
	cin>>n>>k;
	for(int i = 0;i<n;i++){
		cin>>A[i];
		sum+=A[i];
	}
	p=binary_find(0,sum);
	cout<<p<<endl;
	return 0;
}


Measured memory_bytes: 3880
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    int k = 0;
    for (int i = min(A, B);; --i)
    {
        if (A % i == 0 && B % i == 0) ++k;
        if (k == K)
        {
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
    int X,Y,Z;
    cin >> X >> Y >> Z;
    X-=Z;
    cout << X/(Y+Z) << endl;
}

Measured memory_bytes: 256
#include <iostream> 
using namespace std;
int main()
{
	int a; cin>>a;
	int b=a%100;
	a/=100;
	if(a>0 and a<13 and b>0 and b<13) cout<<"AMBIGUOUS";
	else if((a==0 and b==0) or (a==0 and b>12) or (a>12 and b==0) or (a>12 and b>12)) cout<<"NA";
	else if(a>0 and a<13) cout<<"MMYY";
	else cout<<"YYMM";
}






Measured memory_bytes: 3016
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

// 分数を小数に変換する関数
double Fraction(Int numerator, Int denominator) {
    return (double)((double)(numerator) / (double)(denominator));
}

int main(void) {
    Int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << 0.5 << endl;
    } else {
        cout << Fraction(n / 2 + 1, n) << endl;
    }
}


Measured memory_bytes: 3780
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        
//        int n=sc.nextInt();
        char a[]=sc.getCharSet();
        char b[]=sc.getCharSet();
        for (int i = 0; i < a.length; i++) {
			if(a[i]!=b[i])ret("No");
		}

        out.println("Yes");
     	out.flush();
    }
    
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,c;long s;
//	P(int  x, int c, long s) {
//	  this.x=x;
//	  this.c=c;
//	  this.s=s;
//	}
//}


class P implements Comparable<P>{
	int x,c;long s;
	P(int  x, int c, long s) {
	  this.x=x;
	  this.c=c;
	  this.s=s;
	}

    public int compareTo(P p){
        return Long.signum(s-p.s);
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 32988
#ITP1_11_A

def west(d):
	tmp=d[4]
	d[4]=d[1]
	d[1]=d[3]
	d[3]=d[6]
	d[6]=tmp

def east(d):
	tmp=d[4]
	d[4]=d[6]
	d[6]=d[3]
	d[3]=d[1]
	d[1]=tmp

def north(d):
	tmp=d[1]
	d[1]=d[2]
	d[2]=d[6]
	d[6]=d[5]
	d[5]=tmp

def south(d):
	tmp=d[1]
	d[1]=d[5]
	d[5]=d[6]
	d[6]=d[2]
	d[2]=tmp

def kaiten(d, op):
	if   op == "W": west(d)
	elif op == "E": east(d)
	elif op == "N": north(d)
	elif op == "S": south(d)
	else          : raise AssertionError()

def dump(d):
	print(" ".join(map(str,d)))

def inputDice():
	return list(map(int,("-1 "+input()).split()))

d=inputDice()
for op in list(input()):
	kaiten(d,op)
print(d[1])


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
// #define int long longは0とmaxとるときエラー吐かれたので消しときます

signed main() {
  int n, m;
  cin >> n >> m;
  int ar = 10000000;
  int al = -1;
  for(int i = 0; i < m; i++){
    int l, r;
    cin >> l >> r;
    ar = min(r, ar);
    al = max(l, al);
  }
  int ans = max(ar - al + 1, 0);
  cout << ans << endl;
  // あーR‐Lがマイナスになる可能性あるのかー考慮してなかった…
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;

ll func(ll level, ll num){
  // cout<<level<<" "<<num<<endl;
  if(level==0LL)return num;
  if(num<=1LL)return 0LL;
  ll l_burger=ll(pow(2, level+1LL))-1LL;
  if(l_burger<=num){
    return ll(pow(2, level)-1LL)+func(level-1LL, min(l_burger-2LL, num-l_burger))+1LL;
  }else{
    if(num<=1) return 0LL;
  	return func(level-1LL, num-1LL);
  }
}

int main(){
  ll n, x;cin>>n>>x;
  cout<<func(n, x)<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#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 gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
// int bsr(uint x) { return 31^__builtin_clz(x);}
int bsr(ull x) { return 63^__builtin_clzll(x);}

ll f(ll x) {
  if (!x) return 0;
  return (2ll<<bsr(x))-1;
}

int main() {
  ll l,r;
  scanf("%lld%lld",&l,&r);
  if (l == r) {
    cout<<1<<endl;
    return 0;
  }
  ll x = 1ll<<60;
  while (x) {
    if (l&x) {
      assert(r&x);
      l -= x;
      r -= x;
    } else if (r&x) break;
    x >>= 1;
  }
  ll y = x<<1;
  ll z = x+f(r-x);
  ll ans = z-l+1;
  ll s = x+l;
  ans += y-s;
  // cerr<<l<<" "<<r<<" "<<x<<" "<<y<<" "<<s<<endl;
  ans -= max(0ll,z-s+1);
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n, x[114514], y[114514];
int par[222222], siz[222222];
void init(int x) { rep(i, x) { par[i] = i; siz[i] = 1; } }
int find(int x) { if (par[x] == x)return x; return par[x] = find(par[x]); }
void unite(int x, int y) { x = find(x); y = find(y); if (x == y)return; if (siz[x] > siz[y]) { par[y] = x; siz[x] += siz[y]; } else { par[x] = y; siz[y] += siz[x]; } }
int getsize(int x) { return siz[find(x)]; }
signed main() {
	cin >> n; init(222222); rep(i, n) { cin >> x[i] >> y[i]; unite(x[i], y[i] + 100000); }
	map<int, int>mx, my; rep(i, 100001) { mx[find(i)]++; }for (int i = 100001; i < 200001; i++) { my[find(i)]++; }
	int ans = 0; rep(i, 222222) { ans += mx[i] * my[i]; }
	cout << ans - n << endl;
}


Measured memory_bytes: 33152
n = int(input())
s = input()

ans = 0
for i in range(1000):
    iz = str(i).zfill(3)
    idx = 0
    for j in s:
        if idx < 3 and iz[idx] == j:
            idx += 1
    if idx == 3:
        ans += 1

print(ans)

Measured memory_bytes: 41564
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
typedef pair<string,mp> mmp;

int main(){
	ll n;
	cin>>n;
	vector<mmp>  a(n);
	for(int i=0;i<n;i++){
		string s;
		int t;
		cin>>s>>t;
		a[i] = mmp(s,mp(-t,i+1) );
	}
	sort(a.begin(),a.end());
	for(int i=0;i<a.size();i++){
		cout<<a[i].second.second<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
import queue
H, W = list(map(int, input().split()))
M = [[i for i in input()] for j in range(H)]

def bfs(x, y):
  D = [[10 ** 9 for i in range(W)] for j in range(H)]
  q = queue.Queue()
  q.put([x, y])
  D[y][x] = 0
  direct = [[-1, 0], [1, 0], [0, -1], [0, 1]]
  max_distance = 0
  while q.qsize() != 0:
    x, y = q.get()
    for dx, dy in direct:
      nx, ny = x + dx, y + dy
      if nx < 0 or nx >= W or ny < 0 or ny >= H:
        continue
      if M[ny][nx] == "#":
        continue
      if D[ny][nx] > D[y][x] + 1:
        D[ny][nx] = D[y][x] + 1
        max_distance = max([max_distance, D[ny][nx]])
        q.put([nx, ny])
  return max_distance

result = 0
for y in range(H):
  for x in range(W):
    if M[y][x] == "#":
      continue
    result = max([result, bfs(x, y)])
print(result)

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

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const int MOD = 1000000007;
const int MAX_N = 100010;

int N;
V<> X, Y;
V<> RX, RY;

int GetDist(int x1, int y1, int x2, int y2) {
    return abs(x1 - x2) + abs(y1 - y2);
}

signed main() {
    IOS;

    cin >> N;
    X.resize(N);
    Y.resize(N);
    RX.resize(N);
    RY.resize(N);
    REP(i, N) {
        cin >> X[i] >> Y[i];
        RX[i] = X[i] - Y[i];
        RY[i] = X[i] + Y[i];
    }

    int l_i = 0, r_i = 0, u_i = 0, d_i = 0;
    int l_v = LLINF, r_v = -LLINF;
    int d_v = LLINF, u_v = -LLINF;
    REP(i, N) {
        if(RX[i] < l_v) {
            l_i = i;
            l_v = RX[i];
        }
        if(r_v < RX[i]) {
            r_i = i;
            r_v = RX[i];
        }
        if(RY[i] < d_v) {
            d_i = i;
            d_v = RY[i];
        }
        if(u_v < RY[i]) {
            u_i = i;
            u_v = RY[i];
        }
    }
    // 復元して距離を計算
    int ans = 0;
    chmax(ans, GetDist(X[l_i], Y[l_i], X[r_i], Y[r_i]));
    chmax(ans, GetDist(X[u_i], Y[u_i], X[d_i], Y[d_i]));
    print(ans);

    return 0;
}


Measured memory_bytes: 9556
def five_dishes(a,n):
    b = []
    ttime = 0
    maxnum,opt,pos = 0,0,0
    for i in range(n):
        if a[i]%10 == 0:
            pass
        else:
            opt = 10 - a[i]%10
        if maxnum < opt:
            maxnum = opt
            pos = i
    tmp = a.pop(pos)
    for i in range(n-1):
        if a[i]%10 == 0:
            ttime += a[i]
        else:
            ttime += a[i] + 10 - a[i]%10
 
    else:
        ttime += tmp
 
    print("%d"  %ttime)
 
if __name__ == '__main__':
    a = [int(raw_input()) for i in range(5)]
    five_dishes(a,len(a))

Measured memory_bytes: 2692
#include <complex>
#include <cmath>
#include <vector>
#include <cstdio>
using namespace std;

typedef complex<double> xy_t;

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }

int main(){
    int n;
    scanf("%d", &n);
    vector<xy_t> P(n);
    double x, y;
    for(int i=0; i<n; ++i){
        scanf("%lf %lf", &x, &y);
        P[i] = xy_t(x, y);
    }
    double sum = 0.0;
    for(int i=0; i+2<n; ++i){
        xy_t a=P[0], b=P[i+1], c=P[i+2];
        sum += cross_product(b-a, c-a) / 2;
    }
    printf("%.1f\n" ,abs(sum));
}

Measured memory_bytes: 2700
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n;

int W;
int w[120];
int v[120];

ll dp[120000];


int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> W;
	for (int i = 0; i < n; ++i) {
		cin >> w[i] >> v[i];
	}
	for (int i = 0; i < n; ++i) {
		for (int j = W - w[i]; j >= 0; --j)
			dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
	}
	cout << dp[W] << "\n";
	return 0;
}




Measured memory_bytes: 1024
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace AtCoder.XXX.C
{ 
    public class Program
    {
        public static void Main(string[] args)
        {
            var datas = cr();
            var x = datas[0];
            var n = datas[1];
            if(n == 0)
			{
                P(x);
                return;
			}
            var a = cr().ToList();
            var min = x;
            var max = x;
            while(true)
			{
                if(a.Contains(min))
				{
                    min--;
				}
				else
				{
                    //if(min >= 1)
					{
                        P(min);
                        return;
                    }   
				}
                if(a.Contains(max))
				{
                    max++;
				}
				else
				{
                   // if(max <= 100)
					{
                        P(max);
                        return;
                    }
				}
			}

        }

        private static StreamReader sr;
        public static int[] Ecr()
        {
            if (sr == null)
            {
                sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
            }
            return sr.ReadLine().Split().Select(int.Parse).ToArray();
        }
        public static  int[] cr()
        {
            return Console.ReadLine().Split().Select(int.Parse).ToArray();
        }
        public static string Er()
        {
            if (sr == null)
            {
                sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
            }
            return sr.ReadLine();
        }
        public static string r()
        {
            return Console.ReadLine();
        }
        public static int cri()
        {
            return int.Parse(Console.ReadLine());
        }
        public static void P(string str)
        {
            Console.WriteLine(str);
        }
        public static void P(int num)
        {
            P(num.ToString());
        }
    }
}


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

int func(string s,string t){
    int ans = 0;
    for(int c='a';c<='z';c++){
        bool founds=false,foundt=false;
        for(int i=0;i<s.length();i++){
            if(s[i]==c)founds=true;
        }
        for(int i=0;i<t.length();i++){
            if(t[i]==c)foundt=true;
        }
        if(founds && foundt)ans++;
    }
    return ans;
}
int main(int argc, const char * argv[]) {
    int n;
    string s;
    cin>>n>>s;
    int ans = 0;
    for(int i=0;i<=n;i++){
        int temp = func(s.substr(0,i),s.substr(i));
        if(temp>ans)ans = temp;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long
# define fi first
# define se second

using namespace std ;

ll n, x, k;
ll ans[200001], vc[200001];

int main() {
    cin >> n >> k;
    for( int i = 0 ; i < n ; i ++ ) {
        cin >> vc[i] ;
    }
    for( int i = 1 ; i < n ; i ++ ) {
        ans[i] = abs(vc[i] - vc[i-1]) + ans[i-1];
        for( int j = 2 ; j <= k ; j ++ ) {
            if( j <= i ) ans[i] = min(ans[i], abs(vc[i]-vc[i-j]) + ans[i-j]) ;
        }
    }
    cout << ans[n-1] << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>

using namespace std;

void solve3() {
	int N;
	cin >> N;
	long long A[100010];
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	vector<pair<long long, int> > p;
	for (int i = 0; i < N; i++)
	{
		p.push_back(make_pair(A[i], i));
	}
	sort(p.begin(), p.end());
	int ans = 0;
	for (int i = 0; i < N; i+=2)
	{
		if (p[i].second % 2 == 1)ans++;
	}
	cout << ans << endl;
}

int main() {
	solve3();
	return 0;
}



Measured memory_bytes: 3188
from collections import Counter

n, k = map(int, input().split())
A = list(map(int, input().split()))
CA = Counter(A)

kouho = CA.most_common()[::-1]
ans = 0
idx = 0
while idx < len(CA) - k:
    key, val = kouho[idx]
    ans += val
    idx += 1
print(ans)



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

int main(){
  string a,b;
  cin>>a>>b;
  a+=b;
  int x=stoi(a);
  bool ok=0;
  for(int i=1;i<=x;i++){
    if(i*i==x) ok=1;
  }
  if(ok) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
// AGC018 F. Two trees
// Written on 2017/07/26.
//
#include <bits/stdc++.h>
using namespace std;
constexpr int TBD = 2;

pair<int, vector<vector<int>>> read_tree(int N){
    vector<vector<int>> Es(N);
    int root;
    for (int v = 0; v != N; ++v){
        int u;
        cin >> u;
        if (u == -1){
            root = v;
        }else{
            Es[u - 1].push_back(v);
        }
    }
    return make_pair(root, Es);
};

void dfs(int v, const vector<vector<int>> &Es, const vector<int> &Xs, vector<int> &stack){
    for (auto u : Es[v]) dfs(u, Es, Xs, stack);
    if (Xs[v] != 0) stack.push_back(v);
}

void add_edges(const vector<int> &stack, vector<vector<int>> &Es){
    for (int i = 0; i + 1 < stack.size(); i += 2){
        Es[stack[i]].push_back(stack[i + 1]);
        Es[stack[i + 1]].push_back(stack[i]);
    }
}

void fill_Xs(vector<int> &Xs, const vector<vector<int>> &Es){
    for (int v = 0; v != Xs.size(); ++v){
        if (Xs[v] != TBD) continue;
        Xs[v] = 1;
        for (auto u : Es[v]){
            int prev = v;
            int next = u;
            while (Xs[next] == TBD and Es[next].size() == 2){
                Xs[next] = -Xs[prev];
                int temp = prev;
                prev = next;
                next = Es[next][0] + Es[next][1] - temp;
            }
            Xs[next] = -Xs[prev];
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<int>> AEs(N);
    vector<vector<int>> BEs(N);
    int rootA, rootB;
    tie(rootA, AEs) = read_tree(N);
    tie(rootB, BEs) = read_tree(N);
    vector<int> Xs(N, TBD);
    for (int v = 0; v != N; ++v){
        if ((AEs[v].size() + BEs[v].size()) % 2 == 1){
            cout << "IMPOSSIBLE" << endl;
            return 0;
        }
        if (AEs[v].size() % 2 == 1) Xs[v] = 0;
    }
    vector<int> stackA;
    dfs(rootA, AEs, Xs, stackA);
    vector<int> stackB;
    dfs(rootB, BEs, Xs, stackB);

    vector<vector<int>> CEs(N);
    add_edges(stackA, CEs);
    add_edges(stackB, CEs);

    fill_Xs(Xs, CEs);
    cout << "POSSIBLE" << endl;
    cout << Xs[0];
    for (int i = 1; i != N; ++i) cout << ' ' << Xs[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 18992
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iomanip>

using namespace std;

int main(){
    int L;
    cin>>L;
    cout<<fixed<<setprecision(7)<<(double)(L*L*L)/27;
    return 0;

}

Measured memory_bytes: 256
l = [int(input()) for i in range(5)]
k = int(input())

c = 0

for i in range(len(l)):
    for j in range(len(l)):
        if l[i] - l[j] > k:
            c += 1
            
if c == 0:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3060
#include<cstdio>
char s[4];
int i,a,x;
int main(){
    scanf("%s",s);
    for(i=0;i<3;i++){
        if(s[i]=='R')x++;
        else x=0;
        a=a>x?a:x;
    }
    printf("%d",a);
}


Measured memory_bytes: 1736
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt() * a;
        if(b % 2 == 0){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

// 繰り返し二乗法
ll power(ll a, ll b){
    if(a==1)return a;
    // if(a==0)re
    ll res=1;
    while(b>0){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

const int MAX=2100000;

ll fact[MAX], fact_inv[MAX];

void init_fact(ll n){
    fact[0]=1;
    // 階乗の計算
    for(ll i=0; i<n; i++) fact[i+1]=fact[i]*(i+1)%MOD;
    fact_inv[n]=power(fact[n], MOD-2);
    // 逆元の計算
    for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}

ll comb(ll n, ll r){
    return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

ll perm(ll n, ll r){
    return (fact[n]*fact_inv[n-r])%MOD;
}

int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;
    vint T(n),A(n); rep(i,n) cin>>T[i]>>A[i];

    ll a,b;
    a = T.front();
    b = A.front();
    repf(i,1,n){
        ll c,d;
        c = T[i]; d = A[i];
        ll cnt = max((a+c-1)/c, (b+d-1)/d);
        a = c*cnt; b = d*cnt;
    }
    cout<<a+b<<endl;

    return 0;

}

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

bool match(char a, char b) {
  return a == '?' || b == '?' || a == b;
}

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

  int na = a.length(), nb = b.length(), nc = c.length();
  vector<bool> ab(na + nb, true), ac(na + nc, true), bc(nb + nc, true);
  for (int i = 0; i < na; i++)
    for (int j = 0; j < nb; j++)
      if (!match(a[i], b[j])) ab[i - j + nb] = false;
  for (int i = 0; i < na; i++)
    for (int j = 0; j < nc; j++)
      if (!match(a[i], c[j])) ac[i - j + nc] = false;
  for (int i = 0; i < nb; i++)
    for (int j = 0; j < nc; j++)
      if (!match(b[i], c[j])) bc[i - j + nc] = false;

  int ans = na + nb + nc;
  for (int i = -(nb + nc); i <= na + nc; i++)
    for (int j = -(nb + nc); j <= na + nb; j++) {
      int k = j - i;
      bool match_ab = (i < -nb || i > na || ab[i + nb]);
      bool match_ac = (j < -nc || j > na || ac[j + nc]);
      bool match_bc = (k < -nc || k > nb || bc[k + nc]);

      if (match_ab && match_ac && match_bc) {
        int l = min(0, min(i, j));
        int r = max(na, max(i + nb, j + nc));
        ans = min(ans, r - l);
      }
    }
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstring>

double P, E, T;

double fabs(double x){
    if(x < 0) x = -x;
    return x;
}

double dfs(int k, double pro, double L, double R){
    if(k == 0){
        double mid = (L + R) / 2;
        if(fabs(mid - T) <= E) return pro;
        return 0;
    }
    if(T + E < L || T - E > R) return 0;
    double ans = 0;
    double mid = (L + R) / 2;
    if(fabs(R - T) <= E && fabs(T - L) <= E) return pro;
    if(mid >= T){
        ans += dfs(k - 1, pro * (1 - P), L, mid);
        ans += dfs(k - 1, pro * P, mid, R);
    }
    else{
        ans += dfs(k - 1, pro * P, L, mid);
        ans += dfs(k - 1, pro * (1 - P), mid, R);
    }
    return ans;
}
int main(){
    //freopen("input.txt", "r", stdin);
    int K;
    double L, R;
    scanf("%d %lf %lf", &K, &L, &R);
    scanf("%lf %lf %lf", &P, &E, &T);
    double ans = dfs(K, 1.0, L, R);
    printf("%lf\n", ans);
    return 0;
}

Measured memory_bytes: 1084
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    n, m = list(map(int, readline().split()))
    edge = [list(map(int, readline().split())) for _ in range(m)]

    ans = 0
    for i in range(m):
        uf = UnionFind(n)
        for j in range(i):
            a = edge[j][0] - 1
            b = edge[j][1] - 1
            uf.union(a, b)
        for j in range(i+1,m):
            a = edge[j][0] - 1
            b = edge[j][1] - 1
            uf.union(a, b)
        if uf.group_count() != 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


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

double pi = acos(-1);

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


  auto ok = [&](double m) {
    if (a * tan(m) < b) {
      double s = a * b - tan(m) * a * a / 2;
      return s * a <= x;
    } else {
      double s = b / tan(m) * b / 2;
      return s * a <= x;
    }
  };

  double l = 0.0, r = pi / 2;

  for (int i = 0; i < 10000; i++) {
    double m = (r + l) / 2.0;
    if (ok(m)) r = m;
    else l = m;
  }
  printf("%.12f\n", r * 180 / pi);
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005;
const int MOD=1e9+7; 
ll x[N],y[N];
int n,m;
int main()
{
	int n;
	scanf("%d%d",&n,&m);
	int maxX=-(1e9+7),minX=1e9+7;
	int maxY=-(1e9+7),minY=1e9+7;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&x[i]);
	}
	
	for(int i=1;i<=m;i++)
	{
		scanf("%lld",&y[i]);
	}
	sort(x+1,x+n+1);
	sort(y+1,y+m+1);
	ll ans1=0,ans2=0;;
	for(int i=1;i<n;i++)
	{
	     ans1=(ans1%MOD+(((x[i+1]-x[i])%MOD*i%MOD*(n-i)%MOD)%MOD)%MOD)%MOD;

	}
	for(int i=1;i<m;i++)
	{
	     ans2=(ans2%MOD+((y[i+1]-y[i])%MOD*i%MOD*(m-i)%MOD)%MOD)%MOD;
	}
	
	 cout<<(ans1%MOD*ans2%MOD)%MOD<<endl;
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
w = list(map(int, input().split()))
total = sum(w)
tmp = 0
tmpbfo = 0

for i in w:
    tmpbfo = tmp
    tmp += i
    if tmp >= total / 2:
        print(min(abs(total - 2*tmp), total - 2*tmpbfo))
        break
    


Measured memory_bytes: 2940
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
int flag[20];
LL ans = 0;
string str;
LL calu(string str){
    LL s = 0;
    string w;
    REP(a,str.size()){
        if(str.at(a)=='+'){
            s+=stoll(w);
            w.clear();
        }else{
            w+=str.at(a);
        }
    }
    s+=stoll(w);
    return s;
}
void sell(int i){
    if(i==str.size()-1){
        string s;
        s += str.at(0);
        FOR(a,1,i+1){
            if(flag[a-1]==1)s.pb('+');
            s.pb(str.at(a));
        }
       // COUT(s);
        ans +=calu(s);
        return;
    }
    flag[i]=1;sell(i+1);
    flag[i]=0;sell(i+1);
}
int main(){
    cin >> str;
    sell(0);
    COUT(ans);
    return 0;
}


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

using ll = long long;

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n,m;
	cin>>n>>m;

	int el=1;
	int er=int(n/2);
	if(n%2==1) er++;

	int ol=er+1+int(n%2==0);
	int orz=n;

	for(int i=0; i<m; i++)
	{
		if(i%2==0)
		{
			cout << el << " " << er << endl;
			el++;
			er--;
		}

		else
		{
			cout << ol << " " << orz << endl;
			ol++;
			orz--;
		}
	}
}

Measured memory_bytes: 3652
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int ans = 3 * a * a;

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21844
#pragma region include
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#pragma endregion
using namespace std;

#pragma region マクロ
// 配列の長さを取得する(ただし関数内ではポインタサイズに注意)
#define SIZE_OF_ARRAY(array) sizeof(array) / sizeof(*array)

// ソート
#define Sort(array, length) sort(array, array + length)
#define SortDESC(array, length) sort(array, array + length, greater<>())

// 配列の最大値、最小値取得
#define MAX_OF_ARRAY(array, length) *max_element(array, array + length)
#define MIN_OF_ARRAY(array, length) *min_element(array, array + length)
#pragma endregion

#pragma region Utility
#pragma region 配列要素の合計値を取得
template <typename T>
T getSum(T array[], int length)
{
    T sum = 0;
    for (int i = 0; i < length; i++)
    {
        sum += array[i];
    }
    return sum;
}
#pragma endregion

#pragma region ToString(int)
string ToString(int i)
{
    char buffer[1000];
    sprintf(buffer, "%d", i);
    return string(buffer);
}
#pragma endregion

#pragma region 10進数からN進数(<= 10) へ変換
string convertToN(long n, int base)
{
    string ans = "";
    while (n != 0)
    {
        int temp = n % base; // 1桁取得
        ans = ToString(temp) + ans;
        n /= base;
    }
    return ans;
}
#pragma endregion
#pragma endregion

int main()
{
    // ***  問題のpathを記載 ***
    // https://atcoder.jp/contests/abc156/tasks/abc156_c

    // 標準入力から値を取得
    int n;
    cin >> n;
    int array[n];
    for (int i = 0; i < n; i++)
    {
        cin >> array[i];
    }

    // ソートしてみる
    Sort(array, n);

    // 最小値座標〜最大値座標のどこかで集会を開く→全通り探索
    long min = 999999999;
    for (int x = array[0]; x <= array[n - 1]; x++)
    {
        long total_distance = 0;
        // 消費体力の合計を計算
        for (int i = 0; i < SIZE_OF_ARRAY(array); i++)
        {
            total_distance += (array[i] - x) * (array[i] - x);
        }
        // 最小値更新
        if (total_distance < min)
        {
            min = total_distance;
        }
    }

    // 結果出力
    printf("%ld\n", min);

    // 成功時は必ず0を返す
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	while(1){
		int n;
		cin >> n;
		if(n == 0) break;
		for(int i = 0;i < n;i++){
			int pm, pe, pj;
			cin >> pm >> pe >> pj;
			int ave = (pm + pe + pj) / 3;
			if(pm == 100 || pe == 100 || pj == 100) cout << 'A';
			else if((pm + pe) / 2 >= 90) cout << 'A';
			else if(ave >= 80) cout << 'A';
			else if(ave >= 70) cout << 'B';
			else if(ave >= 50 && (pm >= 80 || pe >= 80)) cout << 'B';
			else cout << 'C';
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;

    int cnt=0;

    REP(i,n){
        while(a[i]%2==0){
            a[i]/=2;
            ++cnt;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256