akhauriyash/Code-Regression huggingface dataset:
#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;

typedef long long            ll;
typedef unsigned long long   ull;
typedef vector<int>          vi;
typedef vector<ll>           vl;
typedef pair<int, int>       pi;
typedef pair<ll, ll>         pl;
typedef vector<pi>           vpi;
typedef vector<pl>           vpl;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define read        freopen("in.c", "r", stdin)
#define write       freopen("out.c", "w", stdout)
#define all(a)      a.begin(), a.end()
#define bye         exit(0)
#define mp          make_pair
#define ff          first
#define ss          second
#define L(x)        ((x) << 1)
#define R(x)        ((x) << 1 | 1)
#define SZ(a)       (ll)(a).size()
#define pb          push_back
#define eb          emplace_back
#define eps         1e-9
#define inf         (1000000000)
#define infl        (1000000000000000000LL)
#define cs(p)       printf("Case %d:", (p)++)
#define ptc(c)      putchar(c)
#define gtc()       getchar()
#define nl          puts("")
#define sp          printf(" ")
#define out(a)      printf("%lld", (ll)(a))
#define SET(a, x)   memset((a), x, sizeof(a))
#define dbg(x)      cout << "--- " << #x << " = " << (x) << '\n'

ll bgm(ll a, ll b, ll m) {
    b = (b == -1) ? (m - 2) : b;
    a %= m;
    ll rem = 1;
    while(b != 0) {
        if(b&1)
            rem = (rem * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return rem;
}

inline ll in() {
    ll a;
    assert(scanf("%lld", &a) != EOF);
    return a;
}

const int MAX = 1000000 + 5;
const int LEN = 50;
const ll MOD = 1000000007;

int cnt[30];

int main() {
    //read,write;
    string s,s1,str="";
    cin >> s;
    cin >> s1;
    s+=s;
    //cout << s << "----" << endl;
    int sz = s.size();
    int sz1=s1.size();
    //cout << sz << "    " << sz1 << endl;
    for(int i=0;i<sz-sz1;i++){
        for(int j=i;j<i+sz1;j++){
            str+=s[j];
        }
        //cout << str << "----" << i << endl;
        if(str==s1) cout << "Yes" << endl,bye;
        str="";
    }
    cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 3204
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll n,k;cin>>n>>k;
	if(n<11) k+=(100*(10-n));
	cout<<k<<endl;

}


Measured memory_bytes: 768
import java.util.*;

public class Main{
    
    static final int MOD = (int)1e9 + 7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String l = sc.next();
        int n = l.length();
        
        long[][] dp = new long[101010][2];
        dp[0][0] = 1;
        
        for(int i=0; i<n; i++){
            dp[i+1][1] += dp[i][1]*3;
            dp[i+1][1] %= MOD;
            if(l.charAt(i) == '1'){
                dp[i+1][0] += dp[i][0]*2;
                dp[i+1][0] %= MOD;
                dp[i+1][1] += dp[i][0];
                dp[i+1][1] %= MOD;
            }else{
                dp[i+1][0] += dp[i][0];
                dp[i+1][0] %= MOD;
            }
        }
        
        System.out.println((dp[n][0]+dp[n][1])%MOD);
        
    }
    
}

Measured memory_bytes: 30264
N=int(input())
L=list(map(int,input().split()))

ans=0
for i in range(N):
    a=L[i]
    for j in range(i+1,N):
        b=L[j]
        for k in range(j+1,N):
            c=L[k]
            if a!=b and b!=c and c!=a:
                if abs(a-b)<c and c<a+b:
                    ans+=1
print(ans)

Measured memory_bytes: 68316
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

int32_t main(){
	fastio;
  double R,PI =acos(-1);
  cin>>R;
  cout<<setprecision(5)<<fixed;
  cout<<(2.0*PI*R)<<endl;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, H;
  cin >> N >> H;
  long long a, b[N], A = 0, B = 0, answer = H;
  for (int i = 0; i < N; i++) {
    cin >> a >> b[i];
    A = max(A,a);
  }
  sort(b,b+N,greater<long long>());
  for (int i = 0; i < N; i++) {
    B += b[i];
    answer = min(answer,i+1+max(0ll,(long long)ceil((H-B)*1.0/A)));
  }
  cout << answer;
}

Measured memory_bytes: 4444
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def bitlist(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

#a = list(map(int, input().split()))


n,k,s = list(map(int, input().split()))

nu0 = 1000000000
nu1 =nu0-1
a=[]

if(s==nu0):
    for i in range(k):
        a.append(nu0)
    for i in range(n-k):
        a.append(nu1)
    print(' '.join(map(str,a)))
else:
    for i in range(k):
        a.append(s)
    for i in range(n-k):
        a.append(nu0)
    print(' '.join(map(str,a)))


Measured memory_bytes: 91932
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String code = sc.next();
        StringBuffer sb = new StringBuffer();
        char[] m = code.toCharArray();
        for (int i = 0; i < m.length; i++){
            sb.append(m[i]);
            if (i == 3){
                sb.append(" ");
            }
        }
        System.out.println(sb);
    }
}

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


using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> c(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	for (int i = 0; i < n; ++i) cin >> c[i];

	int sum = 0;
	for (int i = 0; i < n; ++i)
		if (v[i] > c[i])sum += (v[i] - c[i]);

	cout << sum << endl;

	return 0;
}

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

using namespace std;

template <class T>
struct Edge {
    int to;
    T cost;
    Edge(int to, T cost) : to(to), cost(cost){};
};

template <class T>
class Graph {
public:
    explicit Graph(int N = 0) : size(N) { path.resize(size); }
    void span(int u, int v, T cost = 1) { path[u].push_back(Edge<T>(v, cost)); }
    vector<Edge<T>> operator[](int v) const { return path[v]; }

    int size;
    vector<vector<Edge<T>>> path;
};

template <class T>
class TopologicalSort {
public:
    int size;
    Graph<T> graph;
    vector<bool> visited;
    vector<int> order, id;
    // トポロジカルソート後において、頂点vはid[v]番目

    void dfs(int v) {
        if (visited[v]) return;
        visited[v] = true;
        for (const auto& e : graph[v]) dfs(e.to);
        order.push_back(v);
    }

    explicit TopologicalSort(const Graph<T>& g) : size(g.size), graph(g) {
        visited.assign(size, false);
        for (int v = 0; v < size; ++v) dfs(v);
        reverse(order.begin(), order.end());

        id.resize(size);
        for (int i = 0; i < size; ++i) id[order[i]] = i;
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    Graph<int> graph(N);

    for (int i = 0; i < M; ++i) {
        int u, v;
        cin >> u >> v;
        graph.span(u, v);
    }

    TopologicalSort<int> ts(graph);
    for (int v : ts.order) cout << v << endl;
    return 0;
}


Measured memory_bytes: 4540
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    int like[m+1] = {};
    for (int i=0;i<n;i++){
        int k;
        cin >> k;
        for (int j=0;j<k;j++){
            int a;
            cin >> a;
        
            like[a] = like[a] + 1;
        
        }
    }
    int ans = 0;
    for (int i=0;i<=m;i++){
       if (like[i]==n) ans += 1;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    ll n; cin >> n;
    ll ans = 0;
    for(ll a=1; a<=(n-1); a++){
        ans += (n-1)/a;
    }
    cout << ans << endl;
}


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

int main()
{   
    int h,w;
    cin>>h>>w;
    string s[h];
    for(int i=0;i<h;i++) cin>>s[i];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int ans=0;
            if(s[i][j]=='#') cout<<'#';
            else{
                if(i-1>=0&&j-1>=0&&s[i-1][j-1]=='#') ans++;
                if(i-1>=0&&s[i-1][j]=='#') ans++;
                if(i-1>=0&&j+1<w&&s[i-1][j+1]=='#') ans++;
                if(j-1>=0&&s[i][j-1]=='#') ans++;
                if(j+1<w&&s[i][j+1]=='#') ans++;
                if(i+1<h&&j-1>=0&&s[i+1][j-1]=='#') ans++;
                if(i+1<h&&s[i+1][j]=='#') ans++;
                if(i+1<h&&j+1<w&&s[i+1][j+1]=='#') ans++;
                cout<<ans;
            }
        }
        cout<<endl;
    }
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
ll MOD = 1e9+7;
int main() {
  ll n;
  cin >> n;
  vl a(n);
  REP(i,n) cin >> a[i];

  ll ans = 0;
  ll t = 1;
  REP(T,60){
    if(T!=0) t *= 2;
    ll count = 0;
    REP(i,n){
      if(a[i]&t) count++;
    }
    ll tmp = t;
    tmp %= MOD;
    tmp *= count;
    tmp %= MOD;
    tmp *= n-count;
    tmp %= MOD;
    ans += tmp;
    ans %= MOD;
  }
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <assert.h>
 
#define int          long long
#define pb          push_back
#define pii         pair<int,int> 
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007 
#define mem(x)      memset(x,0,sizeof(x));
#define what_is(x)  cout << #x << " is " << x << flush << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
 
using namespace std;
const int maxn = 200010;
int n;
long double x, dp[maxn];
void solve(){
	cin>>n;
	dp[0] = 1;
	rep(coins, 0, n)
	{
		cin>>x;
		for(int i = coins+1; i>=0; i--)
			dp[i] = (i == 0 ? 0 : x * dp[i-1]) + (1-x)*dp[i];
	}
	long double ans = 0;

	rep(heads, 1, n+1)
	{
		int tails = n-heads;
		if(heads>tails)
		ans+= dp[heads];
	}
	cout<<setprecision(10)<<ans;

	



}
 
signed main(){
   
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
     //cin>>t;
 
    while(t--)
        solve();
    
    return 0;
}

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

int main(void){
    ll a; double b;
    cin >> a >> b;

    int ib = b*100+0.5;
    cout << (a*ib)/100 << endl;

    return 0;
}


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

template<class T>
void printIter(const T &a, string delimiter) {
    if (a.size() == 0) return;
    auto it = a.begin();
    cout << *it;
    it++;
    while (it != a.end()) {
        cout << delimiter << *it;
        it++;
    }
    cout << endl;
}

int main() {
    ll N, M;
    ll K;
    cin >> N >> M >> K;
    vector<ll> A(N);
    vector<ll> B(M);
    vector<ll> sumA(N);
    vector<ll> sumB(M);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if (i == 0) sumA[0] = A[i];
        else sumA[i] = sumA[i-1] + A[i];
    }
    for (int i = 0; i < M; ++i) {
        cin >> B[i];
        if (i == 0) sumB[0] = B[i];
        else sumB[i] = sumB[i-1] + B[i];
    }
    ll m = 0;
    for (int i = 0; i < N; ++i) {
        ll k = sumA[i];
        ll tempm = 0;
        if (k > K) break;
        tempm = i + 1;
        auto it = upper_bound(sumB.begin(), sumB.end(), K-k);
//        cout << k << ' ' << *(it-1) << endl;
//        cout << tempm << ' ' << (ll)distance(sumB.begin(), it) << endl;
        tempm += (ll)distance(sumB.begin(), it);
        m = max(m, tempm);
    }
    auto it = upper_bound(sumB.begin(), sumB.end(), K);
    ll tempm = (ll)distance(sumB.begin(), it);
    m = max(m, tempm);
    cout << m << endl;
}



Measured memory_bytes: 9560
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){cout << a << " " << b << " " << c << endl;}
#define INT_MAX 1<<30;
const int MAX = 1020000;
const double EPS = 1e-6;
const int mod = 1e9+7;
 
int main(){
    ll n; cin >> n;
    vl a(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    priority_queue<P> pq;
    rep(i,n){
        if(a[i]>b[i]){
            puts("-1");
            return 0;
        }else if(a[i]<b[i]){
            pq.emplace(b[i],i);
        }
    }
    ll ans = 0;
    while(!pq.empty()){
        P p = pq.top(); pq.pop();
        ll u = p.second;
        ll t = 0;
        if(u==0) t = b[n-1] + b[1];
        else t = b[u-1] + b[(u+1)%n];
        if(p.first-a[u] < t){
            puts("-1");
            return 0;
        }else{
            ans += (p.first-a[u])/t;
            b[u] -= (p.first-a[u])/t * t;
            if(b[u] != a[u]) pq.emplace(b[u],u);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9456
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
vector<ll>co(100010);
map<pll,ll>mapp;
vector<vector<ll> >G(100010);
void dfs(ll i,ll c,ll p){
    ll k=1;
    for(auto e:G[i]){
        if(k==c)k++;
        if(p==e)continue;
        dfs(e,k,i);
        ll s=mapp[mp(min(i,e),max(i,e))];
        co[s]=k;
        k++;
    }
}
int main(){
    ll n;
    cin>>n;
    vector<ll>cnt(n+1);
    rep(i,n-1){
        ll a,b;cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
        mapp[mp(a,b)]=i+1;
        cnt[a]++;
        cnt[b]++;
    }
    dfs(1,0,0);
    ll ans=1;
    REP(i,1,n+1){
        ans=max(ans,cnt[i]);
    }
    cout<<ans<<endl;
    rep(i,n-1){
        cout<<co[i+1]<<endl;
    }
}

Measured memory_bytes: 16640
n = input()
a = input()
b = input()
c = input()

la = list(a)
lb = list(b)
lc = list(c)

total = 0
for i in range(int(n)):
    count = 0
    if la[i] != lb[i]:
        count += 1
    if la[i] != lc[i]:
        count += 1
    if lb[i] != lc[i]:
        count += 1

    if count == 3:
        total += 2
    elif count == 2:
        total += 1
    elif count == 1:
        total += 1
    else:
        total += 0

print(total)

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


int main() {
  string str;
  cin >> str;
  int num_plus = 0;
  for (int i=0; i<4; ++i) {
    if (str.at(i) == '+') {
      num_plus++;
    }
  }
  int ans = 2 * num_plus - 4;
  cout << ans << endl;
  return 0;
}





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

string s;
string res;

void solve(int i, int sum,string ans){
    if(i == 4){
        if(sum == 7){
            ans += "=7";
            res = ans;
        }
        return;
    }
    ans += '+';
    int tmp = s[i] - '0';

    solve(i+1,sum+tmp,ans+s[i]);
    ans.erase(ans.size()-1);
    ans += '-';
    solve(i+1,sum-tmp,ans+s[i]);
}

int main(){
    cin>>s;
    string ans = "";
    int sum=0;
    ans += s[0];
    sum += s[0]-'0';
    solve(1,sum,ans);

    cout<<res<<endl;

    return 0;
}

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

int main(void) {
	int N,T,c[100],t[100];
	cin >> N >>T;
	for (int i = 0; i < N;i++)
		cin >> c[i] >> t[i];
	for (int i = 0;i < N; i++) {
		for (int j = 1;j < N;j++) {
			if (c[j - 1] > c[j]) {
				int n= c[j - 1];
				c[j - 1] = c[j];
				c[j] = n;
				n = t[j - 1];
				t[j - 1] = t[j];
				t[j] = n;
			}
			if (c[j - 1] == c[j] && t[j - 1] > t[j]) {
				int n = c[j - 1];
				c[j - 1] = c[j];
				c[j] = n;
				n= t[j - 1];
				t[j - 1] = t[j];
				t[j] = n;
			}
		}
	}
	for (int i = 0;i < N;i++) {
		if (t[i] <= T) {
			cout << c[i] << endl;
			return 0;
		}
	}
	cout << "TLE" << endl;
	return 0;

}


Measured memory_bytes: 256
K, A, B = map(int, input().split())

if B-A <= 2 or K<=A:
    print(K+1)

else:
    K -= A-1
    counter = A
    flag = K % 2
    K //= 2
    counter += (B-A) * K
    if flag:
        counter += 1

    print(counter)


Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

vector<int> v{3, 5, 7};

bool check(int x) {
    vector<int> has(3);
    while(x>0) {
        if(x%10 == 3) has[0]++;
        else if(x%10 == 5) has[1]++;
        else if(x%10 == 7) has[2]++;
        x /= 10;
    }

    REP(i, 3) if(has[i] == 0) return false;
    return true;
}

int main() {
    ll N, N_cp;
    cin >> N;
    N_cp = N;
    int num_digits = 0;
    REP(i, 10) {
        N_cp /= 10;
        num_digits++;
        if(N_cp==0) break;
    }
    
    vector< vector<int> > digits(10, vector<int>());
    for(int x: v) digits[0].push_back(x);

    for(int i=1; i<num_digits; i++) {
        for(int x: v) for(int y: digits[i-1]) digits[i].push_back(10*y + x);
    }

    int ans = 0;
    for(vector<int> vlist: digits) {
        for(int v: vlist) {
            if(v <= N && check(v)) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

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

    vector<string> text_list;
    rep(i, s.size() - t.size() + 1){
        bool flag = true;
        rep(j, t.size()){
            flag = ((t[j] == s[i + j]) || (s[i + j] == '?')) && flag;
        }

        if(flag){
            string s_tmp = s;
            rep(j, t.size()){
                s_tmp[i + j] = t[j];
            }
            rep(i, s_tmp.size()) if(s_tmp[i] == '?') s_tmp[i] = 'a';
            text_list.push_back(s_tmp);
        }
    }

    if(text_list.size() > 0){
        sort(all(text_list));
        cout << text_list[0] << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }
}

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

using namespace std;

int countDivisors(int n) 
{ 
    int count = 0; 
    for (int i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) {count++; }
            else { count += 2; }
        } 
    } 
    return count; 
} 

int main(){
	int n;
	cin >> n;
	ll ans[10'000'001];
	ans[1] = 1;

  	//get divisors
	ll div[n + 1]; 
    memset(div, 0, sizeof div); 
  
    for (int i = 1; i <= n; i++) { 
        for (int j = 1; j * i <= n; j++) div[i * j]++; 
    } 
  
  	//get value
    for (int i = 2; i <= n; i++) {
    	ans[i] = ans[i-1] + (i*div[i]);
    }
	cout  << ans[n] << endl;
	return 0;
}

Measured memory_bytes: 159900
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 1000005

using namespace std;






int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--)
    {
        ll a,b,c,k;
        cin>>a>>b>>c>>k;
        ll total=min(a,k);
        k-=min(a,k);
        total+=0;
        k-=min(b,k);
        total+=-1*(min(c,k));
        k-=min(c,k);
        cout<<total<<endl;




    }



    return 0;
}

Measured memory_bytes: 3652
n = int(input())
from math import gcd
cou = 0
for i in range(1,int(n**0.5)+1):
  if n%i==0:
    b = n//i-1
    if b>=2 and n//b==n%b:
      cou += b
    
    if i>2:
      c = i-1
      if n//c==n%c:
        cou += c
print(cou)

Measured memory_bytes: 9328
#include <stdio.h>

int calc_sum(n){
	int Sum = 0;
	for(int i = 1;i <= n;i++)
		Sum += i;
	return Sum;
}

int main(){
	int a, b;
	scanf("%d%d", &a, &b);
	int idx, ans;
	idx = b - a - 1;
	ans = calc_sum(idx) - a;
	
	printf("%d", ans);
	
	return 0;
}


Measured memory_bytes: 128
from functools import lru_cache
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
left = -10**9
right = 10**9

@lru_cache(maxsize=100000)
def cal(num):
  tmp = 0
  for i in range(n):
    tmp += abs(a[i]-(num+(i+1)))
  return tmp
 

while abs(right-left)>1:
  mid = (right+left)//2
  if cal(mid-1)<cal(mid+1):
    right = mid
  else:
    left = mid
print(min(cal(left),cal(right)))
    

Measured memory_bytes: 103084
#include <iostream>
using namespace std;
#define m 500000
#define s 2000000000;
int L[m/2+2],R[m/2+2];
int cnt;
void merge(int A[],int a,int mid,int b){
	int n1 = mid - a;
	int n2 = b - mid;
	for(int i=0;i<n1;i++) L[i] = A[a+i];
	for(int i=0;i<n2;i++) R[i] = A[mid+i];
	L[n1] = R[n2] = s;
	int i = 0,j = 0;
	for(int k=a;k<b;k++){
		cnt++;
		if(L[i]<=R[j]) A[k] = L[i++];
		else A[k] = R[j++];
	}
}
void mergeSort(int A[],int a,int b)
{
	if(a+1<b){
		int mid = a + ((b-a)>>1);
		mergeSort(A,a,mid);
		mergeSort(A,mid,b);
		merge(A,a,mid,b);
	}
}
void print(int A[],int n){
	for(int i=0;i<n;i++){
		if(i) cout<<" ";
		cout<<A[i];
	}
	cout<<endl;
}
int main(){
	int A[m],n;
	cnt = 0;
	cin>>n;
	for(int i=0;i<n;i++) cin>>A[i];
	mergeSort(A,0,n);
	print(A,n);
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 6920
import java.io.*;
class Main{
    public static void main(String[] args)throws IOException{
	BufferedReader br =
	    new BufferedReader(new InputStreamReader(System.in));
	int n=Integer.parseInt(br.readLine());
	for(int i=0;i<n;i++){
	    System.out.println(br.readLine().replaceAll("Hoshino","Hoshina"));
	}
    }
}

Measured memory_bytes: 9356
/***** TheAnshul *****/

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
#define N  100005
ll dp[N];
ll a[N];
ll n;
ll fun(ll i)
{
	if(i==n)
		return 0;
	else if(i==n-1)
		return (abs(a[n]-a[n-1]));
	if(dp[i]!=-1)
	{
		return dp[i];
	}
	dp[i]=min(fun(i+1)+abs(a[i]-a[i+1]),fun(i+2)+abs(a[i]-a[i+2]));
	return dp[i];
}
void solve()
{
	cin>>n;
	rep(i,1,n+1)
	{
		cin>>a[i];
	}
	rep(i,1,n+1)
	{
		dp[i]=-1;
	}
	cout<<fun(1);
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	time
	return 0;
}

Measured memory_bytes: 3328
n = int(input(''))
alist = list(map(int,input('').split()))
money=1000
stock=0

for d in range(n-1):
    if stock ==0:
        if alist[d+1] > alist[d]:
            # 明日上がるなら買い
            stock=int(money/alist[d])
            money-=stock*alist[d]
        else:
            # 明日下がる場合は何もしない
            pass
    else:
        if alist[d+1] > alist[d]:
            # 明日上がるなら全部売ってから買い
            money+=stock*alist[d]
            stock=int(money/alist[d])
            money-=stock*alist[d]
        else:
            # 明日下がる場合で株を持っていたら売り
            money+=stock*alist[d]
            stock=0

money+=stock*alist[n-1]
stock=0
print(money)

Measured memory_bytes: 9204
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <unordered_map>
#include <numeric>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int n;
    cin >> n;
    if(n==1){
        cout <<"Hello World" << endl;
    }else{
        int a,b;
        cin >> a >> b;
        cout << a + b << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

char s[101];
int a,b,c,d;
int main(){
    scanf("%d%d",&a,&b);
if (a>=b){
    c=a;
    d=b;
}
else{
    c=b;
    d=a;
}
    for (int i = 1; i<=c; i++) {

    printf("%d",d);}

    return 0;
}

Measured memory_bytes: 1716
#include<cstdio>
int main(){
    int n;
    while(~scanf("%d",&n)){
        int ans=0;
        for(int i=0;i<=9;i++){
            for(int j=0;j<=9;j++){
                for(int k=0;k<=9;k++){
                    for(int l=0;l<=9;l++){
                        if(i+j+k+l==n) ans++;
                    }
                }
            }
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 0
function Main(input) {
  var s = input.split("\n")[0];
  var n = s.length;
  var start;
  var end;

  for (var i = 0; i < n; i++) {
    if (s[i] === "A") {
      start = i;
      break;
    }
  }
  for (var i = n - 1; i >= 0; i--) {
    if (s[i] === "Z") {
      end = i;
      break;
    }
  }

  console.log(end - start + 1);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod=1e9+7;
const int nax=2e5+10;
int add(int a,int b){
	int ans=(a+b)%mod;
	if(ans<0) ans+=mod;
	return ans;
}
int mul(int a,int b){
	return (ll) a*b %mod;
}
int fac[nax],inv[nax];
int power(int a,int b){
	int ans=1;
	while(b){
		if(b%2) ans=mul(ans,a);
		b/=2;
		a = mul(a,a);
	}
	return ans;
}
int ncr(int n,int r){
	if(n<0 or r<0 or n<r)return 0;
	return mul(fac[n], mul(inv[r],inv[n-r]));
}
int f(int a,int b){
	return ncr(a+b,a);
}
int dp[30010];
int main(){
	IOS;
	fac[0]=inv[0]=1;
	for (int i = 1; i < nax; ++i)
	{
		fac[i]=mul(fac[i-1],i);
		inv[i]=power(fac[i],mod-2);
	}
	int h,w;
	cin>>h>>w;
	int n;
	cin>>n;
	vector<pair<int,int> >a;
	for (int i = 0; i < n; ++i)
	{
		int r,c;
		cin>>r>>c;
		a.emplace_back(r,c);
	}
	sort(a.begin(), a.end());
	a.emplace_back(h,w);
	for (int i = 0; i < n+1; ++i)
	{
		int r=a[i].first,c=a[i].second;
		int tot=f(r-1,c-1);
		for (int j = 0; j < i; ++j)
		{
			tot = add(tot , -mul(f(r-a[j].first , c-a[j].second),dp[j]));
		}
		dp[i]=tot;
	}
	cout<<dp[n]<<endl;
	return 0;
}

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

int main(){
 
    int N;
    cin>>N;
    vector<int> S(N);
    int sum;
    for(int i=0;i<N;i++){
        cin>>S[i];
        sum+=S[i];
    }
    if(sum%10!=0) cout<<sum<<endl;
    else{
        sort(S.begin(),S.end());
        bool flag=true;
        int i=0;
        while(flag){
            if((sum-S[i])%10!=0){
                cout<<sum-S[i]<<endl;
                flag=false;
            }
            else i++;
            if(i==N){
                flag=false;
                cout<<0<<endl;
            }
        }
    }
}


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

int n;
long long int a[200010];
long long int ans;
map<long long int, long long int> m;
typedef pair<long long int, long long int> P;

int main(){
	cin >> n;
	a[0] = 0;
	for(int i=0; i<n; ++i)
		cin >> a[i+1];
	for(int i=1; i<n+1; ++i)
		a[i] += a[i-1];
	for(int i=0; i<n+1; ++i){
		auto it = m.find(a[i]);
		if(it != m.end()){
			long long int val = it->second;
			ans += val;
			m[a[i]] = val+1;
		}else{
			m.insert(P(a[i], 1));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 14336
import sys
import  math
import bisect
from statistics import *
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

h, w = na()
li = []
for i in range(h):
    li.append(input())
for i in range(h):
    for j in range(w):
        ct = 0
        if li[i][j] == "#":
            print("#", end="")
        else:
            for p in [li[i-1+k][j-1+l] for k in range(3) for l in range(3) if 0<=i-1+k<=h-1 and 0<=j-1+l<=w-1]:
                if p == "#":
                    ct += 1
            print(ct, end="")
    print()


Measured memory_bytes: 5784
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;

int n, x;

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

int main() {
	read(n);
	while (n--) {
		read(x);
		if (x & 1) continue;
		if (x % 3 && x % 5) return printf("DENIED\n"), 0;
	}
	printf("APPROVED\n");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

const int MAXN = 201;
const int INF = 1000000000;

int N, M, R;
V<int> r;

int field[MAXN][MAXN];
int dist[MAXN][MAXN];
void fw() {
    FOR(i,1,N+1) FOR(j,1,N+1) {
        if(i == j) dist[i][j] = 0;
        else dist[i][j] = ((field[i][j]!=-1) ? field[i][j] : INF);
    }

    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                dist[j][k] = std::min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

int main(){
    INIT;
    cin >> N >> M >> R;
    REP(i,R) { int x; cin >> x; r.push_back(x); }
    FOR(i,1,N+1) FOR(j,1,N+1) field[i][j] = -1;
    REP(i,M) {
        int a, b, c;
        cin >> a >> b >> c;
        field[a][b] = c;
        field[b][a] = c;
    }
    fw();
    int ans = INF;
    std::sort(ALL(r));
    do {
        int x = 0; REP(i,R-1) { x += dist[r[i]][r[i+1]]; }
        ans = std::min(ans, x);
    } while(next_permutation(ALL(r)));
    cout << ans;
}

Measured memory_bytes: 640
#include<stdio.h>
#define WHITE 1
#define BLACK 0

int mat[101][101];
int d[101];
int pi[101];
int color[101];
int n;

void prim(int r){
  int i,mincost,u;
  for(i = 1; i <= n; i++ ){
    d[i] = 2001;
    pi[i] = -1;
    color[i] = WHITE;
  }

  d[r] = 0;

  while(1){
    mincost = 2001;
    for( i = 1; i <= n; i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }
    if(mincost == 2001) break;

    color[u] = BLACK;

    for(i = 1;i <= n; i++){
      if(color[i] != BLACK && mat[u][i] != -1 && mat[u][i] < d[i]){
	pi[i] = u;
	d[i] = mat[u][i];
      }
    }
  }
  
}

int main(){
  int i,j,g=0;

  scanf("%d",&n);

  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      scanf("%d",&mat[i][j]);
    }
  }

  prim(1);
  for(i = 1; i  <= n; i++) g += d[i];
  
  printf("%d\n",g);
  
}



Measured memory_bytes: 2104
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int A, B, K;
    cin >> A >> B >> K;

    ll len = B - A + 1;
    if(len <= 2*K){
        // all
        FOR(i, 0, len){
            p(A+i);
        }
    }else{
        FOR(i, 0, K){
            p(A+i);
        }
        FOR(i, 0, K){
            p(B-K+1+i);
        }
    }

    
    return 0;
}

Measured memory_bytes: 256
D = int(input())
C = list(map(int, input().split()))
S = []
for day in range(D):
  S.append(list(map(int, input().split())))
T = []
for day in range(D):
  T.append(int(input()) - 1)
lasts = [-1] * 26
ans = 0
# simulate every day.
for day in range(D):
  ans += S[day][T[day]]
  lasts[T[day]] = day
  # verification for each contests.
  for i in range(26):
      ans -= C[i] * (day - lasts[i])
  print(ans)


Measured memory_bytes: 9044
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

const int N=1000006;

int n,s1,s2;
char s[N];

int main(){
	int i;
	scanf("%s",s+1); n=strlen(s+1);
	for (i=1;i<=n;i++){
		if (s[i]=='N') s1|=1;
		if (s[i]=='S') s1|=2;
		if (s[i]=='E') s2|=1;
		if (s[i]=='W') s2|=2;
	}
	if (s1==0) s1=3;
	if (s2==0) s2=3;
	if (s1!=3||s2!=3) printf("No\n");
	else printf("Yes\n");
	return 0;
}

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

int main()
{
	int n,m;
	int i,j;
	while(scanf("%d",&n),n)
	{
		char*** table;
	
		table = (char***)malloc(sizeof(char**)*n);
		for(i = 0;i < n;i++)
		{
			table[i] = (char**)malloc(sizeof(char*)*2);
			table[i][0] = (char*)malloc(sizeof(char)*2);
			table[i][1] = (char*)malloc(sizeof(char)*2);
			scanf("%s %s",table[i][0],table[i][1]);
		}
		scanf("%d",&m);
		for(i = 0;i < m;i++)
		{
			char c[2];
			scanf("%s",c);
			for(j = 0;j < n;j++)
			{
				if(*c == table[j][0][0])
				{
					*c = table[j][1][0];
					break;
				}
			}
			printf("%c",*c);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define ll long long
#define hh puts("")
#define pc putchar
#define mo 1000000007
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
using namespace std;
const int N=100005;
int n,m,head[N],cnt,in[N],tot[N],from[N],ans;
struct Edge{
	int v,nx;
}e[N<<1];
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-1;ch=getchar();}
    while(isdigit(ch)){ret=ret*10+(ch^48);ch=getchar();}
    return ret*ff;
}
void write(int x){if(x<0){x=-x,pc('-');}if(x>9) write(x/10);pc(x%10+48);}
void writeln(int x){write(x),hh;}
void writesp(int x){write(x),pc(' ');}
void add(int x,int y){
	e[++cnt].v=y;
	e[cnt].nx=head[x];
	head[x]=cnt;
}
signed main(){
	n=read(),m=read();
	for(int i=1;i<n;i++){
		int x=read(),y=read();
		add(x,y),add(y,x);
	}
	ans=1;
	queue<int> q;
	q.push(1);in[1]=1;
	while(!q.empty()){
		int now=q.front();
		q.pop();
		if(now==1) ans=m;
		else{
			if(m-tot[from[now]]-1<=0){
				write(0);
				return 0;
			}
			else ans=1ll*ans*(m-tot[from[now]]-1)%mo;
			tot[from[now]]++;//¾àÀëÎª1µÄ 
			tot[now]++;
		}
		for(int i=head[now];i;i=e[i].nx){
			int v=e[i].v;
			if(!in[v]) q.push(v),in[v]=1,from[v]=now;
		}
	}
	write(ans);
	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll H,W; cin >> H >> W;
    vector <string> Grid(H);
    loop(i,0,H) cin >> Grid[i];
    queue <pair <pair<int, int>, int> > Q;
    vector < vector <bool> > visited(H, vector<bool> (W, false));
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            if (Grid[i][j]=='#') {
                Q.push({{i,j},0});
                visited[i][j]=true;
            }
        }
    }
    int ans=0;
    while (!Q.empty())
    {
        pair <int,int> cur=Q.front().first;
        int op=Q.front().second;
        ans=max(ans,op);
        Q.pop();
        if (cur.first>0 && !visited[cur.first-1][cur.second]) {
            visited[cur.first-1][cur.second]=true;
            Q.push({{cur.first-1, cur.second}, op+1});
        }
        if (cur.second>0 && !visited[cur.first][cur.second-1]) {
            visited[cur.first][cur.second-1]=true;
            Q.push({{cur.first, cur.second-1}, op+1});
        }
        if (cur.first<H-1 && !visited[cur.first+1][cur.second]) {
            visited[cur.first+1][cur.second]=true;
            Q.push({{cur.first+1, cur.second}, op+1});
        }
        if (cur.second<W-1 && !visited[cur.first][cur.second+1]) {
            visited[cur.first][cur.second+1]=true;
            Q.push({{cur.first, cur.second+1}, op+1});
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
  string N; cin >> N;
  if (N.at(0) == '7' || N.at(1) == '7' || N.at(2) == '7') {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}


Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(4100000)

mod = 10 ** 9 + 7

N, K = map(int,input().split())
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

ans = K

def factorial(n, k, mod):
    fact = 1
    for integer in range(n, n-k, -1):
        fact *= integer
        fact %= mod
    return fact

def dfs(parent, current):
    ret = 1
    for child in graph[current]:
        if child != parent:
            ret *= dfs(current, child)
    L = len(graph[current])
    R = K - 1
    if parent != -1:
        L -= 1
        R -= 1
    ret *= factorial(R, L, mod)
    return ret % mod

ans *= dfs(-1, 0)
ans %= mod

print(ans)

Measured memory_bytes: 87364
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
int nmax=200000;
vvec g(nmax);
vec dp(nmax);

void dfs(int now){
    vec st;
    for(auto next:g[now]){
        dfs(next);
        st.pb(dp[next]);
    }
    int cnt=0LL;
    sort(all(st));
    rep(i,st.size()){
        chmax(cnt,st[i]+ll(st.size())-i);
    }
    dp[now]=cnt;
    return;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    rep(i,n-1){
        int a;cin>>a;a--;
        g[a].pb(i+1);
    }
    dfs(0);
    cout<<dp[0]<<endl;
}

Measured memory_bytes: 17408
// youngjinp20
// 2020 03

#include <bits/stdc++.h>
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }
#define byr(x) [](const auto& a, const auto& b) { return a.x > b.x; }
#define smax(a, b) ((a) < (b) ? ((a)=(b), true) : false)
#define smin(a, b) ((a) > (b) ? ((a)=(b), true) : false)
using namespace std;

typedef long long ll;

const int MAX = 401;
int N;
ll a[MAX];
ll dp[MAX][MAX];
ll sum[MAX];

ll solve(int l, int r) {
	if (dp[l][r]) return dp[l][r];
	if (l == r) return 0;

	ll cost = 1e18;

	for (int i=l; i<r; i++) {
		smin(cost, solve(l,i) + solve(i+1,r));
	}

	return dp[l][r] = cost + sum[r] - sum[l-1];
}

int main() {
	cin >> N;
	ll ct = 0;
	for (int i=1; i<=N; i++){
		cin >> a[i];
		ct += a[i];
		sum[i] = ct;
	}
	cout << solve(1, N);
	return 0;
}


Measured memory_bytes: 1536
/*
    nah nah nah
*/
#include <bits/stdc++.h>
#define ll long long
#define fir first
#define sed second
#define i64 int64_t
#define pii pair< int,int >
using namespace std;
ifstream fi("");
ofstream fo("");

int main(){

ll a,b,c;
cin>>a>>b>>c;
if (a+b+c>=22) cout<<"bust"; else cout<<"win";
}


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


if K % 2 == 0:
    print(-1)

else:
    seen = set()
    ans = 1
    num = 7
    while ans <= K:

        mod = num % K
        if mod in seen:
            ans = -1
            break
        else:
            seen.add(mod)
        
        if mod == 0:
            break
        else:
            num = mod * 10 + 7
            ans += 1
    
    print(ans)



Measured memory_bytes: 200444