akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;

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

/*------------------------------------/
for library*/

constexpr double TL = 1.99;
constexpr ll CYCLES_PER_SEC = 2800000000;
struct Timer {
  ll start;
 
  Timer() { reset(); }
 
  void reset() { start = getCycle(); }
 
  inline double get() { return (double) (getCycle() - start) / CYCLES_PER_SEC; }
 
  inline ll getCycle() {
    unsigned low, high;
    __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
    return ((ll) low) | ((ll) high << 32);
  }
};

uint32_t XorShift(void) {
	static uint32_t x = 123456789;
	static uint32_t y = 362436069;
	static uint32_t z = 521288629;
	static uint32_t w = 88675123;
	uint32_t t;
 
	t = x ^ (x << 11);
	x = y; y = z; z = w;
	return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}

double Prob(void){
	double ret = (double)XorShift() / UINT_MAX;
	return ret;
}

class Status{
public:
};
/*------------------------------------*/
int D = 365;
int c[30];
int s[400][30];
void input(){
    cin >> D;
    rep(i,26)cin >> c[i];
    rep(d,D)rep(i,26)cin >> s[d][i];
}

void simulate(){
    /*
    Timer timer;
    timer.reset();
    while(1){
        auto now_time = timer.get();
        if(now_time >= TL) break;
        auto rest_time = TL - now_time;
    }*/
    rep(i,D){
        cout << XorShift() % 26 + 1 << endl;
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    input();
    simulate();
}


Measured memory_bytes: 3740
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int ININF = 1000000;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    X--;
    Y--;
    vector<int> res(N);
    rep(i, 0, N) {
        rep(j, i + 1, N) {
            int k1 = j - i;
            int k2 = abs(X - i) + 1 + abs(Y - j);
            int k3 = abs(Y - i) + 1 + abs(X - j);
            int k = min({k1, k2, k3});
            res[k]++;
        }
    }
    rep(i, 1, N) { cout << res[i] << endl; }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(int i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define vinn(n,v) int n;cin>>n;vector<int>v(n);loop(i,0,n)cin>>v[i];
#define vinm(n,m,v) int n,m;cin>>n>>m;vector<int>v(n);loop(i,0,n)cin>>v[i];
#define debug(x) cerr<<#x<<" : "<<x<<endl;
mt19937 rd(time(0)); // i = rd%n
signed main() 
{
    fastio();

    int n;
    cin>>n;
    int cnt = 0;
    loop(i,1,n+1)
    {

        if(!(i%3) || !(i%5))continue;

        cnt+=i;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3656
n,k=map(int,input().split())
h=sorted(list(int(input()) for _ in range(n)))

s=[0]*n
for i in range(1,n):
    s[i]=s[i-1]+(h[i]-h[i-1])
ans=float("inf")
for i in range(n-k+1):
    ans=min(ans,s[i+k-1]-s[i])
print(ans)

Measured memory_bytes: 52056
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    bool operator<(const P& p) const {
        auto t = strcmp(s0, p.s0);
        return t != 0 ? t < 0 : strcmp(s1, p.s1) < 0;
    }
    char s0[19], s1[19];
};

template <class F>
int lower_bound(int i0, int i1, F f) {
    while (i0 < i1) {
        int i = (i0 + i1) / 2;
        if (f(i)) i1 = i; else i0 = i + 1;
    }
    return i0;
}

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

    char s[40];
    cin >> s;

    int p[26] = {};
    for (int i = 0; i < n * 2; i++) {
        p[s[i] - 'a']++;
    }

    for (int j = 0; j < 26; j++) {
        if (p[j] % 2 != 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    int m = 1 << n;
    vector<P> a(m);
    for (int k = 0; k < m; k++) {
        int c0 = 0, c1 = 0;
        P p;
        memset(&p, 0, sizeof(p));
        for (int i = 0; i < n; i++) {
            if (k & 1 << i) {
                p.s0[c0++] = s[i];
            } else {
                p.s1[c1++] = s[i];
            }
        }
        reverse(p.s1, p.s1 + c1);
        a[k] = p;
    }
    sort(a.begin(), a.end());

    ll r = 0;
    for (int kk = 0; kk < m / 2; kk++) {
        int c0 = 0, c1 = 0;
        P p;
        memset(&p, 0, sizeof(p));
        for (int i = 0; i < n; i++) {
            if (kk & 1 << i) {
                p.s0[c0++] = s[i + n];
            } else {
                p.s1[c1++] = s[i + n];
            }
        }
        reverse(p.s0, p.s0 + c0);

        int k0 = lower_bound(0, m, [&](int k) {
            return !(a[k] < p);
        });
        int k1 = lower_bound(0, m, [&](int k) {
            return p < a[k];
        });
        r += k1 - k0;
    }

    cout << r * 2 << endl;

    // Sの長さは2N 赤青N個ずつ塗る Sの各英小文字は偶数個でなければならない
    // 赤と青は反対から読むというのが重要 左右はどっちでもいい 赤と青を入れ替えても変わらない つまりつねに偶数通り

    return 0;
}

Measured memory_bytes: 9984
n,k=map(int, input().split())
a = list(map(int, input().split()))
t = [0 for i in range(n)]
now = a[0] -1
t[0] = 1
root = [0]
for i in range(0,k):
    if t[now] == 0:
        root.append(now)
        t[now] = 1
        now = a[now] -1
    else:
        break
if len(root)- 1 == k:
    print(root[-1]+1)
else:
    for i in range(0,len(root)):
        if root[i] == now:
            b = len(root) - i
            c = (k-i)%b
            print(root[i+c]+1)

Measured memory_bytes: 32376
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
const int MOD = 1000000007;
const int oo = 1000000001;
const int N = 2111;

string a , b;
int n, x[N];

vector<int>ones;

int nxt(int go) {
	vector<int>::iterator it = lower_bound(ones.begin(), ones.end(), go);
	if (it == ones.end())
		return n - go + ones[0];
	return *it - go;
}
int prv(int go) {
	vector<int>::iterator it = upper_bound(ones.begin(), ones.end(), go);
	if (it == ones.begin())
		return go + n - ones.back();
	return go - *(--it);
}
int main() {
	//freopen("input.txt", "r", stdin);
	cin >> a >> b;

	n = (int) a.size();
	int res = oo;
	for (int i = 0; i < b.size(); ++i)
		if (b[i] == '1')ones.push_back(i);
	if (ones.size() == 0) {
		int me = 0;
		for (int i = 0 ; i < a.size(); i++) {
			if (a[i] == '1')++me;
		}
		if (me == 0) {
			puts("0");
		} else {
			puts("-1");
		}
		return 0;
	}
	for (int d = -n ; d <= n-1; ++d) {
		memset(x, 0, sizeof x);
		int cnt = 0;
		for (int i = 0; i < a.size(); ++i) {
			int newJ = (i + d + n)%n;
			if (a[i] != b[newJ]) {
				++cnt;
				int nn = nxt(i);
				int pp = prv(i);
				x[nn] = max(x[nn], pp);
			}
		}
		if(!cnt){
			res = min(res,abs(d));
			continue;
		}
		int lft = 0;
		int best = oo, l = -oo, r = -oo;
		for (int rig = n - 1 ; rig >= 0 ; rig--) {
			res = min(res, 2 * (max(d,rig) - min(-lft,d)) - abs(d) + cnt);
			lft = max(lft, x[rig]);
		}
	}
	cout << res << endl;
	return 0;
}

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

int main() {
	int N, ans = 0;
	cin >> N;
	vector<int> A(N);
	for (int& i : A) cin >> i;
	for (int i = 0; i < N - 1; ++i) {
		for (int j = N - 1; j > i; --j) {
			if (A[j - 1] > A[j]) {
				++ans;
				swap(A[j - 1], A[j]);
			}
		}
	}
	for (int i = 0; i < N - 1; ++i) cout << A[i] << ' ';
	cout << A[N - 1] << endl << ans << endl;
}


Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

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

#define MAX 110000

int main(void) {
  string t;
  string anss[50];
  cin >> s;
  cin >> t;

  if (s.length() < t.length()) {
	cout << "UNRESTORABLE" << endl;
	return 0;
  }

  RFOR(i,t.length()-1, s.length()) {
	flag = true;
	FOR(j, 0, t.length()) {
	  if (!(s[i - j] == '?' || s[i - j] == t[t.length() - j - 1])) {
		flag = false;
		break;
	  }
	}
	if (flag) {
	  anss[cnt] = s;
	  FOR(j, 0, t.length()) {
		anss[cnt][i - j] = t[t.length() - j - 1];
	  }
	  cnt++;
	  break;
	}
  }

  FOR(i, 0, cnt) {
	FOR(j, 0, anss[i].length()) {
	  if (anss[i][j] == '?') anss[i][j] = 'a';
	}
  }

  if (cnt > 0) s = anss[0];

  FOR(i, 0, cnt) {
	s > anss[i] ? s = anss[i] : s = s;
  }

  if (cnt > 0) {
	cout << s << endl;
  }
  else {
	cout << "UNRESTORABLE" << endl;
  }

  return 0;
}

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

bool is_prime(int k)
{
	for(int j=2;j*j<=k;j++){
		if(k%j==0) {
			return false;
		}
	}
    return true;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main()
{
    stringstream ss;
    // 入力
    string S;
    cin>>S;
    ll K;
    cin>>K;
    int letid=0;
    while(K>0){
    	if(S[letid]=='1'){
    		K=K-1;
    		letid++;
    		if(K==0) {
    			cout<<1<<endl;
    			return 0;
    		}
    	} else {
    		cout<<S[letid]<<endl;
    		return 0;
    	}
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 998244353;
constexpr long long inf = 3e18;

template<typename Monoid,typename OperatorMonoid,typename F,typename G,typename H>
struct Segtree{
	int size=1;
	vector<Monoid>dat;
	vector<OperatorMonoid>lazy;
	const F f;
	const G g;
	const H h;
	Monoid M;
	OperatorMonoid OM;
	void set(int a,Monoid x){
		dat[a+size-1]=x;
	}
	void init(){
		for(int i=size-2;i>=0;i--){
			dat[i]=f(dat[i*2+1],dat[i*2+2]);
		}
	}
	void eval(int k,int l,int r){
		if(lazy[k]!=OM){
			dat[k]=g(dat[k],lazy[k],(r-l));
			if(r-l>1){
				lazy[2*k+1]=h(lazy[2*k+1],lazy[k]);
				lazy[2*k+2]=h(lazy[2*k+2],lazy[k]);
			}
			lazy[k]=OM;
		}
	}
	void update(int a,int b,OperatorMonoid M,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		eval(k,l,r);
		if(r<=a||b<=l)return;
		if(a<=l&&r<=b){
			lazy[k]=h(lazy[k],M);
			eval(k,l,r);
			return;
		}
		update(a,b,M,k*2+1,l,(l+r)/2);
		update(a,b,M,k*2+2,(l+r)/2,r);
		dat[k]=f(dat[k*2+1],dat[k*2+2]);
	}
	Monoid query(int a,int b,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		eval(k,l,r);
		if(r<=a||b<=l)return M;
		if(a<=l&&r<=b)return dat[k];
		Monoid lv=query(a,b,k*2+1,l,(l+r)/2);
		Monoid rv=query(a,b,k*2+2,(l+r)/2,r);
		return f(lv,rv);
	}
	template<class C>
	int minLeft(int a,int b,C &check,Monoid x,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		eval(k,l,r);
		if(r<=a||b<=l||!check(dat[k],x))return -1;
		if(r-l==1)return l;
		int lv=minLeft(a,b,check,x,k*2+1,l,(l+r)/2);
		if(lv!=-1)return lv;
		return minLeft(a,b,check,x,k*2+2,(l+r)/2,r);
	}
	template<class C>
	int maxRight(int a,int b,C &check,Monoid x,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		eval(k,l,r);
		if(r<=a||b<=l||!check(dat[k],x))return -1;
		if(r-l==1)return l;
		int rv=maxRight(a,b,check,x,k*2+2,(l+r)/2,r);
		if(rv!=-1)return rv;
		return maxRight(a,b,check,x,k*2+1,l,(l+r)/2);
	}
	Segtree(int x,F f,G g,H h,Monoid M,OperatorMonoid OM)
	:f(f),g(g),h(h),M(M),OM(OM){
		while(size<x)size*=2;
		dat.resize(size*2-1,M);
		lazy.resize(size*2-1,OM);
	}
};

struct S{
	int a,b,c;
	int f(){return (a*b+c)%mod;}
};
auto f=[](S a,S b)->S{return S{(a.f()+b.f())%mod,1,0};};
auto g=[](S a,P b,int sz)->S{return S{a.a,a.b*b.first%mod,(a.c*b.first+b.second*sz)%mod};};
auto h=[](P a,P b)->P{return P(a.first*b.first%mod,(a.second*b.first+b.second)%mod);};

signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N,Q;
	cin>>N>>Q;
	Segtree<S,P,decltype(f),decltype(g),decltype(h)>segtree(N,f,g,h,S{0,1,0},P(1,0));
	rep(i,N){
		int a;cin>>a;
		segtree.set(i,S{a,1,0});
	}
	segtree.init();
	while(Q--){
		int t;cin>>t;
		if(!t){
			int l,r,b,c;cin>>l>>r>>b>>c;
			segtree.update(l,r,P(b,c));
		}else {
			int l,r;cin>>l>>r;
			cout<<segtree.query(l,r).f()<<"\n";
		}
	}
}

Measured memory_bytes: 44132
#include<cstdio>
#include<vector>
#include<stack>
using namespace std;
int n;
vector<int> a[100000];
int b[100000];
void dfs(int r,int c){
    stack<int> x;
    x.push(r);
    b[r]=c;
    while(!x.empty()){
        int s=x.top();
        x.pop();
        for(int i=0;i<a[s].size();i++){
            int v=a[s][i];
            if(b[v]==-1){
                b[v]=c;
                x.push(v);
            }
        }
    }
}
void pengyou(){
    int id =1;
    for(int i=0;i<n;i++)b[i]=-1;
    for(int i=0;i<n;i++){
        if(b[i]==-1)dfs(i,id++);
    }
}

int main(){
    int m;
    int s,t;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d%d",&s,&t);
        a[s].push_back(t);
        a[t].push_back(s);
    }
    pengyou();
    int q;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d%d",&s,&t);
        if(b[t]==b[s])printf("yes\n");
        else printf("no\n");


    }

}

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

using namespace std;

int main() {

    int n;
    cin >> n;

    long double ans = 0;

    for (int i = 0; i < n; ++i) {
        long double cur;
        cin >> cur;
        ans += (1 / cur);
    }

    printf("%.10Lf\n", 1 / ans);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		while(true){
			String[] input = br.readLine().split(" ");
			int m = Integer.parseInt(input[0]);
			int f = Integer.parseInt(input[1]);
			int r = Integer.parseInt(input[2]);

			if( m==-1 && f==-1 && r==-1 ) break;

			if( m==-1 || f==-1 || (m+f) < 30){
				sb.append("F\n");
			}else if( (m+f)>=30 && (m+f)<50 && r<50 ){
				sb.append("D\n");
			}else if( (m+f)>=30 && (m+f)<50 && r>=50 ){
				sb.append("C\n");
			}else if( (m+f)>=50 && (m+f)<65 ){
				sb.append("C\n");
			}else if( (m+f)>=65 && (m+f)<80 ){
				sb.append("B\n");
			}else if( (m+f)>=80 ){
				sb.append("A\n");
			}
		}

		System.out.print(sb);
	}
}

Measured memory_bytes: 24140
N, Q = map(int,input().split())
S = input()
acc = [0]*N
for i in range(N-1):
    if S[i:i+2] == "AC":
        acc[i+1] += acc[i]+1
    else:
        acc[i+1] = acc[i]
ans = 0
for i in range(Q):
    l,r = map(int,input().split())
    print(acc[r-1]-acc[l-1])

Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef tuple<int,int,int> tii;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

int main(){
  int N;
  cin >> N;
  int cnt = 0;
  for(int i=0;i<N;i++){
    int x,y;
    cin >> x >> y;
    if(x==y) cnt++;
    else cnt = 0;
    if(cnt==3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl; 
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	int N,K;cin>>N>>K;
	vector<int>p(N);
	for(int i=0;i<N;i++)cin>>p[i];
	
	vector<int>sums(N+1);
	for(int i=1;i<=N;i++)
	{
		sums[i] = sums[i-1] + (1+p[i-1]);
	}
	
	int M = 0;
	for(int i=K;i<=N;i++)
	{
		M = max(M, sums[i]-sums[i-K]);
	}
	
	cout<<fixed<<setprecision(7)<<M*0.5<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
signed main(){
	vp a,b,c;
	char q;int w;
	while(cin>>q){
		if(q=='$')break;
		cin>>w;
		a.pb({q,w});
	}
	while(cin>>q){
		if(q=='$')break;
		cin>>w;
		b.pb({q,w});
	}
	while(cin>>q){
		if(q=='$')break;
		cin>>w;
		c.pb({q,w});
	}
	if(b.size()==1){
		rep(i,a.size())if(a[i].first==b[0].first&&a[i].second>=b[0].second){
			vp out;
			rep(j,i)out.pb(a[j]);
			rep(j,c.size())out.pb(c[j]);
			if(a[i].second!=b[0].second)out.pb({a[i].first,a[i].second-b[0].second});
			loop(j,i+1,a.size())out.pb(a[j]);
			a=out;
			break;
		}
	}else{
		rep(i,a.size()){
			if(a.size()-i<b.size())break;
			bool h=true;
			loop(j,i+1,i+b.size()-1){
				if(a[j]!=b[j-i])h=false;
			}
			if(!h)continue;
			if(a[i].first!=b[0].first||a[i].second<b[0].second)continue;
			if(a[i+b.size()-1].first!=b[b.size()-1].first||a[i+b.size()-1].second<b[b.size()-1].second)continue;
			vp out;
			rep(j,i)out.pb(a[j]);
			if(a[i].second>b[0].second)out.pb({a[i].first,a[i].second-b[0].second});
			rep(j,c.size())out.pb(c[j]);
			if(a[i+b.size()-1].second>b[b.size()-1].second)out.pb({a[i+b.size()-1].first,a[i+b.size()-1].second-b[b.size()-1].second});
			loop(j,i+b.size(),a.size())out.pb(a[j]);
			a=out;
			break;
		}
	}
	rep(i,a.size()-1)if(a[i].first==a[i+1].first){
		a[i].second+=a[i+1].second;
		a.erase(a.begin()+i+1);
		i--;
	}
	rep(i,a.size())cout<<(char)a[i].first<<" "<<a[i].second<<" ";cout<<"$"<<endl;
}
/*
R 100 L 20 E 10 $
R 5 L 10 $
X 20 $

A 3 B 3 A 3 $
A 1 B 3 A 1 $
A 2 $
*/




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

int main() {
  int arr[5], k;
  for(int& i : arr) cin >> i;
  cin >> k;
  
  bool flag = true;
  for(int i = 0; i < 5; i++)
    for(int j = i+1; j < 5; j++)
      flag = flag && (arr[j] - arr[i] <= k);
  cout << (flag ? "Yay!" : ":(");
}

Measured memory_bytes: 888
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

const int N=1e5+5;
int L[N],R[N],mm[N];
int n;

bool inrange(int num){
	if(num<0||num>=n)return false;
	return true;
}

int main(){	
	scanf("%d",&n);
	FER(i,0,n)scanf("%d",&mm[i]);
	L[0]=mm[0];
	FER(i,0,n)L[i]=__gcd(L[i-1],mm[i]);
	R[n-1]=mm[n-1];
	IFR(i,n-2,0)R[i]=__gcd(R[i+1],mm[i]);
	int ret=0;
	FER(i,0,n){
		int ans=0;
		if(inrange(i-1))ans=__gcd(ans,L[i-1]);
		if(inrange(i+1))ans=__gcd(ans,R[i+1]);
		ret=max(ret,ans);
	}
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long A, long long B){
  if(1<=A&&A<=9&&1<=B&&B<=9){
    cout<<A*B<<endl;
  }else{
    cout<<-1<<endl;
  }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
long long gcd(long long a, long long b) { return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b) { return a/gcd(a,b)*b;}

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  rep (i, s.size()) {
    cout << 'x';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int n,m,a,b;
vector<P> t,u;


vector<P> func(vector<P> t){
  sort(t.begin(),t.end());
  t.push_back(P(1e9,0));
  int size=t.size();
  vector<P> res;
  for(int i=0;i+1<size;i++){
    if(t[i].second<t[i+1].first){
      res.push_back(t[i]);
    }else{
      t[i+1].first=t[i].first;
      t[i+1].second=max(t[i+1].second,t[i].second);
    }
  }
  return res;
}

int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>a>>b;
    t.push_back(P(a,b));
  }
  t=func(t);
  int ans=n+1;
  for(int i=0;i<(int)t.size();i++)
    ans+=(t[i].second-t[i].first)*2;
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

int main(){
    int h,w; cin>>h>>w;
    vector<string> G(100);
    for(int i=0;i<h;i++) cin>>G[i];
    int dx[8] = {1,1,1,0,-1,-1,-1,0};
    int dy[8] = {-1,0,1,1,1,0,-1,-1};
    for(int y=0;y<h;y++){
        for(int x=0;x<w;x++){
            if(G[y][x]=='#')cout<<'#';
            else{
                int cnt = 0;
                for(int i=0;i<8;i++){
                    int ny = y+dy[i];
                    int nx = x+dx[i];
                    if(0<=ny&&ny<h&&0<=nx&&nx<w){
                        if(G[ny][nx]=='#')cnt++;
                    }
                }
                cout<<cnt;
            }
            if(x==w-1)cout<<endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    long long N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    N-=1;
    long long diffCD = D-C;
    long long diffAB = abs(B-A);
    
    long long n;
    if (C==0){
        n=0;
    }else{
        n=min({diffAB/C,N});
    }
    long long m=(N-n)/2;
    long long res=(N-n)%2;

    if ((n-res)*C <= diffAB && diffAB <= (n-res)*C+(n+m)*diffCD){
        cout << "YES" << endl;
    }else if((n+res)*C-m*diffCD <= diffAB && diffAB <= (n+res)*C){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
  	int n,m,k;
  	ll temp;
  	cin >> n >> m >> k;
  	ll psA[n+1], psB[m+1];
  	memset(psA, 0, sizeof psA);
  	memset(psB, 0, sizeof psB);
	
  	for (int i = 1; i <= n; i++) {cin >> temp; psA[i] = temp + psA[i-1];}
  	for (int i = 1; i <= m; i++) {cin >> temp; psB[i] = temp + psB[i-1];}
  	int maxx = 0;
  	int j = m;
  	for(int i = 0; i <= n; i++){
      if (psA[i] > k) break;
      while(psB[j] > k-psA[i]) j--;
      maxx = max(maxx, i+j);
    }
    cout << maxx << endl;
  	return 0;
}


Measured memory_bytes: 6716
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(int, N);
  vi A(N); vi B(N); vi C(N-1);
  rep(i, N) { cin >> A[i]; --A[i]; }
  rep(i, N) cin >> B[i];
  rep(i, N-1) cin >> C[i];
  
  ll sum = 0;
  int prev = -2;
  rep(i, N) {
    sum += B[A[i]];
    if(prev == A[i] - 1) {
      sum += C[prev];
    }
    prev = A[i];
  }
  
  fin(sum);
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

ok = True

for i in l:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 == 0:
            pass
        else:
            ok = False

if ok:
    print("APPROVED")
else:
    print("DENIED")


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

int main()
{
  int m, M, count;
  cin >> m >> M;
  
  while(m<=M)
  {
    if(m%10 == m/10000 && m%100/10 == (m%10000)/1000)count++;
    m++;
  }
  cout << count << endl;
  
}
  
    
  
  

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

typedef struct{
 int x;
 int y;
}P;//??¨?????????

char graph[1000][1000];
P aim[10];
P s,g;//s?????????g??????
int N,W,H;
int vis[1000][1000]; //??¨??\?????¨??????
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int bfs(P s,P g);

int main(){
    int i,j,t,step=0;
    cin>>H>>W>>N;
    
    for(i=0;i<H;i++)
    for(j=0;j<W;j++){
        cin>>graph[i][j];
      if(graph[i][j]<='9'&&graph[i][j]>='1'){ 
         t=graph[i][j]-'0';
         aim[t].x=i;
         aim[t].y=j;
      } //???1-N?????????????????¨ aim??°?????? 
      else if(graph[i][j]=='S'){
          s.x=i;
          s.y=j;
          graph[i][j]='.';
      }//?????°??????????????? 
    }
    
    for(i=1;i<=N;i++){
       g.x=aim[i].x;
       g.y=aim[i].y;//1-N ???????°???°??§???????¬?????????? ???????????? 
       step+=bfs(s,g);
       s.x=g.x;
       s.y=g.y;//??°???????????????????????????????????? 
       graph[g.x][g.y]='.';
    }
   
    cout<<step<<endl;
}

int bfs(P s,P g){
    queue<P> que;
      P n;
    
    for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
     vis[i][j]=-1;
     
     que.push(s);
     vis[s.x][s.y]=0;
     
     while(que.size()){
         
       P p=que.front();
         que.pop();
       if(p.x==g.x&&p.y==g.y)
       break;
       
       for(int i=0;i<4;i++){
           n.x=p.x+dx[i];
           n.y=p.y+dy[i];//?????????????°? 
        if(0<=n.x&&n.x<H&&0<=n.y&&n.y<W&&graph[n.x][n.y]!='X'&&vis[n.x][n.y]==-1){
               que.push(n);
               vis[n.x][n.y]=vis[p.x][p.y]+1;
           }
       }
   }
     return vis[g.x][g.y];
}

Measured memory_bytes: 8048
#include <iostream>
using namespace std;
int main(void){
    int K, X;
    string s = " ";
    cin >> K >> X;
    for(int i = -K + 1; i < K; i++){
        if(i == K-1)
            s = "\n";
        cout << X + i;
        cout << s;
    }
}


Measured memory_bytes: 256
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
typedef pair<int, int> pii;

template<class T>
T GCD(T a, T b) {
	if (b == 0)return a;
	return GCD(b, (T)(a % b));
}

template<class T>
T LCM(T a, T b) {
	return a * b / GCD(a, b);
}

long long A, B, C, D;

long long num(long long N) {
	return N - (N/C+N/D-N/LCM(C,D));
}

void solve() {
	cin >> A >> B >> C >> D;
	cout << num(B) - num(A - 1) << endl;
	return;
}

Measured memory_bytes: 256
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 n = s.len();
    let mut f = s[0] == '1' && s[n-2] == '1' && s[n-1] == '0';
    for i in 1..n/2 {
        f &= s[i] == s[n-i-2];
        if !f {
            break;
        }
    }
    if !f {
        println!("-1");
    } else {
        let mut p = 0;
        for i in 0..n-2 {
            while i == p || s[p] == '0' {
                p += 1;
            }
            println!("{} {}", i+1, p+1);
        }
        println!("{} {}", n-1, n);
    }
}


Measured memory_bytes: 5500
#include "bits/stdc++.h"
using namespace std;
void solve(){
    int n;
    cin >> n;
    bool check = false;
    for(int i = 0; i < (n / 4) + 1; i++){
        for(int j = 0; j < (n / 7) + 1; j++){
            if(4 * i + 7 * j == n){
                check = true;
                break;
            }
        }
        if(check)
        break;
    }
    if(check)
    cout << "Yes" << endl;
    else 
    cout << "No" << endl;
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
num = input()
num_arr =[]
str_arr=[]

str_arr = list(num)
num_arr = [int(s) for s in str_arr]

if num_arr[0] == 0 and num_arr[1] != 0:
    if num_arr[2] == 0 and num_arr[3] != 0:
        print("AMBIGUOUS")
    elif num_arr[2] == 1 and 0 <=num_arr[3] <=2:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif num_arr[0] == 1 and 0 <=num_arr[1] <=2:
    if num_arr[2] == 0 and num_arr[3] != 0:
        print("AMBIGUOUS")
    elif num_arr[2] == 1 and 0 <=num_arr[3] <=2:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if num_arr[2] == 0 and num_arr[3] != 0:
        print("YYMM")
    elif num_arr[2] == 1 and 0 <=num_arr[3] <=2:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  
  cin >> a >> b >> c >> d;
  
  if(a+b>c+d)
  {
  	cout << "Left" << endl;
  }
  else if (a+b==c+d)
    cout << "Balanced" << endl;
  else
  {
  	cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef long long unsigned int llong;


int main(){
    string s;
    cin >>s;
    REP(i,s.length()){
        if(i%2==0) printf("%c",s[i]);
    }
    printf("\n");
}

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

vector<vector<int> > mat_dot(vector<vector<int> > first, vector<vector<int> > second, int mod) {
	int n = first.size();
	vector<vector<int> > res(n, vector<int>(n, 0));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			for (int k = 0; k < n; ++k) {
				res[i][j] += first[i][k] * second[k][j];
				res[i][j] %= mod;
			}
		}
	}
	return res;
}

vector<vector<int> > mat_pow(vector<vector<int> > mat, int exp, int mod) {
	int n = mat.size();
	vector<vector<int> > res(n, vector<int>(n, 0));
	for (int i = 0; i < n; ++i) res[i][i] = 1;
	int cnt = 0;
	while ((1<<cnt) <= exp) {
		if ((exp>>cnt) & 1) res = mat_dot(res, mat, mod);
		mat = mat_dot(mat, mat, mod);
		cnt++;
	}
	return res;
}

int main() {
	while (1) {
		int n, m, a, b, c, t;
		cin >> n >> m >> a >> b >> c >> t;
		if (n == 0) break;
		vector<int> s(n);
		for (int i = 0; i < n; ++i) cin >> s[i];
		vector<vector<int> > mt(n, vector<int>(n));
		for (int i = 0; i < n; ++i) {
			if (i > 0) mt[i][i-1] = a;
			mt[i][i] = b;
			if (i < n-1) mt[i][i+1] = c;
		}
		mt = mat_pow(mt, t, m);
		vector<int> ans(n);
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				ans[i] += s[j] * mt[i][j];
				ans[i] %= m;
			}
			cout << (i ? " " : "") << ans[i];
		}
		cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 3140
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C = MAP()

if A == B:
	print(C)
elif A == C:
	print(B)
else:
	print(A)

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;

int n,m,ans;
int a[30],b[30];
bool pass[8],pass2[8];
bool graph[8][8];
void dfs(int p){
    pass[p]=true;
    bool all_visited=true;
    rp(i,n){
        if(!(pass[i])){
            all_visited=false;
        }
    }
    if(all_visited){
        ans++;
    }
    rp(i,n){
        if(pass[i]==false&&graph[p][i]){
            dfs(i);
            pass[i]=false;
        }
    }
}

int main(){
    ans=0;
    cin >> n >> m;
    rp(i,m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        graph[a[i]][b[i]]=true;
        graph[b[i]][a[i]]=true;
    }
    rp(i,n){
        pass[i]=false;
    }
    dfs(0);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
n, k, s = map(int, input().split())
ans = []
for i in range(k):
    ans.append(str(s))
if s != 10**9:
    for i in range(n - k):
        ans.append(str(s + 1))
else:
    for i in range(n - k):
        ans.append(str(s - 1))
print(" ".join(ans))

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

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

int main(){
    long long A, B;
    int C, D;

    cin >> A >> B >> C >> D;
    A -= 1;
    int _G = gcd(C,D);
    int _C = C/_G;
    int _D = D/_G;
    long long G = (long long)_G*_C*_D;
    long long ans = (B - B/C - B/D + B/G) - (A - A/C - A/D + A/G);

    cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args :Array<String>) {
    val map = hashMapOf<String, Int>(
        "SUN" to 7,
        "MON" to 6,
        "TUE" to 5,
        "WED" to 4,
        "THU" to 3,
        "FRI" to 2,
        "SAT" to 1
    )
    val s = readLine()!!
    println(map[s])
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


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

int main(){
    int n,x,counter_odd = 0,counter_four = 0,counter_two = 0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        if(x%2==1)counter_odd++;
        else if(x%4==0)counter_four++;
        else if(x%2==0)counter_two++;
    }
    if(counter_two!=0)counter_odd++;
    if(counter_odd-2>=counter_four)printf("No");
    else printf("Yes");
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define umap unordered_map
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




//———————UnionFind木   UF uf(n);——————————————————————————

struct UF {
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    UF(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void reset(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

//—————————————————————————————————————————————————



int main() {
  int n,m;
  cin >>n>>m;
  
  UF uf(n);
    
  vector<pair<int,int>> p(m);
  
  rep(i,m){
  cin>>p[i].fi>>p[i].se;
  }
  
  int ans=0;
  
  rep(i,m){
    rep(j,m){
      if(i!=j) uf.unite(p[j].fi-1,p[j].se-1);
    }
    if(uf.size(0)!=n) ans++;
    uf.reset(n);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int price = 700;
    string s;

    cin >> s;

    if (s[0] == 'o') price += 100;
    if (s[1] == 'o') price += 100;
    if (s[2] == 'o') price += 100;

    cout << price << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int N;
scanf("%d",&N);
double t = (double)N/2;
int a = (int)t;
int res=0;
if ((double)t>(double)a) {res=t+1;}
else if ((double)t==(int)t){res = (int)t;}
printf("%lf",(double)res/(double)N);
 return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b,ll c){if(a==b)out(c);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
int main(){
    //ll a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;
    string s,t,u;cin>>s>>t>>u;
    string ans=t+s;
    out(ans);
}

Measured memory_bytes: 256
//#define DEB1 //output check function
//#define DEB2 //same output, input from input.txt

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VVI = vector<VI>;


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


#ifdef DEB1
#define DPRINT(x) cout<< #x << "=" << (x) << endl; // print at debug mode
#else
#define DPRINT(x) ;
#endif
#ifdef DEB1
#define DCHECK(x) cout<< "debug check" << #x << endl;
#else
#define DCHECK(x) ;
#endif
 


/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9

// Main program
void solve(){
    int N,L;
    int ans;
    cin >> N >> L;
    ans = (L + N+L-1)*N /2;
    if(L > 0){
        ans = ans - L;
    }
    if(N+L-1 < 0){
        ans = ans - (N+L-1);
    }
    cout << ans <<endl;

}



// ----------------------------------------------
int main() {

#ifdef DEB2
    cout << "DEBUG MODE"  << endl;
	ifstream in("input.txt"); //for debug
	cin.rdbuf(in.rdbuf()); //for debug
#endif

	int T=1; 

	for (int i = 0; i < T; ++i) {
		solve();
	}
}

Measured memory_bytes: 256