akhauriyash/Code-Regression huggingface dataset:
#pragma region include
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (int)(1e9+7)
#define INF (int)(1e9)
#define LLINF (int)(4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename... R> void input(string& f, R&... r) { cin >> f; input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

vector<vector<int>> G;
vector<vector<int>> dist;
int N;
// depth : 根からの深さ
void dfs(int v, int n, int p = -1,int depth = 0) {
    dist[n][v] = depth;
    for (int u : G[v]) {
        if (u != p) dfs(u, n, v, depth + 1);
    }
}
    
int main() {
    input(N);
    G.resize(N);
    dist.resize(2, vector<int>(N));
    REP(i, N-1) {
        int a, b; input(a,b);
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    dfs(0,0);
    dfs(N - 1, 1);
    int cnt[2];
    cnt[0] = cnt[1] = 0;
    REP(i, N) {
        if (dist[0][i] <= dist[1][i]) cnt[0]++;
        else cnt[1]++;
    }
    if (cnt[0] > cnt[1]) puts("Fennec");
    else puts("Snuke");
    getchar(); getchar();
}

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

using Graph = vector<vector<int>>;

vector<bool> seen;
int sum;
int N,M;

void dfs(const Graph &G, int v) {
  
  seen[v]=true;

  int cnt=0;
  for(int i=0;i<N;++i){
    if(seen[i]){
      ++cnt;
    }
  }
  if(cnt==N) ++sum;
  
  for(auto next_v:G[v]){
    if(seen[next_v]) continue;
    dfs(G,next_v);
    seen[next_v]=false;
  }
  
}

int main(){
    cin>>N>>M;
    Graph G(N);
  
    for(int i=0;i<M;++i) {
      int a,b;
      cin>>a>>b;
      --a,--b;
      G[a].push_back(b);
      G[b].push_back(a);
    }

    sum=0;
    seen.assign(N, false);//falseで初期化する
    dfs(G,0);
    cout<<sum<<endl;
}


Measured memory_bytes: 256
using Microsoft.VisualBasic;
using System;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = int.Parse(Console.ReadLine());
            var sp = Console.ReadLine().Split(' ');
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = long.Parse(sp[i]);
                if (a[i] == 0)
                {
                    Console.WriteLine(0);
                    Console.Out.Flush();
                    return;
                }
            }

            const long m = 1000000000000000000;
            long ans = 1;
            for (int i = 0; i < n; i++)
            {
                if ((m)/ans < a[i] || ans*a[i] > m)
                {
                    Console.WriteLine(-1);
                    Console.Out.Flush();
                    return;
                }
                ans *= a[i];
            }

            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 40812
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,i,j,k,x,t;
  while(cin>>k>>x)
  {
    for(i=x-k+1;i<=x+k-1;i++)cout<<i<<" ";
    cout<<endl;

  }
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n;
char s[100010];
int main(){
	scanf("%s",s);
	ll n=strlen(s);
	ll ans1=0,ans2=0;
	rep(i,0,n){
		if(s[i]!='0'+(i%2))ans1++;
		else ans2++;
	}
	printf("%lld",min(ans1,ans2));
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <bitset>
#include <functional>
#include <tuple>
#include <complex>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

const int MAXN = 1 << 18;
const int INF = 1e9;
pair<int, int> a[MAXN];
pair<int, int> b[MAXN];

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

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

    int n;
    cin >> n;

    for (int i = 0; i < (1 << n); ++i) {
        cin >> a[i].first;
        a[i].second = i;
        b[i] = {-INF, -1};
    }

    for (int i = 0; i < (1 << n); ++i) {
        for (int j = 0; j < n; ++j) {
            if ((i & (1 << j)) == 0) {
                int k = i | (1 << j);
                
                if (a[i] != a[k] && a[i] != b[k]) {
                    if (a[i] > a[k]) {
                        b[k] = a[k];
                        a[k] = a[i];
                    } else if (a[i] > b[k]) {
                        b[k] = a[i];
                    }
                }

                if (b[i] != a[k] && b[i] != b[k]) {
                    if (b[i] > a[k]) {
                        b[k] = a[k];
                        a[k] = b[i];
                    } else if (b[i] > b[k]) {
                        b[k] = b[i];
                    }
                }
            }
        }
    }

    int res = 0;
    for (int i = 1; i < (1 << n); ++i) {
        res = max(res, a[i].first + b[i].first);
        cout << res << "\n";
    }

    return 0;
}

Measured memory_bytes: 7168
import java.io.*;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        for(long h = 1; h < 3501; ++h){
            for(long n = 1; n < 3501; ++n){
                long u = N * h * n;
                long d = 4 * h * n - N * n - N * h;
                if(d <= 0) continue;
                if(u < d) continue;
                if(u%d!=0) continue;
                long w = u/d;
                if(4 * h * n * w == N * n * w + N * h * w + N * h * n){
                    System.out.println(h + " " + n + " " + w);
                    return;
                }
            }
        }
        System.out.println("NO!");
    }
}


Measured memory_bytes: 23124
#include<cstdio>
#include<algorithm>
using namespace std;
int n,k,t=0,a[100007];//
bool flag;
int gcd(int x,int y)
{
	return x%y? gcd(y,x%y):y; //
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]==k) flag=1;
		t=gcd(t,a[i]);
	}
	if(flag)
		printf("POSSIBLE\n");
	else
	{
		sort(a+1,a+n+1);
		if(a[n]<k) printf("IMPOSSIBLE\n");
		else
		{
			if(k%t==0) printf("POSSIBLE\n");
			else printf("IMPOSSIBLE\n");
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll cnt=0;
    bool hantei = false;

    while(a%2==0 && b%2 == 0 && c%2 == 0){
        ll i,j,k;
        i = a; j = b; k =c;
        a = 0; b = 0; c = 0;

        a = j/2 + k/2;
        b = i/2 + k/2;
        c = i/2 + j/2;
       

        cnt ++ ;
        if(cnt == 1000000) {
            hantei= true;
            break;
    }
    }
    if(hantei){
        cout << -1<< endl;
    }
    else cout << cnt << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
x=sum(a)%mod
y=0
for i in range(n):
  y+=a[i]**2
  y%=mod
z=pow(2,mod-2,mod)
print(((x**2-y)*z)%mod)

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

int main()
{
    unsigned long long a, b, _a, _b;

    while( cin >> a >> b )          //ユークリッドの互除法
    {
        _a = a;                     
        _b = b;

        while( a > 0 && b > 0)      //余りが0になるまで
        {
            if( a > b )
                a = a % b;
            else
                b = b % a;
        }

        cout << a + b << " " << _a * _b / ( a + b ) << endl;
    
    }

    return 0;
}



Measured memory_bytes: 3028
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int x;
	scan(x);
	if(x>=30){
		prin("Yes");
	}
	else prin("No");
	return 0;
}


Measured memory_bytes: 3628
#define vv(t) vector<vector<t>>
#define v(t) vector<t>
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
    int N, K;   cin >> N >> K;
    vi a;
    rep(i, N){
        char c; cin >> c;       //cout << c;
        int tmp = int(c - '0');
        if((a.size() & 1)==tmp){
            a.pb(1);
        }else if(a.size()==0){
            a.pb(0);
            a.pb(1);
        }else{
            ++a[a.size()-1];
        }
    }
    //cout << endl;
    //rep(i, a.size()){   cout << a[i] << (i&1 ? "]": "[");   }    cout << endl;
    
    int sum = 0, Max, index = 0;
    rep(i, K*2){
        if(i < a.size()){   sum += a[i];   }
    }
    Max = sum;
    //cout << sum << "/";
    
    for(int i=0; i+K*2 < a.size(); i+=2){
        if(i-1 > 0){    sum -= a[i-1];  }
        sum -= a[i];
        sum += a[i+K*2];
        if(i+K*2+1 < a.size()){ sum += a[i+K*2+1];  }
        Max = max(sum, Max);
        //cout << sum << "/";
    }
    //cout << endl;
    cout << Max << endl;   
    return 0;
}

Measured memory_bytes: 892
H, N = gets.chomp.split(" ").map(&:to_i)
AT = []
N.times{
  AT << gets.chomp.split(" ").map(&:to_i)
}

INF = 10 ** 8
DP = Array.new(H, INF)
DP[0] = 0
ans = 10 ** 8
(0...H).each{|i|
  next if DP[i] == INF
  AT.each{|a, b|
    dmg = i + a
    mgc = DP[i] + b
    if dmg >= H then
      ans = mgc if ans > mgc
    elsif DP[dmg] > mgc then
      DP[dmg] = mgc
    end
  }
}

puts ans


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

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int n, m;
    map<string, int> v;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string k;
        cin >> k;
        v[k]++;
    }
    cin >> m;
    for (int j = 0; j < m; ++j) {
        string k;
        cin >> k;
        v[k]--;
    }
    int ans = 0;
    for (auto &&x : v) {
        ans = max(x.second, ans);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll repow(ll k,ll n)
{
    ll ans=1;
    for(int i=0;i<n;i++)
    {
        ans= (((ans)*k) )%mod;
    }
    return ans;
}
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        ll k,n;
        cin>>k>>n;
        if((k*500)>=n)
        {
            cout<<"Yes";
        }
        else
            cout<<"No";
    }
}


Measured memory_bytes: 3644
#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() {
  ll n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);

  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];

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

  ll ans = 0;

  rep(i, n) {
    int left_i = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    if (left_i == -1) {
      break;
    }

    int right_i = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
    if (right_i == -1) {
      break;
    }

    // cout << i << " " << " " << left_i << " " << right_i << endl;
    ans += left_i * (n - right_i);
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define bn(n) (n).begin(), (n).end()
#define FOR(n) for(int i = 0; i < (int)n; i++)


void solve() {
    string a;
    cin >> a;
    sort(bn(a));
    for (int i = 1; i < a.length(); i++) {
        if (a[i] == a[i-1]) {
            cout << "no\n";
            return;
        }
    }
    cout << "yes\n";
}

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

    int t = 1, i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto si : s) os << si << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += (b % mod + mod)) %= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int d, t, s;
    cin >> d >> t >> s;
    cout << (t * s >= d ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3648
N, Y = map(int, input().split())

res = ["-1", "-1", "-1"]
for i in range(N+1):
  if i * 10000 > Y:
    break
  for j in range(N-i+1):
    if i * 10000 + j * 5000 > Y:
      break
    k = N-(i+j)
    if i * 10000 + j * 5000 + k * 1000 == Y:
      res = [str(i), str(j), str(k)]
      break

print(" ".join(res))


Measured memory_bytes: 3060
n,m = gets.chomp.split(" ").map(&:to_i)
ans = Array.new(n,false)
count = Array.new(n,1)
ans[0] = true
m.times do
  x,y = gets.chomp.split(" ").map{|i|i.to_i-1}
  if ans[x]
    ans[y] = true
  end
  if count[x] == 1 && ans[x]
    ans[x] = false
  end
  count[x] -= 1
  count[y] += 1
end
puts ans.count(true)

Measured memory_bytes: 3452
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int nums[105];
bool cmp(int a, int b) {
    return a > b;
}
int main() {
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    int summ = 0;
    for (int i = 1; i <= n; ++i)
        cin >> nums[i], summ += nums[i];
    sort(nums + 1, nums + 1 + n, cmp);
    int number = ceil(1.0 * summ / (4 * m));
    if (nums[m] >= number) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
count = 0
for i in range(1000):
    pas = format(i).zfill(3)
    a = S[:-2].find(pas[0])
    if a >= 0:
        b = S[a+1:-1].find(pas[1])
        if b >= 0:
            if pas[2] in S[a+b+2:]:
                count += 1
print(count)


Measured memory_bytes: 3060
{-# LANGUAGE UnboxedTuples #-}

inf = 10000

a#b = abs (a-b)

solv a b c ls = go ls (# 0,0,0 #) 0 where
  go [] tp cost = case tp of
    (# la, lb, lc #)
      | la==0 || lb==0 || lc==0 -> inf
      | otherwise -> cost + a#la + b#lb + c#lc
  go (l:ls) tp cost = case tp of
    (# la, lb, lc #) ->
      let forA = go ls (# la+l, lb, lc #) $ if la>0 then cost+10 else cost
          forB = go ls (# la, lb+l, lc #) $ if lb>0 then cost+10 else cost
          forC = go ls (# la, lb, lc+l #) $ if lc>0 then cost+10 else cost
          unuse = go ls (# la,lb,lc #) cost
      in minimum [forA, forB, forC, unuse]
    
main = do
  [n,a,b,c] <- map read . words <$> getLine
  ls <- map read . words <$> getContents
  print $ solv a b c ls


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

int main(void)
{
	int arr[30],w,n,a,b,i,temp;
	scanf("%d",&w);
	scanf("%d",&n);
	for(i = 0; i <= 30; i++){
		arr[i] = i + 1;
	}
	for(i = 0; i < n ; i++){
		scanf("%d,%d",&a,&b);
		temp = arr[a-1];
		arr[a-1] = arr[b-1];
		arr[b-1] = temp;
	}

	for(i = 0; i<w;i++){
		printf("%d\n",arr[i]);
	}
	
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

struct Data {
  int index,x1,y1,x2,y2;
  bool operator < ( const Data &data ) const {
    if( x1 != data.x1 ) return x1 < data.x1;
    if( y1 != data.y1 ) return y1 < data.y1;
    if( x2 != data.x2 ) return x2 < data.x2;
    if( y2 != data.y2 ) return y2 < data.y2;
  }
};

int n, program_counter,len;
int answer[100];

bool check(int xL,int xR,int y,vector<Data> &arr){
  rep(i,arr.size()) {
    if( arr[i].y1 < y && y < arr[i].y2 ) {
      if( !( xL <= arr[i].x1 && arr[i].x2 <= xR ) ){
        return false;
      }
    }
  }
  return true;
}

void rec(vector<Data> arr){
  if( arr.empty() ) return;
  sort(arr.begin(),arr.end());
  assert( answer[arr[0].index] == -1 );
  //cout << "update " << arr[0].index+1 << endl;
  answer[arr[0].index] = ++program_counter;
  vector<Data> next, temp;
  int line = arr[0].y2;
  int minX = arr[0].x1, maxX = arr[0].x2;
  assert( minX <= maxX );
  REP(x,maxX,len+1){
    if( !check(minX,maxX,line,arr) ) break;
    ++maxX;
  }
  rep(i,arr.size()) if( answer[arr[i].index] == -1 ){
    if( minX <= arr[i].x1 && arr[i].x2 <= maxX && arr[i].y2 <= line )  {
      next.push_back(arr[i]);
    } else temp.push_back(arr[i]);
  }

  //cout << "[" << minX << "," << maxX << "] " << line << endl;
  //puts("go next");
  //rep(i,next.size()) cout << next[i].index+1 << " "; cout << endl;
  rec(next);
  //puts("go temp");
  //rep(i,temp.size()) cout << temp[i].index+1 << " "; cout << endl;
  rec(temp);
}

int main(){
  bool F = true;
  while( cin >> n, n ){
    if( !F ) puts(""); F = false;
    program_counter = len = 0;
    vector<Data> arr(n);
    rep(i,n){
      answer[i] = -1;
      arr[i].index = i;
      cin >> arr[i].x1 >> arr[i].y1 >> arr[i].x2 >> arr[i].y2;
      len = max(len,arr[i].x2);
    }
    rec(arr);
    rep(i,n) printf("%d\n",answer[i]);
  }
  return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>

int main (void)
{
	int a,b,d,r;
	double f;
	scanf("%d",&a);
	scanf("%d",&b);
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	printf("%d %d %lf",d,r,f);
	return 0;
}

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

int main() {
  string n;
  cin >> n;
  if (n[0] == '7' || n[1] == '7' || n[2] == '7') {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

Measured memory_bytes: 3580
using System;
using System.Linq;

namespace ABC144
{
    class C
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            long x = 0;
            long y = 0;
            long min = long.MaxValue;
            for (long i = 1; i <= Math.Sqrt(N); i++)
            {
                if (N % i == 0)
                {
                    if (i + N / i < min)
                    {
                        x = i;
                        y = N / i;
                        min = i + N / i;
                    }
                }
            }
            Console.WriteLine(x + y - 2);
        }
    }
}


Measured memory_bytes: 13140
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        sx: isize, sy: isize, tx: isize, ty: isize
    }

    for i in 0..(ty - sy) {
        print!("U");
    }
    for i in 0..(tx - sx) {
        print!("R");
    }
    for i in 0..(ty - sy) {
        print!("D");
    }
    for i in 0..(tx - sx) {
        print!("L");
    }

    print!("L");
    for i in 0..(ty - sy + 1) {
        print!("U");
    }
    for i in 0..(tx - sx + 1) {
        print!("R");
    }
    print!("D");
    print!("R");
    for i in 0..(ty - sy + 1) {
        print!("D");
    }
    for i in 0..(tx - sx + 1) {
        print!("L");
    }
    println!("U");
}



Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int a, b; 
	cin >> a >> b;
	if(a<=b)cout << a << endl;
	else cout << a - 1 << endl;
	return 0;
}

//Ctrl+Aを使わない

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

typedef long long ll;
const int N = 1000 + 10;
int v[N*2], u[N*2], cost[N*2];
ll dis[N];
bool vis[N];
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; i++)
    {
        scanf("%d%d%d", &v[i], &u[i], &cost[i]);
        cost[i] = -cost[i];
    }
    memset(dis, 0x3f, sizeof dis);
    memset(vis, 0, sizeof vis);
    dis[1] = 0;
    for(int i = 1; i <= n-1; i++)
        for(int j = 1; j <= m; j++)
            dis[u[j]] = min(dis[u[j]], dis[v[j]] + cost[j]);
    ll ans = dis[n];
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
        {
            if(dis[u[j]] > dis[v[j]] + cost[j])
            {
                dis[u[j]] = dis[v[j]] + cost[j];
                vis[u[j]] = true;
            }
            if(vis[v[j]] == true) vis[u[j]] = true;
        }
    if(vis[n]) puts("inf");
    else cout << -ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

bool solve() {
  string S, T;
  cin >> S;
  cin >> T;
  int n = S.size();

  map<char, set<char>> mp1, mp2;
  REP(i, n) {
    mp1[S[i]].insert(T[i]);
    mp2[T[i]].insert(S[i]);
  }
  for (auto& [ch, s] : mp1) {
    if (s.size() > 1) return false;
  }
  for (auto& [ch, s] : mp2) {
    if (s.size() > 1) return false;
  }
  return true;
}

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

  cout << (solve() ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3856
N,M=  map(int,input().split())

A = list(map(int,input().split()))
sorted(A)
B =[0,2,5,5,4,5,6,3,7,6]
C =[]
for i in A:
    C.append(B[i])
dp = [-1]*(N+1)
dp[0] = 0
for i in range(N+1):
    for a in range(len(C)):
        if i+C[a]<=N and 0<=dp[i]:
            dp[i+C[a]] = max(dp[i]*10+A[a],dp[i+C[a]])
print(dp[-1])

Measured memory_bytes: 14692
/*-------property of the half blood prince-----*/

#include <bits/stdc++.h>
#include <dirent.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define MIN(X,Y) X<Y?X:Y
#define MAX(X,Y) X>Y?X:Y
#define ISNUM(a) ('0'<=(a) && (a)<='9')
#define ISCAP(a) ('A'<=(a) && (a)<='Z')
#define ISSML(a) ('a'<=(a) && (a)<='z')
#define ISALP(a) (ISCAP(a) || ISSML(a))
#define MXX 10000000000
#define MNN -MXX
#define ISVALID(X,Y,N,M) ((X)>=1 && (X)<=(N) && (Y)>=1 && (Y)<=(M))
#define LLI long long int
#define VI vector<int>
#define VLLI vector<long long int>
#define MII map<int,int>
#define SI set<int>
#define PB push_back
#define MSI map<string,int>
#define PII pair<int,int>
#define PLLI pair<LLI,LLI>
#define PDD pair<double,double>
#define FREP(i,I,N) for(int (i)=(int)(I);(i)<=(int)(N);(i)++)
#define eps 0.0000000001
#define RFREP(i,N,I) for(int (i)=(int)(N);(i)>=(int)(I);(i)--)
#define SORTV(VEC) sort(VEC.begin(),VEC.end())
#define SORTVCMP(VEC,cmp) sort(VEC.begin(),VEC.end(),cmp)
#define REVV(VEC) reverse(VEC.begin(),VEC.end())
#define INRANGED(val,l,r) (((l)<(val) || fabs((val)-(l))<eps) && ((val)<(r) || fabs((val)-(r))<eps))
#define INRANGEI(val,l,r) ((val)>=(l) && (val)<=(r))
#define MSET(a,b) memset(a,b,sizeof(a))
using namespace std;
using namespace __gnu_pbds;

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction


//typedef tree < int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

LLI disfromroot[100005];

vector < vector <PII> >g;

void takeg(int n, int m){
    g.clear();
    FREP(i,1,(n+4)){
        vector <PII> line;
        g.PB(line);
    }
    FREP(i,1,m){
        int u,v,w;
        cin>>u>>v>>w;
        g[u].PB(make_pair(v,w));
        g[v].PB(make_pair(u,w));
    }
}

void dfs(int cur, LLI curdis, int par){
    disfromroot[cur]=curdis;
    int deg = g[cur].size();
    FREP(i,0,deg-1){
        int v = g[cur][i].first;
        int ww = g[cur][i].second;
        if(v==par)continue;
        dfs(v,curdis+(LLI)ww,cur);
    }
    return;
}

int main()
{
    int n;
    cin>>n;
    takeg(n,n-1);
    int q,k;
    cin>>q>>k;
    dfs(k,0,-1);
    FREP(i,1,q){
        int x,y;
        cin>>x>>y;
        cout<<disfromroot[x]+disfromroot[y]<<"\n";
    }
    return 0;
}


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

const int N = 1005;
const int MOD = 1e9 + 7;

int dp[N][N];
int n, m;
string arr[N];

void read() {
  cin >> n >> m;
  for (int i = 0 ; i < n ; i++)
    cin >> arr[i];
}

int solve(int r, int c) {
  if (r == n || c == m) return 0;
  if (arr[r][c] == '#') return 0;
  if (r == n-1 && c == m-1) return 1;

  int &ret = dp[r][c];
  if (ret != -1) return ret;

  ret = (solve(r+1, c) + solve(r, c+1)) % MOD;
  return ret;
}

int work() {
  memset(dp, -1, sizeof dp);
  return solve(0, 0);
}

int main() {
  read();
  cout << work() << endl;
  return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
 
int frog(long int n, int h[])
{
  int dp[n+1]={0}, i;
 
  for(i=2 ; i<=n ; i++)
  {
    int op1=abs(h[i]-h[i-1])+dp[i-1];
    int op2= i==2 ? pow(10,9) : abs(h[i]-h[i-2])+dp[i-2];
    dp[i]=min(op1, op2);
}
    return dp[n];
              }
int main()
{long int n, i;
 cin>>n;
 int h[n+1];
 h[0]={0};
 for(i=1 ; i<=n ; i++)
   cin>>h[i];
 
 cout<<frog(n, h);
 
 return 0;
}

Measured memory_bytes: 4356
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt()-1;
		int[] c = new int[n];
		int[] s = new int[n];
		int[] f = new int[n];
		for(int i=0;i<n;i++) {
			c[i] = in.nextInt();
			s[i] = in.nextInt();
			f[i] = in.nextInt();
		}
		
		int[] time = new int[n+1];
		for(int i=0;i<n;i++) {
			time[i] = c[i] + s[i];
			for(int j=i+1;j<n;j++) {
				if(time[i]<s[j]) {
					time[i] = s[j] + c[j];
				}else {
					if(time[i]%f[j]==0) time[i] += c[j];
					else time[i] += (f[j]-time[i]%f[j]) + c[j];
				}
			}
		}
		for(int i=0;i<=n;i++) {
			System.out.println(time[i]);
		}
		in.close();
	}

}


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

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

  int ans;
  int s = -1;
  for (int i = 1; i <= n; i++) {
    int j = i;
    int cnt = 0;
    while (j % 2 == 0) {
      j /= 2;
      cnt++;
    }
    if (s < cnt) {
      s = cnt;
      ans = i;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	for (char it : s)
	{
		print("x");
	}

	println("");
}


Measured memory_bytes: 256
import math

n = int(input())
hL = list(map(int, input().split(" ")))

ans = 0
cont = False
while True:
    if len(set(hL)) == 1 and hL[0] == 0:
        break
    cont = False
    cnt = 0
    for j in range(n):
        if hL[j] != 0:
            hL[j] -= 1
            if not cont:
                cnt += 1
            cont = True
            continue
        else:
            cont = False

    ans += cnt

print(ans)


Measured memory_bytes: 9128
module Main where

import Control.Applicative
import Control.Monad
import Data.List

f1 :: Int -> Int -> Int
f1 k x = (* 2) $ min x (abs $ x - k)

main :: IO ()
main = do
    getLine
    k <- readLn
    xs <- fmap read . words <$> getLine :: IO [Int]
    let ans = sum $ fmap (f1 k) xs
    print ans

Measured memory_bytes: 1020
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<ll, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

int main(){
    fastIO;
    ll a, b, c;
    cin >> a >> b >> c;
    if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
        cout << 0;
    else
        cout << min({a*b,b*c,a*c});
    return 0;
}


Measured memory_bytes: 256
H,W = gets.split.map(&:to_i)

if H%3==0 || H%3==0
  p 0
  exit
end

# first
short_height = (H.to_f/3.to_f).round
rest_height = (H-short_height)

# cut different directions
short_width = (W.to_f/2.to_f).round
rest_width = (W-short_width)
a = W * short_height
b = rest_height*short_width
c = rest_height*rest_width

# cut same directions
second_short_height = ((H-short_height).to_f/2.to_f).round
b2 = second_short_height*W
c2 = (rest_height-second_short_height)*W

pattern1 = [a,b,c].max - [a,b,c].min
pattern2 = [a,b2,c2].max - [a,b2,c2].min

result1 = [pattern1, pattern2].min

#second
short_width = (W.to_f/3.to_f).round
rest_width = (W-short_width)

# cut different directions
short_height = (H.to_f/2.to_f).round
rest_height = (H-short_height)
a = H * short_width
b = rest_width*short_height
c = rest_width*rest_height

# cut same directions
second_short_width = ((W-short_width).to_f/2.to_f).round
b2 = second_short_width*H
c2 = (rest_width-second_short_width)*H

pattern1 = [a,b,c].max - [a,b,c].min
pattern2 = [a,b2,c2].max - [a,b2,c2].min

result2 = [pattern1, pattern2].min



result = [result1, result2].min
p result




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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(string, s);
  int ans = 10000;
  rep(i, s.size() - 2) {
    stringstream ss;
    ss << s.substr(i, 3);
    int x;
    ss >> x;
    ans = min(ans, abs(x - 753));
  }
  out(ans);
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
//#include<array>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
//#include<bitset>
//#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//配列,座標
/*array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
array<int, 4>dir_x2 = { 0,0,1,-1 };
array<int, 4>dir_y2 = { 1,-1,0,0 };
char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };*/

//Union Find
/*class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};*/

//最大公約数,最小公倍数
/*LLI gcd(LLI x, LLI y) {
	LLI  r;
	if (x < y) {
		swap(x, y);
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}
LLI lcm(LLI x, LLI y) {
	return x / gcd(x, y) * y;
}*/

//組み合わせ
/*long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; i--) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; i++) {
		ans = ans / i;
	}
	return ans;
}
long nHr(int n, int r) {
	n = n + r - 1;
	return nCr(n, r);
}*/

//素数判定
/*bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}*/

//サンプル
/*const int n_max = 8;
array<array<bool, n_max>, n_max>graph;
int dfs(int v,int N,array<bool,n_max>visited) {
	int ret = 0;
	bool all_visited = true;
	for (int i = 0; i < N;i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited) {
		return 1;
	}
	for (int i = 0; i < N;i++) {
		if (graph[v][i] == false) {
			continue;
		}
		if (visited[i] == true) {
			continue;
		}
		visited[i] = true;
		ret += dfs(i,N,visited);
		visited[i] = false;
	}
	return ret;
}*/

//サンプル
/*vector<vector<int>>sub;
int dfs(int id) {
	if (sub[id].size() == 0) {
		return 1;
	}
	int minP = (int)1e9;
	int maxP = 0;
	for (int i : sub[id]) {
		int P = dfs(i);
		minP = min(minP, P);
		maxP = max(maxP, P);
	}
	return minP + maxP + 1;
}*/

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	vector<string>vec = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	string A;
	cin >> A;
	LLI res = 0;
	for (int i = 0; i < vec.size();i++) {
		if (A == vec[i]) {
			res = 7 - i % 7;
		}
	}
	cout << res << endl;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

const ll longinf=1LL<<60;

struct LazySegmentTree{
private:
   int n;
   vector<ll> node,lazy;
public:
   LazySegmentTree(int sz,ll init=0){
      n=1;
      while(n<sz)n*=2;
      node.resize(2*n-1,init);
      lazy.resize(2*n-1,0);
   }
 
   void eval(int k,int l,int r){
      if(lazy[k]!=0)node[k]+=lazy[k];
      if(r-l>1){
          lazy[2*k+1]+=lazy[k];
          lazy[2*k+2]+=lazy[k];
      }
      lazy[k]=0;
   }
      //[a,b)にxを加算
   void add(int a,int b,ll x,int k=0,int l=0,int r=-1){
       if(r<0)r=n;
       eval(k,l,r);
       if(r<=a||b<=l)return;
       if(a<=l&&r<=b){
          lazy[k]+=x;
          eval(k,l,r);
       }
       else {
          add(a,b,x,2*k+1,l,(l+r)/2);
          add(a,b,x,2*k+2,(l+r)/2,r);
          node[k]=max(node[2*k+1],node[2*k+2]);
        }
   }
   //[a,b)でのmaxを返す
   ll get(int a,int b,int k=0,int l=0,int r=-1){
      if(r<0)r=n;
      eval(k,l,r);
      if(r<=a||b<=l)return 0;
      if(a<=l&&r<=b)return node[k];
      ll xl=get(a,b,2*k+1,l,(l+r)/2);
      ll xr=get(a,b,2*k+2,(l+r)/2,r);
      return max(xl,xr);
   }
};

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

   vector<ll> w(N), s(N), v(N);
   REP(i, N) cin >> w[i] >> s[i] >> v[i];

   vector<int> ord(N);
   iota(all(ord), 0);
   sort(all(ord),[&](int x,int y){
      return min(s[x], s[y] - w[x]) > min(s[y], s[x] - w[y]);
   });

   vector<ll> dp(20202, -1);
   dp[0] = 0;

   for(int i : ord){
      for(int j = 20200; j >= 0; j--){
         if(dp[j] == -1) continue;
         if(j <= s[i]) chmax(dp[j + w[i]], dp[j] + v[i]);
      }
   }
   cout << *max_element(all(dp)) << endl;

   return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int x,y;
    cin >> x >> y;
    if(y%2==0 && 2*x<=y && y<=4*x)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
string a,b;
int dp[3005][3005];
pii path[3005][3005];
int main(){
    ios::sync_with_stdio(false);
    cin>>a>>b;
    int n=a.size(),m=b.size();
    a='0'+a;b='0'+b;
    for (int i=1;i<=n;++i) for (int j=1;j<=m;++j){
    	if (a[i]==b[j]){
    		dp[i][j]=dp[i-1][j-1]+1;
    		path[i][j]=mp(-1,-1);
		}
		else{
			if (dp[i][j-1]>dp[i-1][j]){
				dp[i][j]=dp[i][j-1];
				path[i][j]=mp(0,-1);
			}
			else{
				dp[i][j]=dp[i-1][j];
				path[i][j]=mp(-1,0);
			}
		}
	}
	int x=n,y=m;
	stack<char> ans;
	while(!(x==0||y==0)){
		pii tmp=path[x][y];
		if (tmp.F==tmp.S) ans.push(a[x]);
		x+=tmp.F;y+=tmp.S;
	}
	while(!ans.empty()){
		cout<<ans.top();
		ans.pop();
	}
    return 0; 
}

Measured memory_bytes: 105984
#include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
      string s, t;
      cin >> s >> t;
      int a, b;
      cin >> a >> b;
      string x;
      cin >> x;
      if(s == x)
        a--;
      else if(t == x)
        b--;
      cout << a << " " << b ;
    }

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

using namespace std;

int n,k;

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

int main()
{
  cin >> n >> k;
  int a, m = 0, g = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    g = gcd(a, g);
    m = max(m, a);
  }

  cout << (m >= k && k % g == 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  vector<vector<bool>> p(n,vector<bool>(n,false));
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    p[a][b]=true;
    p[b][a]=true;
  }

  int ans=0;

  vector<int> q(n-1);
  rep(i,n-1){
    q[i]=i+1;
  }

  //——————————————next_permutaion(np)——————————————
  sort(all(q));
  
  do{
    bool ok=true;
    int pre=0;

    rep(i,n-1) {
      bool memo=false;
      if(p[pre][q[i]]) memo=true;
      if(!memo) {
        ok=false;
        break;
      }
      pre=q[i];
    }

    if(ok) ans++;
  }while(np(all(q)));

  //——————————————————————————————————————————


  cout << ans << endl;
}

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

int main(void) {
	unsigned int N;
	cin >> N;
	set <int> A;
	for (unsigned int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A.insert(a);
	}
	if (A.size()==N) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;j<n;i++)
int main() {
    int s,w;
    cin>>s>>w;
    if(w>=s)
        cout<<"unsafe";
    else
        cout<<"safe";

	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,A; cin>>N;
	bool ok=true;
	for (int i=0; i<N; i++) {
		cin>>A;
		if(A%2) continue;
		if(A%3&&A%5)
			ok=false;
	}
	cout<<(ok?"APPROVED":"DENIED")<<"\n";
	return 0;
}

Measured memory_bytes: 256
short lcs[4002][4002];

int main(){
  char a[4002],b[4002];
  int i,j,_a,_b,m;
  while(~scanf("%s%s",a+1,b+1)){
    memset(lcs,0,sizeof(lcs));
    _a=strlen(a+1);_b=strlen(b+1);
    for(m=0,i=1;i<=_a;i++)
      for(j=1;j<=_b;j++){
        lcs[i][j]=a[i]==b[j]?lcs[i-1][j-1]+1:0;
        if(m<lcs[i][j])m=lcs[i][j];
      }
    printf("%d\n",m);
  }
  return 0;
}

Measured memory_bytes: 30000