akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>

using namespace std;

typedef unsigned long long int ulli;
typedef long long int lli;

#define MAX(x, y) ((x) < (y) ? (y) : (x))

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

    int N;
    cin >> N;
    int *A;
    A = new int[N];

    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
    }

    long long int ret = 0;

    lli *d0 = new lli[N + 1];
    lli *d1 = new lli[N + 1];

    d0[0] = 0;
    d1[0] = -1000000001;

    for (int i = 0; i < N; i++)
    {
        d0[i + 1] = MAX(d0[i] + A[i], d1[i] - A[i]);
        d1[i + 1] = MAX(d0[i] - A[i], d1[i] + A[i]);
    }

    cout << d0[N] << "\n";

    return 0;
}



Measured memory_bytes: 2176
#include <iostream>
#include <vector>

using namespace std;

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

  for (int i = 1; i < N; i += 2) R[0] -= 2 * A[i];
  cout << R[0];
  for (int i = 1; i != N; ++i) {
    R[i] = 2 * A[i - 1] - R[i - 1];
    cout << " " << R[i];
  }
  cout << endl;
}


Measured memory_bytes: 4824
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n; cin >> n;
    vector<long long int> x(n), l(n);
    rep(i,n) cin >> x[i] >> l[i];
    vector<pair<long long int, int>> v(n);
    rep(i,n){
        v[i] = mp(x[i]+l[i], i);
    }
    sort(all(v));
    int ans = 0;
    long long int ls = -2000000000;
    rep(i,n){
        int id = v[i].second;
        if(x[id]-l[id] >= ls){
            ans++;
            ls = v[i].first;
        } 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <map>
#define INF (1LL<<60)
#define ll long long 
using namespace std;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, M, K, S; cin >> N >> M >> K >> S;
	ll P, Q; cin >> P >> Q;
	vector<vector<ll>> G(N + 1);
	vector<ll> cost(N + 1, P);
	vector<bool> kiken(N + 1, false);
	for (int i = 0; i < K;i++) {
		int k; cin >> k;
		kiken[k] = true;
		G[0].push_back(k);
		cost[k] = INF;
	}
	for (int i = 0; i < M;i++) {
		ll a, b; cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	queue<pair<ll, ll>> qq;qq.push({ 0,0 });
	vector<bool> f(N + 1, false);
	while (!qq.empty()) {
		auto p = qq.front(); qq.pop();
		ll s = p.first, n = p.second;
		if (n <= S) {
			for (auto e : G[s]) {
				if (f[e] == false) {
					f[e] = true;
					if(n != 0)cost[e] = Q;
					qq.push({ e,n + 1 });
				}
			}
		}
	}
	vector<ll> dist(N + 1, INF);

	queue<ll> q; q.push(1);
	dist[1] = 0;
	while (!q.empty()) {
		auto n = q.front(); q.pop();
		for (auto e : G[n]) {
			//if (kiken[e] == true)continue;
			if (dist[e] > dist[n] + cost[e]) {
				dist[e] = dist[n] + cost[e];
				q.push(e);
			}
		}
	}
	cout << dist[N] - cost[N] << endl;
}

Measured memory_bytes: 13464
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    ll x;
    cin>>x;
    string s = "";
    while(x) {
        int tmp = ( x%26 -1 + 26)%26;
        s += char('a' + tmp);
        if(x%26 == 0 ) x = x/26 - 1;
        else x /= 26;
    }
    reverse(s.begin() , s.end());
    cout<<s<<'\n';
    return 0;
}

Measured memory_bytes: 3652
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy


def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
def main():
    n,m=map(int,input().split())
    wa=[0]*n
    ac=[0]*n
    for i in range(m):
        a,b=input().split()
        a=int(a)
        if b=="WA" and ac[a-1]==0:
            wa[a-1]+=1
        elif b=="AC":
            ac[a-1]=1
    for i in range(n):
        if ac[i]==0:
            wa[i]=0
   # print(wa,ac)
    print(sum(ac),sum(wa))



if __name__ == "__main__":
    main()

Measured memory_bytes: 5108
//Disjoint Set
//Accepted
//uva 793,273,10685
//
#include<iostream>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n) 

class DisjointSet{
public:
 vector<int> rank,p;
 DisjointSet(){}
 DisjointSet(int size){
   rank.resize(size,0);
   p.resize(size,0);
 }
 void make_set(int x){
   p[x]=x;
   rank[x]=0;
 }
 void merge(int x,int y){
   link(find_set(x),find_set(y));
 }
 void link(int x,int y){
   if (rank[x]>rank[y]){
     p[y]=x;
   }else {
     p[x]=y;
     if ( rank[x] ==rank[y])rank[y]+=1;
   }
 }
 int find_set(int x){
   if (x != p[x])p[x]=find_set(p[x]);
   return p[x];
 }
};

const int N = 1000;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};
char m[N][N+10];

void update(int r,int c,int i,int j,DisjointSet & dj){
  if (m[i][j] == '#')return;
  rep(k,4){
    int nex = j+dx[k],ney = i+dy[k];
    if (ney == -1 || nex == -1 || ney == r || nex == c || m[ney][nex] == '#')continue;
    dj.merge(ney*c+nex,i*c+j);
  }
}

DisjointSet dj(1000*1000);
int solve(int r,int c,vector<int> & t,int gy,int gx){
  rep(i,r*c)dj.make_set(i);
  rep(i,r)rep(j,c)update(r,c,i,j,dj);
  if (dj.find_set(0) == dj.find_set(gy*c+gx))return 0;
  rep(i,t.size()){
    m[t[i]/c][t[i]%c] = '.';
    update(r,c,t[i]/c,t[i]%c,dj);
    if (dj.find_set(0) == dj.find_set(gy*c+gx))return i+1;
  }
  return -1;
}

main(){
  int r,c;
  while(cin>>c>>r && r){
    rep(i,r){
      cin>>m[i];
    }
    int gy,gx;
    rep(i,r)rep(j,c)if (m[i][j] == 't')gy = i,gx = j;
    int t;cin>>t;
    vector<int> ti(t);
    rep(i,t){
      int y,x;
      cin>>x>>y;
      ti[i] = y*c+x;
    }
    cout << solve(r,c,ti,gy,gx) << endl;
  }
  return 0;
}

Measured memory_bytes: 9684
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "
const int MXN = 104;


int main()
{
  LD dim;
  cin >> dim;

  LD res = (dim/3) * (dim/3) * (dim/3);
  printf("%.10Lf\n", res);

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;
typedef long long ll;


int main(){
        ll H, W, D, value;
        cin >> H >> W >> D;
        vector<vector<ll>> A(H*W, vector<ll>(2));
        vector<vector<ll>> Kyori(D);

        for(ll i=0; i<H; i++){
                for(ll k=0; k<W; k++){
                        cin >> value;
                        A[value-1][0] = i;
                        A[value-1][1] = k;
                        }
        }
        for(ll i=0; i<D; i++){
                Kyori[i].push_back(0);
        }
        for(ll i=D; i<W*H; i++){
                Kyori[i%D].push_back(labs(A[i][0] - A[i-D][0]) + labs(A[i][1] - A[i-D][1]));
        }
        for(ll i=0; i<D; i++){
                for(ll k=0; k<Kyori[i].size(); k++){
                        if(k==0)continue;
                        Kyori[i][k] = Kyori[i][k-1] + Kyori[i][k];
                }
        }

        ll Q;
        cin >> Q;
        vector<vector<ll>> X(Q, vector<ll>(2));
        for(ll i=0; i<Q; i++){
                cin >> X[i][0];
                cin >> X[i][1];
        }
        ll d, s, g;
        for(ll i=0; i<Q; i++){
                d = (X[i][0]-1)%D;
                s = (X[i][0]-1)/D;
                g = (X[i][1]-1)/D;
                cout << Kyori[d][g] - Kyori[d][s] << endl;
        }



}


Measured memory_bytes: 15744
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        s: chars,
    }

    let mut a: String = String::new();
    let mut b: String = String::new();

    for i in 0..4{
        if i==0 || i==1 {
            a.push(s[i]);
        } else {
            b.push(s[i]);
        }
    }

    let a_num: usize = a.parse().unwrap();
    let b_num: usize = b.parse().unwrap();

    if a_num==0 {
        if b_num==0 {
            println!("NA");
        } else if 1 <= b_num && b_num <= 12 {
            println!("YYMM");
        } else if 13 <= b_num && b_num <= 99 {
            println!("NA");
        }
    } else if 1 <= a_num && a_num <= 12 {
        if b_num==0 {
            println!("MMYY");
        } else if 1 <= b_num && b_num <= 12 {
            println!("AMBIGUOUS");
        } else if 13 <= b_num && b_num <= 99 {
            println!("MMYY");
        }
    } else if 13 <= a_num && a_num <= 99 {
        if b_num==0 {
            println!("NA");
        } else if 1 <= b_num && b_num <= 12 {
            println!("YYMM");
        } else if 13 <= b_num && b_num <= 99 {
            println!("NA");
        }
    }

}

Measured memory_bytes: 4352
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;




int main(){	
	string s;cin>>s;
	For(i,0,sz(s)){
		if(i&1){
			if(s[i]=='R'){
				cout<<"No"<<endl;
				return 0;
			}

		}
		else{
			if(s[i]=='L'){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;

	return 0;
}


Measured memory_bytes: 3628
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]
CD = [tuple(map(int, input().split())) for _ in range(N)]

for i in range(N):
    AB[i] = (AB[i][0] + 1000000, AB[i][1])
    CD[i] = (CD[i][0] + 1000000, CD[i][1])

AB.sort(key = max, reverse = True)
CD.sort(key = min)



counter = 0
for a, b in AB:
    for c, d in CD:
        if a < c and b < d:
            CD.remove( (c, d) )
            counter += 1
            break

print(counter)


Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
vector<int> data(10001,-1);

int root(int x){
  if(data[x] == -1)return x;
  else return data[x] = root(data[x]);
}

bool same(int x,int y){
  if(root(x) == root(y))return 1;
  else return 0;
}

int unite(int x,int y){
  if(!same(x,y))data[root(x)] = y;
  return 0;
}

int main(){
  int n,q,com,x,y;
  vector<int> ans;
  cin >> n >> q;
  while(data.size()>n+1)data.erase(data.begin());
  for(int i = 0;i < q;i++){
    cin >> com >> x >> y;
    if(com){
      if(same(x,y))ans.push_back(1);
      else ans.push_back(0);
    }
    else{
      unite(x,y);
    }
  }
  for(int i = 0;i < ans.size();i++)cout << ans[i] << endl;
}


Measured memory_bytes: 3396
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	char op;
	while(true){
		scanf("%d %c %d",&a,&op,&b);
		if(op == '?') break;
		switch(op){
		case '+':
			printf("%d\n",a+b);
			break;
		case '-':
			printf("%d\n",a-b);
			break;
		case '/':
			printf("%d\n",a/b);
			break;
		case '*':
			printf("%d\n",a*b);
			break;
		}
	}
}



Measured memory_bytes: 2628
#include <stdio.h>
#define MAX 100000
int A[MAX],n;

int main(){
  int i,k;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  k=partition(0,n-1);

  for(i=0;i<n;i++){
    if(i) printf(" ");
    if(i==k) printf("[");
    printf("%d",A[i]);
    if(i==k) printf("]");
  }
  printf("\n");
  return 0;
}

int partition(int k,int m){
  int i,j;
  int t;
  int x=A[m];
  i=k-1;
  for(j=k;j<m;j++){
    if(A[j]<=x){
      i++;
      t=A[i];A[i]=A[j];A[j]=t;
    }
  }
  t=A[i+1];A[i+1]=A[m];A[m]=t;
  return i+1;
}



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

left = [A[0]] * N
right = [A[-1]] * N

import math

for i in range(1, N):
  left[i] = math.gcd(left[i - 1], A[i])
  
for i in range(N - 2,-1,-1):
  right[i] = math.gcd(right[i + 1], A[i])
  
ans = 0
for i in range(N):
  if i == 0:
    if ans < right[1]:
      ans = right[1]
  elif i == N - 1:
    if ans < left[-2]:
      ans = left[-2]
  else:
    g = math.gcd(left[i - 1],right[i + 1])
    if ans < g:
      ans = g
print(ans)
  

Measured memory_bytes: 20676
#include <iostream>
#include <vector>

#define MAXNUM 500000
#define MAXVALUE 2000000000
int n;
int cnt;
int S[MAXNUM];
int L[MAXNUM/2 + 2];
int R[MAXNUM/2 + 2];


void merge(int *A, int left, int mid, int right){
    int nl = mid - left;
    int nr = right - mid;
    for (int i = 0; i < nl; i++) {
        L[i] = A[left+i];
    }
    for (int i = 0; i < nr; i++) {
        R[i] = A[mid+i];
    }
    L[nl] = MAXVALUE;
    R[nr] = MAXVALUE;
    int i = 0;
    int j = 0;
    for (int k = left; k < right; k++){
        cnt++;
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
        }
    }
}


void mergesort(int *A, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
//         std::cout << "==========" << std::endl;
//         std::cout << mid << std::endl;
//         std::cout << "==========" << std::endl;
        mergesort(A, left, mid);
        mergesort(A, mid, right);
        merge(A, left, mid, right);
    }
}



int main() {
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> S[i];
    }
    mergesort(S, 0, n);
    for (int i = 0; i < n; i++) {
        std::cout << S[i];
        if (i < n-1) {
            std::cout << " ";
        }
    }
    std::cout << std::endl << cnt << std::endl;
}

Measured memory_bytes: 6996
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if (a<c&&c<b)cout<<"Yes"<<endl;
  else if(a>c&&c>b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
    return 0;
}


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

int main()
{
    string s;
    cin>>s;
    int l=s.size();
    bool ans=false;
    for(int i=0;i<l-1;i++){
        if(s[i]==s[i+1]){
            ans=false;
            break;
        }
        else{
            ans=true;
        }
    }
    if(ans)  cout<<"Good";
    else     cout<<"Bad";
}


Measured memory_bytes: 256
#include <iostream> 
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
		int N, Q;
		string S;
		cin >> N >> Q;
		cin >> S;

		vector <int> l(Q), r(Q);
		for ( int i = 0; i < Q; i++ ) {
				cin >> l[i] >> r[i];
		}

		vector<int> cumulative_sum(N + 1, 0);

		for ( int i = 1; i < N; i++ ) {
				if ( S[i - 1] == 'A' && S[i] == 'C' ) {
						cumulative_sum[i + 1] = cumulative_sum[i] + 1;
				}
				else cumulative_sum[i + 1] = cumulative_sum[i];
		}

		for ( int i = 0; i < Q; i++ ) {
				int ans = cumulative_sum[r[i]] - cumulative_sum[l[i]];
				cout << ans << endl;
		}

		return 0;
}


Measured memory_bytes: 2176
#include<cstdio>
using namespace std;
#define N 100500
struct edge{int t,next;}ed[N*2];
int head[N],cnt=1,in[N],n,m,ct,mx,fg,a,b,vis[N];
void adde(int f,int t){ed[++cnt]=(edge){t,head[f]};head[f]=cnt;ed[++cnt]=(edge){f,head[t]};head[t]=cnt;in[f]++;in[t]++;}
void dfs(int u,int id)
{
	vis[u]=1;
	if(u==b)fg=1,vis[u]=0;
	if(u==a&&id)return;
	for(int i=head[u];i;i=ed[i].next)
	if(i!=id&&i!=(id^1)&&!vis[ed[i].t])dfs(ed[i].t,i);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d%d",&a,&b),adde(a,b);a=-1;
	for(int i=1;i<=n;i++)if(in[i]&1){printf("No\n");return 0;}else if(mx<in[i])mx=in[i];
	if(mx>4){printf("Yes\n");return 0;}
	for(int i=1;i<=n;i++)if(in[i]==4){ct++;if(a==-1)a=i;else b=i;}
	if(ct>2){printf("Yes\n");return 0;}
	if(ct==2)
	for(int i=head[a];i;i=ed[i].next)
	if(!vis[ed[i].t])
	{
		fg=0;
		dfs(ed[i].t,1);
		if(!fg){printf("Yes\n");return 0;}
	}
	printf("No\n");
}//

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

#define int long long
using P = pair<int, int>;

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

  vector<int> A(N), B(N);  
  vector<P> sum(N);
  for ( int i = 0; i < N; i++ ) {
    cin >> A[i] >> B[i];
    sum[i] = P(A[i]+B[i], i);
  }

  sort(sum.begin(), sum.end(), greater<P>());
  int ac = 0, bc = 0;
  for ( int i = 0; i < N; i++ ) {
    if ( i%2 == 0 ) {
      ac += A[sum[i].second];     
    } else {
      bc += B[sum[i].second];     
    }
  }

  cout << ac-bc << endl;
  
  return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
 
using namespace std;

int id[100000];
long long fact[100001];
long long inv[100001];
long long mod = 1e9 + 7;

long long pow(long long int a, long long b, long long mod) {
	if (b == 0) return 1;
	else if (b % 2 == 1) {
		return a * pow(a, b - 1, mod) % mod;
	} else {
		long long t = pow(a, b / 2, mod);
		return t * t % mod;
	}
}

void init(int n) {
	fact[0] = 1;
	inv[0] = 1;
	long long now = 1;
	for (int i = 1; i <= n; i++) {
		now = now * i % mod;
		fact[i]	= now;
		inv[i] = pow(fact[i], mod - 2, mod);
	}
}


int comb(int n, int k) {
	if (n < k) return 0;
	if (k <= 0) return 1;
	return ((fact[n] * inv[k]) % mod * inv[n - k]) % mod;
}

int main(int argc, char const *argv[]) {
	int n;
	cin >> n;
	vector<int> A;
	for (int i = 0; i < n + 1; i++) {
		int a;
		cin >> a;
		a--;
		A.push_back(a);
	}
	init(n + 1);
	fill_n(id, 100000, -1);
	int l, r;

	for (int i = 0; i < n + 1; i++) {
		if (id[A[i]] == -1) {
			id[A[i]] = i;
		} else {
			l = id[A[i]];
			r = i;
			break;
		}
	}
	for(int k = 1; k <= n + 1; k++) {
		cout << ((comb(n + 1, k) - comb(l + n - r, k - 1)) + mod) % mod  << endl;
	}

	return 0;
}

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

int K;

int gcd(int a, int b){
  int aa = max(a,b);
  int bb = min(a,b);
  if(aa % bb == 0) return bb;
  else return gcd(bb, aa % bb);
}


int main(){
  cin >> K;

  long long sum = 0;

  for(int i = 1; i <= K; i++){
    for(int j = 1; j <= K; j++){
      for(int k = 1; k <= K; k++){
        sum += gcd(gcd(i,j),k);
      }
    }
  }

  cout << sum << endl;
  return 0;
}
  

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();
    int n;
    cin >> n;
    vector<LL> a(n+1, 0);
    rep(i, n) cin >> a[i+1];
    rep(i, n) a[i+1] += a[i];

    LL ans = LLINF;
    rep(i, n) chmin(ans, abs(a[n]-2*a[i]));
    cout << ans<< endl;
}

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

void dump(vector<int> &data, string name) {
  cout << name << "= { ";
  for(int i = 0; i<data.size(); i++)
    cout << data[i] << " ";
  cout << "} " << endl;
}

int main() {
  int n;
  cin >> n;
  vector <ll> a(n);
  rep(i,n) cin >> a[i];
  vector<int> v;
  v.push_back(a[n-1]);
  for(int i=n-2; i>=0; i--){
    auto p = upper_bound(v.begin(), v.end(), a[i]);
    auto id = distance(v.begin(), p);
    if(id == v.size())
      v.push_back(a[i]);
    else {
      v[id] = a[i];
    }
  }    
  cout << v.size() << endl; 
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  string s, t;
  cin>>s>>t;
  int n=s.size(), m=t.size();
  int ans=1e9;
  REP(i, n-m+1){
    int cnt=0;
    REP(j, m){
      if(s[i+j]!=t[j]){
        ++cnt;
      }
    }
    CHMIN(ans, cnt);
  }
  cout<<ans<<'\n';
  return 0;
}


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

int main() {
  int N;   cin >> N;
  vector<int> d(N);
  for(int i=0; i<N; i++){
    cin >> d[i];
  }int ans = 0;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      ans = ans + d[i]*d[j];
    }
  }
  cout << ans << endl;
      

  
  }

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
int n;
double sum=0;
struct point{
	int x,y;
}P[9];
double dis(int a,int b){
	return sqrt((P[a].x-P[b].x)*(P[a].x-P[b].x)+(P[a].y-P[b].y)*(P[a].y-P[b].y));
}
int fac(int n){
	int f=1;
	while(n>0){
		f*=n--;
	}
	return f;
}
int visit[9];
void dfs(int k,int cnt,double d){
	if(cnt==n){
	sum+=d;
	return;
	}
	visit[k]=1;
	for(int i=1;i<=n;i++){
		if(!visit[i]){
			dfs(i,cnt+1,d+dis(k,i));
			visit[i]=0;
		}
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&P[i].x,&P[i].y);
	for(int i=1;i<=n;i++){
		memset(visit,0,sizeof(visit));
		dfs(i,1,0);
	}
	printf("%.10lf",sum/fac(n));
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int max(int a,int b,int c){
	if(a>b&&a>c)return a;
	else if(b>a&&b>c)return b;
	else return c;
}

int main() {
	int a,b,c,wa,WA;
	int p=0,q=0,r=0,s=0;
	for(int x=p;x==x;p++){
		a=0;
		b=0;
		c=0;
		cin>>a>>b>>c;
		wa=a+b+c;
		WA=a*a+b*b+c*c;
		if(2*max(a,b,c)>=wa)break;
		else if(2*max(a,b,c)*max(a,b,c)==WA)q++;
		else if(2*max(a,b,c)*max(a,b,c)<WA)r++;
		else s++;
		}
		cout<<p<<' '<<q<<' '<<r<<' '<<s<<'\n';
	return 0;
}


Measured memory_bytes: 3104
import itertools
import numpy as np

def main():
    n, m = map(int, input().split(" "))
    ans = 0
    for i in [n, m]:
        iterable = np.arange(start=1, stop=i+1, step=1).astype("str")
        ans += len(list(itertools.combinations(iterable, 2)))


    print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 12392
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

string A, B, C;
bool used1[8009], used2[8009], used3[8009];

int main() {
	cin >> A >> B >> C;

	// A と B の比較
	for (int i = 0; i <= 8000; i++) {
		used1[i] = true;
		for (int j = 0; j < A.size(); j++) {
			int idx = j - (i - 4000);
			if (idx < 0 || idx >= B.size() || A[j] == '?' || B[idx] == '?') continue;
			if (A[j] != B[idx]) used1[i] = false;
		}
	}

	// A と C の比較
	for (int i = 0; i <= 8000; i++) {
		used2[i] = true;
		for (int j = 0; j < A.size(); j++) {
			int idx = j - (i - 4000);
			if (idx < 0 || idx >= C.size() || A[j] == '?' || C[idx] == '?') continue;
			if (A[j] != C[idx]) used2[i] = false;
		}
	}

	// B と C の比較
	for (int i = 0; i <= 8000; i++) {
		used3[i] = true;
		for (int j = 0; j < B.size(); j++) {
			int idx = j - (i - 4000);
			if (idx < 0 || idx >= C.size() || B[j] == '?' || C[idx] == '?') continue;
			if (B[j] != C[idx]) used3[i] = false;
		}
	}

	int Answer = (1 << 30);

	// A が最初の場合
	for (int i = 0; i <= 4000; i++) {
		for (int j = 0; j <= 4000; j++) {
			int p1 = (i - 0) + 4000;
			int p2 = (j - 0) + 4000;
			int p3 = (j - i) + 4000;
			if (used1[p1] == true && used2[p2] == true && used3[p3] == true) {
				int L1 = 0 + A.size();
				int L2 = i + B.size();
				int L3 = j + C.size();
				Answer = min(Answer, max({ L1, L2, L3 }));
			}
		}
	}

	// B が最初の場合
	for (int i = 0; i <= 4000; i++) {
		for (int j = 0; j <= 4000; j++) {
			int p1 = (0 - i) + 4000;
			int p2 = (j - i) + 4000;
			int p3 = (j - 0) + 4000;
			if (used1[p1] == true && used2[p2] == true && used3[p3] == true) {
				int L1 = i + A.size();
				int L2 = 0 + B.size();
				int L3 = j + C.size();
				Answer = min(Answer, max({ L1, L2, L3 }));
			}
		}
	}

	// C が最初の場合
	for (int i = 0; i <= 4000; i++) {
		for (int j = 0; j <= 4000; j++) {
			int p1 = (j - i) + 4000;
			int p2 = (0 - i) + 4000;
			int p3 = (0 - j) + 4000;
			if (used1[p1] == true && used2[p2] == true && used3[p3] == true) {
				int L1 = i + A.size();
				int L2 = j + B.size();
				int L3 = 0 + C.size();
				Answer = min(Answer, max({ L1, L2, L3 }));
			}
		}
	}

	cout << Answer << endl;
	return 0;
}

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


int main() {
  int l, r;
  cin >> l >> r;
  int ans = 0;
  for(int a = 1; a < 10; a++){
    for(int b = 0; b < 10; b++){
      for(int c = 0; c < 10; c++){
        int sum = 10001*a + 1010*b +100*c;
        if(sum >= l && sum <= r){
          ans++;
        }
      }
    }
  }
  
  cout << ans << endl;
    
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << b/c-(a-1)/c << "\n" ;
  
  return 0;
}

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;

	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		var t = Console.ReadLine();
		
		var u = s + t[t.Length-1];
		if(u == t && u.Length == t.Length)
		{
			Console.WriteLine("Yes");
		}
		else
			Console.WriteLine("No");
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 25884
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string s; cin >> s;
	sort(s.begin(), s.end());
	if (s.substr(0, 1) == s.substr(1, 1) && s.substr(1, 1) != s.substr(2, 1) && s.substr(2, 1) == s.substr(3, 1)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
def c_multiple_Clocks(N, T):
    def gcd(a, b):
        while b > 0:
            a, b = b, a % b
        return a

    def lcm(a, b):
        return (a * b) // gcd(a, b)

    ans = 1
    for x in T:
        ans = lcm(ans, x)
    return ans

N = int(input())
T = [int(input()) for _ in range(N)]
print(c_multiple_Clocks(N, T))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <math.h>
#include<iomanip>
using namespace std;
typedef long long ll;

int N, K;

int main() {
	cin >> N >> K;
	cout << fixed << setprecision(20);
    if (N < K) {
        long double sum = 0;
        for (int i = 1; i <= N; i++) {
            long double a = log(K)/log(2) - log(i)/log(2);
            if (a == (int)a) {
                sum += pow(0.5, (int)a);
            }
            else sum += pow(0.5, (int)a+1);
        }
        cout << sum/N << endl;
    }
    else {
        long double sum = 0;
        for (int i = 1; i <= K-1; i++) {
            long double a = log(K)/log(2) - log(i)/log(2);
            if (a == (int)a) {
                sum += pow(0.5, (int)a);
            }
            else sum += pow(0.5, (int)a+1);
        }
        for (int i = K; i <= N; i++) sum += 1;
        cout << sum/N << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)

const ll mod = (ll)998244353;
const ll maxn = (ll)2e5+5;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e18;

ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};


void solve(){
	
	ll x , y;
	cin >> x >> y;
	if(y <= 4*x && y >= 2*x && y%2 == 0) cout << "Yes";
	else cout << "No";
	
	return;
}


int main() {
   
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll T;
    T=1;
    //cin >> T;
    //scanf("%lld",&T);
    ll CT = 0;
    //work();
    while(T--){
    	//cout << "Case " << ++CT <<": " ;
    	//printf("Case %lld: ",++CT);
		solve();
	}
    
    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	long long a, b;
	char op;
	scanf("%lld %c %lld", &a, &op, &b);
	if(op == '+')
		printf("%lld\n", a + b);
		else
			printf("%lld\n", a - b);

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=-mod;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

//関数
//最大公約数
long long gcd(long long m,long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m,long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x,long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//nCr
long long C(long long n, long long r);
//nCr (mod)
long long modC(long long n, long long r) {
    vector<long long> f(n+1),inv(n+1),invf(n+1);
    f[0]=f[1]=1;
    invf[0]=invf[1]=1;
    inv[1]=1;
    for (long long i=2;i<n+1;i++) {
        f[i]=(i*f[i-1])%mod;
        inv[i]=mod-((mod/i)*inv[mod%i])%mod;
        invf[i]=(inv[i]*invf[i-1])%mod;
    }
    long long cmb=f[n]*(invf[r]*invf[n-r]%mod)%mod;
    if (n>=r) return cmb;
    else return 0;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(N);
  if(N%2==0)
    cout<<1.0/2;
  else
    cout<<(N+1)/2.0/N;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(std::string S)
{
    int ans = 0;
    bool con = false;
    int tmp = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')
        {
            if (con)
            {
                tmp++;
            }
            else
            {
                con = true;
                tmp = 1;
            }
        }else{
            con = false;
            ans = max(ans,tmp);
            tmp = 0;
        }
    }
    ans = max(ans,tmp);
    cout << ans << endl;
}

int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 1e5

using namespace std;

long long l,a,b,c,n;

int main(){
    cin>>n;
    vector<long long>v(n+1,0);
    vector<long long>l(n,0);

    for (int i=0; i<n; i++){
        cin>>l[i];
        v[l[i]]++;
    }

    for (int i=1; i<=n; i++){
        a+=(v[i]*(v[i]-1))/2;
    }
    for (int i=0; i<n; i++){
        cout<<a-v[l[i]]+1<<endl;
    }
}


Measured memory_bytes: 6432
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,m;
  cin >> n;
  vector<int> t(n);
  int i;
  for(i=0;i<n;i++) cin >> t[i];
  int sum = 0;
  for(i=0;i<n;i++) sum += t[i];
  cin >> m;
  vector<int> p(m);
  vector<int> x(m);
  for(i=0;i<m;i++) cin >> p[i] >> x[i];
  for(i=0;i<m;i++) cout << sum-t[p[i]-1]+x[i] << "\n";
  return 0;
}

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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;

    for (int i = 1; i < 10; i++) {
        if (n%i == 0 && 1 <= n/i && n/i <= 9) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3644
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap |> sort
	f = 0
	for i in 2:n
		if a[i]==a[i-1]
			f = 1
		end
	end
	println(f==0?"YES":"NO")
end

main()

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


using namespace std;

using ll = long long;


int main() {
    ll N, X, Y;
    cin >> N >> X >> Y;

    vector<vector<ll>> graph(N + 1);
    for (ll i = 1; i < N; i++) {
        graph[i].push_back(i + 1);
        graph[i + 1].push_back(i);
    }
    graph[X].push_back(Y);
    graph[Y].push_back(X);

    vector<ll> cnt(N + 1, 0);
    for (ll i = 1; i < N; i++) {
        vector<bool> discovered(N + 1, false);
        vector<ll> d(N + 1, 0);
        queue<ll> q;

        discovered[i] = true;
        d[i] = 0;
        q.push(i);
        while (!q.empty()) {
            ll now = q.front();
            q.pop();

            for (ll e : graph[now]) {
                if (discovered[e])
                    continue;
                discovered[e] = true;
                q.push(e);
                d[e] = d[now] + 1;
            }
        }

        for (ll j = i + 1; j <= N; j++) {
            cnt[d[j]]++;
        }
    }

    for (ll i = 1; i < N; i++) {
        cout << cnt[i] << endl;
    }
}


Measured memory_bytes: 3784
#include<stdio.h>
int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	if (a < b) {
		printf("a < b\n");
	}
	else if (a > b) {
		printf("a > b\n");
	}
	else if (a == b) {
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn digit_sum(n:i64) -> i64{
    let mut a = n;
    let mut res = 0;
    let mut ten = 1;
    loop {
        res += a%(ten*10)/ten;
        a -= a%ten;
        if a==0 {
            break;
        }
        ten*=10;
    }
    // println!("{} {}", n, res);
    res
}
fn main() {
    input!{
        n:i64
    }
    let mut ans: i64 = 1<<50;
    for a in 1..n {
        ans = std::cmp::min(ans, digit_sum(a) + digit_sum(n-a));
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
N,K=map(int,input().split())
D=[]
A=[]
for i in range(K):
    D.append(int(input()))
    A+=list(map(int,input().split()))
A=list(set(A))
A.sort()
ans=0
for i in range(1,N+1):
    if i not in A:
        ans+=1
print(ans)



Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <bitset>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll p[15], c[15], d, g;
	cin >> d >> g;
	for(int i = 0; i < d; i++)
		cin >> p[i] >> c[i];
	ll res = INF;
	for(int bit = 0; bit < (1<<d); bit++)
	{
		ll sum = 0;
		ll num = 0;
		for(int i = 0; i < d; i++)
		{
			//cout << bitset<8>(bit) << " & " << bitset<8>(1<<i) << " = " << bitset<8>(bit & 1<<i) << " ";
			if(bit & (1<<i))
			{
				sum += c[i] + p[i] * 100 * (i + 1);
				num += p[i];
			}
		}
		if(sum >= g) res = min(res, num);
		else
		{
			for(int i = d - 1; i >= 0; i--)
			{
				if(bit & (1<<i)) continue;
				for(int j = 0; j < p[i]; j++)
				{
					if(sum >= g) break;
					sum += 100 * (i + 1);
					num++;
				}
			}
			res = min(res, num);
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
eval'N,A,B='+`dd`.split*?,
A*=t=(A+B).pow -2+M=10**9+7,M
B*=t
a=A.pow N,M
b=B.pow N,M
s=0
[g=1,*(1...N).map{g=g*_1%M}].map{s+=_1.pow(M-2,M)*(a+b)*100*t=t*N%M
N+=1
a=a*B%M
b=b*A%M}
p s%M

Measured memory_bytes: 22936
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )

using namespace std;
const long long INF = 1LL << 60;

ll N, m[100010],y[100010];
ll sum = 0;
int main(){
  cin >> N;
  rep(i,N+1) cin >> m[i];
  rep(i,N) cin >> y[i];
  m[N+1] = 0;
  rep(i,N+1){
    if(m[i] <= y[i]){
      sum += m[i];
      y[i] -= m[i];
      if(m[i+1] <= y[i]){
        sum += m[i+1];
        m[i+1] = 0;
      }else{
        sum += y[i];
        m[i+1] -= y[i];
      }
    }
    else sum += y[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1792
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

class UnionFind {
	vector<int>parent;
	vector<int>rank;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v)return;
		if (rank[u] < rank[v])parent[u] = v;
		else {
			parent[v] = u;
			if (rank[u] == rank[v])rank[u]++;
		}
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
};

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	while (cin >> N >> M, N) {
		UnionFind uf(N);
		for (int i = 0; i < M; i++) {
			cin >> L >> R;
			L--, R--;
			uf.Unite(L, R);
		}
		vector<int>v(N);
		for (int i = 0; i < N; i++)v[uf.Find(i)]++;
		int num = 0;
		for (int i = 0; i < N; i++) {
			if (v[i] >= 1)num++;
		}
		if (num == N) {
			cout << power(2, N, MOD) << endl;
		}
		else {
			cout << power(2, num, MOD) + 1 << endl;
		}
	}
}


Measured memory_bytes: 4268