akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "the " << #x << " -> "; err(x); } while (0)
void err() { cout << "" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
const int maxn=1e4+7;
string s[maxn];
int main()
{
    int n;
    cin>>n;
    //scanf("%d",&n);
    int la=0,fb=0,ab=0;
    int ans=0;
    for(int i=0;i<n;i++) 
    {
        cin>>s[i];
        for(int j=1;j<s[i].length();j++)
            if(s[i][j]=='B'&&s[i][j-1]=='A') ans++;
        bool a=s[i][s[i].length()-1]=='A',b=s[i][0]=='B';
        if(a&&b) ab++;
        else if(a) la++;
        else if(b) fb++;
    }
    if(la!=0) ans+=min(la,fb)+ab;
    else{
        if(ab){
            ans+=ab-1;
            if(fb) ans++;
        }
    }
    printf("%d\n",ans);

}

Measured memory_bytes: 768
data = list(map(int, input().split()))

n_max = data[0]
m = data[1]

l_max = 0
r_min = n_max

for i in range(m):
    data = list(map(int, input().split()))
    l_max = max(data[0], l_max)
    r_min = min(data[1], r_min)

if r_min < l_max:
    print(0)
else:
    print(r_min - l_max + 1)


Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v) {os << " [" << i++ << "]" << x; if (i % 10 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp) {os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll a, b, c, d;
  std::cin >> a >> b >> c >> d;

  if ((std::abs(a-b) <= d && std::abs(b-c) <= d)||(std::abs(a-c) <= d)) {
    print("Yes");
  } else {
    print("No");
  }

  return 0;
}



Measured memory_bytes: 256
import numpy as np
N = int(input())
A = list(map(int,input().split()))
B = len(A)
ans = 1
a = 0
for a in range(B) :
    ans = ans*A[a] 
    if ans > 10**18 :
        if 0 in A :
            ans = 0
        else :
            ans = -1 
        break
    else :
        a += 1
print(ans)

Measured memory_bytes: 40024
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef pair<LL,LL> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e9+7;
int n,ts,top,tot,now;
vector<pa> v[22222];
LL pt,L,R,K,rch,ans,tmp[222],c[222],a[222],x[222],y[222];
pa stk[222];
struct node{
	LL w[200];
	node(){memset(w,0,sizeof(w));}
	bool operator < (const node & A) const{
		FOR(i,0,199)
			if (w[i]<A.w[i]) return 1;
			else if (w[i]>A.w[i]) return 0;
		return 0;
	}
};
LL bcm(LL x,LL y){
	LL ans=0;
	FOR(i,0,60)
		if ((y>>i)&1){
			if (y-(1ll<<i)>=x) y-=1ll<<i;
			else ++ans;
		}
	return ans;
}
map<node,int> M;
int main(){
	cin>>n>>K;
	FOR(i,1,n) cin>>a[i];
	sort(a+1,a+n+1);
	tmp[0]=-1;
	FOR(j,0,60){
		FOR(i,1,n){
			x[i]=(a[i]>>j);
			y[i]=(a[i])%(1ll<<j);
			tmp[i]=y[i];
		}
		sort(tmp+1,tmp+n+1);
		ts=unique(tmp+1,tmp+n+1)-tmp-1;
		if (tmp[ts]!=(1ll<<j)-1) tmp[++ts]=(1ll<<j)-1;
		FOR(k,1,ts){
			FOR(i,1,n)
				if (tmp[k]<=y[i]) c[i]=x[i];
				else c[i]=x[i]-1;
			pt=bcm(tmp[k-1]+1,tmp[k])+j;
			if (pt>K) continue;
			node P;
			FOR(i,2,n) P.w[i-1]=c[i]-c[i-1];
			if (M.find(P)==M.end()) M[P]=++tot;
			now=M[P];
		//	tmp[k-1]+1~tmp[k]
			L=max(0ll,c[1]-(K-pt)),R=c[1];
			v[now].pb(mp(L,R));
		}
	}
	FOR(i,1,tot){
		top=0;
		for (int j=0;j<v[i].size();++j) stk[++top]=v[i][j];
		sort(stk+1,stk+top+1);
		rch=-1;
		FOR(j,1,top){
			if (stk[j].se<=rch) continue;
			if (stk[j].fi>rch) (ans+=stk[j].se-stk[j].fi+1)%=MO,rch=stk[j].se;
			else (ans+=stk[j].se-rch)%=MO,rch=stk[j].se;
		}
	}
	cout<<(ans+MO)%MO<<endl;
	return 0;
}


Measured memory_bytes: 18304
#include<stdio.h>

int main(void){
    int K, A, B,a,b;
    scanf("%d",&K);
    scanf("%d %d",&A, &B);
    a = A/K;
    b = B/K;
    if(b > a){
        printf("OK\n");
    }
    else{
        if(A%K == 0){
            printf("OK\n");
        }
        else{
            printf("NG\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> p(m);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        p[i]=mp(a,b);
    }
    vin tmp(n);
    rep(i,n-1)tmp[i]=i+2;
    int sum=0;
    if(n>2){
        do{
            vector<bool> ar(n,true);
            bool can1=false;
            rep(i,m){
                if(p[i].first==1&&p[i].second==tmp[0]){
                    ar[1]=false;
                    can1=true;
                }
            }
            if(can1){
                rep(i,n-2){
                    bool can2=false;
                    rep(j,m){
                        if(p[j].first==tmp[i]&&p[j].second==tmp[i+1]&&ar[i+2]){
                            ar[i+2]=false;
                           can2=true;
                        }
                        else if(p[j].second==tmp[i]&&p[j].first==tmp[i+1]&&ar[i+2]){
                            ar[i+2]=false;
                            can2=true;
                        }
                    }
                    if(!can2){
                        can1=false;
                        break;
                    }
                }
                if(can1)sum++;
            }
        }while(next_permutation(all(tmp)));
    }
    if(n==2)sum=1;
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

signed main(){
    int N,x;
    int a[104];
    cin >> N >> x;
    REP(i,N){
        cin >> a[i];
    }
    sort(a,a+N);
    int e=0;
    REP(i,N){
        if(a[i]<=x){
           e++;
           x-=a[i];
        }
    }
    if(x==0){
        cout << e << endl;
    }else{
        cout << min(e,N-1) << endl;
    }
    return 0;
}   

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[200001],b[200001];
ll dp[4005][4005];
ll dp2[4005][4005];
int main(void){
	int ma=2000,mb=2000;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
		dp[ma-a[i]][mb-b[i]]++;
	}
	for(int i=0;i<=ma*2;i++){
		for(int j=0;j<=mb*2;j++){
			dp[i+1][j]+=dp[i][j];
			dp[i+1][j]%=MOD;
			dp[i][j+1]+=dp[i][j];
			dp[i][j+1]%=MOD;
		}
	}
	dp2[0][0]=1;
	for(int i=0;i<=ma*2;i++){
		for(int j=0;j<=mb*2;j++){
			dp2[i+1][j]+=dp2[i][j];
			dp2[i+1][j]%=MOD;
			dp2[i][j+1]+=dp2[i][j];
			dp2[i][j+1]%=MOD;
		}
	}
	ll res=0;
	for(int i=0;i<n;i++){
		res=(res+dp[a[i]+ma][b[i]+mb])%MOD;
	}
	for(int i=0;i<n;i++){
		res=(res-dp2[a[i]*2][b[i]*2]+MOD)%MOD;
	}
	printf("%lld\n",res*500000004LL%MOD);
	return 0;
}


Measured memory_bytes: 252416
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
const double PI = acos(-1);

int main() {
	string s;
	cin >> s;
	if (s[0] == '9' || s[1] == '9')cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#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>;

int main(){
	string s;
	cin >> s;
	int n = s.size();
	int a = 0;
	int b = 0;
	rep(i, n){
		if(s.at(i) == '0'){
			a++;
		}else{
			b++;
		}
	}
	cout << min(a, b)*2 << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
int main(){
	string S;
	cin>>S;
	for(int i=0;i<S.length();i+=2){
		if(S[i]!='R'&&S[i]!='U'&&S[i]!='D'){cout<<"No";return 0;}
	}
	for(int i=1;i<S.length();i+=2){
		if(S[i]!='L'&&S[i]!='U'&&S[i]!='D'){cout<<"No";return 0;}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
num = sum(A)
ans = []
a = 0
for j in range(int(N/2)):
    a += 2*A[1+2*j]
ans.append(num-a)
a = num-a
for i in range(N-1):
    a = 2*A[i] - a
    ans.append(a)
print(*ans)

Measured memory_bytes: 14092
n, q = map(int, input().split())
edges=[[] for i in range(n+1)]
for i in range(1,n):
	a, b=[int(i) for i in input().split()]
	edges[a].append(b)
	edges[b].append(a)
c = [0 for i in range(n+1)]
for i in range(q):
    p, x = map(int, input().split())
    c[p] += x

ind = [0 for i in range(n+1)]
ind[1] = 1
nxt = [1]
nxt_copy = []
while nxt != []:
    for i in nxt:
        for j in edges[i]:
            if ind[j] == 0:
                ind[j] = 1
                c[j] += c[i]
                nxt_copy.append(j)
    nxt = nxt_copy.copy()
    nxt_copy = []

c.pop(0)
print(' '.join(map(str, c)))

Measured memory_bytes: 66840
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<algorithm>
#define L long long
#include<string.h>
#include <math.h>
long long  array1[100002];
using namespace std;
int n;
long long a,b;
int judge(int x)
{
    long long sum=0;
      for(int i=0;i<n;i++)
      {
          long long num=array1[i]-x*b;
          if(num>0)
          {
              sum+= ceil((num*1.0)/(a-b));

          }
          if(sum>x||sum<0)
                return 0;

      }
      return 1;
}

int main()
{   int i;
   cin>>n>>a>>b;
        for(i=0;i<n;i++)
        {
        cin>>array1[i];
        }
            sort(array1,array1+n);
        long long l=0,r=array1[n-1];
         while(l<r)
         {
             long long mind=(l+r)>>1;
             if(judge(mind)==1)  r=mind;
             else
                 l=mind+1;
         }
         cout<<r<<endl;


       return 0;
}







Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <string>
int main(void)
{
	int a, b,c,s;
	std::cin >> a >> b >> c;
	if (a >= b&&a >= c)
	{
		s = b + c;
		if (a == s)
		{
			std::cout << "Yes";
		}
		else
			std::cout << "No";
	}
	if (b > a&&b > c)
	{
		s = a + c;
		if (b == s)
		{
			std::cout << "Yes";
		}
		else
		{

			std::cout << "No";
		}
	}
	if (c > a&&c > b)
	{
		s = a + b;
		if (s == c)
		{
			std::cout << "Yes";
		}
		else
		{
			std::cout << "No";
		}
	}
	return 0;
}
	

		
	

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#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) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	ll kotae = 0;
	bool mae = 0;
	rep(i, N) {
		int a = getint();
		if (mae && a) {
			kotae++;
			a--;
		}
		kotae += a / 2;
		mae = a & 1;
	}
	printf("%lld", kotae);


	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 700 + 10;
int n, m, tot, ans;
bool M[maxn][maxn], dp[maxn][maxn][maxn];
int col[maxn], cnt[maxn][2];
vector<int> E[maxn]; 
void dfs(int x)
{
	if(!col[x]) ++cnt[tot][0];
	else ++cnt[tot][1];
	for(auto v : E[x])
	{
		if(col[v] == -1)
		{
			col[v] = col[x] ^ 1;
			dfs(v);
		}
		else if(col[v] == col[x])
		{
			puts("-1");
			exit(0);
		}
	}
}
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		M[u][v] = M[v][u] = 1;
	}
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
			if(i != j && !M[i][j])
				E[i].push_back(j);
	memset(col, -1, sizeof(col));
	for(int i = 1; i <= n; ++i)
		if(col[i] == -1)
		{
			++tot;
			col[i] = 0;
			dfs(i);
		}
	dp[0][0][0] = 1;
	for(int i = 1; i <= tot; ++i)
		for(int x = 0; x < 2; ++x)
			for(int j = cnt[i][x]; j < maxn; ++j)
				for(int k = cnt[i][x ^ 1]; k < maxn; ++k)
					dp[i][j][k] |= dp[i - 1][j - cnt[i][x]][k - cnt[i][x ^ 1]];
	ans = n * (n - 1) / 2;
	for(int j = 0; j < maxn; ++j)
		for(int k = 0; k < maxn; ++k)
			if(dp[tot][j][k])
				ans = min(ans, j * (j - 1) / 2 + k * (k - 1) / 2);
	printf("%d\n", ans);
	return 0;
}
	
		
	 

Measured memory_bytes: 346368
#include <stdio.h>
#include <string.h>
int main() {
	char str[30];
	char t[300] = {0};
	t['A'] = t['T'] = t['C'] = t['G'] = 1;
	fgets(str, 29, stdin);
	int len = strlen(str);
	int result = 0;
	for (int i = 0; i < len; i++) {
		if (t[str[i]]) {
			//printf("str[%d]\n", i);
			for (int j = 1; j + i < len; j++) {
				if (!t[str[j + i]]) {
					//printf("j = %d\n", j);
					result = j > result ? j : result;
					i = i + j;
					break;
				}
			}
		}
	}
	printf("%d", result);
}

Measured memory_bytes: 128
import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.Map as M
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  [a0, op0, b0] <- words <$> getLine
  let a = read a0 :: Int
  let b = read b0 :: Int
  let op = head op0
  when (op /= '?') $ do
    case op of
      '+' -> print $ a + b
      '-' -> print $ a - b
      '*' -> print $ a * b
      '/' -> print $ a `quot` b
    main

solve :: Double -> (Double, Double)
solve r = (s, c)
 where
  s = pi * (r ^ 2)
  c = 2 * pi * r




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

#define SIZE 10000

struct WORD {
	char value[15];
	struct WORD *next;
};

struct WORD* HashTable[SIZE];	//default: all NULL

int HashFunc(char s[]) {
	long long hash = 0;
	for (int i = 0; s[i] != '\0'; i++) {
		hash += s[i] * (i + 1);
	}
	return (int)(hash * 13 % SIZE);
}

void AddWord(char s[], int hashNum) {
	struct WORD* newWord = (struct WORD*)malloc(sizeof(struct WORD));
	strcpy(newWord->value, s);
	newWord->next = NULL;
	if (HashTable[hashNum] == NULL) HashTable[hashNum] = newWord;
	else {
		newWord->next = HashTable[hashNum];
		HashTable[hashNum] = newWord;
	}
}

void Insert(char s[]) {
	int hash = HashFunc(s);
	AddWord(s, hash);
}

void Find(char s[]) {
	int hash = HashFunc(s);
	struct WORD* pos;
	for (pos = HashTable[hash]; pos != NULL; pos = pos->next) {
		if (!strcmp(s, pos->value)) {
			printf("yes\n");
			return;
		}
	}
	printf("no\n");
	return;
}

int main() {
	int n;
	char command[10], value[15];
	for (int i = 0; i < SIZE; i++) {
		HashTable[i] = NULL;
	}
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s %s", command, value);
		if (!strcmp(command, "insert")) Insert(value);
		else if (!strcmp(command, "find")) Find(value);
	}

	return 0;
}


Measured memory_bytes: 19568
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int K;
    string S;
    cin >> K >> S;
    if (S.size() <= K)
    {
        cout << S << endl;
    }
    else
    {
        cout << S.substr(0, K) + "..." << endl;
    }
}

Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
using namespace std;
#define rep(x, a, b) for(int x=a; x<=b; x++)
int n, a[100100];
int main(){
	scanf("%d", &n);
	rep(i, 1, n) scanf("%d", a+i);
	sort(a+1, a+n+1);
	reverse(a+1, a+n+1);
	a[0]=a[1];
	int x=0;
	while(x+1<n && x+1<a[x+2]) x++;
	int nxt=x+1;
	while(nxt<n && a[nxt+1]>x) nxt++;
	puts(((a[x+1]-x+1)&1)|((nxt-x+1)&1)?"First":"Second");
}

Measured memory_bytes: 512
/*
                Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {   if(n % 2 ==1)
        result=(result * x) % M;
        x=(x*x)% M;
        n=n/2;
    }
return result % M;
}      
bool isPrime(int n) 
{ 
if (n <= 1) 
    return false; 
if (n <= 3) 
    return true; 
if (n % 2 == 0 || n % 3 == 0) 
    return false; 
for (int i = 5; i * i <= n; i = i + 6) 
    if (n % i == 0 || n % (i + 2) == 0) 
        return false; 
return true; 
} 
signed main()
{   jaldi
    int n,k;
    cin>>n>>k;
    double b[n];
    int a[n],i;
    for(i=0;i<n;i++)
    {   cin>>a[i];
        b[i]=(double)(a[i]+1)/2;
     //   cout<<b[i]<<endl;
    }
    double c[n];
    int j=0;
       for(i=0;i<n;i++)
        {  // cout<<b[i]<<" ";
            if(i==0)
            continue;
            else
            b[i]+=(double)b[i-1];
//            cout<<b[i]<<" ";
        }
        for(i=k-1;i<n;i++)
        {   c[i]=double(b[i]-b[i-k]);
        }
    
    for(i=0;i<k-1;i++)
    c[i]=0;
    double res=0;
    for(i=0;i<n;i++)
    res=max(res,c[i]);
    cout<<fixed<<setprecision(6)<<res;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    double r;

    cin >> r;

    printf("%.10f\n", r * 2 * M_PI);
}


Measured memory_bytes: 3792
#include<iostream>
#include<vector>
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;
using ll = long long int;

int main(void) {
    int n; cin >> n;
    vector<int> b(n - 1);
    rep(i, n - 1) cin >> b[i];
    int sum = b[0];
    rep(i, n - 2) sum += min(b[i], b[i + 1]);
    cout << sum + b[n - 2] << endl;
}

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

int main() {
  int N, Ans=1;
  cin >> N;
  for(int i=1; i<=N; i++){
    if(i*i>N){
      Ans=(i-1)*(i-1);
      break;
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
 
class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        long[] A = new long[n];
        long[] B = new long[n];
        for (int i = 0; i < n; i++)
        {
            string[] inputs = Console.ReadLine().Split(' ');
            A[i] = long.Parse(inputs[0]);
            B[i] = long.Parse(inputs[1]);
        }

        long cnt = 0;
        for (int i = n - 1; i >= 0 ; i--)
        {
            long r = (A[i] + cnt) % B[i];
            if(r != 0) cnt += B[i] - r;
            Console.Error.WriteLine("{0} -> {1} : {2}", A[i], A[i] + cnt, B[i]);
            Console.Error.WriteLine("cnt = {0}", cnt);
        }
        Console.WriteLine(cnt);
    }
}

Measured memory_bytes: 8556
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static final FS sc = new FS();  // 封装输入类
    static final PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] ans = new int[n + 1];
        for(int x = 1;x <= n;x++) {
            int x2 = x * x;
            if (x2 > n) {
                break;
            }
            for(int y = 1;y <= n;y++) {
                int y2 = y * y, xy = x * y;
                if (x2 + y2 + xy > n) {
                    break;
                }
                for(int z = 1; z <= n;z++) {
                    int num = x2 + y2 + z * z + xy + y * z + z * x;
                    if (num > n) {
                        break;
                    }
                    ans[num]++;
                }
            }
        }
        for(int i = 1;i <= n;i++) {
            pw.println(ans[i]);
        }
        pw.flush();
    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while(!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch(Exception ignored) {}
            }
            return st.nextToken();
        }
        int[] nextArray(int n) {
            int[] a = new int[n];
            for(int i = 0;i < n;i++) {
                a[i] = nextInt();
            }
            return a;
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 35240
n,a,b = map(int, input().split())
mod = 10 ** 9 + 7

def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res

ans = power_func(2, n, mod) - 1

comb = [1] * (b + 1)

for i in range(b):
    comb[i + 1] = comb[i] * (n - i) * pow(i + 1,mod - 2, mod) % mod

ans -= comb[a] + comb[b]
ans %= mod


print(ans)

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

using namespace std;
int a=-1,b=-1;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C') 
		{
			a=i;
			break;
		}
	}
	for(int i=a+1;i<s.size();i++)
	{
		if(s[i]=='F') 
		{
			b=i;
			break;
		}
	}
	if(a!=-1 && b!=-1) cout<<"Yes";
	else cout<<"No";
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

const double EPS = 1e-10;
const double INF = 1.0/0.0;

int N;
double X[16];
double Y[16];
double A[16];
double D[16][16];
double dp[1 << 15];
bool pos[1 << 15];

bool check(double x) {
  int lim = 1 << N;
  fill(&dp[0], &dp[lim], -INF);
  fill(&pos[0], &pos[lim], false);

  int h = lower_bound(A, A+N, x) - A;
  if (h == N) return false;
  if (h == 0) return true;

  rep(i, N) {
    dp[1 << i] = A[i] - x;
  }

  rep(st, lim) {
    rep(v, N) {
      if (st >> v & 1) continue;
      int nst = st | (1 << v);
      rep(u, N) {
        if (!(st >> u & 1)) continue;

        //if (v >= h) MX(dp[nst], dp[st]);
        MX(dp[nst], dp[st] - D[v][u] + A[v] - x);
      }
    }
  }

  rep(st, lim) {
    if (dp[st] > -EPS) pos[st] = true;
    rrep(U, lim) {
      U &= st;
      int V = st & ~U;
      if (pos[U] && pos[V]) {
        pos[st] = true; 
        break;
      }
    }
  }

  return pos[lim-1];
  //if (dp[lim-1] > -EPS) return true;
  //return false;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  cin >> N;
  double high = 0;
  using Pair = pair<int, pii>;
  vector<Pair> ds;
  rep(i, N) {
    int x, y, a;
    cin >> x >> y >> a;
    ds.eb(Pair(a, pii(x, y)));
    MX(high, double(a));
  }
  sort(all(ds));

  rep(i, N) {
    A[i] = ds[i].X;
    X[i] = ds[i].Y.X;
    Y[i] = ds[i].Y.Y;
  }

  rep(i, N) {
    rep(j, N) {
      double dx = X[i]-X[j];
      double dy = Y[i]-Y[j];
      D[i][j] = sqrt(dx*dx + dy*dy);
    }
  }

  double low = 0;
  rep(i, 45) {
    double mid = (low+high)/2;
    if (check(mid)) low = mid;
    else high = mid;
  }
  cout << low << endl;
}


Measured memory_bytes: 640
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#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) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N, M, S;
	cin >> N >> M >> S;
	if (S >= 2500) S = 2500;

	int U[100], V[100], A[100], B[100];
	vector<pair<int, ll> > E[101];
	rep(i, M) {
		cin >> U[i] >> V[i] >> A[i] >> B[i];
		E[U[i]].pb(mp(V[i], A[i] + B[i] * 100ll));
		E[V[i]].pb(mp(U[i], A[i] + B[i] * 100ll));
	}
	int C[51], D[51];
	rep1(i, N) {
		cin >> C[i] >> D[i];
	}

	ll kotae[51][2501];
	rep1(i, N) rep(j, 2501) kotae[i][j] = 1e18;
	kotae[1][S] = 0;
	priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > PQ;
	PQ.push(mp(0, 10000 + S));

	while (PQ.size()) {
		auto p = PQ.top();
		PQ.pop();
		ll ti = p.first;
		int i = p.second / 10000;
		int gin = p.second - 10000 * i;

		if (ti > kotae[i][gin]) continue;

		ll ti2 = ti + D[i];
		int gin2 = gin + C[i];
		if (gin2 > 2500) gin2 = 2500;
		if (ti2 < kotae[i][gin2]) {
			kotae[i][gin2] = ti2;
			PQ.push(mp(ti2, 10000 * i + gin2));
		}

		for (auto pp : E[i]) {
			int to = pp.first;
			ll ti2 = pp.second / 100;
			int co = pp.second - 100 * ti2;
			if (gin - co >= 0) {
				if (ti + ti2 < kotae[to][gin - co]) {
					kotae[to][gin - co] = ti + ti2;
					PQ.push(mp(ti + ti2, 10000 * to + gin - co));
				}
			}
		}

	}

	for (int i = 2; i <= N; i++) {
		ll saishou = 1e18;
		rep(j, 2501) {
			chmin(saishou, kotae[i][j]);
		}
		co(saishou);
	}



	Would you please return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	4 * MAX5;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll t = 1;
ll n, x, k, q, m, y, r;
string s;


// <------------- Implement Functions Here ----------> //

ll count() {
	ll res = 0;
	while(n) {
		res++;
		n/=k;
	}
	return res;
}


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> k;
	cout << count();
}

int main() {
	fastio; randomINT;
	//cin >> t;
	while (t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 12944
k = int(input())
x = 7%k
s = set()
#i = 1
#while len(s) == 0:
for i in range(1, k+1):
  if x == 0:
    print(i)
    exit()
  #s.add(x)
  x = (x*10+7)%k
  #i += 1
print(-1)


Measured memory_bytes: 80340
#include <cstdio>

using namespace std;
typedef long long llong;

#define MAX
const llong mod = 1000000000 + 7;

int main()
{
  llong N;
  int K;
  scanf("%lld%d", &N, &K);

  int ans = 0;
  while (N > 0)
  {
    N /= K;
    ans++;
  }

  printf("%d", ans);

  return 0;
}

Measured memory_bytes: 1724
s = str(input())

ans, cnt, i = 0, 0, 0
while i < len(s)-1:
  if s[i] == 'A':
    cnt += 1
    i += 1
  else:
    if s[i:i+2] == 'BC':
      ans += cnt
      i += 2
    else:
      cnt = 0
      i += 1
print(ans)

Measured memory_bytes: 9180
N = int(input())
A = list(map(int, input().split()))

top = 0
under = sum(A)
result = abs((A[0])-(sum(A)-A[0]))
for a in A[:-1]:
    top += a
    under -= a
    if result > abs(top - under):
        result = abs(top-under)
print(result)



Measured memory_bytes: 24828
N, X = map(int,input().split())
x = list(map(int,input().split()))

def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

sub_list = []
for i in range(N):
  sub_list.append(abs(x[i] - X))
ans = sub_list[0]
for i in range(N):
  if(sub_list[i]%ans != 0):
    ans = gcd(ans, sub_list[i])
print(ans)

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

vector<vector<pair<int, int>>> gr;
vector<long long> p;
int k;

void dfs(int u, int pv) {
  for (auto e : gr[u]) {
    int v = e.first, c = e.second;
    if (v != pv) {
      p[v] = p[u] + c;
      dfs(v, u);
    }
  }
}

int main() {
  int n;
  scanf("%d", &n);
  gr.resize(n);
  p.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    a--;
    b--;
    gr[a].push_back({b, c});
    gr[b].push_back({a, c});
  }

  int q;
  scanf("%d%d", &q, &k);
  dfs(k - 1, -1);

  for (int i = 0; i < q; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    cout << p[u] + p[v] << '\n';
  }
  
  return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>   
using namespace std;   
typedef long long ll;
int main()  
{   
    cin.tie(0); ios::sync_with_stdio(false);  
	//freopen("input.txt", "rt", stdin);
	int n; cin >> n;
	cout << n * 800 - n/15*200 << "\n";
	return 0;   
}  


Measured memory_bytes: 256
# ContestName
# URL
import sys
#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    H, W, N = i2nn()
    sr, sc = i2nn()
    S = i2s()
    T = i2s()
    h0 = 1
    h1 = H
    w0 = 1
    w1 = W
    for i, s, t in zip(range(N), S[::-1], T[::-1]):
        if t == 'L':
            w1 += 1 if w1 < W else 0
        elif t == 'R':
            w0 -= 1 if w0 > 1 else 0
        elif t == 'U':
            h1 += 1 if h1 < H else 0
        elif t == 'D':
            h0 -= 1 if h0 > 1 else 0

        if s == 'L':
            w0 += 1
        elif s == 'R':
            w1 -= 1
        elif s == 'U':
            h0 += 1
        elif s == 'D':
            h1 -= 1

        if w0 > w1 or h0 > h1:
            print('NO')
            return
    if w0 <= sc and sc <= w1 and h0 <= sr and sr <= h1:
        print('YES')
    else:
        print('NO')

main()

"""
..#
...
"""


Measured memory_bytes: 49228
n,c=map(int,input().split())
d=[list(map(int,input().split())) for i in range(c)]
c_=[list(map(int,input().split())) for i in range(n)]
g=[[] for i in range(3)]
for i in range(n):
    for j in range(n):
        g[(i+j+2)%3].append(c_[i][j]-1)
#print(g)
'''
for i in range(c):
    for j in range(c):
        for k in range(c):
            d[i][j]=min(d[i][j],d[i][k]+d[k][j])
print(d)
'''
f=[[] for i in range(3)]
for i in range(3):
    for j in range(c):
        x=0
        for k in g[i]:
            x+=d[k][j]
        f[i].append((j,x))
    f[i]=sorted(f[i],key=lambda x:x[1])[:3]
ans=[]
#print()
for i in f[0]:
    for j in f[1]:
        for k in f[2]:
            if i[0]!=j[0] and k[0]!=j[0] and i[0]!=k[0]:
                #print(i[0],j[0],k[0])
                #print(i[1],j[1],k[1])
                ans.append(i[1]+j[1]+k[1])
print(min(ans))


Measured memory_bytes: 56284
# encoding:utf-8

def checker(dx, dy, t):
	#print([dx, dy, t])
	if dx + dy <= t and abs(dx + dy - t) % 2 == 0:
		return True
	else:
		return False

def main():
	n = int(input())
	plans = [list(map(int, input().split())) for _ in range(n)]

	#print(checker(0, 1, 3))
	x, y, old_t = [0, 0, 0]
	for i in range(n):
		t, new_x, new_y = plans[i]
		if checker(abs(x - new_x), abs(y - new_y), t - old_t):
			x = new_x
			y = new_y
			old_t = t
		else:
			print("No")
			break
	else:
		print("Yes")


if __name__ == '__main__':
	main()

Measured memory_bytes: 27324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    ll x;
    cin >> x;

    if(x%11 == 0) cout << (x/11)*2 << endl;
    else if(x%11 <= 6 ) cout << (x/11)*2 + 1 << endl;
    else if(x%11 > 6) cout << (x/11)*2 + 2 << endl;

    return 0;
}

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

const int MAX_V = 100;
const int INF = 10000000;

struct edge{int to, cap, rev;};

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap)
{
  G[from].push_back((edge){to, cap, G[to].size()});
  G[to].push_back((edge){from, 0, G[from].size() - 1});
}

int dfs(int v, int t, int f)
{
  if(v == t) return f;

  used[v] = true;
  for(int i = 0; i < G[v].size(); i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to, t, min(f, e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }

  return 0;
}

int max_flow(int s, int t)
{
  int flow = 0;
  for(;;){
    fill(used, used + MAX_V, false);
    int f = dfs(s, t, INF);
    if(f == 0) return flow;
    flow += f;
  }
}

int main()
{
  int v, e;
  cin >> v >> e;
  for(int i = 0; i < e; i++){
    int f, t, c;
    cin >> f >> t >> c;
    add_edge(f, t, c);
  }
  cout << max_flow(0, v-1) << endl;
}

Measured memory_bytes: 1264
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	vector<int>a(10);
	vector<int>b(10);
	rep(i,10)cin>>a[i];
	rep(i,10)cin>>b[i];
	sort(all(a));
	sort(all(b));
	cout<<a[9]+a[8]+a[7]<<" "<<b[9]+b[8]+b[7]<<endl;
}

Measured memory_bytes: 1216
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define rep(i,n) rep1(i,0,n)
#define rep1(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
const double PI = acos(-1);
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    rep(i, m) cin >> x[i];
    x.push_back(-1000000);
    x.push_back(1000000);
    sort(All(x));
    vector<int> d;
    rep1(i,1,x.size()){
        d.push_back(x[i] - x[i - 1]);
    }
    sort(All(d),greater<int>());
    int res = 0;
    rep1(i, n+1, d.size()) res += d[i];
    cout << res << endl;
}

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

using namespace std;

int main(){
	string S, T;
	int a, b;
	cin >> S >> T;
	scanf("%d %d", &a, &b);
	string U;
	cin >> U;
	if (U == S) a--;
	if (U == T) b--;
	printf("%d %d\n", a, b);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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; }

string B,S,D;

int main(){
    cin>>B>>S>>D;
    cout << 'A' << S[0] << 'C' << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
P_Y_list = [list(map(int, input().split())) + [i] for i in range(M)]
P_Y_list.sort(key=lambda x: x[1])
count_P = [0] * (N+1)

# print(P_Y_list)
for idx, p_y in enumerate(P_Y_list):
    p = p_y[0]
    y = count_P[p_y[0]] + 1
    ans = str(p).zfill(6) + str(y).zfill(6)
    p_y += [ans]

    count_P[p_y[0]] += 1

P_Y_list.sort(key=lambda x: x[2])
for p_y in P_Y_list:
    print(p_y[3])

Measured memory_bytes: 100380
import sys
from collections import deque

input = sys.stdin.readline

N = int(input())
N_ = 2 * N + 6
N1, N2, N3, N4, N5 = range(N + 1, N + 6)
G = [[] for i in range(2 * N + 6)]
INF = 10 ** 12

def add_edge(fr, to, cap, cost) :
        G[fr].append([to, cap, cost, len(G[to])])
        G[to].append([fr, 0, -cost, len(G[fr]) - 1])

def flow(s, t, f) :
    ret = 0
    pre_v = [0] * N_
    pre_e = [0] * N_

    while f :
        dist = [INF] * N_
        dist[s] = 0
        que = deque([s])
        updated = [False] * N_
        updated[s] = True

        while que :
            v = que.popleft()
            if not updated[v] :
                continue

            updated[v] = False

            for i, (w, cap, cost, _) in enumerate(G[v]) :
                if cap > 0 and dist[w] > dist[v] + cost:
                    dist[w] = dist[v] + cost
                    pre_v[w], pre_e[w] = v, i
                    que.append(w)
                    updated[w] = True

        d, v = f, t
        while v != s :
            d = min(d, G[pre_v[v]][pre_e[v]][1])
            v = pre_v[v]

        f -= d
        ret += d * dist[t]

        v = t
        while v != s :
            e = G[pre_v[v]][pre_e[v]]
            e[1] -= d
            G[v][e[3]][1] += d
            v = pre_v[v]
    
    return ret

S = 0
for i in range(1, N + 1) :
    Rx, Ry, Rc = map(int, input().split())

    add_edge(0, i, Rc, 0)

    add_edge(i, N1, INF, -Rx - Ry)
    add_edge(i, N2, INF, Rx - Ry)
    add_edge(i, N3, INF, -Rx + Ry)
    add_edge(i, N4, INF, Rx + Ry)
    S += Rc

for i in range(N5, N_ - 1) :
    Bx, By, Bc = map(int, input().split())
    add_edge(N1, i, INF, Bx + By)
    add_edge(N2, i, INF, -Bx + By)
    add_edge(N3, i, INF, Bx - By)
    add_edge(N4, i, INF, -Bx - By)

    add_edge(i, N_ - 1, Bc, 0)

print(-flow(0, N_ - 1, S))


Measured memory_bytes: 120156
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string s; cin >> s;
    string ans = "";

    for(int i = 0; i<s.size(); i+=2){
        ans += s[i];
    }

    cout << ans << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll n;
	rl(n);
	VL arr(n);
	fr(i,0,n)
	{
		rl(arr[i]);
	}
	ll sum=0;
	fr(i,0,n)
	{
		fr(j,i+1,n)
		{
			sum+=arr[i]*arr[j];
		}
	}
	wl(sum);
	NL;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;
bool cmp(pair<int, int> a, pair<int, int> b)
{
	return a.second < b.second;
}
signed main()
{
	fastio();
	int n;
	cin >> n;
	if (n & 1)
	{
		cout << n * 2;
	}
	else
	{
		cout << n;
	}
	sp;
}

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

int n, u, k, v;
int d[101], f[101];
pair<int, vector<int>> G[101];

int ti = 1;

void dfs(int id) {
	d[id] = ti ++;

	vector<int>& adj = G[id].second;
	for (int i=0, l=adj.size(); i<l; ++i) {
		if ( ! d[adj[i]]) {
			dfs(adj[i]);
		}
	}
	f[id] = ti ++;
}

int main() {
	cin >> n;
	for (int i=0; i<n; ++i) {
		cin >> u >> k;
		G[u].first = u;
		while (k --) {
			cin >> v;
			G[u].second.push_back(v);
		}
	}
	for (int i=1; i<=n; ++i) {
		if ( ! d[i]) {
			dfs(i);
		}
	}

	for (int i=1; i<=n; ++i) {
		cout << i << " " << d[i] << " " << f[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1216