akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
using namespace std;

int const MAX= 100005;
int const MAX_V = 100000000000000000;

struct edge
{
	int from; int to; long long cost;
};
vector<edge> V[MAX];
vector<edge> BW, W, B;
int color[MAX];
int parent[MAX];
long long number[MAX];
stack<int> S;


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

	for (int i = 1; i <= m; i++) {
		int u, v; long long c;
		cin >> u >> v >> c;
		V[u].push_back({ u,v,c });
		V[v].push_back({ v,u,c });
	}
	for (int i = 1; i <= n; i++) {
		color[i] = -1;
		parent[i] = -1;
	}
	long long min_white = 1;
	long long min_black = MAX_V;
	color[1] = parent[1] = 0;
	number[1] = 1;
	S.push(1);
	long long shortage = MAX_V;
	while (!S.empty()) {
		int t = S.top();
		S.pop();
		for (int i = 0; i < V[t].size(); i++) {
			edge now = V[t][i];
			if (now.to != parent[now.from]) {
				if (color[now.to] == -1) {
					color[now.to] = !color[now.from];
					parent[now.to] = now.from;
					number[now.to] = now.cost - number[now.from];
					S.push(now.to);
					if (color[now.to] == 1) {
						min_black = min(min_black, number[now.to]);
					}
					else {
						min_white = min(min_white, number[now.to]);
					}
				}
				else {					
					long long dif = now.cost - number[now.to] - number[now.from];
					if (dif % 2 == 1) {
						cout << 0 << endl;
						return 0;
					}
					if (color[now.to] != color[now.from]) {
						if (dif != 0) {
							cout << 0 << endl;
							return 0;
						}
					}
					else if (color[now.to] == 0) {
						if (shortage == MAX_V) {
							shortage = dif / 2;
						}
						else {
							if (shortage * 2 != dif) {
								cout << 0 << endl;
								return 0;
							}
						}
					}
					else {
						if (shortage == MAX_V) {
							shortage = -dif / 2;
						}
						else {
							if (shortage * 2 != -dif) {
								cout << 0 << endl;
								return 0;
							}
						}
					}
				}
			}
		}
	}
	long long inc_b = 1 - min_white;
	long long inc_u = min_black - 1;
	if (shortage == MAX_V) {
		long long zero = 0;
		cout << max(inc_u - inc_b + 1,zero) << endl;
		return 0;
	}
	else {
		cout << (inc_b <= shortage && shortage <= inc_u) << endl;
		return 0;
	}
}

Measured memory_bytes: 9600
#include<stdio.h>
int main()
{
    int A,B;
    scanf("%d%d",&A,&B);
    if((A==1&&B==2)||(A==2&&B==1))
    {
        printf("3");
    }
    else if((A==1&&B==3)||(A==3&&B==1))
    {
        printf("2");
    }
    else
    {
        printf("1");
    }
}


Measured memory_bytes: 2068
#include <iostream>
#include <atcoder/all>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rep2(i,s,t) for(int i = s; i <= t; ++i)
#define rev(i,n) for(int i = n-1; i >= 0; --i)
#define rev1(i,n) for(int i = n; i > 0; --i)
#define rev2(i,s,t) for(int i = s; i >= t; --i)
#define F first
#define S second
using namespace std;
using namespace atcoder;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;
int main()
{
  int n,q; cin >> n >> q;

  fenwick_tree<ll> fw(n);
  rep(i,n) {
    ll a; cin >> a;
    fw.add(i, a);
  }

  rep(i,q) {
    int t; cin >> t;
    if(t == 0) {
      int p, x; cin >> p >> x;
      fw.add(p, x);
    }
    else {
      int l, r; cin >> l >> r;
      cout << fw.sum(l, r) << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 8232
N,K = map(int,input().split())
H = list(map(int,input().split()))

A = [0]*N

for i in range(1,N):
  A[i] = min([(A[i-j]+abs(H[i]-H[i-j])) for j in range(1,min(K+1,i+1))])

print(A[N-1])


Measured memory_bytes: 52448
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_set>
using namespace std;

int main()
{
	//	input	--------------------------------------------------
	int a, b;
//	cin >> a;
	cin >> a >> b;

	/*
	vector< int > vec( a );
//	unordered_set<int> set;

	for( auto &it : vec )
	{
		cin >> it;
//		set.insert( it );
	}
	*/

	//	--------------------------------------------------

	//	10000
	for( int i=0 ; i<=a ; i++ )
	{
		//	5000
		for( int ii=0 ; ii<=a-i ; ii++ )
		{
			//	1000
			int iii = a - i - ii;

			if( i*10000 + ii*5000 + iii*1000 == b )
			{
				cout << i << ' ' << ii << ' ' << iii << endl;
				return 0;
			}
		}
	}

	cout << -1 << ' ' << -1 << ' ' << -1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
	string S;
	string T;
	cin >> S >> T;
	bool judge = false;
	for (int i = (int)S.size() - 1; i >= 0; --i)
	{
		if(S[i] == '?' || S[i] == T[(int)T.size() - 1]){
			bool b = true;
			for (int j = 0; j < (int)T.size(); ++j)
			{
				if(!(S[i-j] == '?' || S[i-j] == T[(int)T.size() - 1-j])){
					b = false;
				}
			}
			if(b){
				for (int j = 0; j < (int)T.size(); ++j)
				{
					S[i-j] = T[(int)T.size() - 1-j];
				}
				judge = true;
				break;
			}
		}
	}
	if(judge){
		for (int i = 0; i < (int)S.size(); ++i)
		{
			if(S[i] == '?'){
				S[i] = 'a';
			}
		}
		cout << S << endl;
	}else{
		cout << "UNRESTORABLE" << endl;
	}
}

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


//@@@@@@
//@ snippet WeightedUnionFind
//@ alias   PotentialedUnionFind
//@ options head
template<class Abel>
struct WeightedUnionFind {
    vector<int> p;      // 親もしくは連結成分の数
    vector<Abel> dw;    // 親ノードとの差分

    explicit WeightedUnionFind(int n, Abel SUM_UNITY = 0)
        : p(n+5, -1), dw(n+5, SUM_UNITY) {}

    int root(int x) {
        if (p[x] < 0) {
            return x;
        } else {
            const int r = root(p[x]);
            return (dw[x] += dw[p[x]]), (p[x] = r);
        }
    }

    // diff(x, y) == w となるようにする
    bool unite(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        if ((x=root(x)) == (y=root(y))) return false;
        p[x] += p[y]; p[y] = x;
        dw[y] = w;
        return true;
    }

    bool same(int x, int y) { return root(x) == root(y); }
    int  size(int x)        { return -p[root(x)]; }
    Abel diff(int x, int y) { return weight(y) - weight(x); }
    Abel weight(int x)      { root(x); return dw[x]; }
};
//@@@@@@@


struct FastIO {
    FastIO() { cin.tie(nullptr); ios::sync_with_stdio(false); }
} fastIO_ydk ;

void ABC087_D()
{
    using i64 = int_fast64_t;

    int N, M;
    cin >> N >> M;

    WeightedUnionFind<i64> uf(N);

    bool ok = true;
    while(M--) {
        int l, r, d;
        cin >> l >> r >> d;

        uf.unite(l, r, d);
        if (uf.diff(l, r) != d) {
            ok = false;
        }
    }

    cout << ((ok) ? "Yes" : "No") << endl;

    return;
}

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


Measured memory_bytes: 1408
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

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

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

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A, B;
    cin >> A >> B;

    ll ans = A+B;
    if(ans<A-B) ans = A-B;
    if(ans<A*B) ans = A*B;

    cout << ans << endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec;
  for (int i = 0; i < N; i++) {
    int tmp = 0;
    cin >> tmp;
    vec.push_back(tmp);
  }
  sort(vec.rbegin(), vec.rend());

  int longest = vec[0];
  int sum = 0;
  for (int i = 1; i < N; i++) {
    sum += vec[i];
  }

  if (longest < sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    int n,dp[200001],h[200000],k;
    scanf("%d %d",&n,&k);
    for(int i=0;i<=n;i++){
        dp[i]=1000000001;
    }
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    dp[1]=0;
    for(int i=1;i<=n-1;i++){
        for(int j=1;j<=k&&i+j<=n;j++){
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j-1]-h[i-1]));
        }
    }
    printf("%d\n",dp[n]);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,i,j,t;

int main() {
    string s;
    cin>>s;
    ll c=0,max=0;
    for(i=0;i<3;i++)
    {
        if(s[i]=='R')
        {
            c++;
        }
        else if(i<2)
        
        {
            if(c>max)
            max=c;
            c=0;
        }
        
        
        if(i==2)
        {
            if(c>max)
            max=c;
        }
        
        
        
        
        
    }
    
    cout<<max<<"\n";
    
    
  
  
  
  
  
  
  
  
      
    
   return 0;   
}
    


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

const int MAXN = 1e5 + 5;
int dp[MAXN], h[MAXN];

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

Measured memory_bytes: 1024
import numpy as np
n, m = map(int,input().split())
a = np.array(input().split(),dtype=int)
sum = 0
num = 0

for i in range(n):
    sum += a[i]
for i in range(n):
    if a[i]*4*m >= sum:
        num += 1

if num < m:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 14532
#!/usr/bin/env python3

#import
#import math
#import numpy as np
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

def mod(num):
    return num % MOD

dp = [[0] * (K + 1) for _ in range(N + 1)]
dp[0][0] = 1

for i in range(1, N + 1):
    s = [0] * (K + 2)
    for j in range(1, K + 2):
        s[j] = mod(s[j - 1] + dp[i - 1][j - 1])

    for j in range(K + 1):
        dp[i][j] =  mod(s[j + 1] - s[max(0, j - A[i-1])])

print(dp[N][K])



Measured memory_bytes: 218420
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
*/
int main()
{
    int A, B;
    cin >> A >> B;
    cout << (A > 9 || B > 9 ? -1 : A * B) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb;
        StringTokenizer st;
        try {
            while (true) {
                String line;
                sb = new StringBuilder();
                Map<String,String> convTable = new HashMap<>();
                int convTableNum = Integer.parseInt(br.readLine().trim());
                if(convTableNum==0){
                    break;
                }
                for (int i = 0; i < convTableNum ; i++) {
                    line = br.readLine();
                    st = new StringTokenizer(line);
                    convTable.put(st.nextToken(),st.nextToken());
                }
                int dataNum = Integer.parseInt(br.readLine().trim());
                for (int i = 0; i < dataNum ; i++) {
                    line = br.readLine().trim();
                    for (Map.Entry<String, String> entry : convTable.entrySet()) {
                        if(entry.getKey().equals(line)){
                            line = entry.getValue();
                            break;
                        }
                    }
                    sb.append(line);
                }
                System.out.println(sb.toString());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

Measured memory_bytes: 42220
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,ans=0; cin>>n;
    vector<int> c(2*n,0);
    rep(i,2*n) cin>>c[i];
    sort(al(c));
    rep(i,n) ans+=c[i*2];
    cout<<ans<<endl;
}

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

#define ll              long long
#define Ull             unsigned long long
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 2;
const ll MOD = 1e9 + 7;


/*bool comp(const pii &p1, const pii &p2)
{
	if (p1.first == p2.first)
		return p1.second < p2.second;

	else
		return p1.first < p2.first;

}*/


void Solve()
{
	int n, m;
	cin >> n >> m;
	vector<int> visited(n + 1, false);
	vector<int> distance(n + 1, INT_MAX);
	vector<int> ans(n + 1, 0);
	vector<int> adj[n + 1];
	while (m--)
	{
		int x, y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	queue<int> q;
	q.push(1);
	distance[1] = 0;
	visited[1] = true;
	while (!q.empty())
	{
		int node = q.front();
		q.pop();



		for (int v : adj[node])
		{
			if (!visited[v])
			{

				distance[v] = distance[node] + 1;
				ans[v] = node;
				q.push(v);
				visited[v] = true;
			}
		}
	}











	/*for (ll i = 0; i < n; i++)
	{
		cout << distance[i] << " ";
	}*/

	bool flag = false;
	for (int i = 2; i <= n; i++)
	{
		if (distance[i] == INT_MAX)
		{
			flag = true;
			break;
		}
	}
	if (flag)
		cout << "No" << "\n";

	else
	{
		cout << "Yes" << "\n";
		for (int i = 2; i <= n; i++)
			cout << ans[i] << "\n";
	}





}


int main()
{

	FastRead;
	int T = 1;
	//cin>>T;
	while (T--)
	{
		Solve();
	}

	return 0;
}


Measured memory_bytes: 10900
#include <cstdio>
#include <cstring>

using namespace std;

int main(void){
	int n, s, i, j, ans, sum, num;
	while(1){
		scanf("%d%d",&n,&s);
		if(n == 0 && s == 0)
			break;
		ans = 0;
		for(i = 0;i < (1 << 10);i++){
			num = sum = 0;
			for(j = 0;j < 10;j++){
				if(1 << j & i){
					num++;
					sum += j;
				}
			}
			if(num == n && sum == s){
				ans++;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const ll INF = 1e17+7;


int main(){

    ll a,b,q;
    cin >> a >> b >> q;
    vector<ll> s(a),t(b);
    for(int i = 0;i < a;i++){
        cin >> s[i];
    }
    for(int i = 0;i < b;i++){
        cin >> t[i];
    }

    for(int i = 0;i < q;i++){
        ll query;
        cin >> query;
        auto s_i = lower_bound(s.begin(),s.end(),query);
        auto t_i = lower_bound(t.begin(),t.end(),query);
        if(s_i == s.end()){
            s_i--;
        }
        if(t_i == t.end()){
            t_i--;
        }
        vector<ll> ta,tb;
        ta.push_back(*s_i);
        if(s_i != s.begin()){
            s_i--;
            ta.push_back(*s_i);
        }
        tb.push_back(*t_i);

        if(t_i != t.begin()){
            t_i--;
            tb.push_back(*t_i);
        }
        
        /*for(int i = 0;i < ta.size();i++){
            cout << ta[i] << " ";
        }
        cout << endl;
        for(int i = 0;i < tb.size();i++){
            cout << tb[i] << " ";
        }
        cout << endl;
        cout << *s_i << " " << *t_i << endl;*/

        ll mini = INF;

        //A→B
        ll now = query;
        for(int i = 0;i < ta.size();i++){
            for(int j = 0;j < tb.size();j++){
                ll tmp = 0;
                ll now = query;
                tmp += (ll)abs(ta[i] - now);//まずAに行く
                now = ta[i];
                tmp += (ll)abs(tb[j] - now);
                mini = min(mini,tmp);
            }
        }
        //cout << mini << endl;
        //B→A
        for(int i = 0;i < tb.size();i++){
            for(int j = 0;j < ta.size();j++){
                ll tmp = 0;
                ll now = query;
                tmp += (ll)abs(tb[i] - now);//まずbに行く
                now = tb[i];
                tmp += (ll)abs(ta[j] - now);
                mini = min(mini,tmp);
            }
        }
        cout << mini << endl;
    }



    



    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int inf = 1000000000;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
const ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    for(int c=1; c<n; c++){
        bool boo = false;
        for(int a=1; a*a<=n-c; a++){
        ll anss = 0;
        int b = (n-c)/a;
        
        if(a*b == n-c){
            if(b==a){
                boo = true;
            }
            anss++;
        }
        ans+=anss*2;
        if(boo){
            ans--;
        }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
   /* ll t;
    cin>>t;
    while(t--)
    {
       
    }*/
    ll n,m;
    cin>>n>>m;
    if(n<=m)
    {
        for(ll i=0;i<m;i++)
        cout<<n;
    }
    else
    {
        for(ll i=0;i<n;i++)
        cout<<m;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#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(x) x.begin(),x.end()
using namespace std;

signed main() {
  string s;
  cin >> s;
  vector<char> c(4);
  rep(i, 4) {
     c.at(i) = s[i];
  }
  sort(all(c));
  if(c[0] == c[1] && c[2] == c[3] && c[0] != c[2]) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter("\n");
		int N = sc.nextInt();
		String zahyo;
		double x[] = new double[N];
		double y[] = new double[N];
		double sum = 0;

		for (int i = 0; i < N; i++) {
			zahyo = sc.next();
			x[i] = Integer.valueOf(zahyo.split(" ")[0]);
			y[i] = Integer.valueOf(zahyo.split(" ")[1]);
		}

		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				sum += Math.sqrt((Math.pow(x[j] - x[i], 2) + Math.pow(y[j] - y[i], 2)));
			}
		}

		System.out.println(2 * sum / N);

	}
}


Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>   
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

string s, s1;
int ans, cur;

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> s;
   for (int i = 0; i < sz (s); i ++) {
      if (s[i] == 'B' && i < sz (s) - 1 && s[i + 1] == 'C') {
         s1 += 'D';
         i ++;
      }
      else s1 += s[i];
   }
   for (int i = 0; i < sz (s1); i ++) {
      if (s1[i] == 'D') ans += cur;
      else if (s1[i] == 'A') cur ++;
      else cur = 0;

   }
   cout << ans;
}                                     

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
// cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int t=0; t<n; t++){
        int b=0, c=0;
        int a[10];
        int i;
        if(!(cin>>a[0])) break;
        for(i=1; i<10; i++) cin>>a[i];
        for(i=0; i<10; i++){
            if(b<c){
                if(c<a[i]) c=a[i];
                else if(b<a[i]) b=a[i];
                else break;
            }else{
                if(b<a[i]) b=a[i];
                else if(c<a[i]) c=a[i];
                else break;
            }
        }
        cout<<(i==10?"YES\n":"NO\n");
    }
    return 0;
}

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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

unordered_map<int64_t, int64_t> bunkai(int64_t N)
{
    unordered_map<int64_t, int64_t> hist;

    int64_t a = 2;
    while (N >= a * a)
    {
        if (N % a == 0)
        {
            hist[a]++;
            N /= a;
        }
        else
            a++;
    }
    hist[N]++;
    return hist;
}

int64_t mypow(int64_t x, int64_t y) //x ^ y
{
    if (y == 1)
        return x;
    else if (y % 2 == 1)
        return mypow(x, y - 1) * x % MOD;
    else
    {
        int64_t tmp = mypow(x, y / 2);
        return tmp * tmp % MOD;
    }
}

int main()
{
    int64_t N, tmp, ans = 0;
    cin >> N;

    vector<int64_t> list(N);
    vector<unordered_map<int64_t, int64_t>> hist(N);
    unordered_map<int64_t, int64_t> LCM;

    for (int i = 0; i < N; i++)
    {
        cin >> list[i];
        auto tmp = bunkai(list[i]);
        hist[i] = tmp;
        for (auto x : tmp)
            LCM[x.first] = max(LCM[x.first], x.second);
    }

    int64_t lcm = 1;
    for (auto x : LCM)
        lcm *= pow(x.first, x.second), lcm %= MOD;
    
    for (int i = 0; i < N; i++)
        ans = (ans + lcm * mypow(list[i], MOD - 2)) % MOD;

    cout << ans;
}

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

int main() {
	string s, t; cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
Sum = [0] * (N+1)

flag = False
for i in range(N):
    if S[i] == "A":
        flag = True
        Sum[i+1] = Sum[i]
    else:
        if S[i] == "C":
            if flag:
                Sum[i+1] = Sum[i] + 1
            else:
                Sum[i+1] = Sum[i]
        else: Sum[i+1] = Sum[i]
        flag = False

for _ in range(Q):
    l, r = map(int, input().split())
    print(Sum[r] - Sum[l])


Measured memory_bytes: 6084
N = int(input())
D = [list(map(int,input().split())) for i in range(N)]
count = 0

for i in range(N-2):
  if D[i][0] == D[i][1]:
    if D[i+1][0] == D[i+1][1]:
      if D[i+2][0] == D[i+2][1]:
        print("Yes")
        break
      else:
        count += 1
    else:
      count += 1
  else:
    count += 1
  
if count == N-2:
  print("No")

Measured memory_bytes: 9140
from itertools import*
N,K,Q,*A=map(int,open(0).read().split())
s=sorted
print(min((s(sum((v[:max(0,len(v)-K+1)]for v in(k*s(v)for k,v in groupby(A,lambda a:a>=Y))),[]))[Q-1:]or[2e9])[0]-Y for Y in A))

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

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;
// library
struct w_union_find{
    // d_ws[a]はroot -> aの重み.
    vector<int> d_ws;
    vector<int> ps;
    w_union_find(int n = 1) : ps(n, -1), d_ws(n, 0){}

    int root(int a){
        if(ps[a] < 0){
            return a;
        }
        int r = root(ps[a]);
        // d_wsはrootからの重みなのでこれでok
        d_ws[a] += d_ws[ps[a]];
        return ps[a] = r;
    }

    bool same(int a, int b){
        return root(a) == root(b);
    }

    int weight(int a){
        root(a);
        return d_ws[a];
    }

    int diff_weight(int a, int b){
        return weight(b) - weight(a);
    }

    bool unite(int a, int b, int w){
        // weight[b] - weight[a] = wとなるようにweight[root(b)]を決定し,aに連結
        // 失敗したときだけfalse.
        if(same(a, b)){
            // 無条件でfalseを返してしまうと元からa -> bがwになっている場合でもfalseになってしまうから下
            return diff_weight(a, b) == w;
        }

        w -= weight(b);
        w += weight(a);

        a = root(a);
        b = root(b);

        if(ps[a] > ps[b]){
            // 要素が多い方に連結.
            swap(a, b);
            w *= -1;
        }
        ps[a] += ps[b];
        ps[b] = a;
        d_ws[b] = w;

        return true;
    }

};

int main(){
    int N, M;
    cin >> N >> M;
    w_union_find uf(N + 1);
    vector<int> ps(N);
    rep(i, N){
        cin >> ps[i];
    }
    rep(i, M){
        int x, y;
        cin >> x >> y;
        uf.unite(x, y, 1);
    }

    int ans = 0;

    rep(i, N){
        if(uf.same(ps[i], i + 1)){
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
import math
N=int(input())
T=[list(map(int,input().split())) for i in range(N)]
cur=[1,1]
for i in T:
    K=max(cur[0]//i[0]+(cur[0]%i[0]!=0),cur[1]//i[1]+(cur[1]%i[1]!=0))
    cur=[j*K for j in i]
print(sum(cur))


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

int main(){
    int K, A, B;
    std::cin >> K >> A >> B;
    
    for(int i=A; i<=B; i++){
        if(i % K == 0){
            std::cout << "OK" << std::endl;
            return 0;
        }
    }
    
    std::cout << "NG" << std::endl;
    return 0;
}



Measured memory_bytes: 3636
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i <= i##_len; ++i)
#define rep3(i, l, r) for (int i = l, i##_len = (r); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = l, i##_len = (r); i <= i##_len; ++i)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef int64_t Int;
typedef long double Ld;

using namespace std;
template <class T>
using Graph = vector<vector<T>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

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

template <typename T>
inline T Gcd(T a, T b) {
    T c;
    while (b) {
        c = b;
        b = a % b;
        a = c;
    }
    return a;
}

Int Lcm(Int a, Int b) {
    if (a < b) {
        swap(a, b);
    }

    return a / Gcd(a, b) * b;
}

vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(all(ret));

    return ret;
}

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

    int n;
    cin >> n;

    if (n) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3648
import sys
input = sys.stdin.readline

class Node:
    def __init__(self):
        self.is_root = True
        self.parent = None
        self.child_num = 0
    
    def root_node(self):
        node = self
        while not node.is_root:
            node = node.parent
        return node

def main():
    N, M = map(int, input().split())

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

    ab = [list(map(int, input().split())) for i in range(M)]
    
    inc = (N * (N-1)) // 2
    ans = [inc]
    for i in range(M-1, -1, -1):
        a, b = ab[i]
        a -= 1
        b -= 1
        root_a = nodes[a].root_node()
        root_b = nodes[b].root_node()
        if root_a == root_b:# もともと連結成分だった場合
            ans.append(inc)
        else:# 新たに連結成分になった場合
            if root_b.child_num > root_a.child_num:
                tmp = root_a
                root_a = root_b
                root_b = tmp
            inc -= (root_a.child_num + 1) * (root_b.child_num + 1)
            ans.append(inc)
            root_b.is_root = False
            root_b.parent = root_a
            root_a.child_num += root_b.child_num + 1

    for i in range(M-1, -1, -1):
        print(ans[i])

if __name__ == "__main__":
    main()



Measured memory_bytes: 49944
function main(input) {
    var n = input.split(/\n/)[0] / 1;
    var l2 = input.split(/\n/)[1];
    var array = l2.split(/\s/);
    for (var i = 0; i < array.length; i++) {
        array[i] /= 1;
    }
    var result = 0;
    for (var j = 0; j < array.length - 2; j++) {
        var three = [array[j], array[j + 1], array[j + 2]];
        var max = Math.max.apply(0, three);
        var min = Math.min.apply(0, three);
        if (three[1] != max && three[1] != min) {
            result++;
        }
    }
    console.log(result);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		Map<String,Integer> poll = new TreeMap<String,Integer>();

		String b = scan.next();
		poll.put(b,1);

		for(int i=1;i<n;i++) {
			String S = scan.next();

			//マップに指定した文字列が存在しないとき
			if(!poll.containsKey(S)) {

				//指定した文字列のキーと値をマップに関連付ける
				poll.put(S, 1);
				}else {
					//
					poll.replace(S,poll.get(S)+1);
				}
		}

		int S = 0;
		for(String k:poll.keySet()) {
			S = Math.max(S, poll.get(k));
		}

		for(String k:poll.keySet()) {
			if(S == poll.get(k)) {
				System.out.println(k);
			}
		}


		scan.close();

	}

}


Measured memory_bytes: 77932
#include <bits/stdc++.h>
using namespace std;
#define M 30005
#define N 1005

int main()
{
    int ma=0,mi=1000,t,b,c,n;
    cin>>n;
    while(n--)
    {
        cin>>t;
        ma=max(ma,t);
        mi=min(mi,t);
    }
    cout<<ma-mi;
    return 0;

}


Measured memory_bytes: 256
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

h, w = MAP()
a = [[0]*(w+1)]
for i in range(1, h+1):
    a.append([0] + LIST())
ans = []
flag = False
for i in range(1, h+1):
    if i % 2 == 1:
        for j in range(1, w+1):
            if a[i][j] % 2 == 1:
                flag = not flag
            if flag:
                if j < w:
                    ans.append([i,j,i,j+1])
                elif i < h:
                    ans.append([i,j,i+1,j])
    else:
        for j in range(w, 0, -1):
            if a[i][j] % 2 == 1:
                flag = not flag
            if flag:
                if j > 1:
                    ans.append([i,j,i,j-1])
                elif i < h:
                    ans.append([i,j,i+1,j])

print(len(ans))
for x in ans:
    print(*x)

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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for (int i=0; i<N; ++i) cin >> A[i];

    int S = accumulate(A.begin(), A.end(), 0);
    int cnt = 0;
    for (int i=0; i<N; ++i) {
        if (A[i] * 4 * M >= S) {
            cnt ++;
        }
    }
    cout << (cnt >= M ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <map>
using namespace std;
typedef pair<int,int> pii;
int miss[66][20];
int main(){
    
  int M,T,P,R;
  int m,t,p,j;
  int i,k;
  vector<pii> team;
  while(cin>>M>>T>>P>>R,M|T|P|R){
    memset(miss,0,sizeof(miss));
    team.clear();
    for(i=0;i<=T;i++){
      team.push_back(pii(0,0));
    }
    
    for(i=0;i<R;i++){
      cin>>m>>t>>p>>j;
      if(j==0){
	team[t].first++;
	team[t].second+=(m+miss[t][p]*20);
      }
      else{
	miss[t][p]++;
      }
    }
    /*
    for(i=0;i<T;i++){
      cout<<i<<":"<<team[i].first<<" : "<<team[i].second<<endl;
    }
    */
    int prei,tmpi,tmp;
    int use[60];
    memset(use,0,sizeof(use));
    for(j=0;j<T;j++){
      i=T;
      while(use[i]==1)i--;
      tmpi=i;
      for(i=i-1;i>0;i--){
	if(use[i]==1) continue;
	if(team[i].first>team[tmpi].first){
	  tmpi=i;
	}
	else if(team[i].first==team[tmpi].first){
	  if(team[i].second<team[tmpi].second){
	    tmpi=i;
	  }
	}
	
      }
      use[tmpi]=1;
      //cout<<"["<<tmpi<<"];"<<team[tmpi].first<<"---"<<team[tmpi].second<<endl;
      if(j==0) cout<<tmpi;
      else if(team[tmpi].first==team[prei].first&&team[tmpi].second==team[prei].second){
	cout<<"="<<tmpi;
      }
      else{
	cout<<","<<tmpi;
      }
      prei=tmpi;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3052
using System;

namespace ABC141_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var flag = true;
            for (int i = 0; i < s.Length; i++)
            {
                if (i % 2 == 0)
                {
                    if (s[i] == 'L')
                    {
                        flag = false;
                    }
                }
                else
                {
                    if (s[i] == 'R')
                    {
                        flag = false;
                    }
                }
            }

            Console.WriteLine(flag ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
 
  int aTimesb = a * b;
  int odd = aTimesb % 2;
  if (odd) {
    cout << "Odd" << endl;
  }else{
    cout << "Even" << endl;
  }
}

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

typedef long long ll;

const ll maxn = 3005;

double dp[maxn][maxn];
double a[maxn];
ll n;

double go(ll h, ll i)
{
    if(i == n)
        return h>(i-h); 
    if(dp[h][i] != -1)
        return dp[h][i];
    return dp[h][i] = a[i] * go(h+1,i+1) + (1 - a[i]) * go(h,i+1); 
    
}


int main()
{
    cout.precision(20);
    cout<<fixed;
    cin>>n;
    for(ll i=0;i<n;i++)
        cin>>a[i];
    
    for(ll i=0;i<maxn;i++)
        for(ll j=0;j<maxn;j++)
            dp[i][j] = -1;

    cout<<go(0,0);

}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
 
int main() {

    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n)    cin >> p[i];

    int ans=0;
    for(int i=1;i<n-1;i++) {
        if(max(p[i],max(p[i-1],p[i+1]))+min(p[i],min(p[i-1],p[i+1]))==p[i+1]+p[i-1])    ans++;
    }

    cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    ll ans = 0;
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n)cin >> d[i];
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int gcd(int a, int b) {
    if (b > a) return gcd(b, a);
    else if (b == 0) return a;
    else return gcd(b, a % b);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, X;
    cin >> N >> X;
    int G = gcd(N, X);
    N /= G;
    X /= G;
    cout << (N - 1) * 3 * G << endl;

    return 0;
}


Measured memory_bytes: 256
# [A,B) + [B,C)の中で過半数なら、どっちかで過半数
# 長さ3以下の区間に帰着できる
# 'xx' or 'xyx'

txt = input()
L = len(txt)

def solve():
  for i in range(L-1):
    if txt[i] == txt[i+1]:
      return ' '.join([str(x) for x in [i+1,i+2]])
  for i in range(L-2):
    if txt[i] == txt[i+2]:
      return ' '.join([str(x) for x in [i+1,i+3]])
  return '-1 -1'

ans = solve()
print(ans)

Measured memory_bytes: 3188
N,K_o=map(int,input().split())
S=[]
K=[]
mod=998244353


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

for i in range(K_o):
  L,R=map(int,input().split())
  for i in range(L,R+1):
    S.append(i)
  K.append([L,R])

bit=Bit(N+1)
bit.add(1,1)
bit.add(2,-1)
for i in range(N):
  for L,R in K:
    value_i=bit.sum(i)
    value_i%=mod
    bit.add(i+L,value_i)
    bit.add(i+R+1,value_i*-1)

print(bit.sum(N)%mod)

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

using namespace std;
typedef long long ll;
#define FOR(i,n) for(int i=0; i<int(n); i++)
#define FOR1(i,m,n) for(int i=int(m); i<int(n); i++)

int main(int argc, char *argv[])
{
    int n, sign=0, a, b, count = 1;

    cin >> n;

    cin >> a;
    FOR1(i,1,n) {
        b = a;
        cin >> a;
        if (sign < 0 && b < a) {
            count ++;
            sign = 0;
        } else if (sign > 0 && b > a) {
            count ++;
            sign = 0;
        } else if (sign == 0) {
            if (b < a)
                sign = 1;
            else if (a < b)
                sign = -1;
        }
    }
    
    printf("%d\n", count);
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;

int main(){

    int n;
    cin >> n;

    int tmpmin = INT_MAX;
    int tmpmax = 0;

    rep(i,n){
        int tmp;
        cin >> tmp;

        tmpmin = min(tmp,tmpmin);
        tmpmax = max(tmp,tmpmax);
    }

    cout << tmpmax - tmpmin << endl;

    return 0;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if( a==b and b==c){
        cout << 1 << endl;
    }else if(a ==b or b==c or a==c ){
        cout << 2 << endl;
    }else{
        cout << 3 << endl;
    }
    return 0;
}

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

int main() {
  
  int n;
  cin >> n;
  
  int s=0;
  for (int i=0; i<9; i++) {
    for (int j=0; j<9; j++) {
      if (n==(i+1)*(j+1)) {
        cout << "Yes" << endl;
        s++;
        break;
      }
    }
    if (s!=0) break;
  }
  if (s==0) cout << "No" << endl;
}

Measured memory_bytes: 256
inf = 10**18
mod = 10**9+7

# a^n
def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


n,k = map(int, input().split())
d = list(input().split())
ans = n
for i in range(n, n*10+1):
    tmp = str(i)
    ok = True
    for c in tmp:
        if c in d:
            ok = False
            break
    if ok:
        ans = i
        break
print(ans)

Measured memory_bytes: 40540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
int gcd(int a,int b){
    if(a < b) return gcd(b, a);
    int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
signed main(){
    int n;cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            int ab=gcd(i,j);
            for(int k=1;k<=n;k++){
                sum+=gcd(ab,k);
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a, LL b) {LL s = 1; while (b > 0) {if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1;} return s;}
LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
int dr[2][4] = {1, -1, 0, 0, 0, 0, -1, 1};
typedef pair<int, int> P;
const int maxn = 1e5 + 10;
int A[maxn], loc[maxn];

int main(void)
{
	LL ans = 0;
	int n; cin >> n;
	for (int i = 1; i <= n; ++i)
		scanf("%d", &A[i]), loc[A[i]] = i;

	set<int> sleft, sright;
	sright.insert(0);
	sright.insert(n + 1);
	sright.insert(-1);
	sright.insert(n + 2);
	for (int i = 1; i <= n; ++i)
		sright.insert(loc[i]);
	for (int i = 1; i < n; ++i) {
		auto it = sright.lower_bound(loc[i]);
		auto it2 = it;
		int a = *(++it);
		int b = *(++it);  b = min(b, n + 1);
		int c = *(--it2);
		int d = *(--it2); d = max(d, 0);
		// cout << a << " " << b << endl;
		ans += 1ll * (loc[i] - c) * (b - a) * i;
		ans += 1ll * (a - loc[i]) * (c - d) * i;
		sright.erase(loc[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    string s;
    cin>>s;
    if(s=="SUN")
    cout<<7;
    if(s=="SAT")
    cout<<1;
    if(s=="FRI")
    cout<<2;
    if(s=="THU")
    cout<<3;
    if(s=="WED")
    cout<<4;
    if(s=="TUE")
    cout<<5;
    if(s=="MON")
    cout<<6;}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();
		
		if((a == b && b != c)||(b == c && b != a) || (a == c && a != b)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22996