akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;

signed main(){
  int a,b;
  cin >> a >> b;
  if(a*b % 2 == 0) cout << "Even" << endl;
  else cout << "Odd" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

class BinaryIndexedTree
{
private:
    std::vector<int> vals;
    int n;
public:
    BinaryIndexedTree(int n_)
        : vals(n_, 0), n(n_) { }

    void add(int a, int w)
    {
        for (int x = a; x <= n; x += x & -x) {
            vals[x - 1] += w;
        }
    }

    int sum(int a) const
    {
        int ret = 0;
        for (int x = a; x > 0; x -= x & -x) {
            ret += vals[x - 1];
        }
        return ret;
    }
};

class SnLine
{
private:
    struct ProdRange
    {
        ProdRange() { l = r = 0; }
        ProdRange(int l_, int r_) { l = l_; r = r_; }
        int l, r;
    };

    static ProdRange makeProdRange(int l, int r)
    {
        return ProdRange { l, r };
    }

    std::multimap<int, ProdRange> prList;

    int numProds;
    int numStops;

public:
    SnLine(int numStops_)
    {
        numStops = numStops_;
        numProds = 0;
    }

    void addProdRange(int l, int r)
    {
        int d = r - l + 1;
        prList.emplace(d, ProdRange(l, r));
        ++numProds;
    }

    void solve()
    {
        BinaryIndexedTree bit(numStops);
        
        auto it = prList.begin();
        int numRemainingProds = numProds;

        for (int d = 1; d <= numStops; ++d)
        {
            int r = numRemainingProds;

            if (1 < d)
            {
                for (int a = d; a <= numStops; a += d)
                {
                    r += bit.sum(a);
                }
            }

            std::cout << r << std::endl;

            for(; it != prList.end() && it->first == d; ++it)
            {
                const ProdRange& pr = it->second;
                bit.add(pr.l, 1);
                bit.add(pr.r + 1, -1);
                --numRemainingProds;
            }
        }
    }
};

int main()
{
    int N, M;
    std::cin >> N >> M;

    SnLine sl(M);

    for (int i = 0; i < N; ++i)
    {
        int l, r;
        std::cin >> l >> r;
        sl.addProdRange(l, r);
    }

    sl.solve();
    return 0;
}


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

int main()
{
	double l;
	double digit,v;
	cin>>l;
	digit=l/3;
	v=digit*digit*digit;
	
	
	
	cout<<fixed<<setprecision(12)<<v<<endl;
	return 0;
	
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func gcd(x, y int) {
	if x == 0 || y == 0 {
		fmt.Println(0)
	} else if x == 1 || y == 1 {
		fmt.Println(1)
	} else if x > y && x%y == 0 {
		fmt.Println(y)
	} else if y > x && y%x == 0 {
		fmt.Println(y)
	} else if x == y {
		fmt.Println(x)
	} else {
		gcd(y, x%y)
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	s := sc.Text()
	x, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}

	sc.Scan()
	s = sc.Text()
	y, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}

	gcd(x, y)
}



Measured memory_bytes: 1108
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail
    int n;
    cin >> n;
    int count = 0;
    if(n > 9)
    {
        count += 9;
    }
    else
    {
        count += n;
        cout << count;
        return 0;
    }
    if(n < 100)
    {
        cout << count;
        return 0;
    }
    if(n > 999)
    {
        count += 999 - 99;
    }
    else
    {
        count += n - 99;
        cout << count;
        return 0;
    }
    if(n < 10000)
    {
        cout << count;
        return 0;
    }
    if(n > 99999)
    {
        count += 99999 - 9999;
    }
    else
    {
        count += n - 9999;
        cout << count;
        return 0;
    }
    cout << count;
    return 0;
}

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

template<typename T>class fenwick_tree{
    
    int size;
    vector<T>bit;//[1,size]

    T sum(int i){T s;for(s=0;i>0;i-=i&-i)s+=bit[i];return s;}//i番目(1-index)までの和を返す
    
    public:
    fenwick_tree(int size):bit(size+1,0LL),size(size){}
    T sum(int l,int r){return sum(r)-sum(l);}//i番目(1-index)までの和を返す
    void add(int i,T x){for(;i<=size;i+=i&-i)bit[i]+=x;}//i番目にxを足す
};

int N,Q;
long long t,a,b;
int main(){
    cin>>N>>Q;
    fenwick_tree<long long>bit(N);
    for(int i=1;i<=N;i++){
        cin>>a;
        bit.add(i,a);
    }
    for(int i=0;i<Q;i++){
        cin>>t>>a>>b;
        if(t==1LL)cout<<bit.sum(a,b)<<endl;
        else bit.add(a+1,b);
    }
    return 0;
}

Measured memory_bytes: 8220
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  vector<ll> sum(n);
  ll s = 0;
  REP(i,n) {
    s += (ll)a[i];
    sum[i] = s;
  }

  ll mx = 1e18;
  ll snuke = a[0];
  ll ariguma = a[n-1];
  if(n == 2){
    mx = abs(snuke-ariguma);
  }

  REP2(i,1,n-1){
  snuke += a[i];
  ariguma = s - snuke;;
  mx = min(mx, abs(ariguma - snuke));
  }


  cout << mx << endl;
  
  return 0;
}

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

typedef struct{
  char pattern;
  int value;
}Card;

void BubbleSort(Card C[], int N);
void SelectionSort(Card C[], int N);
void Bubblecheck(Card C[]);

int main(){
  int i;
  int N;
  Card C1[36], C2[36];

  scanf("%d", &N);
  for(i = 0; i < N; i++){
    if(i == N-1){
      scanf(" %c%d", &C1[i].pattern, &C1[i].value);
    }else{
      scanf(" %c%d ", &C1[i].pattern, &C1[i].value);
    }
  }
  memcpy(C2, C1, sizeof(Card)*N);

  BubbleSort(C1, N);
  for(i = 0; i < N; i++){
    if(i == N-1){
      printf("%c%d\n", C1[i].pattern, C1[i].value);
    }else{
      printf("%c%d ", C1[i].pattern, C1[i].value);
    }
  }
  printf("Stable\n");

  SelectionSort(C2, N);
  for(i = 0; i < N; i++){
    if(i == N-1){
      printf("%c%d\n", C2[i].pattern, C2[i].value);
    }else{
      printf("%c%d ", C2[i].pattern, C2[i].value);
    }
  }
  int count = 0;
  for(i = 0; i < N; i++){
    if(C1[i].pattern != C2[i].pattern){
      count++;
    }
  }

  if(count != 0){
    printf("Not stable\n");
  }else{
    printf("Stable\n");
  }

  return 0;
}

void BubbleSort(Card C[], int N){
  int i, j;
  Card tmp;

  for(i = 0; i < N; i++){
    for(j = N-1; j > i; j--){
      if(C[j].value < C[j-1].value){
        tmp = C[j];
        C[j] = C[j-1];
        C[j-1] = tmp;
      }
    }
  }
}

void SelectionSort(Card C[], int N){
  int i, j;
  int minj;
  Card tmp;

  for(i = 0; i < N; i++){
    minj = i;
    for(j = i; j < N; j++){
      if(C[j].value < C[minj].value){
        minj = j;
      }
    }
    tmp = C[i];
    C[i] = C[minj];
    C[minj] = tmp;
  }
}



Measured memory_bytes: 2092
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

 
 
const ll N = 100005;
const ll mod = 1000000007;
const long long int inf = 1e10+5;
#define pp pair<ll,ll>
 
typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
void fastIO(void);
 
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);



ll fac[N],invfac[N];
ll c(ll n ,ll r)
{
    if(r>n) return 0;
    return modmulti(fac[n],modmulti(invfac[r],invfac[n-r]));
}
int main(){
   // fastIO();
  fac[0]  =1;
  rep1(i,N) fac[i] = modmulti(i,fac[i-1]);
  rep(i,N) invfac[i] = modinv(fac[i]);
  ll n,k;
  cin>>n>>k;
  ll a[n];
  rep(i,n) cin>>a[i];
  sort(a,a+n);
  ll sum = 0;
  rrep(i,n){
        ll cur = modadd(c(i,k-1),-c(n-i-1,k-1));
        //cout<<"c = "<<cur<<endl;
         cur = modmulti(a[i],cur);
         
        sum = modadd(sum,cur);
  }
  cout<<sum<<endl;

  






   

}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}
 

Measured memory_bytes: 2560
import itertools

N, M, Q = map(int, input().split())
a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q
for i in range(Q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

l = list(range(1, M + 1))
hoge = itertools.combinations_with_replacement(l, N)

tmp = []
for v in hoge:
    sum = 0
    for i in range(Q):
        if v[b[i] - 1] - v[a[i] - 1] == c[i]:
            sum += d[i]

    tmp.append(sum)

print(max(tmp))


Measured memory_bytes: 12708
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
typedef long long ll;
using namespace std;

int main()
{
	vector<string> A(3);
	cin >> A[0] >> A[1] >> A[2];
	vector<int> ind(3, 0);
	int sn = 0;
	while (true)
	{
		char next = A[sn][ind[sn]];
		ind[sn]++;
		sn = next - 'a';
		if (ind[sn] == A[sn].size())
		{
			co((char)('A' + sn));
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	vector<int> count(26, 0);
	string s; cin >> s;
	for (int i = 0; i < s.length(); i++) {
		count[s[i] - 'a']++;
	}
	for (int i = 0; i < count.size(); i++) {
		if (count[i] % 2 != 0) {
			cout << "No" << endl;
			return ;
		}
	}
	cout << "Yes" << endl;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int ans = -1;
        for(int i = 0; i <= Math.max(a, b); ++i){
            int x = Math.abs(a - i);
            int y = Math.abs(b - i);
            if(x == y) {ans = i; break;}
        }
        if(ans == -1) System.out.println("IMPOSSIBLE");
        else System.out.println(ans);
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>

int main(void){
  int N=0;
  std::cin>>N;
  if(N%2==0)std::cout<<N<<std::endl;
  else if(N==1)std::cout<<"2"<<std::endl;
  else std::cout<<2*N<<std::endl;

}


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

#define ll long long int
#define LD long double

const int N = 100010;

int inf = 1e9;
int mod = 1e9 + 7;

signed main()
{
    //freopen("IN.txt", "r", stdin);
    //freopen("OUT.txt", "w", stdout);

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n, k; cin >> n >> k;
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        int x; cin >> x;
        if(x >= k) {
            cnt++;
        }
    }
    cout << cnt << "\n";
    return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    int N,D; cin >> N >> D;
    int X[N][D]; REP(i,N)REP(j,D) cin >> X[i][j];

    int ans = 0;
    REP(i,N-1)FOR(j,i+1,N){
        int tmp = 0;
        REP(k,D) tmp += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
        int K = round(sqrt(tmp));
        if(K*K == tmp) ans++;
    }

    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>

using namespace std;

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

    cin >> W >> H >> x >> y >> r;

    if( (x >= r) && (y >= r) && (W >= x + r) && (H >= y + r))
        {
           cout << "Yes" << endl;
        }

    else
        {
            cout << "No" << endl;
         }
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll K,Q;
ll D[5555],Ds[5555],D2[5555],A[5555];
ll N, X, M;
ll i, j, k,ans;

void query(){
    scanf("%lld%lld%lld",&N,&X,&M);
    A[0] = 0;
    Ds[0] = 0;
    fornum(i,0,K){
        D2[i] = D[i] % M;
        Ds[i + 1] = Ds[i] + D2[i];
        A[i + 1] = A[i];
        if(D2[i]==0){
            ++A[i + 1];
        }
    }
    ll n = (N - 1) / K, m = (N - 1) % K;
    ans = N - 1;
    ans -= A[K] * n;
    ans -= A[m];
    //ll nd = Ds[K] / M, ndm = Ds[K] % M;
    ans -= (X % M + Ds[K] * n + Ds[m]) / M;
    printf("%lld\n", ans);
}

int main(){
    scanf("%lld%lld", &K,&Q);
    fornum(i,0,K){
        scanf("%lld", &D[i]);
    }
    while(Q--)
        query();

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = l; i <= r; ++i)
const int N = 1000000 + 5;
const int Mod = 1e9 + 7;
int n, h, d, S, F, dp[N], fac[N];
int read() {
    char c; int x = 0, f = 1;
    c = getchar();
    while (c > '9' || c < '0') { if(c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int Inc(int a, int b) { return (a += b) >= Mod ? a - Mod : a;}
int Dec(int a, int b) { return (a -= b) < 0 ? a + Mod : a;}
int Mul(int a, int b) { return 1ll * a * b % Mod;}
int main() {
    n = read(), h = read(), d = read();
    dp[0] = fac[0] = S = 1;
    rep(i, 1, n) fac[i] = Mul(fac[i - 1], i), F = Inc(F, fac[i]);
    rep(i, 1, h) {
        if(i != h) dp[i] = Mul(S, F);
        else dp[i] = Mul(S, fac[n]);
        S = Inc(S, dp[i]); if(i >= d) S = Dec(S, dp[i - d]);
    }
    printf("%d", dp[h]);
    return 0;
}

Measured memory_bytes: 11600
N, K = map(int, input().split())
ans = 0
for b in range(N + 1)[K:]:
	if b == 0:
		continue
	ans += (b - K) * int(N / b)
	if N % b >= K and K > 0:
		ans += N % b - K + 1
	elif N % b >= K:
		ans += N % b - K
print(ans)

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

bool check(int k, string s) {
    int n = s.size();
    bool res = true;
    FOR (i, n - k, k) {
        if (s[i] != s[n - k]) res = false;
    }
    return res;
}

void _main() {
    string S;
    cin >> S;
    bool allSame = true;
    REP (i, S.size()) {
        if (S[i] != S[0]) allSame = false;
    }
    if (allSame) {
        cout << S.size() << endl;
        return;
    }
    int ok = 1, ng = S.size();
    while (ng - ok > 1) {
        int m = (ok + ng) / 2;
        if (check(m, S)) ok = m;
        else ng = m;
    }
    cout << ok << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 512
N,M=map(int,input().split())
ab=[list(map(int,input().split()))for _ in range(M)]

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())

ans=0
for i in range(M):
    uf=UnionFind(N)
    for j in range(M):
        if i==j:
            continue
        a,b=ab[j]
        uf.union(a-1,b-1)
    ans+=(uf.group_count()>1)
print(ans)

Measured memory_bytes: 9180
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

  int main(){
  
  int n,t,a;
  cin>>n>>t>>a;
  vi h(n);
  rep(i,n)cin>>h[i];
  double MIN=10000;
  int ans;
  if(n==1){
    cout<<1<<endl;
    return 0;
  }
    double k;
  for(int i=0;i<n;i++){
    k=t-0.006*h[i];
    //cout<<k<<endl;
    if(abs(MIN-a)>abs(k-a)){
      ans=i+1;
      MIN=k;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<atcoder/all>
using namespace atcoder;

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    int N, Q; scanf("%d%d", &N, &Q);
    dsu G(N);

    rep(q, Q) {
        int c; scanf("%d", &c);
        if (c == 0) {
            int u, v; scanf("%d%d", &u, &v);
            G.merge(u, v);
        }
        if (c == 1) {
            int u, v; scanf("%d%d", &u, &v);
            printf(G.same(u, v) ? "1\n" : "0\n");
        }
    }

    return 0;
}

Measured memory_bytes: 4096
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
#include <unordered_map>
#include <stack>
#include <bitset>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll pow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = pow(N, P/2);
        return t*t;
    }
    return N * pow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N; cin >> N ;

    // グラフ
    Graph G(N);
    for (int i = 1; i < N; ++i) {
        int a;
        cin >> a;
        a--;
        G[a].push_back(i);

        // 無向グラフの場合は以下を追加
        // G[b].push_back(a);
    }
    rep(i,N)cout<<G[i].size()<<endl;
}

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

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

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

	int n; cin>>n;
	vector<int> cnt(100, 0);
	for(int i = 1; i <= n; i++){
		if(i%10 == 0)continue;
		vector<int> vec;
		int v = i;
		while(v){
			vec.push_back(v%10);
			v /= 10;
		}
		cnt[vec.back()*10 + vec[0]]++;
	}
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		if(i%10 == 0)continue;
		vector<int> vec;
		int v = i;
		while(v){
			vec.push_back(v%10);
			v /= 10;
		}
		ans += cnt[vec[0]*10 + vec.back()];
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;
char s[20];

int main()
{
    int l,a,b,x;
    while(~scanf("%d %d",&a,&b))
    {
        scanf("%s",s);
        l=strlen(s);x=1;
        if(l!=a+b+1) x=0;
        for(l--;l>=0;l--)
        {
            if(l==a)
            {
                if(s[a]!='-') x=0;
                continue;
            }
            if(!(s[l]>='0'&&s[l]<='9')) x=0;
        }
        if(x==1) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
/*
This is code of SuperJ6 for Atcoder.
Don't copy my code during f*kin' contests.

2.71828182845904523536
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define endl '\n'

const int maxn = 200000;
int n, q;
int cnt[maxn];
vector<int> graph[maxn];

void dfs(int c, int p){
	for(int i : graph[c]){
		if(i == p) continue;
		cnt[i] += cnt[c];
		dfs(i, c);
	}
}

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

	cin >> n >> q;
	
	for(int i = 0; i < n - 1; i++){
		int a, b;
		cin >> a >> b;
		a--, b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	
	for(int i = 0; i < q; i++){
		int p, x;
		cin >> p >> x;
		p--;
		cnt[p] += x;
	}
	
	dfs(0, -1);
	
	cout << cnt[0];
	for(int i = 1; i < n; i++) cout << " " << cnt[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 23552
#include<cstdio>
#include<cstring>
const int N=15+10;
int n,m,x,y,f[N][N],ans,sum,l[N],r[N],ok;
int main()
{
	memset(f,-1,sizeof(f));
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&m);
		while(m--)
		{
			scanf("%d%d",&x,&y);
			f[i][x-1]=y;
		}
	}
	for(int mask=0;mask<(1<<n);mask++)
	{
		x=y=0;
		for(int i=0;i<n;i++)
			if(mask&(1<<i))l[++x]=i;
			else r[++y]=i;
		if(x<=ans)continue;
		ok=1;
		for(int i=1;i<=x&&ok;i++)
			for(int j=1;j<=y&&ok;j++)
				if(f[l[i]][r[j]]==1)ok=0;
		for(int i=1;i<=x&&ok;i++)
			for(int j=1;j<=x&&ok;j++)
				if(f[l[i]][l[j]]==0)ok=0;
		if(ok&&x>ans)ans=x;
	}
	printf("%d",ans);
	return 0;
}

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

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> g(h);
    for(int i = 0; i < h; i++) {
        cin >> g[i];
    }
    int dp[h][w];
    memset(dp, 0, sizeof(dp));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(g[i][j] == '#')
                dp[i][j] = 0;
            else if(i == 0 && j == 0){
                dp[i][j] = 1;
            }else if(i == 0) {
                dp[i][j] = dp[i][j-1];
            }else if(j == 0) {
                dp[i][j] = dp[i-1][j];
            }else{
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005

struct Info{

	bool operator<(const struct Info &arg) const{

		if(left != arg.left){

			return left < arg.left;
		}else{

			return right < arg.right;
		}
	}

	ll left,right;
};

int N;
ll L;
Info info[SIZE];
vector<ll> V;
map<ll,int> MAP;
int table[2*SIZE];

int main(){

	scanf("%d %lld",&N,&L);

	for(int i = 0; i < N; i++){

		scanf("%lld %lld",&info[i].left,&info[i].right);

		V.push_back(info[i].left);
		V.push_back(info[i].right);
	}

	sort(info,info+N);

	int x = 0;
	ll pre_right = 0,next_maximum = -HUGE_NUM;

	for(int i = 0; pre_right <= L-1 && i < N; ){

		if(info[i].left <= pre_right){

			next_maximum = max(next_maximum,info[i].right);
			if(next_maximum == L){

				x++;
				break;
			}
			i++;

		}else{ //次の区間に移る

			pre_right = next_maximum;
			next_maximum = -HUGE_NUM;
			x++;
		}
	}

	sort(V.begin(),V.end());
	V.erase(unique(V.begin(),V.end()),V.end());

	//数字の変換表
	for(int i = 0; i < V.size(); i++){

		MAP[V[i]] = i;
	}

	for(int i = 0; i < V.size(); i++){

		table[i] = 0;
	}

	for(int i = 0; i < N; i++){

		table[MAP[info[i].left]]++;
		table[MAP[info[i].right]]--;
	}

	int minimum = table[0];

	for(int i = 1; i < V.size()-1; i++){

		table[i] += table[i-1];
		minimum = min(minimum,table[i]);
	}

	printf("%d %d\n",x,N-minimum+1);

	return 0;
}



Measured memory_bytes: 34432
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
        long am = Math.min(0, A - K);
        String ans = Math.max(0, A - K) + " " + Math.max(0, B + am);
        System.out.println(ans);
    }
}


Measured memory_bytes: 23760
#include<stdio.h>
int main(void)
{
	int An,i,max,min,n ;
	long amount;
	max = -1000000;
	min = 1000000;
	amount = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &An);
		if (max < An)
		{
			max = An;
		}
		if (min > An)
		{
			min = An;
		}
		amount += An;
	}
	printf("%d %d %ld\n", min, max, amount);
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  int64_t INF = 1000000007;
  int64_t N, K;
  cin >> N >> K;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int64_t ans = 0;
  int64_t K1 = (K*(K-1)/2) % INF;
  int64_t K2 = (K*(K+1)/2) % INF;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(A[i] > A[j]){
        ans++;
      }
    }
  }
  int64_t ans1 = 0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(A[i] > A[j]){
        ans1++;
      }
    }
  }
  int64_t ans2 = ans1 - ans;
  cout << (ans * K2 + ans2 * K1) % INF << endl;
}

Measured memory_bytes: 256
# AOJ ITP2_4_A: Reverse
# Python3 2018.6.24 bal4u

n = int(input())
a = list(map(int, input().split()))
q = int(input())
for i in range(q):
	b, e = map(int, input().split())
	a = a[:b] + a[b:e][::-1] + a[e:]
print(*a)


Measured memory_bytes: 5804
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n){return (n==0) ? 1 : 10 * TEN(n-1);}
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,N) for(int i=0;i<(int)(N);i++)
#define rep1(i,N) for(int i=1;i<=(int)(N);i++)
#define fs first
#define sc second
#define eb emplace_back
#define pb eb
#define all(x) x.begin(),x.end()
template<class T, class U> void chmin(T& t, const U& u){ if(t>u) t = u;}
template<class T, class U> void chmax(T& t, const U& u){ if(t<u) t = u;}

#ifdef LOCAL
#define show(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

template<class T,class U>
ostream& operator<<(ostream& os, const pair<T,U>& p){
    return os << "P(" << p.fs << ", " << p.sc << ")";
}
template<class T> ostream& operator<<(ostream& os, const V<T>& v){
    os << "[";
    for(auto d: v) os << d << ", ";
    return os << "]";
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int s,t,p,q,M,y;
    cin >> s >> t >> p >> q >> M >> y;
    cout << (s^t^y) << endl;
}


Measured memory_bytes: 3196
n = gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i)
puts arr.join(' ')
(1..n-1).each do |i|
  key = arr[i]
  j = i - 1
  while j >= 0 && arr[j] > key do
    arr[j + 1] = arr[j]
    j = j - 1
  end
  arr[j + 1] = key
  puts arr.join(' ')
end

Measured memory_bytes: 8828
//A+...+B Problem

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) int n;cin>>n;vector<int>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    ll n,a,b;cin>>n>>a>>b;
    ll e = (a+(n-1)*b);
    ll m = ((n-1)*a+b);
    if(e-m+1<0){
        cout<<0<<nnn;
        return 0;
    }
    cout<<e-m+1<<nnn;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int main(){
    ll N;
    cin >> N;
    int X = N-1;
    int ans = 0;
    REP(i,N){
        if(i==0) continue;
        else{
            ans += X/i;
        }
    }
    cout << ans << endl;
}

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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/**************************************/

/******** User-defined Function *******/




/**************************************/

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n; cin >> n;
  vector<int> a(n);
  int c[1000005];
  memset(c,0,sizeof(c));
  int mx = 0;
  rep(i,n){
       cin >> a[i];
       c[a[i]]++;
       chmax(mx,a[i]);
   }

  sort(all(a));

  int b[1000005];

  for(int i=0;i<1000005;i++) b[i] = 1;

  rep(i,n){
      if(b[a[i]]==0) continue;
      //if(a[i]==1) continue;
      int j=2;
      while(a[i]*j<mx+1){
          b[a[i]*j] = 0;
          j++;
      }
  }

  int ans = 0;
  rep(i,n){
      if(b[a[i]]==1 && c[a[i]]==1) ans++;
  }

  cout << ans << endl;

  return 0;
}
/********  Main() Ends Here *************/


Measured memory_bytes: 11912
#include<stdio.h>
int main()
{
	int N,A;
  scanf("%d",&N);
  scanf("%d",&A);
	int r = N/500;
	int d = r*500+A;
	if(d>=N)
	{
		printf("Yes");
  
	}
	else
	{
		printf("No");
	}


	return 0;
	
}


Measured memory_bytes: 1672
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int dp[10][11]={0};
void ans(int n,int i,int j)
{
    cout<<j;
    if(i==1)
    {
        return;
    }
    int cnt=n;
    if(j!=0)
    {
        if(dp[j-1][i-1]>=cnt)
        {
            ans(cnt,i-1,j-1);
            return;
        }
        else
        {
            cnt-=dp[j-1][i-1];
        }
    }
    if(dp[j][i-1]>=cnt)
    {
        ans(cnt,i-1,j);
        return;
    }
    else
    {
        cnt-=dp[j][i-1];
    }
    if(j!=9)
    {
        if(dp[j+1][i-1]>=cnt)
        {
            ans(cnt,i-1,j+1);
            return;
        }
    }
}
signed main()
{
    SPEED;
    int n;
    cin>>n;
    int cnt=0;
    for(int i=0;i<=9;i++)
    {
        dp[i][1]=1;
    }
    for(int i=2;i<=10;i++)
    {
        for(int j=0;j<=9;j++)
        {
            if(j>0)
            dp[j][i]+=dp[j-1][i-1];
            if(j<9)
            dp[j][i]+=dp[j+1][i-1];
            dp[j][i]+=dp[j][i-1];
        }
    }
    for(int i=1;i<=10;i++)
    {
        for(int j=1;j<=9;j++)
        {
            cnt+=dp[j][i];
            if(cnt>=n)
            {
                cnt-=dp[j][i];
                // cout<<n-cnt<<" "<<i<<" "<<j<<endl;
                ans(n-cnt,i,j);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	ll n;
	cin>>n;
	vector<int> ans;
	reps(i, n-1){
		ans.clear();
		int ai = 0;
		rep(j, n-i){
			if(j==0) ans.push_back(1);
			if(j == ans.size()-1){
				int size = ans.size();
				rep(k,size){
					ans.push_back(ans[k]);
				}
				ans[ans.size()-1]++;
			}
		}
		rep(j, n-i){
			cout<<ans[j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 512
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let list = input
        .split_whitespace()
        .map(|x| x.parse::<u32>().unwrap())
        .collect::<Vec<_>>();
    let n = list[0];
    let m = list[1];
    ((1900 * m + 100 * (n - m)) * 2u32.pow(m)).to_string()
}

#[test]
fn test() {
    let tests = vec![("1 1", "3800"), ("10 2", "18400"), ("100 5", "608000")];
    for (i, (input, output)) in tests.into_iter().enumerate() {
        println!("test:{}", i);
        assert_eq!(run(input.to_string()), output.to_string());
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<ll> v(N);
  rep(i,N)cin >> v[i];
  rep(i,N-1) v[i+1] += v[i];
  //i番目で切るために必要な最小の金額を求める
  ll ans = MAX_LL;
  rep(i,N-1){
    ans = min(ans,abs(v[N-1] - 2*v[i]));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
// int n;
// int dp[100001][4];
// int point[100001][4];

// int maxP(int i,  int last){
//     if(i==n)
//     return 0;
    
//     int ret=INT_MIN;
//     if(dp[i][last]!=-1) return dp[i][last];
//     for(int j=1;j<=3;j++){
        
//         if(j!=last)
//         {
//             ret= max(ret, point[i][j]+maxP(i+1, j));
//         }
        
        
//      }
//      return dp[i][last] = ret;
// }



int main() {
    int n;
     cin>>n;
     vector<int>val(3,0);
      vector<int>dp1(3,0);
     for(int i=0;i<n;i++){
         vector<int>dp2(3,0);
         cin>>val[0]>>val[1]>>val[2];
         for(int i=0;i<3;i++){
             for(int j=0;j<3;j++){
                 if(i!=j){
                     dp2[j] = max( dp2[j],dp1[i] + val[j]);
                 }
             }
             
         }
         dp1=dp2;
     }
     
     cout<<max(dp1[0],max(dp1[2],dp1[1]));
    //  for(int i  = 0; i<n; i++)
    //  {
    //     cin>>point[i][1]>>point[i][2]>>point[i][3];
    //  }
    
     //cout<<maxP(0,0);
     return 0;
    
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007
 
char c[] = "MUJIN";

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 15)print('+');
	else if (a*b == 15)print('*');
	else print("x");


	return 0;
}

Measured memory_bytes: 256
N,X,Y = map(int, input().split())

c = [0 for _ in range(N)]
for i in range(1,N):
  for j in range(i+1,N+1):
    x = abs(X-i)
    y = abs(Y-j)
    a = min(x+y+1, j-i)
    c[a] += 1

for i in range(1,N):
  ans = c[i]
  print(ans)

Measured memory_bytes: 3444
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	static int N = 0;
	static long ans = 0;
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		N = sc.nextInt();
		dfs("", 0, false, false, false);
		System.out.println(ans);
	}
	
	public static void dfs(String s, int len, boolean t3, boolean t5, boolean t7){
		if(len == 10){
			return;
		}else{
			if(len != 0){
				//System.out.println(s);
				if(t3 && t5 && t7 && Integer.parseInt(s) <= N) ans++;
			}
			dfs(s+"3", len+1, true, t5, t7);
			dfs(s+"5", len+1, t3, true, t7);
			dfs(s+"7", len+1, t3, t5, true);
		}
	}
	
	public static void count(String s){
		boolean t3 = false, t5 = false, t7 = false;
		for(int i = 0; i < s.length(); i++){
			if(s.charAt(i) == '3') t3 = true;
			else if(s.charAt(i) == '5') t5 = true;
			else if(s.charAt(i) == '7') t7 = true;
		}
		if(t3 && t5 && t7 && Integer.parseInt(s) < N) ans++;
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


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

int main()
{
  string s;
  cin >> s;
  for (int bit = 0; bit < (1 << 3); bit++)
  {
    int now = (s.at(0) - '0');
    string ans = s.substr(0, 1);
    for (int i = 0; i < 3; i++)
    {
      if (bit & (1 << i))
      {
        now += (s.at(i + 1) - '0');
        ans.push_back('+');
      }
      else
      {
        now -= (s.at(i + 1) - '0');
        ans.push_back('-');
      }
      ans.push_back(s.at(i + 1));
    }
    if (now == 7)
    {
      cout << ans << "=7" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] ary = s.toCharArray();
        for (int i = 0; i < s.length(); i++) {
            if ((i + 1) % 2 == 0) {
                if (ary[i] == 'R') {
                    System.out.println("No");
                    return;
                }
            } else {
                if (ary[i] == 'L') {
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int x;
    cin>>x;
    cout<<(x>=30 ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
const int N=15;
int a[N][N]; 
int main()
{
	int n,d,ans=0;
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=d;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			int s=0;
			for(int k=1;k<=d;k++)
				s+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			if((int)sqrt(s)*(int)sqrt(s)==s)
				ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256