akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main(){
  int a,b;
  int A,B,C; 
  cin >> a >> b;
  
  A = a + a - 1;
  B = b + b - 1;
  C = a + b;
  int ans = max(A, B);
  ans = max(ans, C);
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  unordered_map<int, int> mp;
  REP(n,N){
    int a;
    cin >> a;
    mp[a]++;
  }
  int ans = 0;
  for(auto m=mp.begin(); m!=mp.end(); m++){
    if(m->first > m->second) ans += m->second;
    else if(m->first < m->second) ans += m->second - m->first;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4260
#include<stdio.h>
#include<limits.h>
int main(){
	int n, m;
	int i, j;
	while(scanf("%d%d", &n, &m), n) {
		int cost[100][100] = {0};
		int determined[100] = {0}, undeterminednodes = n;
		//int mincost[100] = {0};
		int *mincost = cost[0];
		int costsum = 0;
		int minnode, minnodecost, nextminnode;

		for(i = 0; i < n; i ++) {
			for(j = 0; j < n; j ++) {
				cost[i][j] = INT_MAX;
			}
		}
		/*for(i = 0; i < n; i ++) {
			mincost[i] = INT_MAX;
		}*/
		for(i = 0; i < m; i ++) {
			int a, b, d;
			scanf("%d,%d,%d", &a, &b, &d);
			cost[a][b] = cost[b][a] = d/100-1;
		}
		minnode = 0;
		minnodecost = 0;

		while(undeterminednodes > 0) {
			determined[minnode] = 1;
			costsum += minnodecost;
			undeterminednodes --;
			mincost[minnode] = INT_MAX;
			minnodecost = INT_MAX;
			for(i = 0; i < n; i ++) {
				if(!determined[i]) {
					if(cost[minnode][i] < mincost[i])
						mincost[i] = cost[minnode][i];
				}
				if(mincost[i] < minnodecost) {
					nextminnode = i;
					minnodecost = mincost[i];
				}
			}
			minnode = nextminnode;
		}
		printf("%d\n", costsum);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, p;
    while(cin >> n >> p, n or p)
    {
        int num = p;
        vector<int> v(n, 0);
        int pos = 0;
        while(true)
        {
            if(num > 0)
            {
                v[pos]++;
                num--;
            }
            else
            {
                num = v[pos];
                v[pos] = 0;
            }
            if(v[pos] == p) break;
            pos = (pos + 1) % n;
        }
        cout << pos << endl;
    }
    return 0;
}




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

int main() {
    int n; cin >> n;
    for (int i=0; i<=n; i += 4) {
        int d = n - i;
        if (d%7) continue;
        else {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,t;
  cin>>n>>x>>t;
  if(n % x ==0){
  cout<< (n/x) * t;}
  else
    cout<< ((n/x) +1)*t;
  //cout<<(n%x==0)? (n/x)*t : ((n/x)+1)*t;
  return 0;}

Measured memory_bytes: 3592
N = int(input())
A = list(map(int,input().split()))
def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

ans = A[0]
tmp = []
for i in range(1,N):
  tmp.append(gcd(ans,A[i]))
print(min(tmp))

Measured memory_bytes: 14252
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int a = 0;
        int b = 0;
        for(int i = 1; i < n; i++){
            a += i;
        }
        for(int i = 1; i < m; i++){
            b += i;
        }
        System.out.println(a + b);
    }
}

Measured memory_bytes: 23508
#include<iostream>
#include<string>
using namespace std;
int main() {
	string o, e;
	int j = 0;
	cin >> o >> e;
	int a = o.size(), b = e.size();
	if ((a + b) % 2 == 1) {
		a--;
	}
	for (int i = 0; i < a+b; i += 2) {
		o.insert(i+1, 1, e[j]);
		j++;
	}
	cout << o << endl;
	return 0;
}


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

int main() {
    int n;
    scanf("%d", &n);
    int type = 0;
    int last = -1;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        if(last == -1) {
            last = x;
        } else if (last == x) {
            // do nothing
        } else if (type != -1 && last < x) {
            last = x;
            type = 1;
        } else if (type != 1 && last > x) {
            last = x;
            type = -1;
        } else {
            last = x;
            type = 0;
            ++ans;
        }
    }
    printf("%d\n", ans+1);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int a,b;
	cin >> a >>b;
	double c = (double) (a+b)/2;
	if (c > (int) (a+b)/2) c +=1;
	cout << (int) c << endl;
	return 0;
}


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

string paircard(int card[]){
		int num[13] = {0};
		for(int i=0;i<5;i++) num[card[i]-1]++;
		sort(num,num+13,greater<int>());
			if(num[0] == 4 && num[1] ==1) return "four card";
			if(num[0] == 3 && num[1] ==2) return "full house";
			if(num[0] == 3 && num[1] ==1) return "three card";
			if(num[0] == 2 && num[1] ==2) return "two pair";
			if(num[0] == 2 && num[1] ==1) return "one pair";
		return "null";
}

bool straight(int card[]){
	if(card[0] == 1 && card[1]==10 && card[2] == 11 && card[3] == 12 && card[4] == 13)
	return true;
	int ans = 1;
	for(int i=0;i+1<5;i++) if(card[0]+i+1 == card[i+1]) ans++;
	if(ans==5) return true;

	return false;
}

string poker(int card[]){
	if(straight(card)){return "straight";}
 	return paircard(card);
}

int main(){
	char k; int card[5];
	while(1){
		cin>>card[0]>>k>>card[1]>>k>>card[2]>>k>>card[3]>>k>>card[4];
				if(cin.eof())break;
		sort(card,card+5);
		cout << poker(card) << endl;
	}
}

Measured memory_bytes: 1212
N, K = map(int, input().split())
AB = list(list(map(int, input().split())) for _ in range(N))

AB.sort()
if AB[0][1] >= K:
    ans = AB[0][0]
else:
    for i in range(1,N):
        AB[i][1] += AB[i-1][1]
        if AB[i][1] >= K:
            ans = AB[i][0]
            break
print(ans)


Measured memory_bytes: 30980
#include<bits/stdc++.h>
using namespace std;
int vis[100][100];

int main()
{
    int n,m;
    char a[55][55];
    long long sum;
    while(cin>>n>>m)
    {
        for(int i=0;i<100;i++)
            for(int j=0;j<100;j++)
            vis[i][j]==0;
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='#')
                {
                    int x1=i-1,y1=j,x2=i,y2=j+1,x3=i+1,y3=j,x4=i,y4=j-1;
                    if(x1>=0&&x1<n&&y1>=0&&y1<m)
                        if(a[x1][y1]=='#')
                            vis[i][j]=1;
                    if(x2>=0&&x2<n&&y2>=0&&y2<m)
                        if(a[x2][y2]=='#')
                            vis[i][j]=1;
                    if(x3>=0&&x3<n&&y3>=0&&y3<m)
                        if(a[x3][y3]=='#')
                            vis[i][j]=1;
                    if(x4>=0&&x4<n&&y4>=0&&y4<m)
                        if(a[x4][y4]=='#')
                            vis[i][j]=1;

                }


            }
            int flag=1;
            for(int i=0;i<n;i++)
                for(int j=0;j<m;j++)
                {
                    if(a[i][j]=='#'&&vis[i][j]!=1)
                        flag=0;
                }
            if(flag)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define R register
#define ll long long
#define mp make_pair
#define pii pair<int, int>
using namespace std;
const int N = 110000;

ll lcm, n, m, a[N];

template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

ll getGcd(ll a, ll b) {
    return b ? getGcd(b, a % b) : a;
}

int main() {
    read(n), read(m);
    for (R int i = 1; i <= n; ++i) read(a[i]);
    int num = 0;
    while (~a[1] & 1) a[1] >>= 1, ++num;
    lcm = a[1];
    for (R int i = 2; i <= num; ++i) m >>= 1;
    for (R int i = 2; i <= n; ++i) {
        for (R int j = 1; j <= num; ++j) {
            if (a[i] & 1) return printf("0\n"), 0;
            a[i] >>= 1;
        }
        lcm = lcm / getGcd(lcm, a[i]) * a[i];
        if (~a[i] & 1 || lcm > m) return printf("0\n"), 0;
    }
    printf("%lld\n", m / lcm - m / 2 / lcm);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <set>

using namespace std;

string s;

int main(){
	cin >> s;
	
	if((s[0] == 'R' or s[1] == 'R') or s[2] == 'R'){
		if(s[0] == 'R'){
			if(s[1] == 'R'){
				if(s[2] == 'R'){
					cout << 3;
				}
				else{
					cout << 2;
				}
			}
			else{
				cout << 1;
			}
		}
		else{
			if(s[1] == 'R' and s[2] == 'R'){
				cout << 2;
			}
			else if(s[1] == 'R' or s[2] == 'R'){
				cout << 1;
			}
		}
	}
	else{
		cout << 0;
	}

	return 0;
}



Measured memory_bytes: 3644
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 12
#define LL long long
char s[MAXN];
int n;
LL ans;
void dfs(int i,int S)
{
	if(i==n-1)
	{
		LL las=0;
		for(int j=0;j<n;j++)
			if(S&(1<<j))
			{
				las*=10;
				las+=s[j]-'0';
				ans+=las;
				las=0;
			}
			else
			{
				las*=10;
				las+=s[j]-'0';
			}
		ans+=las;
		return;
	}
	dfs(i+1,S<<1);
	dfs(i+1,(S<<1)|1);
}
int main()
{
	scanf("%s",s);
	n=strlen(s);
	dfs(0,2);
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
N = int(input())
P = 10 ** 9 + 7
X = 0
Y = 0
for a in map(int, input().split()):
  X += a ** 2
  Y += a
  X %= P
  Y %= P
print(((Y ** 2 % P - X) * pow(2, P - 2, P)) % P)
 

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


Measured memory_bytes: 2728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int n;
int main(){
	n=read();
	for(int i=1;i<10;i++)
		for(int j=1;j<10;j++)
			if(i*j==n){
				puts("Yes");
				return 0;
			}
	puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    int x;
    cin>>x;
    int a[x];
    set<int> s;

    for(int i=0;i<x;i++)
    {
        cin>>a[i];
        s.insert(a[i]);
    }
    int y=0;
    y=s.size();
    //cout<<x<<""<<y<<endl;

    if(x==y)
    cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;

} 



Measured memory_bytes: 11136
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[100005];
int k;

int main()
{
   scanf("%s%d", s, &k);
   int len=strlen(s);
   for(int i=0;i<len;i++)
   {
      if(s[i]=='a') continue;
      int sel=('z'-s[i])+1;
      if(sel<=k) { s[i]='a'; k-=sel; }
   }
   k%=26;
   int x=s[len-1]-'a';
   x+=k;
   s[len-1]=(char)(x+'a');
   printf("%s\n", s);
   return 0;
}


Measured memory_bytes: 384
S = input()

front = int(S[:2])
rear = int(S[2:])

#print(front,rear)

if 1 <= front <= 12 and 1 <= rear <= 12:
	print("AMBIGUOUS")
elif 1 <= front <= 12 and not(1 <= rear <= 12):
	print("MMYY")
elif not(1 <= front <= 12) and 1 <= rear <= 12:
	print("YYMM")
else:
	print("NA")

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i < (int)n;i++)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    int tmp;
    for(int i = 0;i < N;i++)
    {
        cin >> tmp;
        v[i] = tmp - 1;
    }
    int count = 0;
    for(int i = 0;i < N;i++)
    {
        if(i == v[v[i]])
            count++;
    }
    cout << count / 2 << '\n';
}



Measured memory_bytes: 640
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>

template <class F>
class fix_point: F {
public:
  explicit constexpr fix_point(F&& f) noexcept: F(std::forward<F>(f)) {}

  template <class... Args>
  constexpr decltype(auto) operator ()(Args&&... args) const {
    return F::operator ()(*this, std::forward<Args>(args)...);
  }
};

template <class F>
static inline constexpr decltype(auto) make_fix_point(F&& f) noexcept {
  return fix_point<F>{std::forward<F>(f)};
}

struct tree: std::vector<std::vector<size_t>> {
  tree(size_t n): std::vector<std::vector<size_t>>(n) {}

  void connect_with(size_t src, size_t dst) {
    (*this)[src].push_back(dst);
    (*this)[dst].push_back(src);
  }
};

std::vector<intmax_t> nya(const tree& g, intmax_t mod) {
  size_t n = g.size();
  std::vector<size_t> parent(n, -1);
  std::vector<std::vector<intmax_t>> dp0(n), dp1(n);
  std::vector<intmax_t> dp(n);
  for (size_t i = 0; i < n; ++i) {
    dp0[i].resize(g[i].size()+1, 1);
    dp1[i].resize(g[i].size()+1, 1);
  }

  make_fix_point([&](auto f, size_t v, size_t p) -> intmax_t {
    intmax_t res = 1;
    for (size_t i = 0; i < g[v].size(); ++i) {
      size_t u = g[v][i];
      if (u == p) {
        parent[v] = i;
        continue;
      }
      intmax_t tmp = (f(u, v) + 1) % mod;
      (res *= tmp) %= mod;
      dp0[v][i+1] = tmp;
      dp1[v][i] = tmp;
    }
    return res;
  })(0, -1);

  make_fix_point([&](auto f, size_t v, size_t p, size_t pi) -> void {
    if (v != 0) {
      intmax_t tmp = (dp0[p][pi] * dp1[p][pi+1] + 1) % mod;
      dp0[v][parent[v]+1] = tmp;
      dp1[v][parent[v]] = tmp;
    }
    {
      for (size_t i = 1; i < dp0[v].size(); ++i)
        (dp0[v][i] *= dp0[v][i-1]) %= mod;
      for (size_t i = dp1[v].size()-1; i--;)
        (dp1[v][i] *= dp1[v][i+1]) %= mod;
      dp[v] = dp1[v][0];
    }
    for (size_t i = 0; i < g[v].size(); ++i) {
      size_t u = g[v][i];
      if (u != p) f(u, v, i);
    }
  })(0, -1, -1);

  return dp;
}

int main() {
  size_t N;
  intmax_t M;
  scanf("%zu %jd", &N, &M);

  tree g(N);
  for (size_t i = 1; i < N; ++i) {
    size_t x, y;
    scanf("%zu %zu", &x, &y);
    --x;
    --y;
    g.connect_with(x, y);
  }

  auto dp = nya(g, M);
  for (size_t i = 0; i < N; ++i)
    printf("%jd\n", dp[i]);
}


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

int main(){
    long N;
    cin >> N;
    deque<long> A(N);
    for(auto& i : A)cin >> i;
    A.push_front(0);
    partial_sum(begin(A), end(A), begin(A));
    unordered_map<long, long> m;
    long ans(0);
    for(const auto i : A)ans += m[i]++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10184
def dfs(n, s, i):
    if n == 0:
        if s == 0: return 1
        else: return 0
    if i == 10:
        return 0;

    ans = 0
    ans += dfs(n, s, i + 1)
    ans += dfs(n-1, s - i, i + 1)
    return ans


def main():
    while True:
        n, s = map(int, input().split())
        if n == 0: break
        print(dfs(n, s, 0))

    return 0


if __name__ == '__main__':
    main()


Measured memory_bytes: 7728
N = int(input())
S = input()

alf = [
    'A',
    'B',
    'C',
    'D',
    'E',
    'F',
    'G',
    'H',
    'I',
    'J',
    'K',
    'L',
    'M',
    'N',
    'O',
    'P',
    'Q',
    'R',
    'S',
    'T',
    'U',
    'V',
    'W',
    'X',
    'Y',
    'Z',
]

ans = ''

for s in S:
    ans += alf[(alf.index(s) + N) % 26]

print(ans)


Measured memory_bytes: 41580
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {

	lld n, k;
	cin >> n >> k;

	vector<lld> arr(n);
	_input(arr);
	sort(arr.begin(), arr.end(), greater<lld>());

	lld ans = accumulate(arr.begin(), arr.begin() + k, 0ll);
	cout << ans;

	return;
}


signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);

	lld T3X0 = 0, T353 = 1;

	// TESTCASES()
	solveEachTest(T353 - T3X0);
	return 0;
}
// Random Thought :  null

Measured memory_bytes: 3624
N,M = map(int,input().split())
comp = [[] for _ in range(8)]
for i in range(N):
    x,y,z = map(int,input().split())
    raw = [x+y+z,x+y-z,x-y+z,x-y-z,-x+y+z,-x+y-z,-x-y+z,-x-y-z]
    for j in range(8):
        comp[j].append(raw[j])
ans = 0
for k in range(8):
    comp[k].sort(reverse=True)
    sum = 0
    for l in range(M):
        sum += comp[k][l]
    ans = max(ans,sum)


print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
const ll mod = 1e9+7;

main(){
    int count=0;
    ll n,d;cin>>n>>d;
    ll x,y;
    while(n--){
        cin>>x>>y;
        if(abs(sqrt(x*x +y*y))<=d) count++;
    }
    cout<<count;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC124B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] H = Console.ReadLine().Split(' ');
            List<int> H_int = new List<int>();
            int result = 0;
            int counter = 0;

            for (int i = 0; i < N; i++)
            {
                H_int.Add(int.Parse(H[i]));
            }

            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    if (H_int[i] >= H_int[j])
                    {
                        counter++;
                    }
                }
                if (counter == i) result++;
                counter = 0;
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main() {
    //input
    int N,M,K;
    cin >> N >> M >> K;
    cout << (N+M+K >= 22 ? "bust" : "win") << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m,q = inpl()
g = [[0]*n for _ in range(n)]
gg = [[0]*n for _ in range(n)]
for _ in range(m):
    l,r = inpl()
    l,r = l-1, r-1
    g[l][r] += 1
for i in range(n)[::-1]:
    for j in range(n):
        # print(i)
        if i == n-1:
            gg[i][j] += g[i][j]
            continue
        gg[i][j] += g[i][j] + gg[i+1][j]
# print(gg)
for i in range(n):
    for j in range(n-1):
        gg[i][j+1] += gg[i][j]

# pprint.pprint(gg)
for _ in range(q):
    a,b = inpl()
    a,b = a-1,b-1
    print(gg[a][b])

Measured memory_bytes: 84824
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
//#include <tuple>
#include <iomanip>
#include <cstring>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;
/*
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};
*/

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N), B(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  ll sumA = 0, sumB = 0;
  rep(i, N) sumA += A[i];
  rep(i, N) sumB += B[i];
  ll a = sumB - sumA, b = a;
  rep(i, N){
    if(A[i] >= B[i]){
      b -= A[i] - B[i];
    }else{
      ll sa = B[i] - A[i];
      a -= sa / 2;
      A[i] += sa / 2 * 2;
      if(A[i] < B[i]){
        a--, b--;
      }
    }
  }
  if(a >= 0 && b >= 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

#define all(x) (x).begin(), (x).end()
#define int long long

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    vector<int> g(n);
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') g[i] = 1;
        else if (s[i] == 'B') g[i] = 2;
        else g[i] = 4;
    }
    int ans = 0;
    vector<int> cnt(8);
    for (int j = 0; j < n; ++j) {
        for (int k = j + 1; k < n; ++k) {
            if (s[j] != s[k]) {
                ans += cnt[7 ^ g[j] ^ g[k]];
                int len = k - j;
                if (j - len >= 0 && s[j - len] != s[j] && s[j - len] != s[k]) {
                    --ans;
                }
            }
        }
        cnt[g[j]]++;
    }
    cout << ans;
}


Measured memory_bytes: 3648
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-05-12 12:26:41

---------------------------------*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{
	string s;
	cin >> s;
	int res1 = 0, res2 = 0;
	for(int i = 0; i < s.size(); ++i){
		if(i%2){
			if(s[i] == '0')	res1++;
			else	res2++;
		} else{
			if(s[i] == '1')	res1++;
			else	res2++;
		}
	}
	cout << min(res1, res2) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi; 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int mod = 1e9+7;
const int maxn = 1e5+10;
const int inf = 0x3f3f3f3f;
double pi=3.1415926;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	int r;
	cin>>r;
	cout<<2*r*pi<<'\n';
	return 0;
}

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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int n = 100 * a + 10 * b + c;
	if(n % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int gg(int a, int b) {
	if (a<b)
		swap(a, b);
	if (a%b == 0)
		return b;
	else
		return gg(b, a%b);
}

int main() {
	int a, b, x;
	string s, t;
	bool ans = true;
	cin >> a >> b;
	cin >> s >> t;
	x = gg(a, b);
	a /= x;
	b /= x;
	for (int i = 0;i < x;i++) {
		if (s[a*i] != t[b*i]) {
			ans = false;
			break;
		}
	}
	if (ans)
		cout << (long long)x * a*b << endl;
	else
		cout << "-1" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define kq 1000000000+7
using namespace std;
long long n,a[10123],b[10123],res=0,c,res1=1;
int main()
{
    cin >> n;
    for(int i=1; i<=n; i++){
        c=i;
        int j=2;
        while(j<=c){
            if(c % j == 0){
                a[j]++;
                c/=j;
            }
            else j++;
        }
    }
    for(int i=1; i<=n; i++){
        res1*=(a[i]+1);
        res1%=kq;
    }
    cout << res1;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
        long long int a,b,c,sum=0,d=0;
        cin>>a>>b>>c;
        
        for(int i=a;i<=b;i++)
        {
            if(i%c==0)
                 d++;
        }
        
        cout<<d;
        
        
        
    }
    
    


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pl=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using vvi=vector<vi>;
using vvl=vector<vl>;
using vs=vector<string>;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

void solve() {
    int n;
    cin >> n;
    print(n==1? 0 : 1);
    

}   

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cmath>
#include<algorithm> 
using namespace std;
int n;
double v[101];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lf",&v[i]);
	sort(v+1,v+n+1);
	for (int i=2;i<=n;i++)
	{
		v[i]=(v[i]+v[i-1])/2.0;
	}
	printf("%lf",v[n]);
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int ans = (c * 60 + d) - (a * 60 + b) - e;
	ans = max(0, ans);
	cout << ans << endl;
	return 0;
}


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

using ll = long long;

// 2**n - (1 + nCa + nCb)

const ll MOD = 1000000007;

ll modpow(ll x, ll y) {
    if (y == 0) return 1;
    ll res = modpow(x, y / 2);
    return res * res % MOD * (y & 1 ? x : 1) % MOD;
}

ll modcomb(ll n, ll r) {
    ll a = 1, b = 1;
    for (int i = 0; i < r; ++i) {
        a *= n - i;
        a %= MOD;

        b *= i + 1;
        b %= MOD;
    }
    return a * modpow(b, MOD - 2) % MOD;
}

int main() {
    ll n, a, b;
    while (cin >> n >> a >> b) {
        ll ans = MOD*5 + modpow(2, n) - (1 + modcomb(n, a) + modcomb(n, b));
        ans %= MOD;
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define mod 1000000007
#define LL long long
#define maxn 1000010
char s[maxn];
LL fact[maxn<<1],inv[maxn<<1];
int m,n;
LL quick_pow(LL a,LL b){
	LL ret=1;
	while(b){
		if(b&1)ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret%mod;
}
void init(){
	int i;
	fact[0]=1;
	for(i=1;i<=n+m;i++)fact[i]=fact[i-1]*i%mod;
	inv[n+m]=quick_pow(fact[n+m],mod-2);
	for(i=n+m-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
LL C(int n,int m){
	return fact[n]*inv[n-m]%mod*inv[m]%mod;
}
int main(){
	int i;
	LL ans=0;
	scanf("%d%s",&n,s);
	m=strlen(s);
	init();
	for(i=0;i<=n;i++)
		ans=(ans+quick_pow(26,i)*C(n+m-i-1,m-1)%mod*quick_pow(25,n-i)%mod)%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 33932
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int X,Y,Z;
int main(){
    cin >> X >> Y >> Z;
    int ct = 0;
    X -= Z;
    while(X-Y>=Z) ct++, X -= (Y+Z);
    pr(ct);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}


int main() {
    int n;
    cin >> n;
    set<int>st;
    rep(i,n) {
        int a;
        cin >> a;
        if(st.count(a)==1) {
            st.erase(a);
        } else st.insert(a);
    }
    cout << st.size() << endl;
}

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

using namespace std;

int n;
vector<vector<int>> adj;

namespace LCA {

int l, timer;
vector<int> tin, tout;
vector<vector<int>> up;

void dfs(int v, int p) {
    tin[v] = ++timer;
    up[v][0] = p;
    for (int i = 1; i <= l; ++i) up[v][i] = up[up[v][i - 1]][i - 1];

    for (int u : adj[v]) {
        if (u != p) dfs(u, v);
    }

    tout[v] = ++timer;
}

bool is_ancestor(int u, int v) {
    return tin[u] <= tin[v] && tout[u] >= tout[v];
}

void preprocess(int root) {
    tin.resize(n);
    tout.resize(n);
    timer = 0;
    l = ceil(log2(n));
    up.assign(n, vector<int>(l + 1));
    dfs(root, root);
}

}  // namespace LCA

namespace Depth {
vector<int> d;

int dfs(int u, int p) {
    for (int v : adj[u]) {
        if (v == p) continue;
        d[u] = max(d[u], 1 + dfs(v, u));
    }
    return d[u];
}

void preprocess(int root) {
    d.resize(n);
    dfs(root, root);
}

}  // namespace Depth

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

    int a, b;
    cin >> n >> b >> a;
    a--, b--;

    adj.resize(n);
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    LCA::preprocess(a);
    Depth::preprocess(a);

    int cnt = 0;
    bool aoki = false;
    while (a != b) {
        if (not aoki) {
            int p = LCA::up[b][0];
            bool go_up = a != p and LCA::up[p][0] != a;
            bool is_leaf = Depth::d[b] == 0;

            if (is_leaf or go_up) {
                b = p;
            } else {  // pick the deepest child to go to
                int u = -1;
                for (int v : adj[b]) {
                    if (Depth::d[v] > Depth::d[b]) continue;
                    if (u == -1 or Depth::d[v] > Depth::d[u]) u = v;
                }
                b = u;
            }

        } else {
            cnt++;
            for (int v : adj[a]) {
                if (Depth::d[v] > Depth::d[a]) continue;
                if (LCA::is_ancestor(v, b)) {
                    a = v;
                    break;
                }
            }
        }

        aoki ^= 1;
    }

    cout << cnt << '\n';
}

Measured memory_bytes: 22144
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
struct Edge{
	int to, id;
};
vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c = -1, int p = -1) {
	int k = 1;
	rep (i, g[v].size()) {
		int u = g[v][i].to; int ei = g[v][i].id;
		if (u == p) continue;
		if (k == c) k++;
		ans[ei] = k; k++;
		dfs(u, ans[ei], v);
	}
}

void solve() {
	int n; cin >> n;
	g.resize(n);
	ans = vector<int>(n - 1);
	rep (i, n - 1) {
		int a, b; cin >> a >> b;
		a--; b--;
		g[a].push_back({b, i});
		g[b].push_back({a, i});
	}
	dfs(0);
	int mx = 0;
	rep (i, n) {
		mx = max(mx, int(g[i].size()));
	}
	cout << mx << endl;
	rep (i, n - 1) {
		cout << ans[i] << endl;
	}
	return;
}

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

Measured memory_bytes: 8320
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
const int N = 1e5+5;
int dp[N];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin >> n >> k;
	k=min(n-1,k);
	int arr[n];
	for(int i=0;i<n;i++)
		cin >> arr[i];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<=k;i++)
	{
		dp[i]=abs(arr[i]-arr[0]);
		for(int j=0;j<i;j++)
		{
			dp[i]=min(dp[j]+abs(arr[i]-arr[j]),dp[i]);
		}
	}
	for(int i=k+1;i<n;i++)
	{
		dp[i]=1e9;
		for(int j=(i-k);j<i;j++)
		{
			dp[i]=min(dp[j]+abs(arr[i]-arr[j]),dp[i]);	
		}
	}
	cout << dp[n-1];
}

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

using namespace std; 
#define fr for(int i = 0;i < n;i++)
#define pb push_back
#define ll long long int 
void printVector(vector<int>x){
    for(auto i:x){
        cout << i << endl;
    }
    cout << endl;
}
string reverseString(string str,int n){
    string res = "";
    for (int i = n-1; i >= 0; i--)
    {
        res += str[i];
       
    }
    return res;
    
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
        int n,x;
        cin >> n;
        x = ceil(float(n)/float(1000));
        cout << (x * 1000) - n << endl;
    
    
    
   
    

}

Measured memory_bytes: 3600
import math
b, c, h, m = input().split()
b = int(b)
c = int(c)
h = int(h) + int(m) / 60
m = int(m) / 5
num = 0
a = 0

if abs(h - m) > 6:
    if h > m:
        h = h - 12
    else:
        m = m - 12
if h - m ==6:
    a = b + c
    print(a)
else:
    num = abs(h - m)
    radian = 30 * num
    a = math.sqrt(b**2 + c**2 - 2 * b * c * math.cos(math.radians(radian)))
    print(a)

Measured memory_bytes: 9392
#include<bits/stdc++.h>
using namespace std;
int main(){int i,n,m,sum=0,k=0;
cin>>n>>m;
int a[n];
for(i=0;i<n;i++){cin>>a[i];
    sum+=a[i];
}
for(i=0;i<n;i++){
    if(a[i]*4*m>=sum)k++;
}if(k>=m)cout<<"Yes";
if(k<m){cout<<"No";}
    return 0;}

Measured memory_bytes: 256
X = int(input())

up = int(X/100)
dn = int(X%100)

up_month = False
dn_manth = False

if up >= 1 and up <= 12:
    up_month = True

if dn >= 1 and dn <= 12:
    dn_month = True
else:
    dn_month = False
    

if up_month and dn_month:
    print("AMBIGUOUS")
elif up_month:
    print("MMYY")
elif dn_month:
    print("YYMM")
else:
    print("NA")


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

void bfs(vector<vector<int> > &g,vector<int> &parent)
{
	queue<int> q;
	// vector<bool> parent(g.size(),-1);
	q.push(1);
	parent[1]=0;
	while(!q.empty())
	{
		int t=q.front();
		for(int i=0;i<g[t].size();i++)
		{
			if(parent[g[t][i]]==-1)
			{
				q.push(g[t][i]);
				parent[g[t][i]]=t;
			}
		}
		// visited[t]=true;
		q.pop();
	}
	return ;
}


int main()
{
	int n,m;
	cin>>n>>m;
	vector<vector<int> > g(n+1);
	for(int i=0;i<m;i++)
	{
		int u,v;
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vector<int> parent(n+1,-1);
	bfs(g,parent);
	for(int i=2;i<=n;i++)
	{
		if(parent[i]==-1)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes\n";
	for(int i=2;i<=n;i++)
		cout<<parent[i]<<endl;
	return 0;
}

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

void solve() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  repc(x, n - 1) {
    int y = (n - 1) - x;
    i64 mi = (i64) a + (i64) c * x - (i64) d * y;
    i64 ma = (i64) a + (i64) d * x - (i64) c * y;
    if (mi <= b && b <= ma) {
      cout << "YES" << endl;
      return;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N, a[200200], b[200200], c[200200], d[200200], ans;

signed main()
{
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < N; i++){
        cin >> b[i];
    }
    for(int i = 0; i < 30; i++){
        for(int j = 0; j < N; j++){
            c[j] = b[j] % (1ll << (i + 1));
            d[j] = a[j] % (1ll << (i + 1));

        }
        sort(c, c + N);
        int cnt = 0;
        for(int j = 0; j < N; j++){
            cnt += lower_bound(c, c + N, (1ll << (i + 1)) - d[j]) - lower_bound(c, c + N, (1ll << i) - d[j]);
            cnt += lower_bound(c, c + N, (1ll << (i + 2)) - d[j]) - lower_bound(c, c + N, (1ll << (i + 1)) + (1ll << i) - d[j]);
        }
        if(cnt % 2){
            ans += (1ll << i);
        }
    }
    cout << ans << endl;

    return 0;
}

/*



*/


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

using ll= long long;
#define double long double
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _set(x) __builtin_popcount(x)
#define PI  3.14159265358979323846264338327950L
#define mod 1000000007
#define dpv(...) cerr<< "["#__VA_ARGS__ " : ";for(int i: (__VA_ARGS__)){cerr<<i<<" ";}cerr<<"]\n"

const int maxN= 105;
const int INF = 1e9;
int dp[maxN][maxN];
bool g[maxN][maxN];
void solve(){
    int h,w;
    cin>>h>>w;
    char c;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>c;
            g[i][j]=(c=='#')?0:1;
            dp[i][j]= INF;
        }
    }
    dp[0][0]= g[0][0]?0:1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            dp[i+1][j] = min(dp[i+1][j],(g[i][j] && !g[i+1][j])? dp[i][j]+1: dp[i][j] );
            dp[i][j+1] = min(dp[i][j+1],(g[i][j] && !g[i][j+1])? dp[i][j]+1: dp[i][j] );
        }
    }
    cout<<dp[h-1][w-1]<<"\n";
}

int32_t main(){
	IOS
	// freopen("input.txt","r",stdin);
	int _;
	// cin>>_;
	_=1;
	while(_--){
        solve();
    }
	return 0;
}

/*
   check for overflows int long long
   correct size of array
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[256];
char s[256];
int main()
{
    cin>>s;
    int l=1;
    for(int i=0; s[i]; i++)a[s[i]]=1,l++;
    for(int c='z'; c>='a'; c--)
        if(!a[c])s[l++]=c;
    if(next_permutation(s,s+l))
        cout<<s;
    else
        cout<<-1;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int n;
bool odd(int i)
{
    int d = 0;
    while(i > 0)
    {
        i/=10;
        d++;
    }
    return (d%2);
}
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    int res = 0;
    FOR(i, 1,  n + 1)
    {
        if(odd(i)) res++;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        String s = sc.next();
        int ans = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '+') {
                ans++;
            }
            else {
                ans--;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M;

signed main(){
	cin>>N>>M;
	cout<<N*(N-1)/2+M*(M-1)/2<<endl;
	return 0;
}


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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int plan1 = A * N, plan2 = B;
    if (plan1 < plan2) {
        cout << plan1 << endl;
    } else {
        cout << plan2 << endl;
    }
}

Measured memory_bytes: 256