akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <string.h>
 
#define rep(i,n)    for(ll i=0;i<n;i++)
#define repu(i,k,n) for(ll i=k;i<=n;i++)
#define repd(i,k,n) for(ll i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
#define INF (ll)ll_MAX
 
typedef long long ll;
typedef long double ld;
typedef std::pair<ll, ll> pii;
typedef std::vector< ll > vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, ll > > vpp;
 
const ll N = 3*1e5 +5 ;
const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long inf = 1e18;
 
using namespace std;

// ll g[200000], ig[200000];



bool ok;

void dfs1(ll u, bool vis[], ll tot[], ll p[],ll h[], vll v[]){
    if(vis[u]==1) return;
    vis[u] = 1;

    ll sum = 0;

    sum += p[u];

    ll sorr = 0;

    for(ll i=1;i<v[u].size();i++){
        // cout<<'a';
        dfs1(v[u][i],vis,tot,p,h,v);
        sum+= tot[v[u][i]];
        sorr = sorr +  tot[v[u][i]] - h[v[u][i]];
    }

    // cout<<sum;

    tot[u] = sum;

    // if(tot[u]-h[u]>sorr){
    //     cout<<tot[u]-h[u]<<' '<<sorr<<'\n';
    //     ok = false;
    //     // cout<<"NOOOOO";
    // }

    return;

}

void dfs2(ll u, bool vis[], ll tot[], ll p[],ll h[], vll v[]){
    if(vis[u]==1) return;
    vis[u] = 1;

    // ll sum = 0;

    // sum += p[u];

    ll sorr = 0;

    for(ll i=1;i<v[u].size();i++){
        // cout<<'a';
        dfs2(v[u][i],vis,tot,p,h,v);
        // sum+= tot[v[u][i]];
        sorr = sorr +  tot[v[u][i]] - h[v[u][i]];
    }

    // cout<<sum;

    // tot[u] = sum;

    // cout<<sorr<<endl;

    if(tot[u]-h[u]>sorr + 2*p[u]){
        // cout<<u<<' '<<tot[u]-h[u]<<' '<<sorr<<'\n';
        ok = false;
        // cout<<"NOOOOO";
    }

    if((tot[u]-h[u])%2==1){
        ok = false;
    }

    if(h[u]>(tot[u]) or h[u]<(-tot[u])){
        ok = false;
    }

    return;

}





void solve()
{	
    
    string s;
    cin>>s;
    int n = s.length();
    int mx = 0;
    int ctr = 0;
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            ctr++;
            mx = max(mx,ctr);
        }
        else{
            ctr = 0;
        }
    }

    cout<<mx;




}

int main() {


    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif


    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll t = 1;
    // cin>>t;
    ll ctr=0;
    while(t--)
    {   
        ctr++;
        // cout<<"Case #"<<ctr<<": ";
        solve();    
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
}

Measured memory_bytes: 3760
A, B, C, D = gets.split.map(&:to_i)

if (A..B).include?(C)
  puts (A..B).include?(D) ? D - C : B - C
elsif (A..B).include?(D)
  puts D - A
elsif (C..D).include?(A) && (C..D).include?(B)
  puts B - A
else
  puts 0
end



Measured memory_bytes: 1788
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")

#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

inline void setin(string s) {
	freopen(s.c_str(), "r", stdin);
}

inline void setout(string s) {
	freopen(s.c_str(), "w", stdout);
}

template <typename T> inline T range(T l, T r) {
	return uniform_int_distribution <T>(l, r)(rng);
}

template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}
 
template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

#define int long long

const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 55;
int n, a[N], b[N];
vector <ll> mask[N][N];
int pw[N];

void rec(int a, int b, vector <ll> &ans, ll mask = 0) {
	if(a < b)
		return;
	if(a == b) {
		ans.pb(mask);
		return;
	}
	for(int j = b + 1; j <= a; ++j)
		rec(a % j, b, ans, pw[j] | mask);

}

void precalc() {
	for(int i = 0; i <= 50; ++i)
		for(int j = 0; j <= i; ++j)
			rec(i, j, mask[i][j]);
}

main() {
	for(int i = 0; i < N; ++i)
		pw[i] = 1ll << i;
	precalc();
	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	// setin("input.txt");
	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	for(int i = 1; i <= n; ++i)
		cin >> b[i];
	for(int i = 1; i <= n; ++i)
		if(mask[a[i]][b[i]].empty())
			return cout << -1 << endl, 0;
	vector <vector <int>> cur = {};
	for(int i = 1; i <= n; ++i)
		cur.pb(mask[a[i]][b[i]]);
	ll res = 0;
	for(int i = N - 1; i >= 0; --i) {
		vector <vector <int>> temp = {};
		bool flag = true;
		res += pw[i];
		for(const vector <int> &now : cur) {
			vector <int> is = {};
			for(int mask : now)
				if((pw[i] & mask) == 0)
					is.pb(mask);
			if(is.empty()) {
				flag = false;
				break;
			}
		}
		if(flag) {
			for(const vector <int> &now : cur) {
				vector <int> is = {};
				for(int mask : now)
					if((pw[i] & mask) == 0)
						is.pb(mask);
				temp.pb(is);
			}
			cur.swap(temp);
			res -= pw[i];
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(a, n) sort(a, a+n)
#define VSORT(v) sort(v.begin(), v.end())

using namespace std;

int main()
{
    int n;

    cin >> n;

    int a[n], b[n], c[n];

    REP(i, n) {
        cin >> a[i] >> b[i] >> c[i];
    }

    int hap[n][3];
    hap[0][0] = a[0];
    hap[0][1] = b[0];
    hap[0][2] = c[0];

    FOR(i, 1, n) {
        hap[i][0] = max(hap[i-1][1], hap[i-1][2]) + a[i];
        hap[i][1] = max(hap[i-1][0], hap[i-1][2]) + b[i];
        hap[i][2] = max(hap[i-1][0], hap[i-1][1]) + c[i];
    }

    cout << *max_element(hap[n-1], hap[n-1]+3) << endl;

    return 0;
}

Measured memory_bytes: 2560
N = input()
if int(N) == 10**5:
    print(90909)
if len(N) == 5:
    print(int(N) - 9090)
if len(N) == 4:
    print(909)
if len(N) == 3:
    print(int(N) - 90)
if len(N) == 2:
    print(9)
if len(N) == 1:
    print(int(N))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define M 500000
#define MAX 10000000000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll dp[10001];

ll solve(ll a[],ll b[],ll n,ll h)
{
	if(h<=0)
		return 0;
	if(dp[h] != -1)
		return dp[h];
	for(int i=0;i<n;i++)
	{
		if(dp[h] == -1)
			dp[h] = solve(a,b,n,h-a[i])+b[i];
		else
			dp[h] = min(dp[h],solve(a,b,n,h-a[i])+b[i]);	
	}
	return dp[h];
}

int main()
{
	ll h,n;
	cin>>h>>n;
	ll a[n],b[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	fill(dp,dp+10001,-1);
	dp[0] = 0;
	ll ans = solve(a,b,n,h);
	cout<<ans<<endl;
	
	return 0;
}

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

int ans(vector<vector<long>> v,vector<bool>&ny ,long i){
  long m=0;
  long k=-1;
  rep(i,v.size()){
    if(v[i][0]<=i&&ny[i]){
      if(m<v[i][1]){
        m=v[i][1];
        k=i;
      }
    }
  }
  if(k!=-1)ny.at(k)=false;
  return m;
}
  
int main(){
  long n,c=0,ans=0;
  cin>>n;
  vector<string> v(n);
  rep(j,n){
    string s;
    cin>>s;
    vector<char>ch(10);
    rep(i,10)ch[i]=s[i];
    sort(ch.begin(),ch.end());
    rep(i,10)s[i]=ch[i];
    v[j]=s;
  }
  sort(v.begin(),v.end());
  rep(i,n){
    if(i!=n-1&&v[i]==v[i+1])c++;
    else {
      ans+=c*(c+1)/2;
      c=0;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5760
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  cout << 'A' << s2.at(0) << 'C' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F(i,a,b) for (int i=int(a);i<=int(b);i++)
#define R(i,a,b) for (int i=int(a);i<int(b);i++)
#define D(i,a,b) for (int i=int(a);i>=int(b);i--)
#define go(i,x) for (int i=head[x];i;i=Next[i])
#define pb push_back
#define si size()
#define fi first
#define se second
#define pa pair < ll,ll >
#define ll long long
#define mp make_pair
#define be begin()
#define en end()
#define put putchar('\n')
#define gc getchar
#define pc putchar
#define N 6000055
#define mo 998244353
#define inf 1000000007
#define ret return puts("-1"),0
using namespace std;
inline ll read(){
	ll su=0,f=1;char c=gc();
	for (;c<'0'||c>'9';c=gc()) if (c=='-') f=-1;
	for (;c>='0'&&c<='9';c=gc()) su=su*10+c-'0';
	return su*f;
}
inline void wr(ll x){
	if (x<0) pc('-'),wr(-x);
	else{if (x>=10) wr(x/10);pc(x%10+'0');}
}
inline void wri(ll x){wr(x);pc(' ');}
inline void wrn(ll x){wr(x);put;}
inline void wrn(ll x,ll y){wri(x);wrn(y);}
inline void wrn(ll x,ll y,ll z){wri(x);wrn(y,z);}
int n,m,p[N],k,f[N],co[N],su[3],f0,f1,vis[N];
int Next[N*2],head[N],to[N*2],nedge;
#define V to[i]
void add(int a,int b){Next[++nedge]=head[a];head[a]=nedge;to[nedge]=b;}
void add_ne(int a,int b){add(a,b);add(b,a);}
void dfs(int x){
	vis[x]=1;
	su[co[x]]++;
	go(i,x){
		if (vis[V]) continue;
		co[V]=co[x]^1;dfs(V);
	}
}
signed main(){
	n=read();
	R(i,1,n) add_ne(read(),read());
	dfs(1);
	if (min(su[0],su[1])<=n/3){
		f0=3;
		F(i,1,n) vis[i]=0;
		if (su[0]<su[1]){
			F(i,1,n) 
				if (co[i]==0){
					f[i]=f0;vis[f0]=1;f0+=3;
				}
			f0=1;
			F(i,1,n) if (co[i]==1){
				f[i]=f0;f0++;if (vis[f0]) f0++;
			}
		}
		else{
			F(i,1,n){
				if (co[i]==1){
					f[i]=f0;vis[f0]=1;f0+=3;
				}
			}
			f0=1;
			F(i,1,n) if (co[i]==0){
				f[i]=f0;f0++;if (vis[f0]) f0++;
			}
		}
		F(i,1,n) wri(f[i]);
		return 0;
	}
	f0=1;f1=2;
	if (su[0]<su[1]){
		F(i,1,n) 
			if (co[i]==0){
				f[i]=f0;f0+=3;
			}
			else{
				f[i]=f1;f1+=3;
			}
	}
	else{
		F(i,1,n){
			if (co[i]==1){
				f[i]=f0;f0+=3;
			}
			else{
				f[i]=f1;f1+=3;
			}
		}
	}
	f0=3;
	F(i,1,n) if (f[i]>n) f[i]=f0,f0+=3;
	F(i,1,n) wri(f[i]);
	return 0;
}

Measured memory_bytes: 17924
import java.util.*;

class Main {
    static Scanner sc;
    static int n;
    static Pair[] items;
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        n = sc.nextInt();
        items = new Pair[n];
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int l = sc.nextInt();
            items[i] = new Pair(x + l, l);
        }
        Arrays.sort(items);

        int ans = solve();
        System.out.println(ans);
    }

    public static int solve() {
        int[] dp = new int[n];
        dp[0] = 1;
        for (int i = 1; i < n; i++) {
            int left = items[i].x - 2 * items[i].y;
            if (items[i - 1].x <= left) {
                dp[i] = dp[i - 1] + 1;
                continue;
            }
            int index = binarySearch(left, i - 1);
            if (index == -1) {
                dp[i] = dp[i - 1];
            } else {
                dp[i] = Math.max(dp[index] + 1, dp[i - 1]);
            }
        }
        return dp[n - 1];
    }

    public static int binarySearch(int v, int r) {
        if (items[0].x > v) {
            return -1;
        }
        int l = 0;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (items[mid].x > v) {
                r = mid;
            } else {
                l = mid;
            }
        }
        return l;
    }
}

class Pair implements Comparable<Pair> {
    int x, y;

    Pair(int _x, int _y) {
        x = _x;
        y = _y;
    }

    public int compareTo(Pair b) {
        if (x > b.x) {
            return 1;
        } else if (x < b.x) {
            return -1;
        }

        if (y > b.y) {
            return 1;
        } else if (y < b.y) {
            return -1;
        }

        return 0;
    }
}

Measured memory_bytes: 52328
#include<stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		double x1,y1,x2,y2,x3,y3,x4,y4;
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		if((y2-y1)*(x4-x3)==(y4-y3)*(x2-x1))printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

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

long long n;
long long now,total;

int main()
{
	cin>>n;
	now = 1;
	while(n > 0)
	{
		n /= 2;
		total += now;
		now *= 2;
	}
	cout<<total;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int m,n, i;
  int loop,loop2;
  int max, d,e;
  int init,y,a,c;
  double b;

  scanf("%d ",&m);
  for(loop=0;loop<m;loop++){
    scanf("%d %d %d ",&init,&y,&n);

    max = 0;
    for( loop2=0;loop2<n;loop2++){
      scanf("%d %lf %d ",&a,&b,&c );
      d = init;
      e = 0;
      for( i=0;i<y;i++ ){
	if( a==0 ){
	  e+= (d*b);
	}else{
	  d+= (d*b);
	}
	d-=c;
      }
      if( a==0 )d+=e;
      if( d>max )max =d ;
    }
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 0
import numpy as np

nkq = np.array(list(map(int, input().split())))

p = np.array([nkq[1]-nkq[2] for i in range(nkq[0])])

#print(p)
a = np.array([int(input()) for i in range(nkq[2])])
for i in range(nkq[2]):
    p[a[i]-1] += 1
    #print(p)

a = [print('Yes') if p[i] > 0 else print('No') for i in range(len(p))]

Measured memory_bytes: 19032
/*---------------Go Code GO---------------*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using Order_Set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
//(order) Set.order_of_key(); (pointer) Set.find_by_order();

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff
long long MD = 1000000007;

int main()
{
    long long N,K, p, q, ans=0;
    cin>>N>>K;
    N++;
    for(long long i=K; i<=N; i++)
    {
        p = ((N-1)*N)/2;
        p-= ((N-i)*(N-i-1))/2;

        q = ((i-1)*i)/2;
        //cout<<p<<' '<<q<<endl;
        ans=(ans+p-q+1)%MD;
    }

    cout<<ans<<endl;






    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    int n, k; cin >> n >> k;
    string s; cin >> s;
    s[k - 1] = s[k - 1] - 'A' + 'a';
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define endl '\n'  
#define show(a) for(auto i:a) cout<<i<<" ";cout<<endl
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< int , int > mypair;
typedef priority_queue <int> max_heap;
typedef priority_queue <int, vector<int>, greater<int> > min_heap;
const ll mod=1e9+7;
const ll inf=1e9;
const ll N=1e5+10;


int main()
{
	boost;
	int n;
	cin>>n;
	std::vector<mypair> v;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		v.pb(mp(x,i));
	}
	sort(all(v));
	for(auto i:v) cout<<i.ss<<" ";
   	return 0;
}

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

struct Edge{
    int next,to;
}E[500000];
int head[200010],cnt=0;
void add(int x,int y)
{
    E[++cnt].to = y;
    E[cnt].next = head[x];
    head[x] = cnt;
}
const long long mod = 1e9+7;
long long siz[200010];
long long N;
long long inv(long long x)
{
    long long ans = 1;
    long long tmp = x;
    long long TT = mod-2;
    while(TT)
    {
        if (TT&1) ans=ans*tmp%mod;
        tmp = tmp*tmp%mod;
        TT>>=1;
    }
    return ans;
}

void dfs1(int x,int f)
{
    siz[x] = 1;
    for (int i=head[x];i;i=E[i].next)
    {
        int to = E[i].to;
        if (to==f) continue;
        dfs1(to,x);
        siz[x]+=siz[to];
    }
}
long long dp[2000000];
void dfs(int x,int f)
{
    if (x!=1)
    {
        dp[x] = dp[f]*siz[x]%mod*inv(N-siz[x])%mod;
    }
    for (int i=head[x];i;i=E[i].next)
    {
        int to = E[i].to;
        if (to==f) continue;
        dfs(to,x);
    }
}
int main(void)
{
    // freopen("aaa.in","r",stdin);
    scanf("%lld",&N);
    for (int i=1,x,y;i<N;i++)
    {
        scanf("%d%d",&x,&y);
        add(x,y);
        add(y,x);
    }
    dfs1(1,0);
    long long tmp = 1;
    for (int i=1;i<=N;i++)
    {
        tmp = tmp*siz[i]%mod;
    }
    long long nn = 1;
    for (long long i=1;i<=N;i++) nn = nn*i%mod;
    // cout<<nn<<endl;
    // cout<<tmp<<endl;
    dp[1] = nn*inv(tmp)%mod;
    dfs(1,0);
    for (int i=1;i<=N;i++)
    printf("%lld\n",dp[i]);
    return 0;
}

Measured memory_bytes: 10192
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def dfs(n):
    global h
    if n in h:
        return h[n]
    #ddprint(f"dfs {n}")
    if n==1:
        return d
    v1 = n*d
    v3 = v5 = BIG
    if n%2==1:
        v2a = dfs((n-1)//2)+a+d
        v2b = dfs((n+1)//2)+a+d
        v2 = min(v2a,v2b)
    else:
        v2 = dfs(n//2)+a

    if n>=3:
        r = n%3
        if r<=1:
            v3 = dfs((n-r)//3)+b+r*d
        else:
            v3 = dfs((n+1)//3)+b+d

    if n>=5:
        r = n%5
        if r<=2:
            #ddprint(f"dfs {n} v5 b {b} r {r} d {d}")
            v5 = dfs((n-r)//5)+c+r*d
        else:
            v5 = dfs((n+5-r)//5)+c+(5-r)*d

    ret = min([v1,v2,v3,v5])
    h[n] = ret
    #ddprint(f"dfs {n} v1235 {v1} {v2} {v3} {v5} rtn {ret}")
    return ret

k = 400
def foo(n):
    if n<=k:
        return dfs(n)
    v1 = n*d
    m = n
    sm = 0
    while m>k:
        if m%2==1:
            if m%4==1:
                m -= 1
            else:
                m += 1
            sm += d
        m //= 2
        sm += a
    v2 = dfs(m)+sm

    m = n
    sm = 0
    while m>k:
        r = m%3
        if r==1:
            m -= 1
            sm += d
        elif r==2:
            m += 1
            sm += d
        m //= 3
        sm += b
    v3 = dfs(m)+sm

    m = n
    sm = 0
    while m>k:
        r = m%5
        if r<=2:
            m -= r
            sm += r*d
        else:
            m += 5-r
            sm += (5-r)*d
        m //= 5
        sm += c
    v5 = dfs(m)+sm

    #ddprint(f"foo v1235 {v1} {v2} {v3} {v5}")
    return min([v1,v2,v3,v5])

t = inn()
for tt in range(t):
    n,a,b,c,d = inm()
    h = {}
    print(dfs(n))


Measured memory_bytes: 97784
require 'bigdecimal'
require 'bigdecimal/util'

a,b = gets.split
a = a.to_d
b = b.to_d
b1 = b.to_i.to_s.to_d
b2 = b-b1

if a*b == 0
  puts 0
else
  tmp1 = a*b1
  tmp2 = a*b2
  puts (tmp1+tmp2).to_i
end

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

int main( void ) {
  string s1;
  int day;

  cin >> s1;

  if(s1=="SUN") day = 7;
  if(s1=="MON") day = 6;
  if(s1=="TUE") day = 5;
  if(s1=="WED") day = 4;
  if(s1=="THU") day = 3;
  if(s1=="FRI") day = 2;
  if(s1=="SAT") day = 1;

  cout << day << endl;

  return ( 0 );
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
int n,m,k,x1,x2,h1,y2;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>k>>x1>>h1>>x2>>y2;
	x1--;
	h1--;
	x2--;
	y2--;
	char grid[n+10][m+10];
	int dist[n+10][m+10];
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>grid[i][j];
	queue<pair<int,int> >q;
	q.push(make_pair(x1,h1));
	memset(dist,0x3f,sizeof(dist));
	dist[x1][h1]=0;
	while(!q.empty())
	{
		int nx=q.front().first;
		int ny=q.front().second;
		if(nx==x2&&ny==y2)
		{
			cout<<dist[nx][ny]<<endl;
			return 0;
		}
		q.pop();
		for(int i=0;i<4;i++)
		{
			for(int j=1;j<=k;j++)
			{
				int tx=nx+dx[i]*j;
				int ty=ny+dy[i]*j;
				if(tx>=0&&tx<n&&ty>=0&&ty<m)
				{
					if(grid[tx][ty]=='@')
						break;
					if(dist[tx][ty]>1e7)
					{
						dist[tx][ty]=dist[nx][ny]+1;
						q.push(make_pair(tx,ty));
					}
					if(dist[tx][ty]<=dist[nx][ny])
						break;
				}
				else
					break;
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 47608
import sys
a, b, c = [int(i) for i in sys.stdin.readline().split()]
from math import sqrt
import numpy as np
a = np.longlong(a)
b = np.longlong(b)
c = np.longlong(c)
if c - a - b > 0 and 4 * a * b < (c - a - b) ** 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 12508
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline-------------------------------------------
    a = []
    n = int(input())
    for i in range(n+1):
        if i % 3 == 0 or i % 5 == 0:
            a.append(0)
        else:
            a.append(i)
    print(sum(a))
if __name__ == "__main__":
    main() #endline===============================================

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

int main(){
  int N;
  cin >> N;
  
  int num[4];
  for(int i=0;i<4;++i){
    num[i] = N % 10;
    N /= 10;
  }
  
  if(num[0] == num[1] and num[1] == num[2] and num[2] == num[3]){
    cout << "Yes" << endl;
  }
  else if(num[0] == num[1] and num[1] == num[2]) cout << "Yes" << endl;
  else if(num[1] == num[2] and num[2] == num[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		
		if (K!=1) {
			System.out.println(N - K);
		}else {
			System.out.println(0);
		}
		sc.close();
	}
}

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

using namespace std;
using p = pair<long long, int>;
#define INF 100000000
using Graph = vector<vector<int> >;

vector<bool> seen(200001,false);
Graph g(200001);
vector<int> pl;
void bfs(int s){
	seen[s] = true;
	
	for(int next : g[s]){
		if(seen[next]) continue;
		pl[next]+=pl[s];
		bfs(next);
	}
	
}
int main(){
	int n,q;
	cin >> n >> q;
	
	rep(i,n-1){
		int a,b;
		cin >> a >> b; a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	pl.assign(n,0);
	for(int i = 0; i < q; i++){
	int a,x;
		cin >> a >> x; a--;
		pl[a]+=x;
		
	}
	bfs(0);
	rep(i,n)	cout << pl[i] << endl;
}
	
	


Measured memory_bytes: 23552
#include <iostream>

using namespace std;

int n;
int x[105];

int main(){

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

    int ans = 1e9;

    for(int p = 0;p <= 100;p++){
        int tmp = 0;

        for(int i = 1;i <= n;i++){
            tmp += (x[i] - p) * (x[i] - p);
        }
        ans = min(ans,tmp);
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define maxn 105
short n;
string word[maxn];
int isReapeat(short x)
{
    for (short y = 0; y < x; y++)
    {
        // cout << "now " << word[x] << " forw " << word[y] << endl;
        if (word[x] == word[y])
            return 0;
    }
    return 1;
}
int main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    for (short now = 0; now < n; now++)
    {
        cin >> word[now];
        if (now > 0)
        {
            if (!isReapeat(now) || word[now][0] != word[now - 1][word[now - 1].size() - 1])
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        if (s[3 - 1] != s[4 - 1]) return No;
        if (s[5 - 1] != s[6 - 1]) return No;

        return Yes;
    }
}

Measured memory_bytes: 11092
n = int(input())
array = list(map(int, input().split()))

flag = 1
count = 0
while flag:
    flag = 0
    for i in range(1, n)[::-1]:
        if array[i] < array[i-1]:
            array[i], array[i-1] = array[i-1], array[i]
            flag = 1
            count += 1
print(' '.join(list(map(str, array))))
print(count)



Measured memory_bytes: 5604
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<complex>
#include<cmath>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int n;
int main()
{
	read(n);
	while(n--)
	{
		long long a,b;
		read(a);
		read(b);
		if(a==1 && b==1)
		{
			cout<<0<<endl;
			continue;
		}
		if(a>b)	swap(a,b);
		long long s=a*b;
		long long gg=sqrt((long double)(s-1));
	//	cout<<s<<' '<<gg<<endl;
		long long sum=gg*2;
		if(gg==(s-1)/gg)	sum--;
		if(a<=gg)	sum--;
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int f[4][4];
int main()
{
    int a,b,c;
    scanf("%d%d%d",&f[1][1],&f[1][2],&f[2][2]);//先把位置都放好
    a=f[2][2]*3;//a记录行，列，斜线的和。我们知道，这种3*3的方格填数每一行，每一列，每一斜线的和都等于中间数的3倍
    f[1][3]=a-f[1][1]-f[1][2];
    f[3][1]=a-f[1][3]-f[2][2];
    f[3][3]=a-f[1][1]-f[2][2];
    f[2][1]=a-f[1][1]-f[3][1];
    f[2][3]=a-f[2][1]-f[2][2];
    f[3][2]=a-f[1][2]-f[2][2];//这一大段是计算，顺序很重要
    for(int i=1;i<=3;i++)
    {
        for(int j=1;j<=3;j++)
        {
            printf("%d ",f[i][j]);//矩阵输出
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN=2e5+5;
LL a[MAXN];
LL b[MAXN];
int main()
{
    int n;
    while(cin>>n)
    {
        LL ans=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            b[i]=b[i-1]+a[i];
            ans+=a[i];
        }
        LL cmin=INT_MAX;
        for(int i=1;i<n;i++)
        {
            if(cmin>abs(2*b[i]-ans))
                cmin=abs(2*b[i]-ans);
        }
        cout<<cmin<<endl;
    }
    return 0;
}

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

using namespace std;

long long cnt;
int n;
vector<int> g;

void PrintSort(int a[], int n)
{
    for (int i = 0; i < n; ++i)
    {
        cout << a[i] << endl;
    }
}

void InsertionSort(int a[], int n, int g)
{
    for (int i = g; i < n; ++i)
    {
        int v = a[i];
        int j = i - g;
        while (j >= 0 && a[j] > v)
        {
            a[j + g] = a[j];
            j -= g;
            cnt++;
        }
        a[j + g] = v;
    }
}

void ShellSort(int a[], int n){
    int h = 1;
    while(h<=n){
        g.push_back(h);
        h = 3*h + 1;
    }
    int m = g.size();
    cout << m << endl;

    for(int i=m-1;i>=0;--i){
        InsertionSort(a, n, g[i]);
        cout << g[i] << " ";
        if(i==0) cout << endl;
    }
}

int main()
{
    cnt = 0;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    ShellSort(a, n);

    cout << cnt << endl;

    PrintSort(a, n);

    return 0;
}


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

long long n,ans=0;
void dfs(long long x,bool a,bool b,bool c){
  if(x>n)return;
  
  if(a&&b&&c)ans++;
  dfs(x*10+7,true,b,c);
  dfs(x*10+5,a,true,c);
  dfs(x*10+3,a,b,true);
  
}

signed main(){
  cin>>n;
  dfs(0,false,false,false);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    map<int, int> counts;
    int a;
    for(int i=0; i<n; i++){
        cin >> a;
        if(counts.count(a)) counts[a]++;
        else counts[a] = 1;
    }
    int ans = 0;
    while(!counts.empty()){
        auto cur_it = counts.rbegin();
        auto cur = cur_it->first;
        auto cnt = cur_it->second;
        if(cnt == 1) counts.erase(cur);
        else counts[cur] = cnt -1;
        int need = 1;
        while(need <= cur) need *= 2;
        need -= cur;
        auto it = counts.find(need);
        if(it != counts.end()){
            ans++;
            if(it -> second == 1) counts.erase(it->first);
            else counts[it->first] = it->second - 1;
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 9600
/* Never Say Die. */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <ctime>
#include <cstdlib>
using namespace std;
int _c = 0;
template <class _T> inline void read(_T &_a) {
	_a = 0; bool _f = 0;
	while (_c < '0' || _c > '9') _f |= _c == '-', _c = getchar();
	while (_c >= '0' && _c <= '9') _a = _a * 10 + _c - '0', _c = getchar();
	if (_f) _a = -_a;
}
typedef long long LL;
typedef long double LD;


int n;
int cnt[2];

int main() {
	read(n);
	if (n == 1) return puts("YES"), 0;
	for (int i = 1, a; i <= n; i++) read(a), cnt[a & 1]++;
	if (cnt[1] & 1) puts("NO");
	else puts("YES");
	return 0;
}


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

const int INF = 1 << 30;

int main()
{
  int time = 0;
  vector<int> seat(17, INF), ans(100);
  for (int i = 0; i < 100; ++i) {
    time = max(time, i*5);
    int people = 2;
    if (i%5 == 1)
      people = 5;

    for ( ; ; ) {
      for (int j = 0; j < seat.size(); ++j) {
	if (seat[j] <= time)
	  seat[j] = INF;
      }

      int con = 0;
      bool in = false;
      for (int j = 0; j < seat.size(); ++j) {
	if (seat[j] == INF) {
	  ++con;
	  if (con == people) {
	    in = true;
	    for (int k = j; k > j-con; --k)
	      seat[k] = time + 17*(i%2) + 3*(i%3) + 19;
	    ans[i] = max(0, time - i*5);
	    break;
	  }
	} else {
	  con = 0;
	}
      }

      if (in)
	break;

      int min_time = INF;
      for (int j = 0; j < seat.size(); ++j)
	min_time = min(min_time, seat[j]);
      time = min_time;
    }
  }

  int n;
  while (cin >> n)
    cout << ans[n] << endl;

  return 0;
}

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

using namespace std;

void Main()
{
    string s;
    cin >> s;

    int m = (s[5] - '0') * 10 + (s[6] - '0');
    int d = (s[8] - '0') * 10 + (s[9] - '0');

    int v = m * 40 + d;

    if (v <= 4 * 40 + 30)
        cout << "Heisei";
    else
        cout << "TBD";
}

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

    std::cout << std::fixed << std::setprecision(10);

#ifdef DEBUG_BUILD
    while (true)
    {
        Main();
        cout << std::endl;
    }
#endif

    Main();
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int main() {
	int K, S;
	cin >> K >> S;

	int ans = 0;
	int a;
	for (int i = 0;i <= K;i++) {
		a = S - i;

		if (a < 0) {
			continue;
		}
		else if (a > 2 * K) {
			continue;
		}
		else if (a <= K) {
			ans += (a + 1);
		}
		else if (a > K) {
			ans += (2 * K - a + 1);
		}
	}

	

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  long long int N=0;
  long long int A[200000]={0};
  long long int B[200000]={0};
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>A[i];
    B[i]=A[i];
  }
  sort(B,B+N);
  for(int i=0;i<N;i++){
    if(A[i]==B[N-1]){
      cout<<B[N-2]<<endl;
    }
    else{
      cout<<B[N-1]<<endl;
    }
  }
}
  
  

Measured memory_bytes: 4736
n = int(input())
num_list = list(map(int,input().split()))
ans_list = []
cnt = 0
for i,num in enumerate(num_list):
    if i+1 != num: 
        ans_list.append('o')
    else:
        ans_list.append('x')
for i in range(len(ans_list)):
    if i != len(ans_list)-1:
        if ans_list[i] == 'x':
            cnt +=1
            ans_list[i] ='o'
            ans_list[i+1] ='o'
            
    else:
        if ans_list[i] == 'x':
            ans_list[i] ='o'
            cnt +=1
            
print(cnt)

Measured memory_bytes: 13880
#include <stdio.h>
char CH[5];
int N;
int A,B,C,D;
int main()
{
//	freopen("data.in","r",stdin);
//	freopen("yyt.out","w",stdout);
	int I,J,K;
	scanf("%s",&CH[0]);
	A=CH[0]-48;
	B=CH[1]-48;
	C=CH[2]-48;
	D=CH[3]-48;
	if(A+B+C+D==7)
		printf("%d+%d+%d+%d=7",A,B,C,D);
	else if(A+B+C-D==7)
		printf("%d+%d+%d-%d=7",A,B,C,D);
	else if(A+B-C+D==7)
		printf("%d+%d-%d+%d=7",A,B,C,D);
	else if(A+B-C-D==7)
		printf("%d+%d-%d-%d=7",A,B,C,D);
	else if(A-B+C+D==7)
		printf("%d-%d+%d+%d=7",A,B,C,D);
	else if(A-B+C-D==7)
		printf("%d-%d+%d-%d=7",A,B,C,D);
	else if(A-B-C+D==7)
		printf("%d-%d-%d+%d=7",A,B,C,D);
	else if(A-B-C-D==7)
		printf("%d-%d-%d-%d=7",A,B,C,D);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#if defined(_MSC_VER)
#pragma warning(disable : 4996)  // VSでscanfを使う．
#endif

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

  int ans = a + b;

  if ((ans % 2) != 0) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }

  ans /= 2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int flg = 0;
		for(int i = 0;i < S.length();i ++) {
			for(int k = i + 1;k < S.length();k ++) {
				if(S.charAt(i) == S.charAt(k)) flg = 1;
			}
		}
		if(flg == 0) System.out.println("yes");
		else System.out.println("no");
	}
}

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

int main(){ 
    Int A,B,N,ans;

    cin >> A >> B >> N;

    if (N >= B) N = B-1;

    if (N == 0) ans = 0;
    else {
        ans = A * N / B;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N,K;
	public void solve() {
		N = nextInt();
		K = nextInt();

		long ans = K;
		for(int i = 1;i < N;i++){
			ans *= (K - 1);
		}
		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 8148
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int a,b;
int main(){
	cin>>a>>b;
	if(a<=b){
		puts("Impossible");return 0;
	}
	vector<int>vi; rep(i,a+b)vi.pb(i);
	while(vi.size()>1){
		vector<int>vi2;
		for(int i=0;i<vi.size();i+=2){
			if(i+1==vi.size()){
				vi2.pb(vi[i]); break;
			}
			printf("? %d %d\n",vi[i],vi[i+1]);fflush(stdout);
			string str; cin>>str;
			if(str=="Y"){
				vi2.pb(vi[i+1]);
			}
		}
		vi=vi2;
	}
	string ans=""; int x = vi[0];
	rep(i,a+b){
		if(i==x){
			ans.pb('1');continue;
		}
		printf("? %d %d\n",x,i);fflush(stdout);
		string str; cin>>str;
		ans.pb( '0'+(str=="Y") );
	}
	cout << "! " << ans << endl;
}

Measured memory_bytes: 848
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline T int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

ll dph[3 * MAX];
ll dpw[3 * MAX];
vector<pair<ll, ll> > v;

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll h, w, m; cin >> h >> w >> m;
	v.resize(m);
	map<pair<ll, ll>, bool> mp;
	rep(i, m){
		ll hi, wi; cin >> hi >> wi;
		hi--; wi--;
		mp[{wi, hi}] = true;
		v[i] = {wi, hi};
		dph[hi]++; dpw[wi]++;
	}
	ll maxh = 0, maxw = 0;
	rep(i, h) chmax(maxh, dph[i]);
	rep(i, w) chmax(maxw, dpw[i]);
	vector<ll> sumh, sumw;
	// print(maxh, maxw);
	rep(i, h){
		if(maxh == dph[i]) sumh.push_back(i);
	}
	rep(i, w){
		if(maxw == dpw[i]) sumw.push_back(i);
	}
	// print(sumh.size(), sumw.size(), sumh.size() * sumw.size());
	if(sumh.size() * sumw.size() > m){
		cout << maxh + maxw << endl;
	}
	else{
		bool ok = false;
		rep(i, sumh.size()){
			rep(j, sumw.size()){
				if(mp.find({sumw[j], sumh[i]}) == mp.end()){
					ok = true;
				}
			}
		}
		if(!ok){
			cout << maxh + maxw - 1 << endl;
		}
		else{
			cout << maxh + maxw << endl;
		}
	}

	return 0;
}


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

using namespace std;

/*
const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;*/

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

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

void printV(vi v) {
    for (int i = 0; i<v.size(); ++i) cout << v.at(i) << " ";
    cout << "\n";
}

//g++ -std=c++11 -O2 -Wall c.cpp

void solve() {
    ll k; cin >> k;
    string  str = "";
    for (int i = 0; i<k; ++i) {
        str += "ACL";
    }

    cout << str << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

        solve();


    /**
     * ALGORITHME DE TRI ET EN LEVER LES DUPLICATES
     * set<int> s( v.begin(), v.end() );
     * v.assign( s.begin(), s.end() );
     * */
}


Measured memory_bytes: 3604
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    string a, b, c;
    cin >> a >> b >> c;

    cout << (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0] ? "YES" : "NO") << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s=scanner.next();
		String t=scanner.next();
		
		String tmp=s;
		for(int i=0;i<s.length();i++) {
			if(tmp.equals(t)) {
				System.out.println("Yes");
				return;
			}
			tmp=tmp.substring(s.length()-1)+tmp.substring(0, s.length()-1);
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 21844
<?php
  $input_line = fgets(STDIN);
  $nums = explode(" ",$input_line);
  $A = $nums[0];
  $B = $nums[1];
  $C = $nums[2];
  $amount = $C - ($A - $B);
  if ($amount < 0) {
    $amount = 0;
  }
  echo $amount;
?>

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


// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3") 
// #pragma GCC optimization ("unroll-loops")
 
#define ll  long long int
#define all(v) v.begin(),v.end()
#define pb push_back
#define S second
#define F first
#define die() return 0;
 
#define MD          1000000007
#define M           1011
#define N 			12
long long  md=MD;
int dp[M][1<<N];
int a[M],c[M];
int f(int m,int mask,int n){
	if(m<0){
		if(mask==((1<<n)-1))return 0;
		return -2;
	}
	if(dp[m][mask]!=-1)return dp[m][mask];
	int mx=-2;
	int c1=f(m-1,mask,n);
	if(mx==-2)mx=c1;
	int c2=-2;
	c2=f(m-1,mask|c[m],n);
	if(c2!=-2){
		c2+=a[m];
	}
	if(mx==-2)mx=c2;
	mx=min(mx,c2);
	return dp[m][mask]=mx;



}
int solve(){
	int n,i,j,k,m;
	cin>>n>>m;
	for(i=0;i<m;++i){
		int x,y;
		cin>>a[i]>>x;
		int p=0;
		for(j=0;j<x;++j){
			cin>>y;--y;
			p|=(1<<y);
		}
		c[i]=p;
	}
	memset(dp,-1,sizeof(dp));
	int p=f(m-1,0,n);
	if(p==-2)p=-1;
	cout<<p<<"\n";










}


int main(){

 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    t=1;
    // cin>>t;

    while(t--){
    	solve();
    }
    die();



    

}



Measured memory_bytes: 16640