akhauriyash/Code-Regression huggingface dataset:
n,m=[int(x) for x in input().split()]
l=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)
# print(l)

done=[0]*n


def dfs(j):
  que=[j]
  cnt=1
  done[j]=1
  while(que):
    now=que.pop(0)

    for i in l[now]:
      if done[i]!=1:
        que.append(i)
        done[i]=1
        cnt+=1

  return cnt

ma=0
for j in range(n):
  if done[j]!=1:
    now=dfs(j)
  else:
    now=0
  ma=max(now,ma)
  
print(ma)

Measured memory_bytes: 45108
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}
ll p(int a,ll b){
    if(a==0){
        return 1;
    }
    ll k=1;
    for(int i=0;i<a;i++){
        k*=b;
        k%=MOD;
    }
    return k;
}


int main(){
int n;
cin>>n;
vector<ll> v(n);
rep(i,n){
    cin>>v[i];
}
ll ans = 0;


for(int i=0;i<60;i++){
    ll one=0;
    ll zero=0;
    rep(j,n){
        if((v[j]>>i)&1ll){
            one++;
        }else{
            zero++;
        }
    }

    ll k =0;
    if(one!=0){
        k = zero * one;
        k%=MOD;
        k = k * p(i, 2)%MOD;
        ans += k;
        ans %= MOD;
    }
}

cout<<ans%MOD<<endl;


return 0;
}


Measured memory_bytes: 2560
N, L = map(int, input().split())
listNL = [i for i in range(L, N+L)]
sumNL = sum(listNL)

minNL = 101

for j in range(N):
    if listNL[j] == 0:
        minNL = 0
    elif listNL[j] > 0:
        minNL = min(minNL, listNL[j])
    else:
        minNL = (-1)*(min(abs(minNL), abs(listNL[j])))
    

print(sumNL - minNL)


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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	long long l, r;
	cin >> l >> r;
	long long ans = 1e10;
	for (long long i = l; i < l + 2019 && i < r; ++i) {
		for (long long j = i + 1; j <= l + 2019 && j <= r; ++j) {
			ans = min(ans, (i * j) % 2019);
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define CFS           \
    cin.tie(nullptr); \
    ios::sync_with_stdio(false);
#define CST(x) cout << fixed << setprecision(x);
using namespace std;
const int IINF = 1 << 30;
const long LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
// const int MOD = 998244353;

int main()
{
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << "\n";
    }
    else {
        cout << "No" << "\n";
    }
}

Measured memory_bytes: 256
N, K = map(int, input().split())
lst = []
for _ in range(N):
    lst.append(int(input()))
lst = sorted(lst)
ret = 100000000000
 
for idx, x in enumerate(lst[:-K+1], 0):
    tmp = lst[idx + K-1] - x
    if tmp < ret:
        ret = tmp
print(ret)

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

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

  auto f = [&](int sign) {
    long long ans = 0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      sum += a[i];
      if (sign * sum <= 0) {
        ans += -1 * sign * sum + 1;
        sum = sign;
      }
      sign = sum < 0 ? 1 : -1;
    }
    return ans;
  };

  cout << min(f(1), f(-1)) << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e3 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


int n,m;
int a[N],b[N],c[N][15];

int dp[N][1<<13];

int fun(int x,int i){
  //  printf("%d\n", x);
    for(int j=1;j<=b[i];++j){
        if(check_bit(x,c[i][j]-1)==0){
            x+=(1<<(c[i][j]-1));
        }
    }
  //  printf("%d\n", x);
    return x;
}
int func(int i,int have)
{
    if(i>m){
        for(int j=0;j<n;++j){
            if(check_bit(have,j)!=1){
              //  printf("%d %d\n", have,j);
                return M;
            }
        }
        return 0;
    }

    if(dp[i][have]!=-1) return dp[i][have];
    dp[i][have]=min(a[i]+func(i+1,fun(have,i)),func(i+1,have));
    return dp[i][have];
}

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

    int t=1,te=0;
    // cin>>t;
    while(t--){
        
        cin>>n>>m;

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

            for(int j=1;j<=b[i];++j){
                cin>>c[i][j];
            }
        }
        memset(dp,-1,sizeof(dp));

        int res=func(1,0);

        if(res==M)res=-1;

        printf("%d\n", res);
        //printf("Case %d: ",++te);
    }
    return 0;
}

Measured memory_bytes: 32512
#include <bits/stdc++.h>
#define int long long int
#define MOD 1000000007
using namespace std;
bool strictly_inc(vector <int> v) {
        for(int i=0;i<v.size()-1;i++) {
                if(v[i] >= v[i+1])
                        return false;
        }
        return true;
}
bool strictly_dec(vector <int> v) {
        for(int i=0;i<v.size()-1;i++) {
                if(v[i] < v[i+1])
                        return false;
        }
        return true;
}
void solve() {
        int n;
        cin >> n;
        cout << n*(n-1)/2 << endl;
        return ;
}

int32_t main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        solve();
        return 0;
}


Measured memory_bytes: 256
import java.util.*;

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


Measured memory_bytes: 26440
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#define F first 
#define S second
const ll N = 200022 ;
int n, h[N], dp[N]; 
int main()
{
	scanf("%d", &n) ;
	for(int i = 1 ; i <= n ; i ++)	
		scanf("%d", &h[i]) ;
	dp[2] = fabs(h[2]-h[1]) ;
	for(int i = 3 ; i <= n ; i ++)
		dp[i] = min(dp[i-2]+fabs(h[i]-h[i-2]), dp[i-1]+fabs(h[i]-h[i-1])) ;
	cout << dp[n] ; 
}


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

int N;
vector<vector<pair<int, int> > > G;
vector<int> res;

void dfs(int v, int p, int c){
    res[v] = c;
    for(int i = 0; i < G[v].size(); i++){
        /* 親 */
        if(G[v][i].first == p) continue;
        if(G[v][i].second % 2 == 1) dfs(G[v][i].first, v, 1-c);
        else dfs(G[v][i].first, v, c);
    }
}

int main(void){
    // Your code here!
    cin >> N;
    G.assign(N, vector<pair<int, int>>());
    int u, v, w;
    for(int i = 0; i < N-1; i++){
        cin >> u >> v >> w;
        u--; v--;
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
    }
    
    res.assign(N, 0);
    dfs(0, -1, 0);
    for(int i = 0; i < N; i++) cout << res[i] << endl;
}


Measured memory_bytes: 8192
#!/usr/bin/env python3
import itertools
import math
n = int(input())
xs = []
ys = []
for _ in range(n):
    x, y = map(int, input().split())
    xs += [x]
    ys += [y]
num = 0
den = 0
for p in itertools.permutations(range(n)):
    dist = 0
    for i in range(n - 1):
        x1 = xs[p[i]]
        y1 = ys[p[i]]
        x2 = xs[p[i + 1]]
        y2 = ys[p[i + 1]]
        dist += math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
    num += dist
    den += 1
print('%.12f' % (num / den))


Measured memory_bytes: 3064
#include<cstdio>
using namespace std;
const int maxn = 100000;
int num[maxn + 10];
int main()
{
	int n;
	scanf("%d",&n);
	int h,t;
	int z = 0;
	scanf("%d",&h);
	int ans = 1;
	for(int i = 2;i <= n;++i)
	{
		scanf("%d",&t);
		if(z == 0)
		{
			if(t > h)
			{
				z = 1;
				h = t;
			}
			else if(t < h)
			{
				z = 2;
				h = t;
			}
		}
		else if(z == 1)
		{
			if(t < h)
			{
				z = 0;
				++ans;
			}
			h = t;
		}
		else if(z == 2)
		{
			if(t > h)
			{
				z = 0;
				++ans;
			}
			h = t;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>
#include <numeric>

using namespace std;

int main(void)
{
	vector <long long int> card;
	long long int t, n, S = 0,R = 0;
	long long int res = 2100000000;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> t;
		card.push_back(t);
		S += t;
	}

	for (int i = card.size() - 1; i > 0; i--)
	{
		S -= card[i];
		R += card[i];
		if (abs(S - R) < res)
		{
			res = abs(S - R);
		}
	}

	cout << res << endl;
	return 0;

}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
ll cnt[2 * N];
ll cal(ll a)
{
    return a * (a - 1) / 2;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    cin >> n;
    int a[n + 1];
    ll val = 0;
    FOR(i, 1, n)
    {
        cin >> a[i];
        cnt[a[i]]++;
    }
    FOR(i, 1, n)
    {
        val += cal(cnt[i]);
    }
    //cout << val << endl;
    FOR(i, 1, n)
    {
        cout << val - cal(cnt[a[i]]) + cal(cnt[a[i]] - 1) << '\n';
    }
    return 0;
}


Measured memory_bytes: 3968
using System;

namespace ABC064A
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');
            int r = int.Parse(str[0]);
            int g = int.Parse(str[1]);
            int b = int.Parse(str[2]);
            if ( (r*100+g*10+b) % 4 == 0){
               Console.WriteLine("YES");
            } else {
               Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 11092
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int mod = 1000000007;
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        long ans = 0;
        long p = 0;
        for (int i = 0; i < n; i++) {
            ans = (ans + ((long) nums[i] * p ) % mod) % mod;
            p = (nums[i] + p) % mod; 
        }
        System.out.println(ans);
	}
}

Measured memory_bytes: 61292
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

int main()
{
	long long int i, j, k, l, m,N,X,H,W, n,A,B, sum, flag, cc, cnt;
	sum = 0;
	flag = 1;
	char S[11]={};
	char ya[4];
	cin >> S;
	ya[0] = 'Y';
	ya[1] = 'A';
	ya[2] = 'K';
	ya[3] = 'I';
	for (i = 0; i <4; i++) {
		if (S[i] != ya[i]) {
			flag = 0;
			break;
		}
	}
	if (flag == 1) {
		cout << "Yes" << endl;

	}
	else
		cout << "No" << endl;







    return 0;
}



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


int main() {
  int N;
  cin >> N;
  int64_t Luca0 = 2, Luca1 = 1, Luca2;
  if (N == 1) {
    cout << 1 <<endl;
  }
  else {
    for (int i = 0; i < N-1; i++) {
      Luca2 = Luca1 + Luca0; 
      Luca0 = Luca1;
      Luca1 = Luca2;
    }
    cout << Luca2 << endl;
  }
        
}

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

using namespace std;

const long long mod = 1e9+7;
vector<long long> DP;


long long dp(long long n){
    if(DP[n] == 0){
        return DP[n];
    } else if (DP[n] > 0){
        return DP[n];
    } else {
        DP[n] = (dp(n-1) + dp(n-2))%mod;
    }

    return DP[n];
}

int main(){
    int n, m, x; cin >> n >> m;
    DP.assign(n, -1);

    while(m--){
        cin >> x;
        DP[x-1] = 0;
    }
    if(DP[0] == 0 && DP[1] == 0){
        cout << "0";
        return 0;
    } else if(DP[0] == 0 && DP[1] == -1){
        DP[1] = 1;
    } else if(DP[0] == -1 && DP[1] == 0){
        DP[0] = 1;
    } else if(DP[0] == -1 && DP[0] == -1){
        DP[0] = 1;
        DP[1] = 2;
    }
    cout << dp(n-1)%mod;
    return 0;
}

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

const int M = 1000000007;
const long long LM = (long long)1e17;
int d[5] = { 0, 1, 0, -1, 0 };

int main() {
    int w, h, si, sj, gi, gj;
    cin >> w >> h;
    vector<string> s(h);
    queue<pair<int, int>> q;
    vector<vector<int>> dsp(h, vector<int>(w, M));
    vector<vector<long long>> dg(h, vector<long long>(w, LM * 2));
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
        for (int j = 0; j < w; ++j) {
            if (s[i][j] == 's') {
                si = i;
                sj = j;
            }
            else if (s[i][j] == 'g') {
                gi = i;
                gj = j;
                dg[i][j] = 0;
            }
            else if (s[i][j] == '*') {
                dsp[i][j] = 0;
                q.push(make_pair(i, j));
            }
        }
    }
    while (!q.empty()) {
        pair<int, int> p = q.front();
        q.pop();
        int pi = p.first, pj = p.second;
        for (int i = 0; i < 4; ++i) {
            int ti = pi + d[i], tj = pj + d[i + 1];
            if (s[ti][tj] != '#' && dsp[ti][tj] > dsp[pi][pj] + 1) {
                dsp[ti][tj] = dsp[pi][pj] + 1;
                q.push(make_pair(ti, tj));
            }
        }
    }
    q.push(make_pair(gi, gj));
    while (!q.empty()) {
        pair<int, int> p = q.front();
        q.pop();
        int pi = p.first, pj = p.second;
        for (int i = 0; i < 4; ++i) {
            int ti = pi + d[i], tj = pj + d[i + 1];
            if (s[ti][tj] != '#' && s[ti][tj] != '*' && dg[ti][tj] > dg[pi][pj] + 1) {
                dg[ti][tj] = dg[pi][pj] + 1;
                q.push(make_pair(ti, tj));
            }
        }
    }
    long long l = 0, r = LM;
    double k = -1;
    while (l <= r) {
        long long m = (l + r) / 2;
        int c = 0;
        long long dist = 0;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                if (s[i][j] == 's' || s[i][j] == '.') {
                    ++c;
                    if (dg[i][j] > dsp[i][j] + m) {
                        --c;
                        dist += dsp[i][j];
                    }
                    else {
                        dist += dg[i][j];
                    }
                }
            }
        }
        k = dist / (double)c;
        if (m - 1e-9 < k && k < m + 1) {
            break;
        }
        else if (m < k) {
            l = m + 1;
        }
        else {
            r = m - 1;
        }
    }
    printf("%.12lf\n", min((double)dg[si][sj], dsp[si][sj] + k));
    return 0;
}

Measured memory_bytes: 6392
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long x = in.nextLong();
        long y = in.nextLong();

        int len = 0;
        long cur = x;
        while (cur <= y) {
            len++;
            cur = cur * 2;
        }

        System.out.println(len);
    }
}

Measured memory_bytes: 35896
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define mod 1000000007
using namespace std;

int main(){
	ll n, k; cin >> n >> k;
	ll ans = 0, e = 0,o = 0;
	for (ll i = k % 2 ? 2 : 1; (i*k)/2 <= n; i+= k % 2 ? 2 : 1){
		if (i % 2) o++;
		else e++;
	}cout << (ll)(pow(o, 3) + pow(e, 3)) << endl;

	return 0;
}

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

int main()
{
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	int dx = tx - sx;
	int dy = ty - sy;

	cout << string(dx, 'R');
	cout << string(dy, 'U');
	cout << string(dx, 'L');
	cout << string(dy, 'D');
	cout << "D" << string(dx + 1, 'R');
	cout <<  string(dy + 1, 'U') << "L";
	cout << "U" << string(dx + 1, 'L');
	cout <<  string(dy + 1, 'D') << "R";
	cout << endl;
}


Measured memory_bytes: 256
s=input()
temp=""
for c in s:
     if c!="x": temp+=c
if temp!=temp[::-1]: print(-1)
elif len(temp)==0:  print(0)
else:
    a=temp[0:len(temp)//2]
    l,r=0,len(s)-1
    ans=0
    while l<r:
        if s[l]==s[r]:
            l+=1
            r-=1
            continue
        elif s[l]=="x": l+=1
        else: r-=1
        ans+=1
    print(ans)

Measured memory_bytes: 9304
#include<stdio.h>
int main(void)
{
	int e[12],i,j,box;
	for(i=0;i<12;i++){
		scanf("%d",&e[i]);
	}
	for(i=0;i<11;i++){
		for(j=i+1;j<12;j++){
			if(e[i]>e[j]){
			box=e[i];
			e[i]=e[j];
			e[j]=box;
			}
		}
	}
	if(e[0]==e[1]&&e[1]==e[2]&&e[2]==e[3]&&e[4]==e[5]&&e[5]==e[6]&&e[6]==e[7]&&e[8]==e[9]&&e[9]==e[10]&&e[10]==e[11]){
	printf("yes\n");
	}
	else{
	printf("no\n");
	}
	return 0;
}
	


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

vector<long long> h;

long long parent(int n){
  return n/2;
}

long long left(int n){
  return n*2;
}
long long right(int n){
  return n*2+1;
}

void maxHeapify(int x){
  int l = left(x), r = right(x);

  int largest = x;
  if(l < h.size() && h[l] > h[largest]) largest = l;
  if(r < h.size() && h[r] > h[largest]) largest = r;

  swap(h[x], h[largest]);

  if(largest != x) maxHeapify(largest);
}

void buildMaxHeap(){
  for(int i=h.size()/2; i>0; --i){
    maxHeapify(i);
  }
}

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

  h.resize(n+1);
  for(int i=1; i<=n; ++i) cin >> h[i];

  buildMaxHeap();

  for(int i=1; i<h.size(); ++i){
    cout << " " << h[i];
  }cout << endl;
}



Measured memory_bytes: 6676
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

//graph[出発地]に辺を入れる。initした後に入れないとダメ
struct edge{int to; int cost;};
vector<vector<edge>> graph(0);
vector<int> d(0);
const int MAX_dist=1e9;

//頂点数でinitが必要
void init(int n){
    graph.resize(n);
    d.resize(n,MAX_dist);
}

//スタート地点を入れる
//O((V+E)logV)くらい V:頂点, E:辺の数
void dijkstra(int s){
//if(d.size()==0){cout<<"You Should init"<<endl;return;}
    priority_queue<P, vector<P>, greater<P>> que;
    d[s]=0;
    que.emplace(0,s);
    while(!que.empty()){
        P p=que.top();
        que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        rep(i,graph[v].size()){
            edge e=graph[v][i];
            if(d[e.to]>d[v]+e.cost){
            d[e.to]=d[v]+e.cost;
            que.emplace(d[e.to],e.to);
            }
        }
    }
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,m;
    cin>>n>>m;
    vector<vector<int>> g(n,vector<int>(0));
    int x,y;
    rep(i,m){
        cin>>x>>y;
        x --,y --;
        g[x].emplace_back(y);
    }
    int s,t;
    cin>>s>>t;
    s--,t--;

    init(n*3);
    rep(i,n){
        for(auto z:g[i]){
            graph[i].push_back({z+n,1});
            graph[i+n].push_back({z+n+n,1});
            graph[i+n+n].push_back({z,1});
        }
    }
    dijkstra(s);
    if(d[t]==MAX_dist) cout<<-1<<endl;
    else cout<<d[t]/3<<endl;
}/*
./problem.exe
*/

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

int main(){
    int N,M; cin >> N >> M;
    vector<int> g[100100];
    for(int i=0;i<N;i++){
        int a,b; cin >> a >> b;
        g[a].push_back(b);
    }
    priority_queue<int> que;
    int ans=0;
    for(int i=1;i<=M;i++){
        for(auto v:g[i]){
            que.push(v);
        }
        if(!que.empty()){
            int res=que.top(); que.pop();
            ans+=res;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5632
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


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


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


void solve(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a>c)	 swap(a,c);
	if(b>=a && b<=c){
		int d1,d2;
		d1=b-a; d2=c-b;
		if(d1<=d && d2<=d){
			cout<<"Yes";
		} else cout<<"No";
	} else{
		int d1=c-a;
		if(d1<=d)
		cout<<"Yes";
		else
		cout<<"No";
	}
	
}


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


int32_t main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}


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

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

    if(n==0)break;

    char c[100];
    for(int i=0; i<n; i++){
      cin >> c[i];
    }

    int cnt[26] = {0};

    for(int i=0; i<n; i++){
      cnt[(int)(c[i]-'A')]++;

      int max1 = -1;
      int max2 = -1;

      for(int j=0; j<26; j++){
        if(cnt[j]>max1){
          max2 = max1;
          max1 = cnt[j];
        }else if(cnt[j]>max2){
          max2 = cnt[j];
        }
      }

      if(max1-max2>n-(i+1)){
        for(int j=0; j<26; j++){
          if(cnt[j]==max1){
            cout << (char)(j+'A') << ' ';
            break;
          }
        }
        cout << (i+1) << endl;
        break;
      }

      if(i==n-1){
        cout << "TIE" << endl;
        break;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 3104
l, r = map(int, input().split())
if r - l >= 2018:
  print(0)
  exit()
l = l % 2019
r = r % 2019
if l > r:
  r += 2019
ans = 2019
for i in range(l, r):
  for j in range(i+1, r+1):
    ans = min(ans,i*j%2019)
print(ans)

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

int r, g, b;

int main() {
	cin >> r >> g >> b;
	int a = 100 * r + 10 * g + b;
	if (a % 4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

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

using namespace std;
const int N = 3e3 + 123 ;
double mem[N][N] , p[N];
bool vis[N][N];
int n;
double solve(int i , int h){
//    if(idx >= n) return(n - h < h);
//    if(vis[idx][h])
//        return mem[idx][h];
//    vis[idx][h] = 1;
//    double ret = 0;
//    ret+=(p[idx] * solve(idx + 1 , h + 1));
//    ret+=(( 1.0 - p[idx] )* solve(idx + 1 , h));
//    return mem[idx][h] = ret;
    if ( i >= n ) return ( n - h < h );
    if ( vis[i][h] ) return mem[i][h];

    vis[i][h] = 1;

    double ret = 0;
    ret += p[i] * solve ( i+1, h+1 );
    ret += (1.0 - p[i] ) * solve( i+1, h );

    return mem[i][h] = ret;
}
int main()
{   ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 0 ; i < n ; ++i) cin >>p[i];
    cout << fixed << setprecision(10) << solve(0 , 0);

    return 0;
}


Measured memory_bytes: 84352
#include<bits/stdc++.h>
#define ll  long long
#define pp pair<int,int>
#define ppn pair<pp,int>
#define F first
#define S second
#define N 1000005
#define mod 1000000007
#define pi 3.14159265358979323846

using namespace std;



int main()
{


    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

   int n;
   cin>>n;
      cout<<(n?0:1)<<endl;
}


Measured memory_bytes: 3652
N = int(input())
A = list(map(int, input().split()))
sumA = sum(A)

subsum = 0
for itr, val in enumerate(A):
  subsum += val
  if subsum >= sumA / 2:
    p = itr
    ax = val
    break

ans = min(subsum * 2 -sumA, sumA - (subsum - ax) * 2)
print(ans)

Measured memory_bytes: 26764
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int> pii;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n;
const int Maxn=2e5+5;
const int mod=1e9+7;
int a[Maxn];

int main(){
	scanf("%d",&n);
	int sum=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum=((ll)sum+a[i])%mod;
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		sum=(((ll)sum-a[i])%mod+mod)%mod;
		ans=((ll)ans+(ll)a[i]*sum%mod)%mod;
	}
	cout<<ans%mod<<endl;
	return 0;
}

Measured memory_bytes: 4452
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        char c1[1000],c2[1000];
        scanf("%s",&c1);
        scanf("%s",&c2);
        string s1,s2;
        s1=c1, s2=c2;
        if(s1=="0" && s2=="0"){
            printf("0\n");
            continue;
        }
        reverse(s1.begin(),s1.end());
        reverse(s2.begin(),s2.end());
        int n=max(s1.size(),s2.size())+1;
        for(int i=s1.size();i<n;i++){
            s1+='0';
        }
        for(int i=s2.size();i<n;i++){
            s2+='0';
        }
        string res;
        int b=0;
        for(int i=0;i<max(s1.size(),s2.size());i++){
            int u=s1[i]-'0'+s2[i]-'0'+b;
            b=(u>=10); u%=10;
            res+=u+'0';
        }

        reverse(res.begin(),res.end());
        string res2;
        int j=0;
        while(res[j]=='0') j++;
        for(;j<res.size();j++){
            res2+=res[j];
        }

        if(res2.size()>80){
            printf("overflow\n");
        }else{
            printf("%s\n",res2.c_str());
        }
    }
    return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll> 
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w,inf=1e9+7,ans=0,ans_=0;cin>>h>>w;
  ll s1=(w+2)/3,t1=(h+2)/3;
  {
    // | |
    ll s2=(w-s1+1)/2, ans1=h*s1-h*(w-s1-s2);
    // | -
    ll t2=(h+1)/2;
    ll ans2=h*s1-(w-s1)*(h-t2);
    ll ans3=abs(h*(s1-1)-(w-s1+1)*t2);
    ans=min({ans1,ans2,ans3});
  }
  {
    // - -
    ll t2=(h-t1+1)/2, ans1=w*t1-w*(h-t1-t2);
    // - |
    ll s2=(w+1)/2;
    ll ans2=w*t1-(h-t1)*(w-s2);
    ll ans3=abs(w*(t1-1)-(h-t1+1)*s2);
    ans_=min({ans1,ans2,ans3});
  }
  ans=min(ans,ans_);
  print(ans);
  return 0;
}

Measured memory_bytes: 256
import Control.Monad (replicateM)
import Data.Array
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInts :: IO [Integer]
readInts = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readStrings :: IO [BS.ByteString]
readStrings = BS.words <$> BS.getLine

main :: IO ()
main = do
  (n:_) <- readInts
  st <- map (change . words) <$> replicateM (fromInteger n) getLine
  x <- getLine
  print $ solve st x

change :: [String] -> (String, Integer)
change (s:t:_) = (s, read t)

solve :: [(String, Integer)] -> String -> Integer
solve ((s, _):st) x
  | s == x = sum $ map snd st
  | otherwise = solve st x

Measured memory_bytes: 1020
#include<iostream>
#include<cstdio>
#include<vector>
#define maxn 2000010
#define ll long long
#define mod 924844033
using namespace std;
int n,x,y,cnt[maxn],siz[maxn],r[maxn];
ll fac[maxn],inv[maxn],A[maxn],B[maxn];
vector<int>vec[maxn];
ll ksm(ll x,ll i){
	ll res=1;
	for(;i;i>>=1,x=x*x%mod)
		if(i&1)res=res*x%mod;
	return res;
}
void dfs(int u,int fa){
	siz[u]=1;
	for(auto v:vec[u]){
		if(v==fa)continue;
		dfs(v,u);
		siz[u]+=siz[v];
	}
	cnt[siz[u]]--;
	if(u!=1)cnt[n-siz[u]]--;
}
inline void NTT(ll *A,int lim,int opt){
	for(register int i=0;i<lim;i++)if(i<r[i])swap(A[i],A[r[i]]);
	for(register int mid=1;mid<lim;mid<<=1){
		ll W=ksm(5,(mod-1)/(mid<<1));if(opt==-1)W=ksm(W,mod-2);
		for(register int step=mid<<1,j=0;j<lim;j+=step){
			ll w=1;
			for(register int k=0;k<mid;k++,w=w*W%mod){
				ll x=A[j+k],y=w*A[j+mid+k]%mod;
				A[j+k]=(x+y)%mod;
				A[j+mid+k]=(x-y+mod)%mod;
			}
		}
	}
	if(opt==-1){
		ll inv=ksm(lim,mod-2);
		for(register int i=0;i<lim;i++)A[i]=A[i]*inv%mod;
	}
}
int main(){
	scanf("%d",&n);
	fac[0]=inv[0]=1;
	for(register int i=1;i<=n;i++)fac[i]=fac[i-1]*i%mod;
	inv[n]=ksm(fac[n],mod-2);
	for(register int i=n-1;i;i--)inv[i]=inv[i+1]*(i+1)%mod;
	for(register int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		vec[x].push_back(y);
		vec[y].push_back(x);
	}
	dfs(1,0);
	cnt[n]=n;
	int lim=1,l=0;
	while(lim<n*2)lim<<=1,l++;
	for(register int i=0;i<lim;i++)r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
	for(register int i=0;i<=n;i++)A[n-i]=fac[i]*cnt[i]%mod;
	for(register int i=0;i<=n;i++)B[i]=inv[i];
	NTT(A,lim,1);NTT(B,lim,1);
	for(register int i=0;i<lim;i++)A[i]=A[i]*B[i]%mod;
	NTT(A,lim,-1);
	for(register int i=1;i<=n;i++)printf("%lld\n",(A[n-i]*inv[i]%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 90752
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

a, b = nm()

print((b - a) * (b - a - 1) // 2 - a)

Measured memory_bytes: 3696
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  Scanner sc;

  int date(int y, int m, int d) {
    return ( y - 1 ) * ( 19 + 20 ) * 5 + ( ( y - 1 ) / 3 ) * 5 + ( m - 1 ) * 20
        - ( y % 3 == 0 ? 0 : ( m - 1 ) / 2 ) + d;
  }

  void run() {
    int n = ni();
    int base = date( 1000, 1, 1 );
    for ( int i = 0; i < n; ++i ) {
      int y, m, d;
      y = ni();
      m = ni();
      d = ni();
      int dst = date( y, m, d );

      System.out.println( base - dst );
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }

}

Measured memory_bytes: 20688
#include <stdio.h>
#include <string.h>

#define def_func(name) int name(int f, int l)
#define gen_func(name, next, aop1, op1, aop2, op2) \
def_func(name){ \
    int i; \
    for (i = l; i >= f; i--){ \
        if (expr[i] == ')') i = find_open(f, i - 1) - 1; \
        if (expr[i] == aop1) return (name(f, i - 1) op1 next(i + 1, l)); \
        if (expr[i] == aop2) return (name(f, i - 1) op2 next(i + 1, l)); \
    } \
    return (next(f, l)); \
} \

char expr[128];

def_func(eval);
def_func(term);
def_func(factor);
def_func(find_open);
 
int main(void)
{
    int n, i;

    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf(" %s", expr);
        printf("%d\n", eval(0, strlen(expr) - 2));
    }
    return (0);
}

gen_func(eval, term, '+', +, '-', -)
gen_func(term, factor, '*', *, '/', /)
def_func(factor)
{
    if (expr[f] == '(') return (eval(f + 1, l - 1));
    return (atoi(expr + f));
}

def_func(find_open)
{
    int i;
    int close = 0;
    for (i = l; i >= f; i--){
        if (expr[i] == ')') close++;
        if (expr[i] == '('){
            if (close == 0) break;
            close--;
        }
    }
    return (i);
}

Measured memory_bytes: 596
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	// var ap [100000]int
	// var bp [100000]int
	// var x, y, c, p int

	io := NewIo()
	defer io.Flush()

	A := io.NextInt()
	// B := io.NextInt()
	// M := io.NextInt()
	// fmt.Printf("%v %v %v\n", A, B, M)
	mat := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	// fmt.Printf("%d\n", A)
	res := mat[A-1]
	// fmt.Printf("%d %d\n", A, mat[A-1])
	// amin := 10000000
	// for i := 0; i < A; i++ {
	// 	ap[i] = io.NextInt()
	// 	if amin > ap[i] {
	// 		amin = ap[i]
	// 	}
	// }

	// bmin := 100000000
	// for i := 0; i < B; i++ {
	// 	bp[i] = io.NextInt()
	// 	if bmin > bp[i] {
	// 		bmin = bp[i]
	// 	}
	// }

	// min := amin + bmin

	// for i := 0; i < M; i++ {
	// 	x = io.NextInt()
	// 	y = io.NextInt()
	// 	c = io.NextInt()
	// 	p = ap[x-1] + bp[y-1] - c
	// 	if min > p {
	// 		min = p
	// 	}
	// }
	io.PrintLn(res)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAX = 1e5+2;
int n,m;
int res;
int u0,v0;
int h[MAX];
vector<int> adj[MAX];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>u0>>v0;
        adj[u0].push_back(v0);
        adj[v0].push_back(u0);
    }
    for(int i=1;i<=n;i++)
    {
        bool flag = true;
        for(int j=0;j<adj[i].size();j++)
        {
            if(h[i] <= h[adj[i][j]])
            {
                flag = false;
                break;
            }
        }
        res+=flag;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 9116
#include <stdio.h>
#include <math.h>


int main(void)
{
	//変数の宣言
	int n;
	int a[100010];
	int i;
	int max=0;
	double center;
	int near=0;
	int temp1,temp2;
	
	//データの読み込み
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	
	for(i=0;i<n;i++){
//		printf("max=%d,a[i]=%d\n",max,a[i]);
		if(max<a[i]) max=a[i];
	}
	
//	printf("max=%d\n",max);
	center=(double)max/2;
//	printf("center=%lf\n",center);
	
	for(i=0;i<n;i++){
		temp1=fabs(a[i]-center);
		temp2=fabs(near-center);
//		printf("temp1=%lf,temp2=%lf",temp1,temp2);
		if(temp1<temp2) near=a[i];
	}
	
//	printf("計算部分終了\n");
	
	//出力
	
	printf("%d %d",max,near);
	
//	printf("結果の出力終了\n");
	
	return 0;
}



Measured memory_bytes: 640
num_a = 5
antennas = [int(input()) for _ in range(num_a)]
k = int(input())
exist = False
for q in range(num_a - 1, 0, -1):
    for p in range(q - 1, -1, -1):
        if antennas[q] - antennas[p] > k:
            exist = True
            break

if exist:
    print(":(")
else:
    print("Yay!")


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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.beggin(), x.end(), greater<t>());
#define dump(x)  cout << #x << " = " << (x) << endl
#define vuniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define minse(m, s) m.insert(make_pair(s, 1));
#define mfin(m, s) m.find(s) != m.end()

#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

int main(){
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i < x + k; i++) {
        cout << (i == x - k + 1 ? "": " ") << i;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

long a[1005][1005];
char m[1005][1005];

int main()
{
	long rows, cols;
    cin>>rows>>cols;
    memset(a, 0, sizeof(a));
    for(int i = 0; i < rows; ++i)
        for(int j = 0; j < cols; ++j)
            cin>>m[i][j];
    a[0][0] = 1;
    for(int i = 1; i < cols; ++i)
        if(m[0][i] != '#')
            a[0][i] += a[0][i - 1];
    for(int i = 1; i < rows; ++i)
        if(m[i][0] != '#')
            a[i][0] += a[i - 1][0];
    for(int i = 1; i < rows; ++i)
    {
        for(int j = 1; j < cols; ++j)
        {
            if(m[i][j] != '#')
            {
                if(m[i - 1][j] != '#')
                    a[i][j] = (a[i][j] % mod + a[i - 1][j] % mod) % mod;
                if(m[i][j - 1] != '#')
                    a[i][j] = (a[i][j] % mod + a[i][j - 1] % mod) % mod; 
            }
        }
    }
    cout<<a[rows - 1][cols - 1] % mod;
    return 0;
}

Measured memory_bytes: 9088
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>	
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int main()
{
	IO;
	int n{},res{},ans{},f{};
	cin>>n;
	vector<ll>v(n);
	For(i,0,n)cin>>v[i];
	while(true){
		For(i,0,n)
		{
			if(v[i]&1){f=1;break;}
			else if(!(v[i]%2))res++,v[i]/=2;
		}
		if(f){cout<<ans<<'\n';break;}
		if(res==n)ans++;
		res=0;
	}
//	system("pause");
	return 0;	
}

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

using namespace std;
#define MAX 1000

int lcs(string X, string Y) {
  int c[MAX+1][MAX+1];
  int m, n;
  m = X.size();
  n = Y.size();
  int maxlen = 0;
  X = ' ' + X;
  Y = ' ' + Y;

  for (int i = 0; i <= m; i++) {
    c[i][0] = 0;
  }
  for (int j = 0; j <= n; j++) {
    c[0][j] = 0;
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (X[i] == Y[j]) {
        c[i][j] = c[i - 1][j - 1] + 1;
      } else {
        c[i][j] = max(c[i][j - 1], c[i - 1][j]);
      }
      maxlen = max(maxlen, c[i][j]);
    }
  }
  return maxlen;
}


int main()
{
  int q; cin >> q;
  for (int i = 0; i < q; i++) {
    string x, y; cin >> x >> y;
    cout << lcs(x, y) << endl;
  }
  return 0;
}


Measured memory_bytes: 7036
#a=int(input())
#b,c=int(input()),int(input())
# c=[]
#  for i in b:
#     c.append(i)
N,T = map(int,input().split())
# f = list(map(int,input().split()))
#j = [input() for _ in range(a)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split())))
a=[]
for i in range(N):
    c,d = map(int,input().split())
    if T>=d:
        a.append(c)
if len(a)==0:
    print("TLE")
else:print(min(a))


Measured memory_bytes: 61704
s = input()
s = list(s)

for i in range(len(s)):
    if (i % 2 == 0 and s[i] == 'L') or (i % 2 == 1 and s[i] == 'R'):
        print('No')
        break
    if i == len(s)-1:
        print('Yes')

Measured memory_bytes: 2940
n, m, c = map(int, input().split(' '))
coff = list(map(int, input().split(' ')))
ans = 0
for _ in range(n):
    a = list(map(int, input().split(' ')))
    tmp = 0
    for i, j in zip(a, coff):
        tmp += (i * j)

    tmp += c

    if tmp > 0:
        ans += 1
print(ans)

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

vector<ll> toDigit(ll num)
{
	vector<ll> d;
	while (num)
	{
		d.push_back(num%10);
		num /= 10;
	}
	reverse(d.begin(), d.end());
	return d;
}

int main(int argc, char **argv)
{
	ll N; cin >> N;

	ll cnt[10][10]{};
	FOR(n, 1, N+1)
	{
		vector<ll> v = toDigit(n);
		++cnt[v.front()][v.back()];
	}

	ll res{0};
	FOR(i, 1, 10)FOR(k, 1, 10)
	{
		res += cnt[i][k] * cnt[k][i];
	}

	std::cout << res << std::endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
  string str;
  ll N;
  cin >> str >> N;

  ll strLen = (ll)str.length();

  map<string, ll> m;
  for (int i = 1; i <= min(5LL, strLen); ++i) {
    for (int p = 0; p < strLen - i + 1; ++p) {
      string tmp = "";
      for (int j = 0; j < i; ++j) {
        tmp += str[p+j];
      }
      m[tmp]++;
    }
  }

  ll cnt = 0;
  string ans;
  for (auto kv : m) {
    ans = kv.first;
    cnt++;
    if (cnt == N) break;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e+9 + 7;
 
int main(){
  ll n,k;
  cin >> n >> k;
  ll r,s,p;
  cin >> r >> s >> p;
  string t;
  cin >> t;
  bool flag[k];
  for(int i = 0;i<k;++i) flag[i] = true;
  ll ans = 0;
  int tmp = 0;
  for(int i = 0; i<n; ++i){
    tmp = i%k;
    if(i>=k){
      if(t[i] == t[i-k]) flag[tmp] = !flag[tmp];
      else flag[tmp] = true;
    }
    if(flag[tmp]){  
      if(t[i] == 'r') ans += p;
      else if(t[i] == 's') ans += r;
      else if(t[i] == 'p') ans += s;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
var
  a:array[1..100] of longint;
  n,i,s,x,y:longint;
begin
  readln(n);
  for i:=1 to n do
    begin
      read(a[i]);
      s:=s+a[i];
    end;
  readln(n);
  for i:=1 to n do
    begin
      readln(x,y);
      writeln(s-a[x]+y);
    end;
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> void show(vector<T>v){rep(i,v.size()-1){cout<<v.at(i)<<" ";}cout<<v.at(v.size()-1)<<endl;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here

int main() {
    int a, b, t;
    cin >> a >> b >> t;
    cout << (t / a) * b << endl;
    return 0;
}

Measured memory_bytes: 256