akhauriyash/Code-Regression huggingface dataset:
def get_i(i)
  if $s[i] != i
    nums = [$s[i]]
    $s[i] = $s[$s[i]]
    while $s[i] != $s[$s[i]]
      nums << $s[i]
      $s[i] = $s[$s[i]]
    end
    nums.each {|j| $s[j] = $s[i]}
    $s[i]
  else
    i
  end
end

n, q = gets.split.map(&:to_i)
$s = (0...n).to_a

q.times do
  com, x, y = gets.split.map(&:to_i)
  xi = get_i(x)
  yi = get_i(y)
  case com
  when 0
    $s[xi] = yi if xi != yi
  when 1
    puts xi == yi ? '1' : '0'
  end
end

Measured memory_bytes: 6280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	char c; cin >> c;
	int x = c - 'A';
	if(0 <= x && x <= 26){
		print("A")
	}else{
		print("a")
	}
	
	return 0;
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        cout<<((n>=30)?"Yes":"No")<<endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    int ans = a + b;
    if (a * 2 - 1 > ans) {
        ans = a * 2 - 1;
    }
    if (b * 2 - 1 > ans) {
        ans = b * 2 - 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
 } 

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

namespace ConsoleApp88 {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();

            var array = S.ToCharArray();

            int cnt_0 = array.Where(x => x == '0').Count();
            int cnt_1 = array.Where(x => x == '1').Count();

            Console.WriteLine(Math.Min(cnt_0, cnt_1) * 2);
        }
    }
}

Measured memory_bytes: 11616
/*
    Written by Nitrogens
    Desire for getting accepted!!
*/
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <stack>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl

ll a[maxn], b[maxn], c[maxn];
ll dp[maxn][3];

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);

    int n;
    scanf("%d", &n);

    memset(dp, 0, sizeof(dp));
    for(int i = 1; i <= n; i++) scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
    for(int i = 1; i <= n; i++)
    {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }

    printf("%lld\n", max(dp[n][0], max(dp[n][1], dp[n][2])));

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


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

struct pro{
  string str;
  int time;
};

  pro que[100000];
int head,tail,leng=100000;

int isEmpty(){
  return head==tail;
}

void enqueue(pro x){
  que[tail]=x;
  if(tail+1==leng) tail=0;
  else tail++;
}

pro dequeue(){
  pro x;
  x=que[head];
  if(head+1==leng) head=0;
  else head++;
  return x;
}

int main(){
  pro x;
  int n,q,cnt=0;
  cin>>n>>q;
  pro scn;
  for(int i=0;i<n;i++){
 cin>>scn.str>>scn.time;
 enqueue(scn);
  }
  while(!isEmpty()){
    x=dequeue();
    if(x.time>q)cnt+=q,x.time-=q,enqueue(x);
       else{
 cnt+=x.time;
 cout<<x.str<<" "<<cnt<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5112
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AWhiteCells solver = new AWhiteCells();
        solver.solve(1, in, out);
        out.close();
    }

    static class AWhiteCells {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int W = in.nextInt();
            int H = in.nextInt();
            int w = in.nextInt();
            int h = in.nextInt();
            out.print((W - w) * (H - h));

        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public void close() {
        }

    }
}



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

namespace AtCoder.Contest.A
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			int r = cin.NextInt();
			Console.WriteLine(r * r);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    string t = s;
    rep(i, s.size()){
        if(s[i] + n < 91){
            t[i] = s[i] + n;
        }else{
            t[i] = s[i] - (26 - n);
        }
    }
    cout << t << endl;
    return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int k, t;
  cin >> k >> t;
  vector<int> a(t);
  rep(i, t) cin >> a.at(i);
  int maxV = 0;
  rep(i, t) {
    maxV = max(maxV, a.at(i));
  }
  int res = max(maxV - (k - maxV) - 1, 0);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  vector<int> x(n);
  for(int i=0; i<n; i++){
    cin >> x[i];
  }
 
  priority_queue<int> pq;
  for(int j=1; j<101; j++){
    int sum=0;
  for(int k=0; k<n; k++){
    sum = sum + ((j-x[k])*(j-x[k]));
  }
    pq.push(sum);
  }
  
  while(pq.size()!=1){
    pq.pop();
  }
  
  cout << pq.top() << endl;
    
}

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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	
	vector<int> a(n);
	int d, t;
	for (int i = 0; i < k; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> t;
			a[t - 1]++;
		}
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == 0) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007LL;
const double INF=1000000000;
const int MAX=100001;
int main(){
    int n;
    while(cin>>n,n){
        int k[110];
        for(int i=0;i<n;i++){
            cin>>k[i];
        }
        string s;
        cin>>s;
        for(int i=0;i<s.length();i++){
            int a;
            if(s[i]>='a'&&s[i]<='z'){
                a=s[i]-'a';
            }else{
                a=s[i]-'A'+26;
            }
            a-=k[i%n];
            if(a<0){
                a+=52;
            }
            if(a<26){
                s[i]='a'+a;
            }else{
                s[i]='A'+a-26;
            }
        }
        cout<<s<<endl;
    }
    return 0;
}

                           



Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <climits>

using namespace std;

const int MAX_N = 1 << 17;

typedef pair<int, int> P;

int n, cnt[MAX_N];
P dat[2*MAX_N-1];

void init(int n_){
  n = 1;
  while(n < n_) n *= 2;
  for(int i=0;i<2*n-1;i++) dat[i] = make_pair(INT_MAX, INT_MAX);
}

void update(int k, P a){
  k += n - 1;
  dat[k] = a;
  while(k > 0){
    k = (k - 1) / 2;
    dat[k] = min(dat[k*2+1], dat[k*2+2]);
  }
}

//min [a, b)
//call query(a, b, 0, 0, n)
P query(int a, int b, int k, int l, int r){
  if(r <= a || b <= l) return make_pair(INT_MAX, INT_MAX);
  if(a <= l && r <= b) return dat[k];
  else{
    P vl = query(a, b, k*2+1, l, (l+r)/2);
    P vr = query(a, b, k*2+2, (l+r)/2, r);
    return min(vl, vr);
  }
}

int main(){
	int N, R, L;
	cin >> N >> R >> L;
	memset(cnt, 0, sizeof(cnt));
	init(N);
	for(int i=0;i<N;i++) update(i, make_pair(0, i));
	int T = 0;
	for(int i=0;i<R;i++){
		int d, t, x;
		cin >> d >> t >> x;
		d--;
		if(T != t){
			P tmp = query(0, N, 0, 0, n);
			cnt[tmp.second] += t - T;
		}
		P tmp = query(d, d + 1, 0, 0, n);
		update(d, make_pair(tmp.first - x, tmp.second));
		T = t;
	}
	if(T != L){
		P tmp = query(0, N, 0, 0, n);
		cnt[tmp.second] += L - T;
	}
	int valM = -1, id;
	for(int i=0;i<N;i++){
		if(valM < cnt[i]){
			valM = cnt[i];
			id = i;
		}
	}
	cout << id + 1 << endl;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	bool F[402][402] = {};
	bool S[402][402] = {};

	void Solve() {
		UL H, W; cin >> H >> W;
		rep(y, H) {
			rep(x, W) {
				char c; cin >> c;
				S[x + 1][y + 1] = (c == '#');
			}
		}
		rep(x, W + 2) F[x][0] = F[x][H + 1] = true;
		rep(y, H + 2) F[0][y] = F[W + 1][y] = true;
		ULL ans = 0;
		rep(sy, H) rep(sx, W) {
			if (F[sx + 1][sy + 1]) continue;
			ULL Black = 0, White = 0;
			queue<pair<UL, UL>> Q; Q.push({ sx + 1, sy + 1 });
			while (Q.size()) {
				UL x = Q.front().first, y = Q.front().second;
				Q.pop();
				if (F[x][y]) continue;
				F[x][y] = true;
				(S[x][y] ? Black : White)++;
				if (S[x][y] != S[x + 1][y]) Q.push({ x + 1, y });
				if (S[x][y] != S[x][y + 1]) Q.push({ x, y + 1 });
				if (S[x][y] != S[x - 1][y]) Q.push({ x - 1, y });
				if (S[x][y] != S[x][y - 1]) Q.push({ x, y - 1 });
			}
			ans += (Black * White);
		}
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

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

int main() {
    string s, t;
    cin >> s >> t;

    vector<pair<char, char>> st, ts;
    rep(i, s.size()){
        st.push_back(make_pair(s.at(i), t.at(i)));
        ts.push_back(make_pair(t.at(i), s.at(i)));
    }
    sort(st.begin(), st.end());
    for(ll i=0; i<s.size()-1; i++){
        if(st.at(i).first == st.at(i+1).first){
            if(st.at(i).second != st.at(i+1).second){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    sort(ts.begin(), ts.end());
    for(ll i=0; i<s.size()-1; i++){
        if(ts.at(i).first == ts.at(i+1).first){
            if(ts.at(i).second != ts.at(i+1).second){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

}


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

const int maxn=2e5+5;

int fa[maxn],sum[maxn];

inline int find(int x)
{
    if(x==fa[x]) return x;
    return fa[x]=find(fa[x]);
}

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

    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++) fa[i]=i,sum[i]=1;
    for(int u,v,i=1;i<=m;i++)
    {
        cin>>u>>v;
        u=find(u),v=find(v);
        if(u==v) continue;
        fa[u]=v;sum[v]+=sum[u];
    }
    int ans=0;
    for(int i=1;i<=n;i++) ans=max(ans,sum[i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5192
#include <cstdio>
#include <cmath>

#include <iostream>
#include <vector>

using namespace std;

#define MAX(A, B) ((A < B) ? (B) : (A))

unsigned long long CEIL(unsigned long long A, unsigned long long B) {
	unsigned long long C = A / B;
	if ((A % B) != 0) ++C;
	return C;
}

int main(int argc, char const *argv[]) {
	unsigned long long n, a = 1, b = 1, aa, bb, f;
	cin >> n;

	for (unsigned long long i = 0; i < n; ++i) {
		cin >> aa >> bb;
		f = MAX(CEIL(a, aa), CEIL(b, bb));
		a = aa * f; b = bb * f;
	}

	cout << (a + b) << endl;

	return 0;
}

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

ll f(int u, int i, vector<vector<int> >& G, vector<vector<ll> >& memo) {
	if (memo[u][i] != -1) return memo[u][i];
	if (i == 0) return memo[u][i] = 1 * MOD + 1;
	ll X = 1, Y = 1;
	int v = u, j = i - 1;
	for (int t = 0; ; t++) {
		ll z = f(v, j, G, memo);
		int x = z / MOD, y = z % MOD;
		if (t % 2 == 1) swap(x, y);
		X = X * x % MOD;
		Y = Y * y % MOD;
		v = G[v][j];
		if (v == G[u][i]) break;
		j = G[v].size() - 1;
	}
	return memo[u][i] = X * MOD + (X + Y) % MOD;
}

int solve(int n, int m, vector<int> a, vector<int> b) {
	if (n % 2 == 1) return 0;
	vector<vector<int> > G(n);
	G[0].push_back(n - 1);
	for (int u = 0; u + 1 < n; u++)
		G[u].push_back(u + 1);
	for (int i = 0; i < m; i++) {
		a[i]--; b[i]--;
		if (a[i] > b[i]) swap(a[i], b[i]);
		if ((b[i] - a[i]) % 2 == 1)
			G[a[i]].push_back(b[i]);
	}
	vector<vector<ll> > memo(n);
	for (int u = 0; u < n; u++) {
		sort(G[u].begin(), G[u].end());
		memo[u] = vector<ll>(G[u].size(), -1);
	}
	return f(0, G[0].size() - 1, G, memo) % MOD;
}

int main() {
	for (;;) {
		int n, m; cin >> n >> m;
		if (n == 0 && m == 0) break;
		vector<int> a(m), b(m);
		for (int i = 0; i < m; i++)
			cin >> a[i] >> b[i];
		cout << solve(n, m, a, b) << endl;
	}
}

Measured memory_bytes: 9368
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll a[4];
    rep(i,4)cin >> a[i];
    ll mx = -(1LL<<60);
    rep(i,2){
        rep(j,2){
            chmax(mx,a[i]*a[j+2]);
        }
    }    
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll X,D,K;
int main(){
	cin>>X>>K>>D;
	X=abs(X);
	if(X/D>=K)cout<<X-K*D;
	else{ll p=X/D;X%=D,K-=p;
	if(K%2==0)cout<<X;
	else cout<<abs(X-D);
}
}

Measured memory_bytes: 3644
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) {if (x % y == 0) return y;else return LGCD(y, x % y);}
ll LLCM(ll x, ll y) {return x * y / LGCD(x, y);}

int GCD(int x, int y) {if (x % y == 0) return y;else return GCD(y, x % y);}
int LCM(int x, int y) {return x * y / GCD(x, y);}

int main() {
	int n;
	
	int ans = 0;
	cin >> n;
	int s = n / 2;
	vector<int>d(n);
	for (int i = 0;i < n;i++) {
		cin >> d.at(i);
		
	}
	sort(d.begin(), d.end());

		cout << d[s]-d[s-1] << endl;
	return 0;
}


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

int main(void){
    int N;
    scanf("%d",&N);

    int max = 0;
    int cnt = 0;
    while(N--){
        int x,y;
        scanf("%d%d",&x,&y);
        if(x == y){
            cnt++;
            if(max < cnt){
                max = cnt;
            }
        } else {
            cnt = 0;
        }
    }

    printf((max>=3)?"Yes\n":"No\n");
    
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
using namespace std;
int main(void){
    int W,H,x,y,r;
    cin >> W;
    cin >> H;
    cin >> x;
    cin >> y;
    cin >> r;
    if(x < 0 || y < 0){
        cout << "No";
    }
    else if(x+r <= W && y+r <= H){
        cout << "Yes";
    }
    else if(x+r < 0 || y+r < 0){
        cout << "No";
    }
    else{
        cout << "No";
    }
    cout << endl;
}


Measured memory_bytes: 3100
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static int MAXN = 1600;
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n=cin.nextInt();
        BigInteger ans=BigInteger.ONE;
        for(int i=0;i<n;i++){
        	BigInteger tmp=cin.nextBigInteger();
        	ans=(ans.multiply(tmp)).divide(ans.gcd(tmp));
        }
        out.println(ans);
        out.flush();
        out.close();
        cin.close();
    }
}

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

const ll INF = 1LL << 60;

string S;
int main() {
    cin >> S;
    map<char, ll> mp;

    if (mp.size() == 1) {
        cout << "YES" << endl;
        return 0;
    }

    rep(i, S.size()) {
        mp[S[i]]++;
    }

    // ll max_v = 0;
    // for (auto v : mp) {
    //     cout << v.first << " " << v.second << endl;
    //     // max_v = max(max_v, v.second);
    // }
    if (mp['a'] == mp['b'] && mp['b'] == mp['c']) {
        cout << "YES" << endl;
    } else if (mp['a'] == mp['b'] + 1 && mp['a'] == mp['c'] + 1) {
        // a が1こ多い
        cout << "YES" << endl;
    } else if (mp['b'] == mp['a'] + 1 && mp['b'] == mp['c'] + 1) {
        // b が1こ多い
        cout << "YES" << endl;
    } else if (mp['c'] == mp['a'] + 1 && mp['c'] == mp['b'] + 1) {
        // c が1こ多い
        cout << "YES" << endl;
    } else if (mp['a'] == mp['c'] + 1 && mp['b'] == mp['c'] + 1) {
        // ab が1こ多い
        cout << "YES" << endl;
    } else if (mp['b'] == mp['a'] + 1 && mp['c'] == mp['a'] + 1) {
        // bc が1こ多い
        cout << "YES" << endl;
    } else if (mp['c'] == mp['b'] + 1 && mp['a'] == mp['b'] + 1) {
        // ca が1こ多い
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

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

ll lcm(ll a, ll b)  {
    return (a*b)/gcd(a, b);
}


void solve(){

    ll N;
    cin>>N;
    ll i,temp;
    vector<ll> v;
    for(i=0;i<N;i++){
        cin>>temp;
        v.push_back(temp);
    }
    ll r=0;
    ll A[N]={};
    A[1] = abs(v[1]-v[0]);
    for(i=2;i<N;i++){
        A[i] = min(abs(v[i]-v[i-2])+A[i-2],abs(v[i]-v[i-1])+A[i-1]);
    }
    cout<<A[N-1];

}

int main(){
    //freopen("D:\\codes\\1input.txt","r",stdin);
    //freopen("D:\\codes\\1output.txt","w",stdout);
    ll T=1;
    //cin>>T;
    for(ll t=1;t<=T;t++){

        //cout<<"Case #"<<t<<": ";
        solve();
        //cout<<"\n";
    }
}


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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) {if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }
template<class T>
inline T upper(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	cout << n * 800 - n / 15 * 200 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// Welcome to my source code!

int main() {
    int n, a;
    cin >> n;
    bool flag = true;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a % 2 == 0) {
            if (a % 3 != 0 && a % 5 != 0) flag = false;
        }
    }
    if (flag) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

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

int main(){

    int ans=0;
    string s;
    cin>>s;
    if(s[0]=='1') ans++;
    if(s[1]=='1') ans++;
    if(s[2]=='1') ans++;
  
	cout<<ans<<endl;







    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace cswork
{

    class Program
    {
        public Program() { }

        Scanner cin;

        void Omame()
        {
            cin = new Scanner();
            long n = cin.nextLong();
            long a = cin.nextLong();
            long b = cin.nextLong();

            long ans = 0;
            for (int i = 1; i <= n; i++)
            {
                string s = i.ToString();
                int tmp = 0;
                for (int j = 0; j < s.Length; j++)
                {
                    tmp += s[j] - '0';
                }
                if (a <= tmp && tmp <= b)
                {
                    ans += i;
                }
            }
            Console.WriteLine(ans);
        }
        static void Main(string[] args)
        {
            new Program().Omame();
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();

            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next();
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    int N; cin >> N;
    vector < ll > A(N);
    REP(i,N) cin >> A[i];

    int cnt = 0;
    int zero = 0;
    ll sum = 0;
    REP(i,A.size()) {
        if (A[i] >= 0) sum += A[i];
        else sum -= A[i];
        if (A[i] == 0) {
            zero++;
        }
        if (A[i] < 0) {
            cnt++;
        }
    }

    if (zero > 0) {
        cout << sum << endl;
        return 0;
    }

    if (cnt % 2 == 0) {
        cout << sum << endl;
        return 0;
    }

    ll ans = 0;
    REP(i,A.size()) {
        if (A[i] < 0) {
            ans = max(ans, sum + 2LL * A[i]);
        } else {
            ans = max(ans, sum - 2LL * A[i]);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
using System;
class Program
{
  static void Main(string[] args)
  {
    string[] ab = Console.ReadLine().Split(' ');
    int a = int.Parse(ab[0]);
    int b = int.Parse(ab[1]);
    
    if ((a*b) % 2 == 0)
    {
      Console.WriteLine("Even");
    }
    if ((a*b) % 2 == 1)
    {
      Console.WriteLine("Odd");
    }
  }
}

Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<set>
#include<functional>
#include<queue>
#define int long long
using namespace std;

int a[100];
signed main() {
	int b; cin >> b;
	for (int c = 0; c < b; c++) {
		cin >> a[c];
	}
	cout << *max_element(a, a + b) - *min_element(a, a + b) << endl;
}

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

if s >= 3:
    red = [None]*s
    red[0]= 0
    red[1]= 0
    red[2]= 0
    for x in range(3,s):
        red[x] = (red[x-1] + red[x-3] + 1) % 1000000007
    print((red[s-3]+1) % 1000000007)

else:
    print(0)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (long long r = (aa); r >= (bb); r--)
using namespace std;
long long n;
map <long long, vector <pair <long long, long long> > > m;
long long f(long long p, vector <long long> v){
    if(p>n){
        //cout << "hi" << endl;
        return 0;
    }
    bool fl = true;
    long long ans = 0;
    if(v[p]==-1){
        rep(i,0,m[p].size()){
            if(m[p][i].second==0 && v[m[p][i].first]==1){
                fl = false;
            } else if(m[p][i].second==1 && v[m[p][i].first]==0){
                fl = false;
                
            }
        }
        //cout << p << " " << fl << endl;
        if(fl){
            vector <long long> v2 = v;
            rep(i,0,m[p].size()){
                v2[m[p][i].first] = m[p][i].second;
            }
            v2[p]=1;
            v[p]=0;
            return max(1+ f(p+1, v2), f(p+1, v));
        } else{
            v[p]=0;
            return f(p+1, v);
        }
    } else if (v[p]==0){
        return f(p+1, v);
    } else{
        rep(i,0,m[p].size()){
            if(m[p][i].second==0 && v[m[p][i].first]==1){
                fl = false;
            } else if(m[p][i].second==1 && v[m[p][i].first]==0){
                fl = false;
            }
        }
        if(fl){
            vector <long long> v2 = v;
            rep(i,0,m[p].size()){
                v2[m[p][i].first] = m[p][i].second;
            }
            v2[p]=1;
            return (1+ f(p+1, v2));
        }else{
            v[p]=0;
            return -1000000000000000;
        }
    }
    //cout << p << " " << ans << endl;
    
}
int main()
{
    cin >> n;
    rep(i,1,n+1){
        long long s,x, y;
        cin >> s;
        rep(j,0,s){
            cin >> x >> y;
            m[i].push_back({x,y});
        }
    }
    vector <long long> v(18, -1);
    cout << f(1, v) << endl;
    
    
}

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

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  vector<int> b(N);
  for (int i = 0; i < N; i++) {
    cin >> b.at(i);
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < N; k++) {
        if (A.at(i).at(j) == b.at(k)) {
          A.at(i).at(j) = 0;
        }
      }
    }
  }
  string a = "No";
  for (int i = 0; i < 3; i++) {
    if (A.at(i).at(0) == 0 & A.at(i).at(1) == 0 & A.at(i).at(2) == 0) {
      a = "Yes";
    }
  }
  for (int i = 0; i < 3; i++) {
    if (A.at(0).at(i) == 0 & A.at(1).at(i) == 0 & A.at(2).at(i) == 0) {
      a = "Yes";
    }
  }
  if (A.at(0).at(0) == 0 & A.at(1).at(1) == 0 & A.at(2).at(2) == 0) {
      a = "Yes";
  }
  if (A.at(0).at(2) == 0 & A.at(1).at(1) == 0 & A.at(2).at(0) == 0) {
      a = "Yes";
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int d, s, t; cin >> d >> s >> t;
	cout << (s * t >= d ? "Yes" : "No") << '\n';
	return 0;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  for(int i = 0; i < min(k, 50); i++){
    vector<int> imos(n);	 //I'll begin the imos method
    for(int j = 0; j < n; j++){
      int l = max(0, j-a[j]);
      int r = min(n-1, j+a[j]);
      imos[l]++;
      if(r+1 < n){
      	imos[r+1]--;
      }
    }
    for(int k = 0; k < n; k++){
      if(k > 0){
        imos[k] += imos[k-1];
      }
    }
    /*for(int l = 0; l < n; l++){
      a[l] = imos[l];
    }*/
    a = imos;
  }
  
  for(int i = 0; i < n; i++){
    cout << a[i] << " ";
  }
}

Measured memory_bytes: 4816
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   string a,b,c;
   cin >> a >> b >> c;

   if((a[a.size()-1] == b[0]) && (b[b.size()-1] == c[0])) cout << "YES" << endl;
   else cout << "NO" << endl;




   return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;

const int MAXN = 1e5+2; //AREGLAAAAAAAAR!!!!

int main(){

	int n;
	ri(n);
	int px=0,py=0,pt=0;
	FOR(i,0,n){
		int t,x,y;
		riii(t,x,y);
		int ans=abs(px-x)+abs(py-y),anst=t-pt;
		int cicle=anst-ans;
		if(ans!=0 && ans<=anst && (anst==ans || (anst-ans)%2==0)){
			pt=t;
			px=x,py=y;
		}else{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <iterator>
#include <list>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <sstream>
#include <iomanip>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  vector<int> B(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> B[i];
  }

  vector<int> C(N);
  for (int i = 1; i < N; i++) {
    cin >> C[i];
  }

  int ans = B[A.front()];
  for (int i = 1; i <= N; i++) {
    ans += B[A[i]];
    if (A[i-1] + 1 == A[i]) {
      ans += C[A[i-1]];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long a, b, m;

	std::cin >> a >> b >> m;

	std::vector<long long> va(a), vb(b);

	for (long long i = 0; i < a; i++)
	{
		std::cin >> va[i];
	}

	for (long long i = 0; i < b; i++)
	{
		std::cin >> vb[i];
	}

	long long min = *std::min_element(va.begin(), va.end()) + *std::min_element(vb.begin(), vb.end());

	for (long long i = 0; i < m; i++)
	{
		long long x, y, z;

		std::cin >> x >> y >> z;
		x--; y--;

		min = std::min(min, va[x] + vb[y] - z);
	}

	std::cout << min << std::endl;

	return 0;
}

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

int main() {
  string S;
  cin >> S;

  bool ans = true;

  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < S.size(); j++) {
      if (i == j) continue;
      if (S[i] == S[j]) {
        ans = false;
        break;
      }
    }
  }

  cout << ((ans) ? "yes" : "no") << endl;
}

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

int main() {
    int n;
    cin >> n;
    int64_t ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
bool check(string target, string s, int pos)
{
    int cnt = 1;
    while(pos + 2 * cnt < s.size())
    {
        string tmp = "";
        for(int i = pos; i < s.size(); i += cnt)
        {
            tmp += s[i];
            if(tmp == target) return true;
        }
        cnt++;
    }
    return false;
}
int solve(string target, vector<string> &v)
{
    int res = 0;
    for(int i = 0; i < v.size(); i++)
    {
        for(int j = 0; j < v[i].size(); j++)
        {
            if(v[i][j] == target[0])
            {
                if(check(target, v[i], j))
                {
                    res++;
                    break;
                }
            }
        }
    }
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string target; cin >> target;
    vector<string> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    cout << solve(target, v) << endl;
    return 0;
}




Measured memory_bytes: 3244
n,a,b=map(int,input().split())
c=d=1
e=0
m=10**9+7
for i in range(1,b+1):
    c=(c*(n+1-i))%m
    d=(d*i)%m
    if i==a or i==b:
        e+=c*pow(d,m-2,m)%m
print((pow(2,n,m)-e-1)%m)

Measured memory_bytes: 39152
#include<bits/stdc++.h>
using namespace std;
long long n;
string ans="";
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	while(n)
	{
		long long nw=n%(long long)26;
		if(nw==0)
			ans+='z';
		else
			ans+=(char)'a'+nw-1;
		n/=(long long)26;
		if(nw==0)
			n--;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3688
#include <stdio.h>

int main(void) {
    int N;
    scanf("%d", &N);

    int H[N];
    for (int i = 0; i < N; i++) {
        scanf("%d", &H[i]);
    }

    int max = 0;
    int tmp_max = 0;
    for (int i = 0; i < N - 1; i++) {
        if (H[i] >= H[i + 1]) {
            tmp_max++;
        } else {
            if (tmp_max > max) {
                max = tmp_max;
            }
            tmp_max = 0;
        }
    }
    if (tmp_max > max) {
        max = tmp_max;
    }

    printf("%d\n", max);

    return 0;
}

Measured memory_bytes: 512
#include<map>
#include<vector>
#include<string>
#include<iostream>
using namespace std;
typedef multimap<string,string>M;
vector<M> vm(51);
void F(const string&in,int index,string s)
{
	if(index==in.size())
	{
		cout<<s<<".\n";
		return;
	}
	for(int i=1;i<min<int>(in.size()-index+1,51);++i)
	{
		string sub=in.substr(index,i);
		pair<M::iterator,M::iterator>p=vm[i].equal_range(sub);
		for(M::iterator ite=p.first; ite!=p.second;++ite)
		{
			F(in,index+i,index?s+" "+ite->second:ite->second);
		}
	}
}
int main()
{
	char tr[256]={};
	tr['a']=tr['b']=tr['c']='2';
	tr['d']=tr['e']=tr['f']='3';
	tr['g']=tr['h']=tr['i']='4';
	tr['j']=tr['k']=tr['l']='5';
	tr['m']=tr['n']=tr['o']='6';
	tr['p']=tr['q']=tr['r']=tr['s']='7';
	tr['t']=tr['u']=tr['v']='8';
	tr['w']=tr['x']=tr['y']=tr['z']='9';
	int n,i;
	string s,t;
	while(cin>>n,n)
	{
		for(i=0;i<vm.size();++i)
			vm[i].clear();
		while(n--)
		{
			cin>>s;
			t.clear();
			for(i=0;i<s.size();++i)
				t+=tr[s[i]];
			vm[t.size()].insert(make_pair(t,s));
		}
		cin>>s;
		F(s,0,"");
		cout<<"--\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
vector<pi>item;
vector<ll>values[4];
int main(){
	for(int i=0; i<4; i++) values[i].push_back(0);
	int n;
	ll w;
	cin>>n>>w;
	for(int i=0; i<n; i++){
		ll ww,v;
		cin>>ww>>v;
		item.push_back(pi(ww,v));
	}
	sort(all(item));
	ll most_light = item[0].first;
	reverse(all(item));
	for(int i=0; i<item.size(); i++){
		values[item[i].first-most_light].push_back(item[i].second);
	}
	for(int i=0; i<4; i++){
		for(int j=1; j<values[i].size(); j++){
			values[i][j]+=values[i][j-1];
		}
	}
	long long maxval = 0;
	long long unit = most_light;
	for(int i=0; i<values[0].size(); i++){
		long long val1 = values[0][i];
		for(int j=0; j<values[1].size(); j++){
			long long val2 = values[1][j];
			for(int p=0; p<values[2].size(); p++){
				long long val3 = values[2][p];
				for(int q=0; q<values[3].size(); q++){
					long long val = values[3][q];
					val+=(val1+val2+val3);
					long long weight = unit*i;
					weight+=(unit+1)*j;
					weight+=(unit+2)*p;
					weight+=(unit+3)*q;
					if(weight<=w) maxval = max(maxval,val);
				}
			}
		}
	}
	cout<<maxval;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int n;
int a[200007],b[200007];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	long long cnt1=0,cnt2=0;
	for (int i=1;i<=n;i++)
		if (b[i]<a[i]) cnt2+=a[i]-b[i];
		else
		{
			if ((b[i]-a[i])%2==0) cnt1+=(b[i]-a[i])/2;
			else
			{
				++cnt2;
				cnt1+=(b[i]-a[i]+1)/2;
			}
		}
	if (cnt1<cnt2) printf("No\n"); else printf("Yes\n");
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#define  MAX 100
typedef struct{//all number is 0
  int color;//0 white /1 gray /2 black
  int distance;
}Graf;

Graf A[MAX];//本体
int G[MAX][MAX];//グラフ
int Q[MAX];//次に候補
int head,tail;

void enque(int x){
  Q[tail]=x;
  tail=(tail+1)%MAX;
}
int deque(void){
  int x=Q[head];
  head=(head+1)%MAX;
  return x;
}

void BFS(int u,int n){
  int i;
  int v;
  if(A[u].color!=0)return;
  A[u].color=1;
  enque(u);
  	
  while(head!=tail){ //not empty
   
    u=deque();
    
    for(v=0;v<n;v++){
      if(G[u][v]==1 && A[v].color==0){
	A[v].color=1;
	A[v].distance = A[u].distance+1;

	enque(v);
      }
    }
    A[u].color=2;
  }
}


int main(){
  int id;
  int n;
  int agree;
  int i,j;
  int hand;
 
  for(i=0;i<100;i++){ //all 0
    A[i].color=A[i].distance=0; // all 0
    
    for(j=0;j<100;j++){
      G[i][j]=0;
    }
  }

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&agree);
    
    for(j=0;j<agree;j++){
      scanf("%d",&hand);
      G[id-1][hand-1]=1;
    }
  }
    
    BFS(0,n);
    
  for(i=0;i<n;i++){//OUTPUT
    if(A[i].distance==0 && i!=0)printf("%d -1\n",i+1);
    else printf("%d %d\n",i+1,A[i].distance);
  }
  
  return 0;
}



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

int main() {
  while(1) {
    char x[1000];
    cin >> x;

    if (x[0] == '0') { break; }

    int sum = 0;
    for (int i = 0; x[i] != '\0' ; i++) {
      sum += x[i] - '0';
    }

    cout << sum << endl;
  }

  return 0;
}



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

int main(){
	int n;
	cin >> n;
	
	vector<int> a;
	rep(i,n){
		int aa;
		cin >> aa;
		a.push_back(aa);
	}
	
	vector<int> a_sort = a;
	sort(a_sort.begin(),a_sort.end());
	
	
	rep(i,n){
		if(a[i] == a_sort[n-1]) cout << a_sort[n-2] << endl;
		else cout << a_sort[n-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
  int N = S.size();
  int anker1 = (N - 1) / 2;
  int anker2 = (N + 3) / 2;

  string subS1 = S.substr(0, anker1);
  string subS2 = S.substr(anker2 - 1, N - anker2 + 1);

  string rS = S;
  string rSubS1 = subS1;
  string rSubS2 = subS2;
  reverse(rS.begin(), rS.end());
  reverse(rSubS1.begin(), rSubS1.end());
  reverse(rSubS2.begin(), rSubS2.end());

  bool flag = (S == rS) and (subS1 == rSubS1) and (subS2 == rSubS2);

  cout <<(flag ? YES : NO) << endl;
}

signed main(){
  std::string S;
  std::cin >> S;
  solve(S);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e10;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 100;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll l = -1,r = n;
    string s;
    cout << 0 << endl;
    cin >> s;
    char g;
    if (s[0] == 'V') return 0;
    if (s[0] == 'M') g = 'M';
    if (s[0] == 'F') g = 'F';
    rep(i,20){
        ll m = (l+r)/2;
        cout << m << endl;
        cin >> s;
        if (s[0] == 'V') return 0;
        if (m%2 == 0){
            if (s[0] == g) l = m;
            else r = m;
        }
        else{
            if (s[0] == g) r = m;
            else l = m;
        }
    }
}


Measured memory_bytes: 852