akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define int long long
#define ll long long
#define lson node<<1
#define rson (node<<1)+1
#define endl "\n"

const int maxn=2e6+10;
const ll mod=1e9+7;
const double pi=acos(-1);

ll qpow(ll a,ll n)
{
    ll b=1;
    while(n)
    {
        if(n&1)
            b=b*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return b;
}
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 prime[maxn],s,v[maxn];
//void prime_init()
//{
//    for(int i=2; i<=maxn; i++)
//    {
//        if(!v[i])
//        {
//            prime[s++]=i;
//            for(int j=1; j*i<=maxn; j++)
//                v[i*j]=1;
//        }
//    }
//}
int r[maxn],w[maxn];
signed main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int sr=0,sw=0;
    for(int i=0; i<n; i++)
        if(s[i]=='W')
            w[sw++]=i;
    for(int i=n-1; i>=0; i--)
        if(s[i]=='R')
            r[sr++]=i;
    int sum=0;
    int x=0,y=0;
    while(x<sr&&y<sw&&r[x]>w[y])
    {
        sum++;
        x++,y++;
    }
    for(int i=y; i<sw; i++)
        if(w[i]<r[x])
            sum++;
        else
            break;
    cout<<sum;
    return 0;
}


Measured memory_bytes: 5316
import java.util.*;
import java.util.stream.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int cnt = 0;
		for (int i=a; i<=b; i++) {
			if (c % i == 0)
				cnt++;
		}
		out.println(cnt);
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}


Measured memory_bytes: 26244
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    int a, b; cin>>a>>b;
    vector<bool> v(1010, false);
    for(int i=a; i<b; i++){
        v[i] = true;
    }

    int n; cin>>n;
    int ans = 0;
    for(int i=0; i<n; i++){
        int s, f; cin>>s>>f;
        for(int j=s; j<f; j++){
            if(v[j]) ans = 1;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprev(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

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

    vector<int> arr(N);
    rep(i, N)
    {
        cin >> arr[i];
    }
    sort(all(arr));
    int min = arr[0];
    rep(i, N)
    {
        arr[i] -= min;
    }
    int sum = accumulate(arr.begin(), arr.end(), 0);
    sum /= arr.size();

    //cout << sum << endl;
    ll r = 0;
    rep(i, N)
    {
        //cout << arr[i] << endl;
        int k = abs(arr[i] - sum);
        r += k * k;
    }
    ll rr = r;

    sum++;
    r = 0;
    rep(i, N)
    {
        //cout << arr[i] << endl;
        int k = abs(arr[i] - sum);
        r += k * k;
    }
    if (r < rr)
        rr = r;

    cout << rr << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[8]={0,1,0,-1,1,-1,1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
int main(){
	int n;cin>>n;
	ll a[1010];
	ll suma=0;ll sumb=0;
	bool f=false;
	ll ma=-INF;int mai;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]>ma){
			ma=a[i];
			mai=i;
		}
		if(a[i]<0){
			continue;
		}
		f=true;
		if(i%2){
			suma+=a[i];
		}else{
			sumb+=a[i];
		}
	}
	int s;
	vector<int> ans;
	if(!f){
		cout<<ma<<endl;
	}else if(suma>sumb){
		cout<<suma<<endl;
		s=1;
	}else{
		cout<<sumb<<endl;
		s=0;
	}
	if(f){
		if((s&&n%2&&a[n]<0)||(s==0&&n%2==0&&a[n]<0)){
			ans.push_back(n);
		}
		for(int i=n;i>=1;i--){
			if(i%2==(s+1)%2){
				if(a[i-1]<0){
					ans.push_back(i-1);
				}else{
					ans.push_back(i);
				}
			}
		}
		if(s&&a[1]<0){
			ans.push_back(1);
		}
	}else{
		for(int i=1;i<mai;i++){
			ans.push_back(1);
		}
		for(int i=n;i>mai;i--){
			ans.push_back(i-mai+1);
		}
	}
	cout<<ans.size()<<endl;
	for(auto& e:ans){
		cout<<e<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
	static void Main()
	{
	int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
	int answer = 0;
    int[] numDivides = new int[3];
      
      for(int i = 0; i < 3; i++) numDivides[i]=nums[i]%2;
      
      if(numDivides[0]!=numDivides[1] && numDivides[0]!=numDivides[2])
      {
        nums[1]++;
        nums[2]++;
        answer++;
      }
       if(numDivides[1]!=numDivides[0] && numDivides[1]!=numDivides[2])
      {
        nums[0]++;
        nums[2]++;
        answer++;
      }
       if(numDivides[2]!=numDivides[1] && numDivides[2]!=numDivides[0])
      {
        nums[0]++;
        nums[1]++;
        answer++;
      }
      Array.Sort(nums);
      answer+=(nums[2]-nums[1])/2;
      answer+=(nums[2]-nums[0])/2;  
      
	Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}

Measured memory_bytes: 13140
S = str(input())

S = S[::-1]

words = ('dreamer', 'dream', 'eraser', 'erase')
sdrow = [word[::-1] for word in words]

while S:
    flag = False
    for drow in sdrow:
        if S.startswith(drow):
            flag = True
            S = S.replace(drow, '', 1)
    if not flag: break

print('NO') if S else print('YES')

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 5e3 + 5;
const LL inf = 1e18;
int n, k, p[N], c[N], cnt;
LL score[N], ans = -inf;
int vis[N];
inline LL calc(int S)
{
	memset(vis, 0, sizeof(vis)); cnt = 0;
	while (!vis[S]) {
		cnt++;
		score[cnt] = score[cnt - 1] + c[p[S]];
		vis[S] = cnt;
		S = p[S];
	}
	
	LL res = -inf;
	for (int i = 1; i <= n; i++)
	if (vis[i] && k >= vis[i]) res = max(res, (k - vis[i]) / cnt * max(0LL, score[cnt]) + score[vis[i]]);
	return res;
} 
int main(){
	scanf ("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf ("%d", &p[i]);
	for (int i = 1; i <= n; i++) scanf ("%d", &c[i]);
	
	for (int i = 1; i <= n; i++) ans = max(ans, calc(i));
	printf ("%lld\n", ans);
  return 0;
}

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

#define Bye return 0
#define ll long long

void solve(){

    int n; cin>>n;
    string str; cin>>str;
    int maxi = 0;
    int x = 0;
    for (int i = 0; i<n; i++){
        x = (str[i] == 'I') ? x + 1 : x - 1;
        maxi = max(maxi, x);
    }
    cout<<maxi<<endl;
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 3596
/*input
5
7 8 8 8 8
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=1000005;
const ll magic=500;

const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int a[maxn];

int main()
{
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>a[i];
	if(n==1){
		if(a[0]==1)	cout<<"Second\n";
		else cout<<"First\n";
		return 0;
	}

	int turn=0;
	while(1){
		int cnt=0;
		int id=0;
		REP(i,n){
			if(a[i]%2==0) cnt++;
			else id=i;
		}
		if(cnt%2==1){
			if(turn%2==0) cout<<"First\n";
			else cout<<"Second\n";
			return 0;
		}
		else if(cnt!=n-1||a[id]==1){
			if(turn%2) cout<<"First\n";
			else cout<<"Second\n";
			return 0;
		}
		else{
			REP(i,n) if(a[i]%2) a[i]--;
			int gg=a[0];
			REP(i,n) gg=__gcd(gg,a[i]);
			REP(i,n) a[i]/=gg; 
		}
		turn++;
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b,x; cin>>a>>b>>x;
	if(a<=x && x<=a+b) cout<<"YES";
	else cout<<"NO";
	
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

		int w = sc.nextInt();

		while (w >= 0) {

			int price = 1150;

			if (w > 30) {
				price += 160 * (w - 30);
				w = 30;
			}
			
			if (w > 20) {
				price += 140 * (w - 20);
				w = 20;
			}
			
			if (w > 10) {
				price += 125 * (w - 10);
			}

			System.out.println(4280 - price);

			w = sc.nextInt();
		}
	}
}



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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
	string S;
	cin >> S;
	int size = S.size();
	vector<vector<mint>> dp(size + 1, vector<mint>(13));
	dp[0][0] = 1;
	int powmod = 1;
	for (int n = 0;n< size ;++n) {
		if ('?' == S[size - 1 - n]) {
			for (int l = 0; l<10; ++l) {
				for (int m = 0; m < 13; ++m) {
					dp[n + 1][(m + powmod * l) % 13] += dp[n][m];
				}
			}
		}
		else {
			for (int m = 0;m<13;++m) {
				dp[n + 1][(m + powmod * (S[size - 1 - n]-'0'))%13] += dp[n][m];
			}
		}
		powmod *= 10;
		powmod %= 13;
	}
	cout << dp[size][5] << endl;
	return 0;
}

Measured memory_bytes: 16644
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

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

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(a+b, min(b+c, c+a)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#include <map>
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
#define ll long long
constexpr ll MOD = 1e9 + 7;
ll gcd(ll a, ll b) {return b % a ? gcd(b % a, a) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
using namespace std;
using P = pair<ll, ll>;
using VI = vector<ll>;

long cnt = 0;
long a, b, c;

void sim() {
    if (cnt > 1e7) {
        cout << -1 << endl;
        exit(0);
    }
    if ((a % 2) | (b % 2) | (c % 2) | ((b + c) % 2) | ((a + c) % 2) | ((a + b) % 2)) {
        cout << cnt << endl;
        exit(0);
    }
    long p, q, r;
    p = (b + c) / 2;
    q = (a + c) / 2;
    r = (a + b) / 2;
    a = p;
    b = q;
    c = r;
    cnt++;
}

int main() {
    cin >> a >> b >> c;
    while (1) sim();
}


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

//qsort
int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}
int desc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}
 
int main(void) {
 
  // 入力
   int n;
  scanf("%d",&n);
   int list[n];
  for(int i=0;i<n;i++){
    scanf("%d",&list[i]);
  }
 
  // 昇順sort
  qsort(list, n, sizeof(int), asc);
  
  int halfN = n/2;
  printf("%d\n",list[halfN]-list[halfN-1]);
 
  return 0;
}


Measured memory_bytes: 892
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

const int maxn = 100000, maxnv = maxn * 6;
const int inf = 1e9;

int n;
pair<int, int> point[maxn << 1];

int nv;
vector<int> g[maxnv];
int dfn[maxnv], clk;
int stk[maxnv], top;
int cntscc, sccid[maxnv];

int Tarjan(int u) {
  int low = dfn[u] = clk++;
  stk[top++] = u;
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i];
    if (dfn[v] == -1) {
      low = min(low, Tarjan(v));
    } else if (sccid[v] == -1) {
      low = min(low, dfn[v]);
    }
  }
  if (low == dfn[u]) {
    while (true) {
      int v = stk[--top];
      sccid[v] = cntscc;
      if (v == u) {
        break;
      }
    }
    ++cntscc;
  }
  return low;
}

bool SolveSat(void) {
  memset(dfn, -1, nv * sizeof(int));
  memset(sccid, -1, nv * sizeof(int));
  clk = top = cntscc = 0;
  for (int i = 0; i < nv; ++i) {
    if (dfn[i] == -1) {
      Tarjan(i);
    }
  }
  for (int i = 0; i < n; ++i) {
    if (sccid[i << 1] == sccid[i << 1 | 1]) {
      return false;
    }
  }
  return true;
}

#define TREE(i) ((n << 1) + (i))
#define LEAF(i) ((n << 2) + (i))
#define POINT(i) (i)

void AddEdge(int i, int l, int r) {
  for (l += n << 1, r += n << 1; l < r; l >>= 1, r >>= 1) {
    if (l & 1) {
      g[POINT(i)].push_back(TREE(l++));
    }
    if (r & 1) {
      g[POINT(i)].push_back(TREE(--r));
    }
  }
}

bool IsValid(int d) {
  nv = n * 6;
  for (int i = 0; i < nv; ++i) {
    g[i].clear();
  }

  for (int i = 1; i < n << 1; ++i) {
    g[TREE(i)].push_back(TREE(i << 1));
    g[TREE(i)].push_back(TREE(i << 1 | 1));
  }
  for (int i = 0; i < n << 1; ++i) {
    g[LEAF(i)].push_back(POINT(point[i].second ^ 1));
  }

  for (int i = 0; i < n << 1; ++i) {
    int x = point[i].first;
    int l = upper_bound(point, point + (n << 1), make_pair(x - d, inf)) - point;
    int r = lower_bound(point, point + (n << 1), make_pair(x + d, -inf)) - point;
    AddEdge(point[i].second, l, i);
    AddEdge(point[i].second, i + 1, r);
  }

  return SolveSat();
}

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int pos1, pos2;
    scanf("%d%d", &pos1, &pos2);
    point[i << 1] = make_pair(pos1, i << 1);
    point[i << 1 | 1] = make_pair(pos2, i << 1 | 1);
  }
  sort(point, point + (n << 1));

  int low = 0, high = 1e9;
  while (low < high) {
    int mid = high - (high - low >> 1);
    if (IsValid(mid)) {
      low = mid;
    } else {
      high = mid - 1;
    }
  }

  printf("%d\n", low);
  return 0;
}


Measured memory_bytes: 28288
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
using namespace std;

int main(){ 
  int n;
  cin>>n;
  tuple<string,int,int> a[n];
  rep(i,0,n){
    cin>>get<0>(a[i])>>get<1>(a[i]);
    get<1>(a[i])*=-1;
    get<2>(a[i])=i;
  }
  sort(a,a+n);
  rep(i,0,n) co(get<2>(a[i])+1);
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              (double)3.14159265358979323844
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

ll add(ll a,ll b) {
	return ((a%hell)+(b%hell))%hell;
}
ll sub(ll a,ll b) {
	return ((a%hell)-(b%hell)+hell)%hell;
}
ll mul(ll a,ll b) {
	return ((a%hell)*(b%hell))%hell;
}

const ll MAXN=100005;
ll n;
vi a[MAXN];
ll dp[MAXN][2];

ll dfs(ll node,ll color,ll par) {
	if (dp[node][color]!=-1)return dp[node][color];
	dp[node][color]=1;
	if (color==1){
		for(auto i:a[node]){
			if(i!=par){
				dp[node][color]=mul(dp[node][color],dfs(i,0,node));
			}
		}
	}
	else{
		for(auto i:a[node]){
			if(i!=par){
				dp[node][color]=mul(dp[node][color],add(dfs(i,0,node),dfs(i,1,node)));
			}
		}
	}
	return dp[node][color];
}

void solve() {
    cin>>n;
    rep(i,0,n-1){
    	ll x,y;
    	cin>>x>>y;
    	a[x].pb(y);
    	a[y].pb(x);
    }
    memset(dp,-1,sizeof dp);
    cout<<add(dfs(1,0,-1),dfs(1,1,-1))<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 15616
#ifdef LOCAL
#include "debug.h"
#else
#include <bits/stdc++.h>
#define debug(x...)
#endif

//#define int ll
//#pragma GCC optimize("Ofast")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define sz(x) int((x).size())

#ifdef ONLINE_JUDGE
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#else
mt19937 rng(1000 - 7);
#endif

const int N = 3e3 + 10;
const int M = 1e3 + 10;
const int MOD = 998244353;
//const int MOD = 1e9 + 7;
const ld eps = 1e-6;
const pii dir[] = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 } };

int a[10][45][20];

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cout << fixed << setprecision(9);
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int n;
    cin >> n;

    ll ans = 0;
    for (int it = 0; it < n; it++) {
        string s;
        cin >> s;

        bool r = count(s.begin(), s.end(), '.');
        while (r && s.back() == '0') {
            s.pop_back();
        }
        if (s.back() == '.') {
            s.pop_back();
            r = false;
        }

        int cnt;
        if (!r) {
            cnt = 0;
        }
        else {
            cnt = sz(s) - s.find('.') - 1;
            s.erase(s.find('.'), 1);
        }
        ll y = stoll(s);
        debug(y);

        int p = 0, q = 0;
        while (y % 2 == 0) {
            p++;
            y /= 2;
        }
        while (y % 5 == 0) {
            q++;
            y /= 5;
        }

        debug(cnt, p, q);
        
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 45; j++) {
                for (int k = 0; k < 20; k++) {
                    if (j + p >= cnt + i && k + q >= cnt + i) {
                        ans += a[i][j][k];
                    }
                }
            }
        }
        a[cnt][p][q]++;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3680
#include <iostream>
using namespace std;
int main()
{
  int Bottle1, Bottle2, Bottle3;
  int ans;
  cin>>Bottle1>>Bottle2>>Bottle3;
  ans = Bottle3+Bottle2 - Bottle1;
  if (ans<=0)
  {
    cout<<"0";
    cout<<endl;
  }
  else
  {
    cout<<ans;
    cout<<endl;
  }
}

Measured memory_bytes: 256
import itertools
import math

N = int(input())

X = []
Y = []
for _ in range(N):
    x, y = map(int, input().split());
    X.append(x)
    Y.append(y)

s = 0
for p in itertools.permutations(range(N), N):
    for i in range(len(p) - 1):
        s += (((X[p[i]] - X[p[i+1]]) ** 2) + ((Y[p[i]] - Y[p[i+1]]) ** 2)) ** 0.5

print(s / math.factorial(N))

Measured memory_bytes: 3064
import std.stdio;
import std.string;
import std.conv;
import std.array;

void main()
{
    int N = readln.chomp.to!int;
    int[3][] price = new int[3][](N);
    foreach (i; 0..N) price[i] = readln.split.to!(int[]);

    int[3][] max_sum = new int[3][](N);
    max_sum[0] = price[0];

    foreach (i; 1..N){
        foreach (j; 0..3){
            int max_p = 0;
            foreach (k; 0..3){
                if (k == j) continue;
                if (max_sum[i - 1][k] > max_p) max_p = max_sum[i - 1][k];
            }
            max_sum[i][j] = max_p + price[i][j];
        }
    }

    int max = max_sum[$ - 1][0];
    foreach (i; 1..3){
        if (max_sum[$ - 1][i] > max) max = max_sum[$ - 1][i];
    }

    writeln(max);
}



Measured memory_bytes: 5116
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<string>
#include<string.h>
#include<vector>
#include<queue>
#include<stack> 
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const double eps=1e-8;
const double inf=0x3f3f3f3f;
const int maxn=1e7+15;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};

bool isPrime(ll n)
{
	if(n==2||n==3) return true;
	ll cnt=sqrt(n);
	for(ll i=2;i<=cnt;i++)
	{
		if(n%i==0) return false;
	}
	return true;
}
ll Count(ll n)
{
	if(n==1) return 1;
	if(n==2||n==3) return 2;
    ll s=1;
    //ll cnt=sqrt(n);
    for(ll i=2 ;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ll a=0 ;
            while(n%i==0)
            {
                n/=i;
                a++;
            }
            s=s*(a+1) ;
        }
    }
    if(n>1) s=s*2;
    return s;
}

int num[maxn];
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0); 
	ll n,i,j;
	ll ans=1;
	cin>>n;
	num[1]=1;
	for(i=2;i<=n;i++)
	{
		for(j=i;j<=n;j+=i)
	    num[j]++;
	}
    for(i=2;i<=n;i++)
    {
    	num[i]++;
    	ans+=num[i]*i;
	}
	cout<<ans<<endl;
}

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

const int MAXN = 3000 + 10;

char s[MAXN], t[MAXN], tmp[MAXN];
int f[MAXN][MAXN];

int main() {
    scanf("%s %s", s + 1, t + 1);
    int n = strlen(s + 1), m = strlen(t + 1);
    for (int i = n; i >= 1; --i) {
        for (int j = m; j >= 1; --j) {
            f[i][j] = max(f[i + 1][j], f[i][j + 1]);
            if (s[i] == t[j]) f[i][j] = max(f[i][j], f[i + 1][j + 1] + 1);
        }
    }
    int i = 1, j = 1;
    while (i <= n && j <= m) {
        if (s[i] == t[j]) putchar(s[i]), i ++, j ++;
        else if (f[i][j] == f[i + 1][j]) i ++;
        else j ++;
    }
    return 0;
}

Measured memory_bytes: 35584
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

if __name__ == "__main__":
    n,m = map(int,input().split())
    s = input()
    t = input()
    G = gcd(n,m)
    ansL = n // G * m
    flag = True
    n = n // G
    m = m // G
    for i in range(0,G):
        if s[i*n] != t[i*m]:
            flag = False
    if flag:
        print(ansL)
    else:
        print(-1)

Measured memory_bytes: 3316
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s1 = sc.next();
    String s2 = sc.next();
    String s3 = sc.next();
    String t1 = String.valueOf(s1.charAt(0)).toUpperCase();
    String t2 = String.valueOf(s2.charAt(0)).toUpperCase();
    String t3 = String.valueOf(s3.charAt(0)).toUpperCase();
    System.out.println(t1 + t2 + t3);
  }
}

Measured memory_bytes: 21844
package main

import (
	"fmt"

)

func main(){
  var k,a,b int64;
  fmt.Scan(&k);
  fmt.Scan(&a);
  fmt.Scan(&b);
  if(a%k==0){
    fmt.Println("OK")
    return
  }
  start:=a/k
  for ;start*k<=b;start++{
    if(start*k>=a){
    fmt.Println("OK")
    return
    }
  }
  fmt.Println("NG")
}

Measured memory_bytes: 1752
N = int(input())
A = sorted(list(map(int, input().split())))

ans = 0
MOD = 10**9+7
total = sum(A)

for i in range(N-1):
    tmp = A[i]
    total -= tmp
    ans += (tmp * total) % MOD
    ans %= MOD

print(ans)

Measured memory_bytes: 31504
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>

using namespace std;
#define INF (1 << 30)
typedef pair<int, int> P;
typedef pair<int, P> T;

vector<P> edge[105];
int n, m, l, k, a, h;
bool recover[105];
int dist[105][105];

void dijkstra(int s){
	for(int i = 0;i < 105;i++)
		for(int j = 0;j < 105;j++)
			dist[i][j] = INF;
	dist[s][m] = 0;
	priority_queue<T, vector<T>, greater<T> > pq;
	pq.push(T(0, P(s, m)));
	while(!pq.empty()){
		T tmp = pq.top();pq.pop();
		int d = tmp.first, from = tmp.second.first, blood = tmp.second.second;
		if(dist[from][blood] < d)continue;
		for(int i = 0;i < edge[from].size();i++){
			int to = edge[from][i].first, r = edge[from][i].second;
			if(r > blood)continue;
			if(dist[to][blood - r] <= d + r)continue;
			dist[to][blood - r] = d + r;
			pq.push(T(dist[to][blood - r], P(to, blood - r)));
		}
		if(blood < m && recover[from]){
			if(dist[from][blood + 1] <= d + 1)continue;
			dist[from][blood + 1] = d + 1;
			pq.push(T(dist[from][blood + 1], P(from, blood + 1)));
		}
	}
}

int main(){
	int t, x, y;
	while(cin >> n >> m >> l >> k >> a >> h, n){
		fill(recover, recover + 105, false);
		for(int i = 0;i < 105;i++)edge[i].clear();
		for(int i = 0;i < l;i++){
			cin >>t;
			recover[t] = true;
		}
		for(int i = 0;i < k;i++){
			cin >> x >> y >> t;
			edge[x].push_back(P(y, t));
			edge[y].push_back(P(x, t));
		}
		dijkstra(a);
		int res = INF;
		for(int i = 0;i < 105;i++){
			res = min(res, dist[h][i]);
		}
		if(res == INF)cout <<"Help!" << endl;
		else cout << res << endl;	
	}
	return 0;
}

Measured memory_bytes: 1472
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

template <class InputIterator, class Predicate>
typename iterator_traits<InputIterator>::difference_type
  mycount_if(InputIterator first, InputIterator last, Predicate pred) {
  typename iterator_traits<InputIterator>::difference_type ret = 0;
  for ( ; first != last; ++first)
    if (pred(first)) ret++;
  return ret;
}

int main()
{
  int N;
  cin >> N;
  vector<int> H(N);
  for_each(H.begin(), H.end(), [](int& e) { cin >> e; });
  int ans = 0;
  auto genLeqFunc = [](int X) {
    return [=](int& x) { return x <= X; };
  };
  cout << mycount_if(H.begin(), H.end(), [&](auto now) {
    auto leqHi = genLeqFunc(*now);
    return all_of(H.begin(), now, leqHi);
  }) << endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
q = gets.to_i
m = gets.split.map(&:to_i)

memo = {}

solve = ->(i, m) {
  return memo[[i, m]] if memo.has_key?([i, m])
  return true if m.zero?
  return false if i >= n || m < 0
  memo[[i, m]] = solve.(i + 1, m) || solve.(i + 1, m - a[i])
}

m.each do |target|
  puts solve.(0, target) ? "yes" : "no"
end


Measured memory_bytes: 8880
from math import gcd


def lcm(X, Y):  # 最小公倍数
    return (X * Y) // gcd(X, Y)

n, m = map(int, input().split())
s, t = input(), input()

l = lcm(n, m)
ln, lm = l // n, l // m
if all(s[i // ln] == t[i // lm] for i in range(0, l, lcm(ln, lm))):
    print(l)
else:
    print(-1)


Measured memory_bytes: 65016
n = int(input())
tree = [None] * n
root = set(range(n))


def preorder(i):
    if i == -1: return
    (l, r) = tree[i]
    yield i
    for v in preorder(l): yield v
    for v in preorder(r): yield v


def inorder(i):
    if i == -1: return
    (l, r) = tree[i]
    for v in inorder(l): yield v
    yield i
    for v in inorder(r): yield v


def postorder(i):
    if i == -1: return
    (l, r) = tree[i]
    for v in postorder(l): yield v
    for v in postorder(r): yield v
    yield i


while n:
    i, l, r = list(map(int, input().split()))
    tree[i] = (l, r)
    root -= {l, r}
    n -= 1

root_node = root.pop()

for name, func in (('Preorder', preorder), ('Inorder', inorder), ('Postorder', postorder)):
    print(name)
    print(' ', end='')
    print(*func(root_node))

Measured memory_bytes: 7812
ENV[A='RUBY_THREAD_VM_STACK_SIZE']||exec({A=>?5*8},'ruby',$0);F=->c{H[c].all?{|e|Z[e]?(Z[c]-Z[e])%2>0:(Z[e]=Z[c]^1;F[e])}};N,M=gets.split.map &:to_i;H=Hash.new{|h,k|h[k]=[]};Z={1=>0};$<.map{|e|a,b=e.split.map &:to_i;H[a]<<b;H[b]<<a};p (F[1]?(x,y=Z.partition{|k,v|v<1};x.size*y.size):N*~-N/2)-M

Measured memory_bytes: 108612
package main

import (
  "fmt"
)

func divmod(a, b int) (int, int) {return a / b, a % b}
func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func main() {
  var n, a, b int 
  fmt.Scan(&n, &a, &b)
  q, r := divmod(n, a + b)
  res := a * q + minInt(r, a)
  fmt.Println(res)

}

Measured memory_bytes: 512
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N = int(input())
    a = list(map(int, input().split()))

    idx = {}
    for i in range(N):
        idx[a[i]] = i

    left_idx, right_idx = list(range(N + 1)), list(range(N + 1))
    ans = 0
    for a in range(N, 0, -1):
        i = idx[a]
        l, r = left_idx[i], right_idx[i]
        ans += (i - l + 1) * (r - i + 1) * a

        left_idx[r + 1] = l
        right_idx[l - 1] = r

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 47260
#include <bits/stdc++.h>
#define inf (1 << 29)
using namespace std;
const int maxn = 16;
typedef long long ll;
ll C[1 << maxn];
int A[maxn][maxn],N;
ll memo[1 << 16];
ll solve(int mask){
    if (!mask)return 0;
    ll &ans = memo[mask];
    if (ans!= LLONG_MIN)return ans;
    for (int m = mask;m;m = (m-1) & mask){
        ans = max(ans,solve(mask^m)+C[m]);
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen(".in","r",stdin);
    cin >> N;
    for (int i = 0; i < N;i++){
        for (int j = 0; j < N;j++){
            cin >> A[i][j];
        }
    }
    for (int mask = 1; mask < ( 1<< N);mask++){
        for (int i = 0; i < N;i++){
            if ((mask)& (1 << i))continue;
            for (int j = 0; j < i;j++){
                    if (mask & (1 << j))
                C[mask|(1 << i)]+= A[j][i];
            }

        }
    }
    for (int i = 1; i < (1 << N);i++){
        memo[i] = LLONG_MIN;
    }
    cout << solve((1 << N)-1);
    return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = ""+n;
        int ketawa = 0;
        for(char c : s.toCharArray()) {
            int keta = Integer.parseInt(String.valueOf(c));
            ketawa += keta;
        }
        System.out.println(n % ketawa == 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;

ll fpow(ll base, ll exp) {
	ll res = 1;
	while(exp) {
		if ( exp&1 )
			res = (res*base) % mod;
		exp >>= 1;
		base = (base*base) % mod;
	}
	return res;
}

void solve() {
	ll n; cin >> n;
	ll ans = ((fpow(10,n) - 2*fpow(9,n))%mod + fpow(8,n))%mod;
	while(ans<0) ans+=mod;
	cout << ans%mod << '\n';
}	

int main(int argc, char * argv[]) 
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:/Users/Fish_Brother/Desktop/in", "r", stdin);
	//freopen("C:/Users/Fish_Brother/Desktop/out", "w", stdout);
#endif
	//int t; cin >> t; while(t--)
	solve();

    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<string>
using namespace std;
int main(){
int a[] = { 0,1,3,1,2,1,2,1,1,2,1,2,1 };
int x,y;
cin >>x>>y;
if(a[x]==a[y])
cout << "Yes"  << endl;
else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;

int main(){
    int n, k; cin >> n >> k;
    vector<vector<int>> a(2*k, vector<int>(2*k, 0));
    int x, y;
    char c;
    for(int i=0; i<n; i++){
        cin >> x >> y >> c; 
        if(c == 'W'){a[x%(2*k)][y%(2*k)]++;}
        else{a[(x+k)%(2*k)][y%(2*k)]++;}
    }
    for(int i=0; i<2*k; i++){
        for(int j=0; j<2*k-1; j++){
            a[i][j+1] += a[i][j];
        }
    }
    for(int i=0; i<2*k; i++){
        for(int j=0; j<2*k-1; j++){
            a[j+1][i] += a[j][i];
        }
    }
    int ans = 0;
    for(int i=0; i<k; i++){
        for(int j=0; j<k; j++){
            int ret = 0;
            ret += a[i+k][2*k-1] - a[i][2*k-1] + 2 * a[i][j+k];
            ret += a[2*k-1][j+k] - a[2*k-1][j] + 2 * a[i+k][j];
            ret -= 2 * a[i+k][j+k] + 2 * a[i][j];
            ans = max(ans, max(ret, n-ret));
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main(void){
  int n,d,i,j,k;
  double x[10][10];
  cin>>n>>d;

  for(i=0;i<n;i++){
    for(j=0;j<d;j++){
      cin>>x[i][j];
    }
  }

  int cnt=0;
  double tmp;
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      tmp=0;
      for(k=0;k<d;k++){
        tmp+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }

      tmp=sqrt(tmp);

      if(floor(tmp)==ceil(tmp)){
        cnt++;
      }
    }
  }

  cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] input = scan.nextLine().split("");
		scan.close();
		boolean same = false;
		for(int i=0; i<input.length-1; i++) {
			String str1 = input[i];
			for(int j=i+1; j<input.length; j++) {
				String str2 = input[j];
				if(str1.equals(str2)) {
					same = true;
				}
			}
			if(same) {
				break;
			}
		}
		
		if(same) {
			System.out.println("no");
		} else {
			System.out.println("yes");
		}
	}

}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  short a,b;in(a,b);
  out(6-a-b);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

struct UnionFind{
  vector<int> parent;
  vector< ll > dist;
  UnionFind(int x=1){
    parent.clear();
    parent.resize(x,-1);
    dist.clear();
    dist.resize(x,0);
  }
  int find(int x){
    if(parent[x]<0)return x;
    int r=find(parent[x]);
    dist[x]+=dist[ parent[x] ];
    return parent[x]=r;    
  }
  ll depth(int x){
    find(x);
    return dist[x];
  }
  bool same(int x,int y){
    return (find(x)==find(y));
  }
  int size(int x){
    return -parent[find(x)];
  }
  void unite(int x,int y,ll k=0){
    k+=depth(y);
    k-=depth(x);
    k*=-1;
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(size(x)<size(y)){
      swap(x,y);
      k*=-1;
    }
    parent[x]+=parent[y];
    parent[y]=x;
    dist[y]=k;
  }
};




int main(){
  int n,q;
  scanf("%d %d",&n,&q);
  UnionFind T(n);
  for(int i=0;i<q;i++){
    int type,x,y;
    scanf("%d %d %d",&type,&x,&y);
    if(type==0){
      int a;
      scanf("%d",&a);
      T.unite(x,y,a);
    }else{
      
      if(!T.same(x,y)){
        printf("?\n");
      }else{
        printf("%lld\n",T.depth(x)-T.depth(y));
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3860
n, k, c = map(int, input().split())
s = input()
fastest_schedule = [None for i in range(n)]
latest_schedule = [None for i in range(n)]
count = 1
last_workday = -10**10
for i in range(n):
    if s[i] == 'o' and i - last_workday > c:
        fastest_schedule[i] = count
        last_workday = i
        if count < k:
            count += 1
        else:
            break
count = k
last_workday = 10**18
for i in range(n-1,-1,-1):
    if s[i] == 'o' and last_workday - i > c:
        latest_schedule[i] = count
        last_workday = i
        if count > 1:
            count -= 1
        else:
            break

for i in range(n):
    if fastest_schedule[i] == latest_schedule[i] and fastest_schedule[i] != None:
        print(i+1)
    

Measured memory_bytes: 90444
import java.util.*;
 
	public class Main {
		public static void main(String[] args) {
      	Scanner sc = new Scanner(System.in);
      
      	long N  =sc.nextLong();
       	long K  =sc.nextLong();
          
        if(N>K && N%K!=0){
           System.out.println(K-(N%K));
        }
          else if(N<K && K-N<N){
            System.out.println(K-N);
          }
          else if(N<K && K-N>N){
           System.out.println(N);
          }
          else{
          System.out.println(0);
          }
    }
}

Measured memory_bytes: 35596
n = int(input())
l = list(map(int,input().split()))
print(*l)
for i in range(1,n):
    v = l[i]
    j = i-1
    while j>=0 and l[j]>v:
        l[j+1] = l[j]
        j -= 1
    l[j+1] = v
    print(*l)

Measured memory_bytes: 7984
#include <bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;

template<class T> inline
void read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    x *= f;
}

/*============ Header Template ============*/

const int N = 200000 + 5;

int n, m, q;
int dis[N][15], ci[N], inq[N];
vector <int> bi[N];
queue <int> Q;

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; ++ i) {
        int a, b;
        scanf("%d%d", &a, &b);
        bi[a].push_back(b);
        bi[b].push_back(a);
    }
    scanf("%d", &q);
    for (int i = 1; i <= q; i++) {
        int v, d;
        scanf("%d%d%d", &v, &d, &ci[i]);
        dis[v][d] = i;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 10; j; j--)
            if (dis[i][j] > dis[i][j - 1])
                dis[i][j - 1] = dis[i][j];
        Q.push(i); inq[i] = 1;
    }
    while (!Q.empty()) {
        int t = Q.front(); Q.pop(); inq[t] = 0;
        for (int i = 0; i < bi[t].size(); ++ i) {
            int cg = 0;
            for (int j = 10; j; j--)
                if (max(dis[t][j], dis[bi[t][i]][j]) > dis[bi[t][i]][j - 1]) {
                    dis[bi[t][i]][j - 1] = max(dis[t][j], dis[bi[t][i]][j]);
                    cg = 1;
                }
            if (cg && !inq[bi[t][i]]) {
                Q.push(bi[t][i]);
                inq[bi[t][i]] = 1;
            }
        }
    }
    for (int i = 1; i <= n; ++ i) cout << ci[dis[i][0]] << "\n";
    return 0;
}

Measured memory_bytes: 16888
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::max;

fn main() {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();

    if a + b < c {
        println!("No");
        return;
    }
    println!("Yes");
}


Measured memory_bytes: 4352
N=int(input())
A=list(map(int,input().split()))

d={}

for i,j in enumerate(A):
    d[i]=j

d=sorted(d.items(),key=lambda x:x[1],reverse=True)

dp=[[0]*(N+1) for _ in range(N+1)]

c=0
for k,v in d:
    for i in range(c+1):
        dp[i+1][c-i]=max(dp[i+1][c-i],dp[i][c-i]+abs(v*(k-i)))
        dp[i][c-i+1]=max(dp[i][c-i+1],dp[i][c-i]+abs(v*(N-(c-i)-k-1)))
    c+=1

ans=0
for i in range(N):
    ans=max(ans,dp[i][N-i])

print(ans)

Measured memory_bytes: 100436
#include<stdio.h>
int main(void){
	int syozi,oturi;
	int i,j,k,l,m,n;

	while(1){
		scanf("%d",&syozi);
		if(syozi==0){
			return 0;
		}
		oturi=1000-syozi;
		for(i=0;i<=9;i++){for(j=0;j<=9;j++){for(k=0;k<=9;k++){
		for(l=0;l<=9;l++){for(m=0;m<=9;m++){for(n=0;n<=9;n++){
			if((500*n+100*m+50*l+10*k+5*j+1*i)==oturi){
				printf("%d\n",n+m+l+k+j+i);
				goto ohari;
			}
		}}}}}}
ohari:
		;
	}
	return 0;
}

Measured memory_bytes: 0
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, M, K;
  cin >> N >> M >> K;
  vector<int64_t> A(N + 1, 0);
  for (int64_t i = 1; i <= N; ++i) {
    int64_t v;
    cin >> v;
    A[i] = min(A[i - 1] + v, kInf);
  }
  vector<int64_t> B(M + 1, 0);
  for (int64_t i = 1; i <= M; ++i) {
    int64_t v;
    cin >> v;
    B[i] = min(B[i - 1] + v, kInf);
  }
  int64_t result = 0;
  int64_t b = M;
  for (int64_t a = 0; a <= N; ++a) {
    while (b >= 0 && A[a] + B[b] > K) {
      --b;
    }
    if (b < 0) {
      break;
    }
    result = max(result, a + b);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 6356
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		String s = in.next();
		
		if(a >= 3200) {
			System.out.println(s);
		} else {
			System.out.println("red");
		}

		in.close();
	}
}

Measured memory_bytes: 23764