akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}
	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

ll dp1[maxn], dp2[maxn];

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, k, c; cin >> n >> k >> c;
	string s; cin >> s;

	dp1[0] = 0;

	for (ll i = 1; i <= n; i++) {
		char cc = s[i - 1];
		dp1[i] = max(dp1[i - 1], dp1[i]);
		if (cc == 'o') {
			dp1[i] = max(dp1[i], (i - c - 1 >= 0 ? dp1[i - c - 1] : 0) + 1);
		}
	}
	dp2[n + 1] = 0;

	for (ll i = n; i >= 1; i--) {
		char cc = s[i - 1];
		dp2[i] = max(dp2[i + 1], dp2[i]);
		if (cc == 'o') {
			dp2[i] = max(dp2[i], (i + c + 1 <= n + 1 ? dp2[i + c + 1] : 0) + 1);
		}
	}

	vector<ll>vec;

	for (ll j = 0; j <= n + c + 2; j++) {
		ll x = (j <= n + 1 ? dp2[j] : 0);
		ll y = (j - c - 1 >= 0 ? dp1[j - c - 1] : 0);
		x += y;
		if (x >= k) {
			vec.push_back(j);
		}
	}

	for (ll i = 1; i <= n; i++) {
		ll id = upper_bound(all(vec), i) - begin(vec);
		if (id != vec.size() and vec[id] - c - 1 < i or dp1[i - 1] >= k or dp2[i + 1] >= k) {
			continue;
		} else if (c == 0 and dp1[i-1] + dp2[i+1] >= k) {
			continue;
		} else {
			cout << i << '\n';
		}
	}


	return 0;
}

/*


*/

Measured memory_bytes: 7048
(n,m,p),*l=[list(map(int,s.split()))for s in open(0)];I=float('inf');d=[0]*2+[I]*n
for i in range(n*2):
 for a,b,c in l:
  if d[b]>d[a]-c+p:d[b]=[d[a]-c+p,-I][i>n]
 if i==n:x=d[n]
print([max(-x,0),-1][d[n]!=x])

Measured memory_bytes: 47456
n,m = map(int,input().split())
V = [[] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    V[a].append(b)
    V[b].append(a)
W = V[1]
z = []
for x in W:
    z.append(V[x])
s = 0
for q in z:
    if n in q:
        s = 1
        break
if s == 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 115012
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

// union-find
struct union_find {
    vector<int> data;

    union_find(int size) {data.resize(size,-1);}

    int find(int x) {
        if (data[x] < 0) {return x;}
        return data[x] = find(data[x]);
    }

    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) {return false;}
        if (data[x] > data[y]) swap(x,y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int size(int x) {return -data[x];}
};

int main() {
    int n, m; cin >> n >> m;
    vint p(n);
    rep(i,n) cin >> p[i];
    union_find uf(n);
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        uf.unite(a,b);
    }
    int ans = 0;
    rep(i,n) {
        if (uf.find(i) == uf.find(p[i]-1)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	long long a, b, c, N;
	a = 1; b = 1; c = 1; N = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		a *= 8;
		b *= 9;
		c *= 10;
		a %= 1000000007;
		b %= 1000000007;
		c %= 1000000007;
	}
	if (c - (2 * b - a) <= 0) {
		cout << (c - (2 * b % 1000000007 - a) + 1000000007) % 1000000007;
	}
	else {
		cout << (c - (2 * b % 1000000007 - a)) % 1000000007;
	}
	return 0;
}

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

typedef long long ll;
using namespace std;

typedef pair<int,int> P;

int n;
int x[100005],y[100005];

int ct(int a){
	int cnt = 0;
	while(a > 1){
		a /= 2;
		cnt++;
	}
	return cnt;
}


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

	cin >> n;

	vector<P> a;

	for (int i = 0;i < n;i++){
		cin >> x[i] >> y[i];
		a.push_back(P(x[i]+y[i],1));
	}

	sort(a.begin(),a.end());

	while(true){
		vector<P> nex;
		nex.push_back(a[0]);
		for (int i = 1;i < a.size();i++){
			if(a[i] == a[i-1]){
				nex[nex.size()-1].second++;
			}else{
				nex.push_back(a[i]);
			}
		}
		bool flag = true;
		for (int i = 0;i < nex.size();i++){
			if(nex[i].second >= 2){
				int tmp = nex[i].second-(1<<ct(nex[i].second));
				if(tmp!=0)nex.push_back(P(nex[i].first,tmp));
				nex[i].first += ct(nex[i].second);
				nex[i].second = 1;
				flag = false;
			}
		}
		sort(nex.begin(),nex.end());
		a = nex;
	
		//for (int i = 0;i < a.size();i++){
		//	cout << a[i].first << " " << 0 << endl;
		//}
		//cout << endl;

		if(flag) break;
	}

	for (int i = 0;i < a.size();i++){
		cout << a[i].first << " " << 0 << endl;
	}

	return 0;

}



Measured memory_bytes: 5992
#include <stdio.h>

int main(){


  int a, b;

  scanf("%d%d", &a, &b);

  if ( a < b) {
    
printf("a < b\n");
  } else if (a > b){
    printf("a > b\n");

  } else if (a == b){
    printf("a == b\n");  
}
 return 0;

}


Measured memory_bytes: 2100
#include <iostream>
using namespace std;
int main()
{
	int d, r;
	while (1)
	{
		cin>>d>>r;
		if (d ==0 && r == 0)
			break;
		else
		{
			for (int i =0; i < d;i++)
			{
				for (int j=0;j <r;j++)
				{
					cout<<"#";
				}
				cout<<endl;
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3088
#include <iostream> 
using namespace std; 
int main() 
{ 
  int N; string s; 
  scanf("%d", &N); 
  cin>>s; 
  long long red, green, blue, result; 
  red = green = blue = 0; 
  for(int i = 0; i < s.size(); i++) 
  { 
    if(s[i] == 'R') red++; 
    if(s[i] == 'G') green++; 
    if(s[i] == 'B') blue++; 
  } 
  result = red * green * blue; 
  for(int i = 0; 2 * i < N; i++) 
  { 
    for(int j = 0; 2 * i + j < N; j++) 
    { 
      if(s[j] != s[i + j] && s[j] != s[2 * i + j] && s[i + j] != s[2 * i + j]) 
      { 
        result--; 
      } 
    } 
  } 
  printf("%lld", result); 
  return 0; 
}


Measured memory_bytes: 3780
#include <stdio.h>
#define N 100
#define exch(a, b) {int x = a; a = b; b = x;}
#define less(a, b) (a < b)
#define compexch(a, b) {if(less(a, b)){exch(a, b);count++;}}

void printarr(int *a, int n){
  int i;
  for(i = 0; i < n; i++){
    printf("%d", a[i]);
    printf((i == n - 1) ? "" : " ");
  }
  printf("\n");
}

int bubblesort(int *a, int n){
  int i, j, count = 0;
  for(i = 0; i < n - 1; i++)
    for(j = n - 1; j >= i; j--){
      compexch(a[j], a[j - 1]);
    }
    return count;
}

int main(void){
  int n, i, a[N], count;
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);
  count = bubblesort(a, n);
  printarr(a, n);
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 604
import java.util.*;
import java.text.DecimalFormat;

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

		if (S.equals("SUN"))
			System.out.println(7);
		else if (S.equals("MON"))
			System.out.println(6);
		else if (S.equals("TUE"))
			System.out.println(5);
		else if (S.equals("WED"))
			System.out.println(4);
		else if (S.equals("THU"))
			System.out.println(3);
		else if (S.equals("FRI"))
			System.out.println(2);
		else
			System.out.println(1);

	}
}

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

int main(){
 long long int x;
  long long int money=100;
  int count = 0;
  scanf("%lld",&x);
  while(money<x){
    money = money * 1.01;
    count++;
  }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int sum = 0;
  vector<int> year(1001,0);
  for(int i=1; i<=999; i++){
    if(i%3 == 0){
      sum += 200;
    }else{
      sum += 195;
    }
    year[i] = sum;
  }
  // cout << sum << endl;
  int _;
  cin >> _;
  while(_--){
    int y,m,d;
    cin >> y >> m >> d;
    int now = year[y-1];
    for(int i=1; i<m; i++){
      now += 20 - (y%3!=0 and i%2==0);
    }
    now += d-1;
    cout << sum - now << endl;
  }
  return 0;
}



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

long n, k, c = 0, m = 0;
long a[200001];

int main()
{
	cin >> n;

	a[0] = 0;

	for (int i = 1; i <= n; i++) {
		cin >> k;
		a[i] = a[i - 1] + k;
	}

	sort(a, a + n + 1);

	for (int i = 0; i < n; i++) {
		if (a[i] == a[i + 1])
			c++;
		else if (c > 0) {
			m += c * (c + 1) / 2;
			c = 0;
		}
	}

	if (c > 0)
		m += c * (c + 1) / 2;

	cout << m << endl;

	return 0;
}

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

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

	ll k = x / 500;

	ll ans = (ll)k * 1000;

	x = x - (k * 500);

	k = x / 5;

	ans = ans + (k * 5);

	cout << ans << endl;
}

Measured memory_bytes: 3584
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i*10000 + j*5000 + (n - i - j)*1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    map<string,ll> mp;
    ll n;
    cin>>n;
    string str;
    for(ll i=0;i<n;i++)
    {
        cin>>str;
        mp[str]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"];
    return 0;
}

Measured memory_bytes: 3628
#ABC095C
def main():
    import sys
    A,B,C,X,Y = map(int, sys.stdin.readline().split())
    # cをi枚とする
    ans = -1
    for i in range(0, 2*10**5+1, 2):
        tmp = max((X-i//2)*A, 0) + i*C + max((Y-i//2)*B, 0)
        if ans ==-1 or ans > tmp:
            ans = tmp
    print(ans)
    
   
    
if __name__=='__main__':
    main()


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

using namespace std;

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

int main(void)
{
	int h, w;
	cin >> h >> w;
	vec<string> a(h);
	rep(i, h) cin >> a[i];

	int flag = 1;
	rep(i, h - 1) rep(j, w - 1) {
		if (a[i][j] == '#') {
			if (a[i][j + 1] == a[i + 1][j]) flag = 0;
		} else {
			if (a[i][j + 1] == '#' && a[i + 1][j] == '#') flag = 0;
			else if (a[i][j + 1] == '.' && a[i + 1][j] == '.' && a[i + 1][j + 1] == '#') flag = 0;
		}
	}
	if (flag) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 384
S = input()
ff = int(S[:2])
ll = int(S[2:])
if 0<ff<=12 and 0<ll<=12:
    print("AMBIGUOUS")
elif (ff == 0 or ff>12) and 0<ll<=12:
    print("YYMM")
elif 0<ff<=12 and (ll>12 or ll== 0):
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  int N;
  cin >> N;
  vector<bool> prime((int)100000,true);
  prime[0] = false;
  prime[1] = false;
  for(int i = 2; i * i <= 100000; i++){
    if(prime[i] == false) continue;
    int x = 2;
    while(x * i <= 100000){
      prime[x*i] = false;
      x++;
    }
  }
  //cout << "hi" << endl;
  int cnt = 0;
  vector<int> ans;
  FOR(i,6,100000){
    if(i % 5 == 1 && prime[i]){
      ans.push_back(i);
      cnt++;
      if(cnt == N) break;
    }
  }
  //cout << "hi" << endl;

  rep(i,N){
    if(i != N-1)cout << ans[i] << ' ';
    else cout << ans[i] << endl;
  }
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  long h[N];
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  
  long dp[N];
  
  for (int i = 0; i < N; i++) {
    if (i == 0){
      dp[i] = 0;
      continue;
    }
    if (i == 1){
      dp[i] = abs(h[i]-h[i-1]);
      continue;
    }
    dp[i] = min(
              dp[i-1]+abs(h[i]-h[i-1])
            , dp[i-2]+abs(h[i]-h[i-2])
            );
  }
  
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>

using namespace std;

static char RED = 'R';
static char WHITE = 'W';

vector<char> readProblem();
int getMinOperationCount(vector<char>);

int main() {
  vector<char> initialStones = readProblem();
  int minOperationCount = getMinOperationCount(initialStones);
  cout << minOperationCount << endl;
}

int getMinOperationCount(vector<char> initialStones) {
  int whiteOnLeft = 0;
  int redOnRight = 0;
  for (int idx = 0; idx < initialStones.size(); idx++) {
    if (initialStones[idx] == RED) {
      redOnRight++;
    }
  }
  
  int minOperationCount = initialStones.size(); // effectively infinite
  for (int separator = 0; separator <= initialStones.size(); separator++) {
    int operationCount = max(whiteOnLeft, redOnRight);
    if (minOperationCount > operationCount) {
      minOperationCount = operationCount;
    }
    
    if (separator < initialStones.size()) {
      if (initialStones[separator] == RED) {
        redOnRight--;
      } else {
        whiteOnLeft++;
      }
    } else {
      // we already have minimum value
      // so we don't have anything to do here.
    }
  }
  return minOperationCount;
}

vector<char> readProblem() {
  int stoneCount;
  cin >> stoneCount;
  string stoneMarks;
  cin >> stoneMarks;
  vector<char> stones(stoneCount);
  for (int idx = 0; idx < stoneCount; idx++) {
    stones[idx] = stoneMarks[idx];
  }
  return stones;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, T;
    cin >> N >> T;
    vector<int> imos(T + 1, 0);
    for (int n = 0; n < N; ++n){
        int l, r;
        cin >> l >> r;
        ++imos[l];
        --imos[r];
    }
    int cum = 0;
    int max_cum = 0;
    for (auto v : imos){
        cum += v;
        max_cum = max(max_cum, cum);
    }
    cout << max_cum << endl;
    return 0;
}

Measured memory_bytes: 3292
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cstring>

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.0000000001;

typedef long long ll;

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

int main() {
    ll a, b;
    cin >> a >> b;
    ll c = gcd(a, b);
    ll *p = new ll[500000];
    ll pc = 0;
    for (ll i = 2; i*i <= c; i++) {
        bool flag = true;
        for (ll j = 0;j < pc && p[j]*p[j] <= i;j++) {
            if (i % p[j] == 0) {
                flag = false;
                break;
            }
        }
        if (flag) {
            p[pc] = i;
            pc++;
        }
    }
    int r = 1;
    for (ll i = 0;i < pc;i++) {
        if ((c % p[i]) == 0) {
            r++;
            while((c % p[i]) == 0)c /= p[i];
        }
    }
    if (c != 1) r++;
    cout << r << endl;
}

Measured memory_bytes: 2816
s = input()
dirset = set()
for i in s:
  dirset.add(i)
if "N" in dirset and "S" in dirset:
  if ("E" in dirset and "W" in dirset) or (not "E" in dirset and not "W" in dirset):
    print("Yes")
  else:
    print("No")
elif "E" in dirset and "W" in dirset:
  if not "N" in dirset and not "S" in dirset:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
  int A,B,C;
  cin >> A >> B >> C;
  bool flag = false;

  for(int i = 1; i <= B; i++){
    if((A*i % B) == C) flag =true;
  }

  if(flag == true) cout << "YES" << "\n";
  else cout << "NO" << "\n";

  return 0;
}


Measured memory_bytes: 256
a=input()
b=int(input())
if b<101:
  if a[:b]=='1'*b:print(1)
  else:
    k=0
    while a[k]=='1':k+=1
    print(a[k])
else:
  k=0
  while a[k]=='1':k+=1
  print(a[k])

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<array>
#include <vector>

using namespace std;

int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int a[6],t;
#define f(A,B,C,D) (t=a[D],a[D]=a[C],a[C]=a[B],a[B]=a[A],a[A]=t)
int main(void)
{
	int n,r,i;
	char s[9];
	while(scanf("%d",&n),n)
	{
		for(r=i=1;i<7;++i)a[i-1]=i;
		while(n--)
		{
			scanf("%s",s);
			if(s[0]=='N')f(0,4,5,1);
			if(s[0]=='S')f(0,1,5,4);
			if(s[0]=='E')f(0,2,5,3);
			if(s[0]=='W')f(0,3,5,2);
			if(s[0]=='R')f(1,3,4,2);
			if(s[0]=='L')f(1,2,4,3);
			r+=a[0];
		}
		printf("%d\n",r);
	}
	return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

  int x,y;
  Scd2(x,y);
  YesNo( x*2<=y && x*4>=y && y%2==0 );
  
  return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
#define f first
#define s second
typedef double D;
typedef complex<D> P;
typedef pair<P, P> L;
typedef vector<P> VP;
const D EPS = 1e-9;
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)
D dot(P a, P b) {return (conj(a)*b).X; }
D cross(P a, P b) {  return (conj(a)*b).Y;}
int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;
  if (cross(b,c) < -EPS) return -1;
  if (dot(b,c)   < -EPS) return +2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}
bool isecSP(P a1, P a2, P b) {
  return !ccw(a1, a2, b);
}
bool isecSS(P a1, P a2, P b1, P b2) {
  return ccw(a1, a2, b1)*ccw(a1, a2, b2) <= 0 &&
         ccw(b1, b2, a1)*ccw(b1, b2, a2) <= 0;
}
P proj(P a1, P a2, P p) {
  return a1 + dot(a2-a1, p-a1)/norm(a2-a1) * (a2-a1);
}
D distSP(P a1, P a2, P p) {
  P r = proj(a1, a2, p);
  if (isecSP(a1, a2, r)) return abs(r-p);
  return min(abs(a1-p), abs(a2-p));
}
D distSS(P a1, P a2, P b1, P b2) {
  if (isecSS(a1, a2, b1, b2)) return 0;
  return min(min(distSP(a1, a2, b1), distSP(a1, a2, b2)),
             min(distSP(b1, b2, a1), distSP(b1, b2, a2)));
}
main(){
    int n;
    cin>>n;
    double a[8];
    while(n--){
        rep(i,8)cin>>a[i];
        printf("%.9f\n",distSS(P(a[0],a[1]),P(a[2],a[3]),P(a[4],a[5]),P(a[6],a[7])));
    }
}

Measured memory_bytes: 3272
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Stack;

public class Main 
{
	static class Node
	{
		int i;
		HashSet<Node> e = new HashSet<>();
		boolean vis = false;
		boolean bt = false;
		
		public Node(int id)
		{
			i=id;
		}
		
		public String toString()
		{
			return Integer.toString(i);
		}
	}

	static Node[] nd;
	
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		nd = new Node[n];
		boolean[] rootcan = new boolean[n];
		
		for(int i = 0; i < n; i++)
		{
			nd[i] = new Node(i);
		}

		for(int i = 0; i < n-1+m; i++)
		{
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			nd[a].e.add(nd[b]);
			rootcan[b] = true;
		}
		
		int root = -1;
		for(int i = 0; i < n && root==-1; i++)
			if(!rootcan[i])
				root = i;
		
		Stack<Node> q = new Stack<>();
		Stack<Node> st = new Stack<>();
		
		q.add(nd[root]);
		
		while(!q.isEmpty())
		{
			Node pos = q.peek();
			
			if(!pos.vis)
			{
//				System.out.println("go " + pos.i);
				pos.vis = true;
				
				for(Node e : pos.e)
				{
					if(!e.vis)
					{
						q.add(e);
					}
				}
			}
			else if(!pos.bt)
			{ //backtrack
				pos.bt = true;
				st.add(pos);
//				System.out.println("bt " + pos);
				q.pop();
			}
			else q.pop();
		}
		
//		System.out.println(st);
		int[] a = new int[n];
		for(int i = 0; i < n-1; i++)
		{
//			System.out.println("peek " + st.peek());
//			System.out.println("peek " + Integer.toString((int)(st.peek().i)+1));
			Node pos = st.pop();
			for(Node e : pos.e)
			{
				a[e.i] = pos.i+1;
			}
		}
		
		for(int i = 0; i < n; i++)
			System.out.println(a[i]);
//		System.out.println(Arrays.toString(a));

	}

}


Measured memory_bytes: 113380
//package atcoder;
 
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
//import java.math.BigDecimal;
 
public class Main {
	public static void main(String [] args) {
	    String x;
		Scanner sc = new Scanner(System.in);
		x=sc.next();
		//char char型の値 = 変数.next().charAt(取得したい位置);
		
		if(x.charAt(0)=='A'||x.charAt(0)=='B'||x.charAt(0)=='C'||x.charAt(0)=='D'||x.charAt(0)=='E'||x.charAt(0)=='F'||x.charAt(0)=='G'||x.charAt(0)=='H'||x.charAt(0)=='I'||x.charAt(0)=='J'||x.charAt(0)=='K'||x.charAt(0)=='L'||x.charAt(0)=='M'||x.charAt(0)=='N'||x.charAt(0)=='O'||x.charAt(0)=='P'||x.charAt(0)=='Q'||x.charAt(0)=='R'||x.charAt(0)=='S'||x.charAt(0)=='T'||x.charAt(0)=='U'||x.charAt(0)=='V'||x.charAt(0)=='W'||x.charAt(0)=='Y'||x.charAt(0)=='Z') {
			System.out.println("A");
		}else {
			System.out.println("a");
		}
	
			 
	}
}

Measured memory_bytes: 35648
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int solve(Int A, Int B){
  if(A > B) swap(A, B);

  auto check=[&](Int x){
    //1 <= x < B
    //a = [A+1, A + x]
    //b = [1, x]
    //1 <= i <= x
    //max((A + i) * (x - i + 1));
    //A + i = x - i + 1
    //i + i = x + 1 - A
    //2 * i = x + 1 - A
    //i = (x + 1 - A) / 2;
    Int v = (x + 1 - A) / 2;
    Int mx = 0;
    for(Int i = v - 10; i < v + 10; i++){
      Int a = A + i;
      Int b = (x - i + 1);
      if(!(A + 1 <= a && a <= A + x)) continue;
      if(!(1 <= b && b <= x)) continue;
      Max(mx, a * b);
    }
    return mx < A * B;
  };

  Int L = 0, R = B;
  while(L + 1 < R){
    Int M = (L + R) / 2;
    check(M)? (L=M):(R=M);
  }
  Int res = (A - 1) + L;
  return res;
}


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int Q;
  cin>>Q;
  while(Q--){
    Int A, B;
    cin>>A>>B;
    Int ans = solve(A, B);
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include "stdio.h"

char letter[101];
int num[26] = {};

int main() {
	scanf("%s", letter);
	for (int i = 0; i < 100; i++) {
		if (letter[i]<'a' || letter[i]>'z') break;
		num[letter[i] - 'a']++;
	//	printf("%c", letter[i]);
	}
	for (int i = 0; i < 26; i++) {
	//	printf("%d", i + 'a');
		if (num[i] % 2 != 0) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
n = int(input())
i = 0
tp, hp = 0, 0
tc, hc = [], []

while n > i:
    tc, hc = map(str, input().split())
    if tc > hc:
        tp += 3
    elif tc < hc:
        hp += 3
    elif tc == hc:
        tp += 1
        hp += 1
    i += 1

print("{} {}".format(tp, hp))



Measured memory_bytes: 5600
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

const i64 MAXN = 1000006;

i64 n;

i64 r[MAXN];

void rev() {
    r[1] = 1;
    for (i64 i = 2; i <= 1000000; ++i) {
        r[i] = (mod - (mod / i) * r[mod % i] % mod) % mod;
    }
}

i64 cnk(i64 n, i64 k) {
    i64 res = 1;
    for (i64 i = n - k + 1; i <= n; ++i) {
        res *= i;
        res %= mod;
    }
    for (i64 i = 2; i <= k; ++i) {
        res *= r[i];
        res %= mod;
    }
    return res;
}


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    i64 x, y;
    cin >> x >> y;

    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    if (x > y) {
        swap(x, y);
    }
    i64 s = (x + y) / 3;
    i64 b = x - s;
    i64 a = y - s;

    //if (a + 2 * b != x) {
    //    throw 1;
    //}
    //if (2 * a + b != y) {
    //    throw 2;
    //}

    rev();
    i64 R = cnk(a + b, a);
    cout << R << endl;

    return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;



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

    int answer ;
    answer = min(a*n,b);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
input = sys.stdin.readline

def main():
    n,m = map(int,input().split())
    G = [0] * (n - 1)
    for _ in range(m):
        a,b = map(int,input().split())
        if a > b:
            a,b = b,a
        a -= 1
        b -= 1
        G[a] += 1
        if b != n - 1:
            G[b] -= 1
    
    ans = 'YES'
    if G[0]%2 == 1:
        print('NO')
        return

    for i in range(1,n - 1):
        G[i] += G[i - 1]
        if G[i]%2 == 1:
            ans = 'NO'
            break
    print(ans)
if __name__=='__main__':
    main()

Measured memory_bytes: 7236
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>

int main() {
	int a=0, b, ans[1024],num[1024];
	for (int i = 0; i < 1024; i++) {
		ans[i] = 0;
		num[i] = 0;
		for (int j = 0; j < 10; j++) {
			int m = 1;
			for (int k = 0; k < j; k++)m *= 2;
			if (i / m % 2 == 1) {
				ans[i] += j;
				num[i]++;
			}
		}
	}
	while (a==a) {
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0) {
			break;
		}
		else {
			int an = 0;
			for (int i = 0; i < 1024; i++) {
				if (ans[i] == b && num[i] == a) {
					an++;
				}
			}
			printf("%d\n", an);
		}
	}
}



Measured memory_bytes: 2012
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
using bll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll N_MAX = 1000;

ll N;
ll A[N_MAX][N_MAX];

signed main() {
	std::chrono::system_clock::time_point  starttime, endtime;
    starttime = std::chrono::system_clock::now();

	scanf("%lld", &N);
	vector<vector<ll>> a(N, vector<ll>(N-1, 0));

	rep(i, N) rep(j, N-1) {
		ll t;
		scanf("%lld", &t);
		a[i][j]=t-1;
	}


	ll ans=0;
	vector<ll> index(N,0);
	while(1){
		endtime = std::chrono::system_clock::now();
    	double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(endtime - starttime).count();
		if(elapsed>1980){
			p(N*(N-1)/2);
			exit(0);
		}
		map<pair<ll,ll>,ll> m;
		rep(i,N){
			if(index[i]==N-1)continue;
			ll t=i,s=a[i][index[i]];
			if(s>t)swap(s,t);
			m[make_pair(s,t)]++;
		}

		bool gotonext=false;
		debug(m);
		debug(index);
		for(auto p:m){
			if(p.second!=2)continue;
			gotonext=true;
			index[p.first.first]++;
			index[p.first.second]++;
		}

		if(!gotonext){break;}
		ans++;
	}

	rep(i,N){
		if(index[i]!=N-1){
			p(-1);
			return 0;
		}
	}

	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;



int main(){
	int n,k,d, t;
	cin >> n >> k;
	V<int> v(n);

	REP(i,k) {
		cin >> d;
		REP(j,d) {
			cin >> t;
			v[t-1] = 1;
		}
	}
	int ans = 0;
	REP(i,n) {
		if(v[i] == 0) {
			ans += 1;
		}
	}

	cout << ans << endl;



    return 0;
}



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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

ll pow_mod(ll n, ll m, ll mod=1000000007){
    ll a = 1;
    while(m>0){
        if(m&1) a = a*n % mod;
        n = n*n % mod;
        m >>= 1;
    }
    return a;
}

ll combi(ll n, ll m, ll mod=1000000007){
    static const ll N_MAX = 1000000;
    static vll fac(N_MAX+1, -1);
    static vll ifac(N_MAX+1, -1);

    if(fac[0]<0){
        fac[0] = ifac[0] = 1;
        rep(i, N_MAX){
            fac[i+1] = fac[i] * (i+1) % mod;
            ifac[i+1] = ifac[i] * pow_mod(i+1, mod-2, mod) % mod;
        }
    }

    if(n<=0 && m<=0) return 1;
    if(n<m || n<0) return 0;
    return (ifac[n-m] * ifac[m] % mod) * fac[n] % mod;
}

int main(){
    ll x, y;
    cin >> x >> y;

    if((x+y)%3!=0 || x>y*2 || y>x*2) cout << 0 << endl;
    else{
        ll n = (x+y)/3;
        ll d = x-y;
        ll p = (n+d)/2;
        cout << combi(n, p) << endl;
    }
}


Measured memory_bytes: 15872
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
long long a[300];
long long dp[300][90001];
long long dp_sup[300][90001];
const long long MOD = 998244353;
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
      cin >> a[i];
    }

    long long sum_a = accumulate(a, a + N, (long long) 0);
    dp[0][0] = 2;
    dp[0][a[0]] = 1;
    for(int i = 1; i < N; i++){
      for(int j = 0; j <= sum_a; j++){
        dp[i][j] = (dp[i][j] + 2 * dp[i - 1][j] % MOD) % MOD;
        if(j - a[i] >= 0){
          dp[i][j] = (dp[i][j] + dp[i - 1][j - a[i]]) % MOD;
        }
      }
    }

    long long co_ans = 0;
    int begin;
    if(sum_a % 2 == 0){
      begin = sum_a / 2;
    } else {
      begin = sum_a / 2 + 1;
    }
    for(int i = begin; i <= sum_a; i++){
      co_ans = (co_ans + dp[N - 1][i]) % MOD;
    }
    co_ans = (3 * co_ans) % MOD;
    
    dp_sup[0][0] = 1;
    dp_sup[0][a[0]] = 1;
    for(int i = 1; i < N; i++){
        for(int j = 0; j <= sum_a; j++){
            dp_sup[i][j] = dp_sup[i - 1][j];
            if(j - a[i] >= 0){
                dp_sup[i][j] = (dp_sup[i][j] + dp_sup[i - 1][j - a[i]]) % MOD;
            }
        }
    }
    
    if(sum_a % 2 == 0){
        co_ans = ((co_ans - (dp_sup[N - 1][sum_a / 2] * 3) % MOD) % MOD + MOD) % MOD;
    }
    long long ans = 1;
    for(int i = 0; i < N; i++){
      ans = (3 * ans) % MOD;
    }
    cout << ((ans - co_ans) % MOD + MOD) % MOD << endl;
    return 0;
}


Measured memory_bytes: 421376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

vector<int> g[200005];
vector<int> ans;

void dfs(int v,int p = -1)
{
    for(int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        if(to == p){
            continue;
        }else{
            ans[to] += ans[v];
            dfs(to,v);
        }
    }
}

int main()
{
    int n,q;
    cin >> n >> q;
    for(int i= 0; i < n-1; i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    ans.resize(n);
    for(int i = 0; i < q; i++){
        int p,x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    for(int i = 0; i < n; i++){
        cout << ans[i] << ' ';
    }
}


Measured memory_bytes: 26624
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    bool dp[n];
    memset(dp, 0, sizeof(dp));
    dp[n-1] = true;
    for (int i = n-2; i >= 0; i--) {
        dp[i] = (h[i] - h[i+1] <= 1 && dp[i+1]) ? true : false;
        if(h[i] - h[i+1] == 1 && dp[i])
        {
            h[i]--;
        }
    }
    if(dp[0])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}



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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long MAX = 10000000001;
            var sc = new Scanner();
            int x = sc.NextInt();
            int y = sc.NextInt();
            int z = sc.NextInt();
            int p = sc.NextInt();
            long[] a = new long[x];
            long[] b = new long[y];
            long[] c = new long[z];
            for (int i = 0; i < x; i++) a[i] = sc.NextLong();
            for (int i = 0; i < y; i++) b[i] = sc.NextLong();
            for (int i = 0; i < z; i++) c[i] = sc.NextLong();

            Array.Sort(a); Array.Reverse(a);
            Array.Sort(b); Array.Reverse(b);
            Array.Sort(c); Array.Reverse(c);

            var list = new List<long>(3000);
            for (int i = 0; i < x; i++)
            {
                for (int j = 0; j < y; j++)
                {
                    for (int k = 0; k < z; k++)
                    {
                        if ((i + 1) * (j + 1) * (k + 1) > p) break;
                        list.Add(a[i] + b[j] + c[k]);
                    }
                }
            }

            list.Sort();
            list.Reverse();
            for (int i = 0; i < p; i++)
            {
                Console.WriteLine(list[i]);
            }
        }
    }

    class Scanner
    {
        int index = -1;
        string[] buf;

        public Scanner()
        {
        }

        public int NextInt()
        {
            CheckNext();
            return int.Parse(buf[index++]);
        }

        public long NextLong()
        {
            CheckNext();
            return long.Parse(buf[index++]);
        }

        public string NextString()
        {
            CheckNext();
            return buf[index++];
        }

        private void CheckNext()
        {
            if (index >= 0 && index < buf.Length) return;

            buf = Console.ReadLine().Split(' ');
            index = 0;
        }
    }
}


Measured memory_bytes: 15840
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
#pragma endregion

int main()
{
  init_main();

  ll x;
  cin >> x;
  for (ll k = 1; k <= x * x; k++)
  {
    if (x % k != 0)
      continue;
    for (ll a = -1010; a <= 1010; a++)
    {
      ll b;
      b = a - k;
      if (a * a * a * a * a - b * b * b * b * b == x)
      {
        cout << a << " " << b << "\n";
        return 0;
      }
      b = a - x / k;
      if (a * a * a * a * a - b * b * b * b * b == x)
      {
        cout << a << " " << b << "\n";
        return 0;
      }
      b = a + k;
      if (a * a * a * a * a - b * b * b * b * b == x)
      {
        cout << a << " " << b << "\n";
        return 0;
      }
      b = a + x / k;
      if (a * a * a * a * a - b * b * b * b * b == x)
      {
        cout << a << " " << b << "\n";
        return 0;
      }
    }
  }
  assert(false);
  return 0;
}


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

ll n,m;
vector<ll> a(50),b(50);
bool reached[50];
bool graph[50][50];


void dfs(ll v){
  reached[v]=true;
  rep(i,n){
    if(graph[v][i]==false) continue;
    if(reached[i]==true) continue;
    dfs(i);
  }
}

int main(){
  
  cin>>n>>m;
  
  rep(i,m){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  ll ans=0;
  rep(i,m){
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
    rep(j,n) reached[j]=false;
    dfs(0);
    bool bridge=false;
    rep(j,n) if(!(reached[j])) bridge=true;
    if(bridge) ans++;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    
  }
  
  cout<<ans<<endl;
  
  
  
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};
typedef struct node * NodePointer;
NodePointer nil;
NodePointer Search(int key){
  NodePointer cur = nil->next;
  while( cur != nil && cur->key != key ){
    cur = cur->next;
  }
  return cur;
}
void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}
void print(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}
void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
}
void dFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void dLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void del(int key){
  NodePointer t = Search(key);
  if ( t == nil ) return;
  deleteNode(t);
}
void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}
int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if(!( 0 <= key && key <= 2000000000)){printf("error") ;}
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) dFirst();
	else if ( com[6] == 'L' ) dLast();
      } else {
	del(key); nd++; 
      }
      size--;
    }
    if ( size > 1000000 ) { printf("error"); }
  }  
  if(!( np+nd <= 2000000)){printf("error") ;}
  if(!( nd <= 20)){printf("error") ;}
  print();
  return 0;
}



Measured memory_bytes: 36128