akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
)

const scBufSize = 1 * 1024 * 1024 // 1MB
var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, scBufSize), scBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func main() {
	n := scani()
	k := scani()
	l := scani()

	road := NewUnion(n)
	rail := NewUnion(n)
	for i := 0; i < k+l; i++ {
		o, d := scanRoad()
		if i < k {
			road.unite(o, d)
		} else {
			rail.unite(o, d)
		}
	}
	group := map[[2]int]int{}
	for i := 0; i < n; i++ {
		road.parent[i] = road.root(i)
		rail.parent[i] = rail.root(i)
		group[[2]int{road.parent[i], rail.parent[i]}]++
	}
	var ret []string
	for i := 0; i < n; i++ {
		ret = append(ret, strconv.Itoa(group[[2]int{road.parent[i], rail.parent[i]}]))
	}
	os.Stdout.WriteString(strings.Join(ret, " "))
}

type union struct {
	parent []int
}

func NewUnion(n int) union {
	u := union{parent: make([]int, n)}
	for i := 0; i < n; i++ {
		u.parent[i] = i
	}
	return u
}

func (u union) root(x int) int {
	if u.parent[x] == x {
		return x
	}
	u.parent[x] = u.root(u.parent[x])
	return u.parent[x]
}

func (u union) same(x, y int) bool {
	return u.root(x) == u.root(y)
}

func (u union) unite(x, y int) {
	r1 := u.root(x)
	r2 := u.root(y)
	if r1 == r2 {
		return
	}
	u.parent[r2] = r1
}

func scani() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanRoad() (o, d int) {
	o = scani() - 1
	d = scani() - 1
	return
}


Measured memory_bytes: 32384
N=int(input())

S=[]

for i in range(N):
    S.append(input())


ac=0
wa=0
tle=0
re=0

for i in range(len(S)):
    if S[i]=="AC":
        ac+=1
    elif S[i]=="WA":
        wa+=1
    elif S[i]=="TLE":
        tle+=1
    elif S[i]=="RE":
        re+=1

print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))

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

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

    if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2])
        cout << "Yes";
    else
        cout << "No";
    cout << endl;

    return 0;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main{
	
	public static void main(String[] args) {
		int val;
		int val2;
		int result;
		Scanner in = new Scanner(System.in);
		Stack<Integer> stack = new Stack<>();
		String expression = in.nextLine();
		String[] arr = expression.split(" ");

		for(String str : arr) {
			
			
			switch(str) {
			case "+" :
				val = stack.pop();
				val2 = stack.pop();
				stack.push(val + val2);
				break;
			case "-":
				val = stack.pop();
				val2 = stack.pop();
				stack.push(val2 - val);
				break;
			case "*":
				val = stack.pop();
				val2 = stack.pop();
				stack.push(val * val2);	
				break;
			case "/":
				val = stack.pop();
				val2 = stack.pop();
				stack.push(val2 / val);
				break;
			default:
				stack.push(Integer.parseInt(str));
				break;
			
			}
			
			
		}
		
		result = stack.pop();
		System.out.println(result);
			
	}
		
}


Measured memory_bytes: 26288
#include <iostream>
#include <cstdio>
using namespace std;
int h,m,s;
void solve(){
	int t=(h*60+m)*60+s;
	int r=60*60*2-t;
	printf("%02d:%02d:%02d\n",r/60/60,(r/60)%60,r%60);
	r*=3;
	printf("%02d:%02d:%02d\n",r/60/60,(r/60)%60,r%60);
}
int main(){
	while(cin>>h>>m>>s&&h!=-1){
		solve();
	}
	return 0;
}

Measured memory_bytes: 0
using System;
class Program
{
    static void Main(string[] args)
    {
        string n = Console.ReadLine();
      int N = int.Parse(n);
        if(N >= 1000 && N <= 1998)
        {
            Console.WriteLine("ABD");
        }
        else
        {
            Console.WriteLine("ABC");
        }
    }
}

Measured memory_bytes: 11092
#include <vector>
#include <iostream>
#include <algorithm>

using std::cin;
using std::cout;
using std::vector;
using std::reverse;
using std::for_each;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for_each(v.begin(),v.end(),[](int &_e){cin >> _e;});
	int q;
	cin >> q;
	while (q--) {
		int b;
		int e;
		cin >> b >> e;
		reverse(v.begin() + b,v.begin() + e);
	}
	int i = 1;
	for_each(v.begin(),v.end(),[&i,n](int _e){cout << _e << (i++ == n ? "\n" : " ");});
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>
using namespace std;

int n,m;
bool t[16][16],closed[16][66000];
vector<int> r[16];

class P{
public:
	int id,bit,cost;
	vector<int> pass;

	P(){}
	P(int _id,int _bit,int _cost,vector<int> _pass){
		id = _id;
		bit = _bit;
		cost = _cost;
		pass = _pass;
	}
};

void printPass(vector<int> v){
	cout<<"You can go home in "<<v.size()<<" steps.\n";
	for(int i=0;i<v.size();i++){
		if(v[i] >= 100)
			cout<<"Move to room "<<v[i]/100<<".\n";
		else if(v[i] > 0)
			cout<<"Switch on room "<<v[i]<<".\n";
		else
			cout<<"Switch off room "<<-v[i]<<".\n";
	}
}

int main(void){
	while(cin>>n>>m,n){
		memset(t,0,sizeof(t));
		for(int i=0;i<m;i++){
			int a,b;
			cin>>a>>b;
			a--; b--;
			t[a][b] = t[b][a] = true;
		}
		int first = 0;
		for(int i=0;i<n;i++){
			int x;
			cin>>x;
			if(x) first |= (1<<i);
		}
		for(int i=0;i<n;i++){
			int k;
			cin>>k;
			r[i].clear();

			while(k--){
				int ri;
				cin>>ri;
				ri--;
				r[i].push_back(ri);
			}

			sort(r[i].begin(),r[i].end());
		}

		queue<P> open;
		memset(closed,0,sizeof(closed));
		open.push(P(0,first,0,vector<int>()));

		int ansCode = 0;
		P ans;
		while(!open.empty()){
			P p = open.front(); open.pop();
			if(closed[p.id][p.bit]) continue;
			closed[p.id][p.bit] = true;

			if(p.id == n-1){
				if(p.bit == (1<<(n-1))){
					ansCode = 2;
					ans = p;
					break;
				}
				ansCode = 1;
			}

			for(int i=0;i<r[p.id].size();i++){
				if(r[p.id][i] == p.id) continue;

				int now = (p.bit & (1<<r[p.id][i]));
				int nbit = (p.bit ^ (1<<r[p.id][i]));
				vector<int> npass = p.pass;

				if(now > 0){ //switch off
					npass.push_back(-r[p.id][i]-1);
				}
				else{
					npass.push_back(r[p.id][i]+1);
				}
				open.push(P(p.id,nbit,p.cost+1,npass));
			}

			for(int i=0;i<n;i++){
				if(t[p.id][i] && (p.bit & (1<<i))>0){
					vector<int> npass = p.pass;
					npass.push_back((i+1)*100);
					open.push(P(i,p.bit,p.cost+1,npass));
				}
			}
		}

		if(ansCode == 2)
			printPass(ans.pass);
		else if(ansCode == 1)
			cout<<"You can not switch off all lights.\n";
		else
			cout<<"Help me!\n";
	}

	return 0;
}

Measured memory_bytes: 7092
#include <bits/stdc++.h>
using namespace std;
vector<int >v;
void sum(int a, int b,int k)
{
    for (int i = 1; i <= min(a,b); i++){
        if (a % i == 0 && b % i == 0){
            v.push_back(i);
//            cout<<i<<endl;
        }
    }
    sort(v.begin(),v.end(),greater<int>());
//    for(int i=0;i<v.size();i++)cout<<" "<<v[i];
    cout<<v[k-1]<<endl;
}

int main()
{
    int A ,B ,k;
    cin>>A>>B>>k;
    sum(A, B,k);
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BCakesAndDonuts {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;
	    bool res = false;
	    for(int i=0; i<=25; i++){
	        for(int j=0; j<=15; j++){
	            if(i*4 + 7*j == n) res = true;
	        }
	    }

	    ans(res, out);
	}
};


int main() {
	BCakesAndDonuts solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;

#define int ll

int N;
int l[64], t[64], r[64], b[64];
int table[256][256];

inline bool in(int i, int j){return i >= 0 && j >= 0 && i < 256 && j < 256;}
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};

void dfs(int x, int y){
    int t = table[x][y];
    table[x][y] = -1;
    for(int d = 0; d < 4; d++){
        int nx = x + dx[d], ny = y + dy[d];
        if(in(nx, ny) && table[nx][ny] == t) dfs(nx, ny);
    }
}

signed main(void){
    while(cin >> N, N){
        vector<int> tmp;
        map<int, int> zip;
        for(int i = 0; i < N; i++){
            cin >> l[i] >> t[i] >> r[i] >> b[i];
            tmp.pb(l[i]);
            tmp.pb(t[i]);
            tmp.pb(r[i]);
            tmp.pb(b[i]);
        }
        sort(tmp.begin(), tmp.end());
        for(int i = 1; i <= tmp.size(); i++){
            zip[tmp[i-1]] = i;
        }
        memset(table, 0, sizeof(table));
        for(int i = 0; i < N; i++){
            int mask = 1LL << i;
            int left = zip[l[i]];
            int right = zip[r[i]];
            int top = zip[t[i]];
            int bottom = zip[b[i]];
            for(int x = left; x < right; x++)
                for(int y = bottom; y < top; y++)
                    table[x][y] |= mask;
        }
        int ans = 0;
        for(int i = 0; i < 256; i++)
            for(int j = 0; j < 256; j++)
                if(table[i][j] != -1){
                    ans++;
                    dfs(i, j);
                }

        cout << ans << endl;
    }
}

Measured memory_bytes: 4812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int a,b;
  cin >> a >> b;
  if(abs(a-b) % 2 != 0){
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  cout << (a+b) / 2 << endl;
}



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

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    int W,H,N;
    cin >> W >> H >> N;
    vector<int> x(N);
    vector<int> y(N);
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i] >> a[i];
    }
    int x1=0;
    int x2=W;
    int y1=0;
    int y2=H;

    for(int i=0;i<N;i++){
        if(a[i]==1){
            x1=std::max(x1,x[i]);
        }
        else if(a[i]==2){
            x2=std::min(x2,x[i]);
        }
        else if(a[i]==3){
            y1=std::max(y1,y[i]);
        }
        else{
            y2=std::min(y2,y[i]);
        }
    }

    int w=std::max(x2-x1,0);
    int h=std::max(y2-y1,0);
    cout << w*h << endl;
    return 0;
}



Measured memory_bytes: 256
///=======================///
/// coder: Andy - Tohrumi ///
///=======================///

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)
#define int long long

using namespace std;

typedef pair<ll, ll> pll;	typedef pair<int, int> ii;
typedef vector<pll> vll;	typedef vector<string> vs;		typedef vector<ii> vii;
typedef vector<int> vi; 	typedef vector<ll> vl;

///====code start here====///

signed main() {
	fastio;
	int test; cin >> test;
	while(test--) {
		int n; cin >> n;
		ll k, l, r, ans = 0;
		vector<vl> left(n), right(n);
		
		rep(i, 0, n) {
			cin >> k >> l >> r;
			
			ans += min(l, r);
			if(l > r) left[k - 1].pb(l - r);
			else right[k - 1].pb(r - l);
		}
		
		priority_queue<ll> pq;
		
		Rep(i, n - 1, -1) {
			rep(j, 0, (int)left[i].size()) pq.push(left[i][j]);
			if(!pq.empty()) {
                ans += pq.top();
                pq.pop();
            }
		}
		
		while(!pq.empty()) pq.pop();
		rep(i, 0, n) {
			if(!pq.empty()) {
				ans += pq.top();
				pq.pop();
			}
			rep(j, 0, (int)right[i].size()) pq.push(right[i][j]);
		}
		
		cout << ans << endl;
	}
	return 0;
}


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

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

  if(x-r<0 || x+r>W || y-r<0 || y+r>H)
    cout << "No" <<"\n";
  else
    cout << "Yes" <<"\n";
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> p(n), t;
    for (int i = 0; i < n; i++) cin >> p[i];
    t = p;
    sort(p.begin(), p.end());
    int diff = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] != t[i]) diff++;
    }
    cout << (diff == 2 || diff == 0 ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  
  int a[200010],b[200010];
  bool r1[n];
  bool r2[n];
  
  for(int i=0;i<n;i++){
    r1[i]=false;
    r2[i]=false;
  }
  
  for(int i=0;i<m;i++){
    cin >> a[i] >>b[i];
    if(a[i]==1) r1[b[i]-1]=true;
    if(b[i]==n) r2[a[i]-1]=true;
  }
  
  bool ok=false;
  for(int i=1;i<n-1;i++){
    if(r1[i]==true && r2[i]==true)ok=true;
  }
  if(ok)cout <<"POSSIBLE" <<endl;
  else cout << "IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 2176
/*Rajeev Ranjan
  CSE @MNNIT */

#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define S second
#define F first
#define boost ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
typedef long long int ll;
typedef double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N = 1e5 + 5;

ll a[N][3],dp[N][3];

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

    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<3;j++)
            cin>>a[i][j];
    }


    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(j==0)
                dp[i][j] = a[i][j] + max(dp[i-1][1],dp[i-1][2]);
            else if(j==1)
                dp[i][j] = a[i][j] + max(dp[i-1][0],dp[i-1][2]);
            else
                dp[i][j] = a[i][j] + max(dp[i-1][0],dp[i-1][1]);
        }
    }

    ll ans=0;
    for(int i=0;i<3;i++)
        ans= max(ans,dp[n][i]);

    cout<<ans<<endl;
    return 0;
}


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

vector<bool> seen;
vector<int> d;
vector<int> f;

void dfs(const vector<vector<int>> &G, int v, int &time){
    seen[v] = true;
    d[v] = time;
    time++;

    for(auto next_v: G[v]){
        if(seen[next_v]) continue;
        dfs(G, next_v, time);
    }

    f[v] = time;
    time++;
}

int main(){
    int n;
    cin >> n;
    vector<vector<int>> G(n);

    for(int i = 0; i < n; i++){
        int u, k;
        cin >> u >> k;
        for(int j = 0; j < k; j++){
            int v;
            cin >> v;
            G[u-1].push_back(v-1);
        }
    }


    int time = 1;
    seen.assign(n, false);
    d.resize(n);
    f.resize(n);
    
    for(int i = 0; i < n ; i++){
        if(!seen[i]) dfs(G, i, time);
    }

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


Measured memory_bytes: 3144
#include<cstdio>
#include<algorithm>
using namespace std;

const int MAXN=30;
const int MAXM=(1<<21)+5;
const int MOD=1e9+7;

int n,m,p,ans,now;
int dp[2][MAXN][MAXM],nxt[MAXM][MAXN];
int bz[MAXN][MAXN];

int main(){
    scanf("%d%d%d",&n,&m,&p); n--;
    for(int i=0;i<(1<<n);i++){
        int t=-1;
        for(int j=n-1;j>=0;j--){
            if((i&(1<<j))) t=j;
            nxt[i][j]=t;
        }
    }
    for(int i=1;i<=m;i++)
        for(int j=0;j<n;j++)
            bz[i][j]=-1;
    for(int i=1;i<=p;i++){
        int j,k,l;
        scanf("%d%d%d",&j,&k,&l);
        bz[j][k-1]=l;
    }
    dp[0][n][0]=1;
    now=1;
    for(int i=1;i<=m;i++){
        for(int s=0;s<(1<<n);s++) dp[now][0][s]=dp[now^1][n][s];
        for(int j=0;j<=n;j++)
            for(int s=0;s<(1<<n);s++)
                dp[now^1][j][s]=0;
        for(int j=0;j<n;j++)
            for(int s=0;s<(1<<n);s++)
                if(dp[now][j][s]){
                    for(int k=0;k<=1;k++){
                        if(bz[i][j]!=-1&&bz[i][j]!=k) continue;
                        int t=(s&(1<<j));
                        if(t) t=1;
                        if(!k&&t==1) continue;
                        if(k==t) (dp[now][j+1][s]+=dp[now][j][s])%=MOD;
                        else{
                            int r=nxt[s][j];
                            if(r==-1) (dp[now][j+1][s+(1<<j)]+=dp[now][j][s])%=MOD;
                            else (dp[now][j+1][s+(1<<j)-(1<<r)]+=dp[now][j][s])%=MOD;
                        }
                    }
                }
        now^=1;
    }
    for(int i=0;i<(1<<n);i++)
        (ans+=dp[now^1][n][i])%=MOD;
    printf("%d",(ans+MOD)%MOD);
}


Measured memory_bytes: 227584
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

#define forn(i,n) for (ll i = 0; i < ll(n); ++i)
#define forsn(i,x,y) for(long long i = (x) ; i <= (y) ; ++i)
typedef long long ll;
typedef long double ld;

int main() {
  ll n, l;
  cin >> n >> l;
  //n = 100000;
  //l = 1000000000;
  vector<ll> a(n);
  ll total = 0;
  forn(i,n) {
    cin >> a[i];
    //a[i] = 1000000000;
    //if(i == 50000) a[i] = 1000000000;
    total += a[i];
  }
  //cout << total << endl;
  bool res = false;
  int i = 0;
  for(;i < n-1; i++) {
    if(a[i] + a[i+1] >= l) {
      res = true;
      break;
    }
  }

  cout << (res?"Possible":"Impossible") << endl;
  
  if(res) {
    for(int j = 1; j <= i; j ++) {
      cout << j << endl;
    }
    for(int j = n-1; j > i; j--) {
      cout << j << endl;
    }
  }
  return 0;
}

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

using namespace std;
typedef long long int ll;

set <ll> g[100009];
int main()
{
	ll n,m;cin>>n>>m;ll h[100009];
	for(ll i=1;i<=n;i++) cin>>h[i];
	for(ll i=1;i<=m;i++)
	{
		ll a,b;cin>>a>>b;
		g[a].insert(b);
		g[b].insert(a);
	}
	
	ll cnt=0;
	for(ll i=1;i<=n;i++)
	{
		ll maxi=-1;
		for(auto it:g[i]) maxi=max(maxi,h[it]);
		if(maxi<h[i]) cnt++;
	}
	cout<<cnt;
		
	
}


Measured memory_bytes: 18436
n,k=map(int,input().split())
a=list(map(int,input().split()))
def count(num):
    if num%(k-1)==0:
        a=(num//(k-1))
    else:
        a=(num//(k-1)+1)
    return a
if n==k:
    print(1)
else:
    one=0
    ans=0
    for i in range(n):
        if a[i]==1:
            one=i+1 #１が左からone番目にある(１スタート)
            break
    l=one-1 #１より左にある数
    r=n-one
    c=0
    if l==0:
        ans+=count(r)
        c=1
    if r==0:
        ans+=count(l)
        c=1
    if c==0:
        cl,cr=count(l),count(r)
        l_start=cl+count(r-(cl*(k-1)-l))
        r_start=cr+count(l-(cr*(k-1)-r))
        ans=min(l_start,r_start)
    print(ans)

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

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

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> a[i][j];
    }
  }

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

  for(int i=0;i<n;i++){
    int sum = 0;
    for(int j=0;j<m;j++){
      sum += a[i][j]*b[j];
    }
    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 1196
n,a,b=map(int,input().split())
s=[int(input()) for _ in range(n)]
u=max(s)//b+1
l=0
while l+1<u:
    m=(u+l)//2
    if m<sum((max(h-b*m,0)+a-b-1)//(a-b) for h in s):
        l=m
    else:
        u=m
print(u)

Measured memory_bytes: 7196
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n,num[110]={},x,ans1=0,ans2=0;
	vector<int> ans;
	while(cin>>n)	num[n]++;
	for(int i=1;i<=100;i++){
		if(num[i]>ans2){
			ans.clear();
			ans.push_back(i);
			ans2 = num[i];
		}
		else if(num[i]==ans2)	ans.push_back(i);
	}
	for(int i=0;i<ans.size();i++)	cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 3000
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b, c, d int
	fmt.Scanf("%d %d %d %d\n", &a, &b, &c, &d)
	arr := []int{a, b, c, d}
	sort.Ints(arr)
	if arr[0] == 1 && arr[1] == 4 && arr[2] == 7 && arr[3] == 9 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

typedef vector<int> Edges;
typedef vector<Edges> Graph;

int n;
ll len[1200000];
bool root[1200000];
Graph g;
vector<int> order;

int main() {
  while (scanf("%d", &n) > 0) {
while(n > 1000000);
    MEMSET(root, false);
    g = Graph(n);
    REP(i, n) {
      int p;
      scanf("%lld %d", &len[i], &p);
      if (p != -1) {
        g[p].push_back(i);
      } else {
        root[i] = true;
      }
    }
    REP(i, n) {
      if (!root[i]) { continue; }
      queue<int> que;
      que.push(i);
      while (!que.empty()) {
        int from = que.front();
        que.pop();
        order.push_back(from);
        FORIT(it, g[from]) {
          int to = *it;
          que.push(to);
        }
      }
    }
    reverse(order.begin(), order.end());
    ll ans = 0;
    REP(i, n) {
      int from = order[i];
      vector<int> lens;
      FORIT(it, g[from]) {
        lens.push_back(len[*it]);
      }
      sort(lens.begin(), lens.end());
      ll sum = 0;
      FORIT(it, lens) {
        ans += sum;
        sum += *it;
      }
      len[from] += sum;
    }
    printf("%lld\n", ans);
  }
}

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

int main(){   
   int n,a,b,sum=0,bsum=0;
   string s;
   cin >> n >> a >> b;
   cin >> s;
   for(int i=0;i<n;i++){
       if(s.at(i)=='a'){
           if(a+b>sum){
               cout << "Yes" <<endl;
               sum++;
           }else{
                cout << "No" << endl;
           }
           
       }
       if(s.at(i)=='b'){
           if(a+b>sum){
               if(b>bsum){
               cout << "Yes" <<endl;
               sum++;
               bsum++;
               }else{
               cout << "No" << endl;
                }
           }else{
                cout << "No" << endl;
            }
           
       }
       if(s.at(i)=='c'){
           cout << "No" << endl;
       }
   }
}
 

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

enum {
	MALE, FEMALE
};

int main(){
	int N;
	cin >> N;
	
	int current, before, before_i;
	// [ok, ng)
	int ok = 0, ng = N;
	for(int i=0;i<20;i++) {
		string s;
		if(i == 0) {
			cout << 0 << endl;
			cin >> s;
			if(s == "Vacant") {
				return 0;
			} else if(s == "Male") {
				current = MALE;
			} else if(s == "Female") {
				current = FEMALE;
			}
			before = current;
			before_i = 0;
			continue;
		}

		int mid = (ok + ng) / 2;
		cout << mid << endl;
		cin >> s;
		if(s == "Male") {
			current = MALE;
		} else if(s == "Female") {
			current = FEMALE;
		} else {
			return 0;
		}

		if((mid - before_i) % 2 == 0) {
			if(before == current) {
				// 次の探索範囲は[mid, ng)
				if(mid >= before_i) {
					ok = mid;
				} else {
					ng = mid;
				}
			} else {
				// 次の探索範囲は[ok, mid)
				if(mid >= before_i) {
					ng = mid;
				} else {
					ok = mid;
				}
			}
		} else {
			if(before == current) {
				if(mid >= before_i) {
					ng = mid;
				} else {
					ok = mid;
				}
			} else {
				if(mid >= before_i) {
					ok = mid;
				} else {
					ng = mid;
				}
			}
		}
		before = current;
		before_i = mid;
	}
}

Measured memory_bytes: 852
#ifdef Prateek
  #include "C:\Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 3e5 + 10; 

int t[4*N];

int sum(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return max(sum(v*2, tl, tm, l, min(r, tm))
          , sum(v*2+1, tm+1, tr, max(l, tm+1), r));
}

void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = max(t[v*2] , t[v*2+1]);
    }
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n, k;
   cin >> n >> k;
   vector<int> A(n);
   for(int i = 0; i < n; ++i) {
      cin >> A[i];
   }
   int ans = 1;
   for(int i = n-1; i >= 0; --i) {
      int mn = max(0ll, A[i]-k);
      int mx = min(N-1, A[i]+k);
      int q = sum(1, 0, N-1, mn, mx);
      ans = max(ans, q+1);
      update(1, 0, N-1, A[i], q+1);
   }
   cout << ans << '\n';
   return 0;
} 


Measured memory_bytes: 13768
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

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

int main(void) {
  ll x;
  cin >> x;

  ll ans=(x/500)*1000 + ((x%500)/5) * 5;
  prt(ans);
}


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

long long n,sum=0;
string s;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin>>s;
    for(int i=0;i<s.size();i++){
        n=s[i]-'0';
        sum+=n;
    }
    istringstream ss(s);
    ss>>n;
    if(n%sum==0)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

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

using namespace std;

int main() {
	string W, T;
	int pos = 0;
	int count = 0;

	cin >> W;
	transform(W.begin(), W.end(), W.begin(), ::toupper);
	getline(cin, T); //read \n

	while (true){
		getline(cin, T);

		if (T == "END_OF_TEXT")
			break;

		transform(T.begin(), T.end(), T.begin(), ::toupper);

		pos = 0;
		int i = 0;
		while (true) {

			pos = T.find(W, pos + i);
			if (pos == 0) {
				if (T.length() != W.length()) {
					if (T.substr(W.length(), 1) == " ") {
						count++;
					}
				}
				else
					count++;
			}
			else if (pos > 0) {
				if (W.length() == T.substr(pos).length() && T.substr(pos - 1, 1) == " ") {
					count++;
				}
				else if(T.substr(pos - 1, 1) == " " && T.substr(pos + W.length(), 1) == " ") {
					count++;
				}
			}
			else
				break;

			i = 1;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  bool ok = false;
  for (int i = 0; i < a + b; i++){
    int t = 60 * i + c;
    int r = t % (a + b);
    if (r <= a){
      cout << t << endl;
      ok = true;
      break;
    }
  }
  if (!ok){
    cout << -1 << endl;
  }
}


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

int N, M;
ll K;
vector<int> A, B;
int ans = 0;
ll now = 0;

void newbfs(int ai, int bi, ll now) {
  while (bi < M) {
    if (now + B.at(bi) > K) break;
    now += B.at(bi);
    bi++;
  }
  ans = max(ans, ai + bi);

  if (ai == 0) return;
  ai--;
  now -= A.at(ai);
  newbfs(ai, bi, now);
}

int main() {
  cin >> N >> M >> K;
  A = vector<int>(N);
  B = vector<int>(M);
  rep(i, N) cin >> A.at(i);
  rep(i, M) cin >> B.at(i);

  int ai = 0;
  ll now = 0;
  while (ai < N) {
    if (now + A.at(ai) > K) break;
    now += A.at(ai);
    ai++;
  }
  ans = ai;

  newbfs(ai, 0, now);
  cout << ans << endl;
}


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

using namespace std;

#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define LL long long
#define ULL unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<LL,int>
#define PLL pair<LL,LL>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<LL,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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



const int N=1e6;
int cnt[N+2];

void PreCal()
{
    int i,j;
    for(i=1;i<=N;i++)
    {
        for(j=i;j<=N;j+=i)++cnt[j];
    }
}

int main()
{
    FAST();
    PreCal();
    int n,ans=0;
    cin >> n;
    for(int i=1;i<n;i++)ans+=cnt[i];
    cout << ans;
    return 0;
}


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

using namespace std;

int main()
{
    int i,j,k,n,m,x=0,y,z;
    cin>>n;
    int a[n+1];
    int b[n+1];
    int c[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=n;i++)
    {
        cin>>b[i];
    }
    for(i=1;i<n;i++)
    {
        cin>>c[i];
    }
    for(i=1;i<=n;i++)
    {
        if(a[i]==a[i-1]+1 && i>1)
        {
            x=x+b[a[i]]+c[a[i-1]];
            //cout<<x<<endl;
        }
        else
        {
            x=x+b[a[i]];
            //cout<<x<<endl;
        }
    }
    cout<<x<<endl;
}


Measured memory_bytes: 256
def main_function():
    from sys import stdin
    from sys import stdout
    input = stdin.readline
    print = stdout.write

    n, m = list(map(int, input().split()))
    a = list(map(int, input().split()))
    summa = sum(a)
    if summa > n:
        print(f'-1')
    else:
        print(f'{n - summa}')


if __name__ == '__main__':
    main_function()

Measured memory_bytes: 9980
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

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

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

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    vector<int> a;
    for(int i=0;i<m;i++){
        int k;
        scanf("%d",&k);
        int temp=0;
        for(int j=0;j<k;j++){
            int pos;
            scanf("%d",&pos);
            pos--;
            temp=temp|(1<<pos);
        }
        a.push_back(temp);
    }
    debug(a);
    vector<int> parity(m);
    for(auto &x:parity)scanf("%d",&x);
    int cnt=0;
    for(int i=0;i<pow(2,n);i++){
        bool okay=true;
        for(int j=0;j<m;j++){
            int set_b=__builtin_popcount(a[j]&i);
            debug(i,j,a[j],set_b,parity[j]);
            if(set_b%2!=parity[j]%2){
                okay=false;
                break;
            }
        }
        if(okay){
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


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

using namespace std;

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

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

  int x;
  cin >> x;
  while (!is_prime(x)) {
    ++x;
  }
  cout << x;

  return 0;
}

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

int main() {
    int n;
    cin>>n;
    ll l[n];
    
    for(int i=0;i<n;i++)
        cin>>l[i];
        
    int ans=0;
    
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            if(l[i]==l[j])
                continue;
            for(int k=j+1;k<n;k++){
                if(l[j]==l[k]||l[k]==l[i])
                    continue;
                if(((l[i]+l[j])>l[k])&&((l[j]+l[k])>l[i])&&((l[i]+l[k])>l[j]))
                    ans++;
                   
            }
        }
    }
    
    cout<<ans;
}

Measured memory_bytes: 3676
N = int(input())

def is_753(n):
    return '3' in list(str(n)) and '5' in list(str(n)) and '7' in list(str(n))

dict_753 = [3, 5, 7]

def generate753():
    list_753s = []
    for keta in range(3, 10):
        for n in range(3 ** keta):
            n_753 = 0
            for k in range(keta):
                n_753 = n_753 * 10 + dict_753[n % 3]
                n = int(n / 3)
            if is_753(n_753):
                list_753s.append(n_753)
    return list_753s

print(len([n for n in generate753() if n <= N]))

Measured memory_bytes: 4356
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forv(i,x) for(auto &i:x)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r)
{
    return l+rng()%(r-l+1);
}
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define pii pair<int,int>
#define fi first
#define se second
#define batbit(i,x) (x|(1ll<<i))
#define getbit(i,x) ((x>>i)&1)

main()
{
    int x,y;
    cin >> x >> y;
    if(x>3) x=4;
    if(y>3) y=4;
    int a[5];
    a[1]=300000;
    a[2]=200000;
    a[3]=100000;
    a[4]=0;
    cout << a[x]+a[y]+(x==1&&y==1?400000:0);
}


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

int main() {
  int input;
  cin >> input;
  
  int temp = input; 
  vector <int> S(4); 
  
  for (int i=0; i<4; i++){
    S.at(i) = floor(temp/pow(10, 3-i));
    temp -= S.at(i)*pow(10, 3-i);
  }

  
  int top, bottom;  
  top = S.at(0)*10+S.at(1);
  bottom = S.at(2)*10+S.at(3);
  
  if ( (top < 1 || 12 < top) && (bottom < 1 || 12 < bottom) ){
    cout << "NA"<< endl;
  }else if ( (top < 1 || 12 < top) && !(bottom < 1 || 12 < bottom) ){
    cout <<"YYMM"<< endl;
  }else if ( !(top < 1 || 12 < top) && (bottom < 1 || 12 < bottom) ){
    cout <<"MMYY"<< endl;
  }else{
    cout <<"AMBIGUOUS"<< endl;
  }
    
}

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

int main()
{
    int n;
    string tmp;
    cin >> n;
    vector<int> map(4, 0);
    
    for(int i = 0; i < n; ++i)
    {
        cin >> tmp;
        if(tmp == "AC")
        {
            map[0]++;
        } else if(tmp == "WA")
        {
            map[1]++;
        } else if(tmp == "TLE")
        {
            map[2]++;
        } else if(tmp == "RE")
        {
            map[3]++;
        }
    }
    
    for(int i = 0; i < 4; ++i)
    {
        if(i == 0)
            cout << "AC" << " x " << map[i] << "\n";
        if(i == 1)
            cout << "WA" << " x " << map[i] << "\n";
        if(i == 2)
            cout << "TLE" << " x " << map[i] << "\n";
        if(i == 3)
            cout << "RE" << " x " << map[i] << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define FOR(i, l, r) for(int i = int(l); i <= int(r); ++i)

using namespace std;
const int Nmax = 1e5 + 7;

int n, x[Nmax], y[Nmax], t[Nmax];

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    FOR(i, 1, n) {
        cin >> t[i] >> x[i] >> y[i];
        if ((t[i] - t[i - 1]) < abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])
            || (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]) - t[i] + t[i - 1] + 100000000) % 2 == 1) { cout << "No"; return 0; }
    }
    cout << "Yes";
}


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

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

using namespace std;

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

	int sum=0;
	rep(i,n) sum+=l+i;

	int ans=1e9;
	rep(i,n){
		int tmp=sum-(l+i);
		if(abs(sum-ans)>abs(sum-tmp)) ans=tmp;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, a, b, g, h;
string s;
signed main() {
	cin >> n >> a >> b >> g >> h >> s;
	a--; b--; g--; h--;
	for (int i = a; i < g; i++) {
		if (s[i] == '#' && s[i + 1] == '#') {
			cout << "No\n";
			return 0;
		}
	}
	for (int i = b; i < h; i++) {
		if (s[i] == '#' && s[i + 1] == '#') {
			cout << "No\n";
			return 0;
		}
	}
	if (g < h) {
		cout << "Yes\n";
	}
	else {
		for (int i = max(0ll,b - 1); i < h; i++) {
			if (i + 2 < n && s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
				cout << "Yes\n";
				return 0;
			}
		}
		cout << "No\n";
	}
}

Measured memory_bytes: 640
import sys
input = sys.stdin.buffer.readline

def main():
    N,M = map(int,input().split())
    INF = 10**7
    k = []
    for _ in range(M):
        a,b = map(int,input().split())
        c = list(map(int,input().split()))
        bit = 0
        for i in c:
            bit += 2**(i-1)
        k.append((a,bit))
    dp = [INF for _ in range(1<<N)]
    dp[0] = 0
    for i in range(M):
        a,bit = k[i]
        for j in range(1<<N):
            af = bit|j
            dp[af] = min(dp[af],dp[j]+a)
            
    print(dp[-1] if dp[-1] != INF else -1)
if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
 
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    /*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        n:usize,
        ass:[usize;n],
    }
    let ass = ass;
    let mut ass = ass.into_iter().enumerate().collect::<Vec<(usize,usize)>>();
    ass.sort_by(|&(_,a),&(_,b)|a.cmp(&b));
    let ass:Vec<String> = ass.iter().map(|&(i,_)|(i+1).to_string()).collect();
    println!("{}",ass.join(" "));

}    


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


int main() {
  int N;
  cin >> N;
  vector<long long> L(N + 1);
  L[0] = 2;
  L[1] = 1;
  rep(i, N - 1){
    L[i + 2] = L[i] + L[i + 1];
  }
  cout << L[N] << endl;
}

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

int main(){

    int N;
    string W[100];
    cin >> N;
    for( int i = 0; i < N; i++ ) cin >> W[i];


    bool check = true; // しりとりのルールを守っているかどうか

    for( int i = 0; i < N-1; i++ ){
        if( W[i].back() != W[i+1].front() ){
            check = false;
            break;
        }
    }

    for( int i = 0; i < N; i++ ){
        for( int j = 0; j < N; j++ ){
            if( W[i] == W[j] && i != j ){
                check = false;
                break;
            }
        }
        if( ! check ) break;
    }

    if( check ) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef
tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> order_set;
const ll mod=1e9+7;
const int N=2e6+10;
const int M=20;

ll power(ll x, unsigned ll y, ll p)
{
     ll res = 1; 
     x = x % p;
     while (y > 0)
     {
         if (y & 1)
             res = (res*x) % p;
         y = y>>1;
         x = (x*x) % p;  
     }
    return res;
}


int main() 
{
    FAST;
    srand(time(NULL));
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n;
    cin >> n;
    ll a[n];
    ll x=0,mx=0;
    ll i;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
        x+=a[i];
        mx=max(mx,a[i]);
    }
    cout << x-mx+mx/2;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, A, B, K;
    cin >> N >> A >> B >> K;

    vector<ll> fact(N+1);
    fact[0] = 1; fact[1] = 1;
    for (int i = 2; i < N+1; i++) {
        fact[i] = fact[i-1] * i % MOD;
    }   

    vector<ll> inv(N+1); inv[1] = 1;
    for (int i = 2; i < N+1; i++) {
        inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
    }   
    vector<ll> invfact(N+1);
    invfact[0] = 1; invfact[1] = 1;
    for (int i = 2; i < N+1; i++) {
        invfact[i] = invfact[i-1] * inv[i] % MOD;
    }   

    ll ans = 0;
    ll tmp;
    for (ll i = 0; i < N+1; i++) {
        if(K - i * A >= 0 && (K - i * A) % B == 0 && (K - i * A) / B <= N){
            tmp = fact[N] * fact[N] % MOD;
            tmp = tmp * invfact[i] % MOD;
            tmp = tmp * invfact[N-i] % MOD;
            tmp = tmp * invfact[(K - i * A) / B] % MOD;
            tmp = tmp * invfact[N - (K - i * A) / B] % MOD;
            ans = (ans + tmp) % MOD;
        }


    }

    printf("%lld\n", ans);

}


Measured memory_bytes: 10380