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

using namespace std;

#define ll         long long int
#define eb         emplace_back

static const int maxn = 2e5 + 5;

struct information
{
      ll h, d;
      information(ll h = 0, ll d = 0) : h(h), d(d) {}
      inline bool operator < (const information &p) const
      {
            return h < p.h;
      }
};

int N;
ll height[maxn];
ll score[maxn];
ll dp[maxn];

inline void divideConquer(int l, int r)
{
      if (l >= r) return;
      int mid = (l + r) / 2;
      divideConquer(l, mid);
      vector <information> vec;
      for (int i = l; i <= mid; i++)  vec.eb(height[i], dp[i]);
      sort(vec.begin(), vec.end());
      int n = vec.size();
      vector <ll> prefixMax(n);
      ll maxi = -1;
      for (int i = 0; i < n; i++)
      {
            if (vec[i].d > maxi) maxi = vec[i].d;
            prefixMax[i] = maxi;
      }
      for (int i = mid+1; i <= r; i++)
      {
            ll h = height[i];
            auto it = lower_bound(vec.begin(), vec.end(), h) - vec.begin();
            --it;
            if (it >= 0 && it < n)
            {
                  dp[i] = max(dp[i], score[i] + prefixMax[it]);
            }
      }
      divideConquer(mid+1, r);
}

int main()
{
      //freopen("in.txt", "r", stdin);

      cin >> N;
      for (int i = 1; i <= N; i++)
      {
            cin >> height[i];
      }
      for (int i = 1; i <= N; i++)
      {
            cin >> score[i];
            dp[i] = score[i];
      }
      divideConquer(1, N);
      ll maxi = -1;
      for (int i = 1; i <= N; i++) if (dp[i] > maxi) maxi = dp[i];
      cout << maxi;
}


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

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

  if(a > b) swap(a, b);
  if(b > c) swap(b, c);
  if(a > b) swap(a, b);

  cout<<a<<" "<<b<<" "<<c<<endl;
  return 0;
}


Measured memory_bytes: 3060
fun main(args:Array<String>){
    val (H,N) = readLine()!!.split(" ").map{it.toInt()}
    val sp = readLine()!!.split(" ").map(String::toInt)
    //println(H)
    //println(N)
    //println(sp)
    
    val total = sp.reduce{x,y -> x+y}
    //println(total)
    
    println(if(H<=total) "Yes" else "No")
}

Measured memory_bytes: 51592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int i = 0;

		while (i < 1) {
			boolean sosu = true;
			int y = 2;
			while (sosu) {
				if (X % y == 0) {
					sosu = false;
				}
				if (X == y) {
					sosu = false;
					i++;
				}
				y++;
			}
			X++;
		}
		System.out.println(X-1);

	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define boost std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
constexpr int MAXN = 3e5 + 5;
constexpr int LOG = 25;
constexpr int BIT = 24;
using namespace std;
template <typename T> inline void read(T &x) {
    int f = 1; x = 0;
    char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}
vector <pair <int, int> > G[MAXN];
int L;
int main() {
    cin >> L;
    double tmp = L / 3.0;
    cout << setprecision(12) << fixed << tmp * tmp * tmp;
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//const ll MOD = 998244353;
typedef pair<ll,ll> P;

const int MAX_N = 3000;
vec nCm(MAX_N+1,0);
vec fact(MAX_N+1,0),fact_inv(MAX_N+1,0);

ll fastpow(ll a, ll pw, ll MOD) {
	ll res = 1;
	while (pw) {
		if (pw & 1) res = res * a % MOD;
		a = a * a % MOD;
		pw >>= 1;
	}
	return res;
}
void makefact(ll n, ll MOD){//MODは素数かつnより大きい
    ll ans = 1;
    fact.at(0) = ans;
    fact_inv.at(0) = ans;
    reps(i,1,n+1){
        (ans *= i)%=MOD;
        fact.at(i) = ans;
        fact_inv.at(i) = fastpow(ans,MOD-2,MOD);
    }
    return;
}
void makenCm(ll n, ll MOD){
    rep(i,n+1){
        ll ans = fact.at(n);
        (((ans*=fact_inv.at(n-i))%=MOD)*=fact_inv.at(i))%=MOD;
        nCm.at(i) = ans;
    }
    return;
}

int main() {
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    vec b(N,0);
    makefact(N-1, N);
    makenCm(N-1, N);
    rep(i,N){
        if(a[i] == 1){
            ll facti = 1;
            rep(j,N){
                (b[j] += N*N - nCm.at(j)*facti)%=N;
                (facti *= N - i)%=N;
            }
            (b[N-1] += 1)%=N;
        }
    }
    rep(i,N) cout<<b[N-1-i]<<' ';
    cout<<endl;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a == b + c){
			System.out.print("Yes");
		}
		else if(b == a + c){
			System.out.print("Yes");
		}
		else if(c == a + b){
			System.out.print("Yes");
		}
		else{
			System.out.print("No");
		}

	}

}


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



int main(){
   int a, b;
   cin >> a>> b;
   if(a>8||b>8) cout<< ":(" << endl;
   else cout << "Yay!" << endl;
      }

Measured memory_bytes: 256
#include <stdio.h>

int unique(int [], int);
void pri(int [], int);

int main(void)
{
    int i, n, A[100000];

    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", A + i);
    
    n = unique(A, n);
    pri(A, n);
    return 0;
}

int unique(int A[], int N)
{
    int i, j;

    for (i = 0, j = 1; j < N; j++)
        if (A[i] != A[j])
            A[++i] = A[j];
    return i + 1;
}

void pri(int A[], int N)
{
    int i;
    
    for (i = 0; i < N; i++) {
        if (i > 0) putchar(' ');
        printf("%d", A[i]);
    }
    putchar('\n');
}


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

int main(){
	int h, w;
	while(true) {
		scanf("%d%d", &h, &w);
		if(h == 0 && w == 0) break;
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
}



Measured memory_bytes: 3096
#include<iostream>

using namespace std;
int main()
{
int n,d,x,ans=0;
int a[1001];
cin>>n>>d>>x;
for(int i=1;i<=n;i++)
{
	cin>>a[i];
	ans++;
	int s=a[i];
	while(s<=d)
	{
		if(s+1<=d) ans++;
		s+=a[i];
	}
}
cout<<ans+x;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int64_t N,A,b[200001]={};
    int64_t i,j,k;

    cin>>N;
    for(i=2;i<=N;i++){
        cin>>A;
        b[A]++;
    }
    for(i=1;i<=N;i++){
        cout<<b[i]<<endl;
    }
    return 0;

}


Measured memory_bytes: 5196
import java.util.Scanner;

public class Main {
	static boolean[][] nodes;
	static int cnt = 0;

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

		char a = sc.next().charAt(0);
		char b = sc.next().charAt(0);

		char ans = 'H';
		if (a == 'H') {
			if (b == 'D') {
				ans = 'D';
			}
		} else {
			if (b == 'H') {
				ans = 'D';
			}
		}

		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> an(N);
  vector<int> bn(N);

  REP(n,N) cin >> an.at(n);
  REP(n,N) bn.at(n) = 0;

  int cnt = 0;
  int i;
  RREP(n,N){
    cnt = 0;
    for (i= 2*(n+1); i <= N; i += (n+1)) cnt += bn.at(i-1);
    if( cnt%2 != an.at(n)) bn.at(n) = 1;
  }

  cout << accumulate(bn.begin(), bn.end(), 0) << endl;
  REP(n,N) if(bn.at(n) == 1) cout << n+1 << " ";
  cout << endl;

}

Measured memory_bytes: 2432
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	int n,k;
	cin>>n>>k;
	cout<<(k<=(n+1)/2?"YES":"NO")<<endl; 
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
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;
}

int main(){
   double w,h,x,y;
   cin>>w>>h>>x>>y;

   double cx=w/2;
   double cy=h/2;
   bool f=false;
   if(cx==x && cy==y) f=true;
   cout<<std::setprecision(10)<<double(w)*double(h)/2;
   cout<<" ";
   f? cout<<1:cout<<0;
   return 0;
}


Measured memory_bytes: 3784
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

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

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 21) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 100010;
const int MOD = 1000000007;
const int INF = 1000000000;

int main()
{
	
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; ++ i)
	{
		int cnt = 0;
		for (int j = 1; j <= i; ++ j)
			if (i%j == 0) cnt ++;
		if (i%2 == 1 && cnt == 8) ++ ans;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1<<20|3,mo=998244353;
int n,m,a[26][26],f[26][26],g[26][26],C[26][26],p[26],q[26],fac[N],ifac[N];
inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
inline void sub(int &x, int y){x=x-y>=0?x-y:x-y+mo;}
inline int power(int a, int n) {
	int res=1;
	while (n) {
		if (n&1) res=1LL*res*a%mo;
		a=1LL*a*a%mo; n>>=1;
	}
	return res;
}
void iniC(int n){
	fac[0]=1;rep(i,1,n)fac[i]=1LL*fac[i-1]*i%mo;
	ifac[n]=power(fac[n],mo-2);
	per(i,n-1,0)ifac[i]=1LL*ifac[i+1]*(i+1)%mo;
}
int dfs(int dep, int lim, int n, int m){
	if(dep>n){
		int res=1ll*fac[n]*fac[m]%mo;
		rep(i,1,n){
			int j=i;while(j+1<=n&&p[j+1]==p[i])j++;
			res=1ll*res*ifac[j-i+1]%mo;i=j;
		}
		memset(q,0,sizeof(q));
		rep(i,1,n)q[p[i]]++;
		per(i,m,1)q[i]+=q[i+1];
		rep(i,1,m){
			int j=i;while(j+1<=m&&q[j+1]==q[i])j++;
			res=1ll*res*ifac[j-i+1]%mo;i=j;
		}
		return res;
	}
	int res=0;
	while(lim>=0){
		p[dep]=lim;add(res,dfs(dep+1,lim,n,m));lim--;
	}
	return res;
}
int solve(int n, int m){
	return dfs(1,m,n,m);
}
bool gg1[16][1<<10|3],gg2[16][1<<10|3];
bool ck(int s, int t){
	rep(i,1,n)if((s>>i-1&1)&&gg1[i][t])return 0;
	rep(i,1,m)if((t>>i-1&1)&&gg2[i][s])return 0;
	return 1;
}
int main() {
	iniC(20);
	rep(i,0,20){
		C[i][0]=C[i][i]=1;
		rep(j,1,i-1)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	}

	n=10;m=10;
	rep(i,0,10)rep(j,0,10)f[i][j]=solve(i,j);
	rep(i,1,10)rep(j,1,10)rep(x,0,i)rep(y,0,j)
		g[i][j]=(g[i][j]+1ll*C[i][x]*C[j][y]%mo*f[x][j-y]%mo*f[i-x][y])%mo;
	g[0][0]=1;
		
	read(n);read(m);rep(i,1,n){
		char S[27];scanf("%s",S+1);rep(j,1,m)a[i][j]=S[j]=='#';
	}
	rep(i,1,n)rep(t,1,(1<<m)-1){
		int tot=0,cur=0;
		rep(j,1,m)if(t>>j-1&1)tot++,cur+=a[i][j];
		gg1[i][t]=tot==cur||0==cur;
	}
	rep(j,1,m)rep(s,1,(1<<n)-1){
		int tot=0,cur=0;
		rep(i,1,n)if(s>>i-1&1)tot++,cur+=a[i][j];
		gg2[j][s]=tot==cur||0==cur;
	}
//	rep(i,1,n)rep(j,1,m)printf("%d %d:%d\n",i,j,f[i][j]);
//	printf("qwq %d %d\n",gg1[1][3],gg2[2][3]);
	int res=f[n][m];
	rep(s,1,(1<<n)-1)rep(t,1,(1<<m)-1)if(ck(s,t)){
	//	printf("%d %d\n",s,t);
		int x=n;rep(i,0,n-1)x-=s>>i&1;
		int y=m;rep(i,0,m-1)y-=t>>i&1;
		
		if(!x&&!y)add(res,1);
		else if(!x)add(res,power(2,y));
		else if(!y)add(res,power(2,x));
		else add(res,g[x][y]);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

template< typename flow_t >
struct Dinic {
  const flow_t INF;

  struct edge {
    int to;
    flow_t cap;
    int rev;
    bool isrev;
    int idx;
  };

  vector< vector< edge > > graph;
  vector< int > min_cost, iter;

  Dinic(int V) : INF(numeric_limits< flow_t >::max()), graph(V) {}

  void add_edge(int from, int to, flow_t cap, int idx = -1) {
    graph[from].emplace_back((edge) {to, cap, (int) graph[to].size(), false, idx});
    graph[to].emplace_back((edge) {from, 0, (int) graph[from].size() - 1, true, idx});
  }

  bool bfs(int s, int t) {
    min_cost.assign(graph.size(), -1);
    queue< int > que;
    min_cost[s] = 0;
    que.push(s);
    while(!que.empty() && min_cost[t] == -1) {
      int p = que.front();
      que.pop();
      for(auto &e : graph[p]) {
        if(e.cap > 0 && min_cost[e.to] == -1) {
          min_cost[e.to] = min_cost[p] + 1;
          que.push(e.to);
        }
      }
    }
    return min_cost[t] != -1;
  }

  flow_t dfs(int idx, const int t, flow_t flow) {
    if(idx == t) return flow;
    for(int &i = iter[idx]; i < graph[idx].size(); i++) {
      edge &e = graph[idx][i];
      if(e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
        flow_t d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  flow_t max_flow(int s, int t) {
    flow_t flow = 0;
    while(bfs(s, t)) {
      iter.assign(graph.size(), 0);
      flow_t f = 0;
      while((f = dfs(s, t, INF)) > 0) flow += f;
    }
    return flow;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      for(auto &e : graph[i]) {
        if(e.isrev) continue;
        auto &rev_e = graph[e.to][e.rev];
        cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
      }
    }
  }
};

int main(){
  int n;
  cin >> n;
  int a[n],b[n];
  int c[n],d[n];
  rep(i,n)cin >> a[i] >> b[i];
  rep(i,n)cin >> c[i] >> d[i];
  Dinic<int> G(2*n+2);
  rep(i,n){
    rep(j,n){
      if(a[i]<c[j]&&b[i]<d[j]){
        G.add_edge(i+1,j+1+n,1);
      }
    }
  }
  rep(i,n)G.add_edge(0,i+1,1);
  rep(i,n)G.add_edge(n+1+i,2*n+1,1);
  cout << G.max_flow(0,2*n+1) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define read(x) scanf("%d",&x)
string S,T;
string S2,S3;
const ll P=1e9+21,MOD=1e9+7;
const ll H=13;
int maxMatch[4500005];
ll Hpow[4500005];
int Tsize;
int main(){
	ios::sync_with_stdio(false);
	cin>>S>>T;Tsize=T.size();
	Hpow[0]=1;
	for (int i=1;i<4500005;++i) Hpow[i]=Hpow[i-1]*H%MOD;
	while(S2.size()<=Tsize+S.size()) S2+=S;
	// max len of S=1.5e6
	S3=S2;S2+=S2;S3+=S2;
	ll hashT=0;
	for (int i=0;i<Tsize;++i){
		hashT+=T[i];hashT*=H;hashT%=MOD;
	}
	ll hashS=0;
	for (int i=0;i<Tsize;++i){
		hashS+=S2[i];hashS*=H;hashS%=MOD;
	}
	if (hashS==hashT) maxMatch[Tsize-1]=1;// end pos
	int ans2=maxMatch[Tsize-1];
	for (int i=Tsize;i<S2.size();++i){
		hashS-=S2[i-Tsize]*Hpow[Tsize]%MOD;
		hashS+=S2[i];
		if (hashS<0) hashS+=MOD;
		hashS*=H;
		hashS%=MOD;
		if (hashS==hashT) maxMatch[i]=maxMatch[i-Tsize]+1;
		ans2=max(ans2,maxMatch[i]);
	}
	int ans3=ans2;
	for (int i=S2.size();i<S3.size();++i){
		hashS-=S3[i-Tsize]*Hpow[Tsize]%MOD;
		hashS+=S3[i];
		if (hashS<0) hashS+=MOD;
		hashS*=H;
		hashS%=MOD;
		if (hashS==hashT) maxMatch[i]=maxMatch[i-Tsize]+1;
		ans3=max(ans3,maxMatch[i]);
	}
	if (ans3!=ans2) cout<<-1<<endl;
	else cout<<ans2<<endl;
	return 0; 
}

Measured memory_bytes: 62732
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n) cin >>x[i];
    sort(all(x));

    ll ans = INF;
    for (int i=1;i<=100;++i) {
        ll sum = 0;
        rep(j, n) {
            sum += abs(x[j] - i) * abs(x[j] - i);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>


int main(int argc, char const *argv[]) {
    int x[100],y[100];
    int N,M,X,Y;
    int key_x,key_y;
    
    scanf("%d %d %d %d",&N,&M,&X,&Y);
    
    key_x = X;
    key_y = Y;

    for(int i = 0; i < N; i++){
        scanf("%d",&x[i]);
        if(key_x < x[i]) key_x = x[i];
    }
    for(int i = 0; i < M; i++){
        scanf("%d",&y[i]);
        if(key_y > y[i]) key_y = y[i];
    }

    if (key_x < key_y) printf("No War");
    else printf("War");

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl 	"\n"

typedef vector< ll > 	vi;
typedef vector< vi > 	vvi;
typedef pair< ll,ll > 	ii;

#define pb 		push_back
#define all(c) 		(c).begin(),(c).end()
#define present(c,x) 	((c).find(x) != (c).end())
#define rep(i,n)        for(ll i=0LL; i<(n); i++)

#define MOD 	1000000007
#define INF 	(int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

//Maths functions
ll Digit(ll N){ll res=0;while(N) res++, N/=10;return res;}
ll Gcd(ll a,ll b){ return b?Gcd(b,a%b):abs(a); }


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

	ll n,m;
	cin>>n>>m;
	

	ll a[n];
	for(ll i=0; i<n; i++)
		a[i]= -1;

	ll x,y; bool flag=false;
	
	rep(i,m){
		cin>>x>>y;
		
		if(flag==false && ( a[x-1] == -1 || a[x-1]==y) )
			a[x-1] = y;

		else { cout<<"-1"; return 0;}
	}


	if( n>1 && a[0]==0 )
		{ cout<<"-1";	return 0; }

	if(n==1)
	{	if(a[0]!= -1)
			cout<<a[0];
		else cout<<"0";
		 return 0;
	}


	for(ll i=0; i<n; i++)
	{
		if(i==0 && a[i]==-1)
			cout<<"1";
		else if(i!=0 && a[i]==-1)
		cout<<"0";
		else cout<<a[i];
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int n = tmp[0], k = tmp[1], q = tmp[2];
	int[] p = new int[n];
	for (int i = 0; i < q; i++)
	{
	    int a = int.Parse(ReadLine());
	    p[a-1]++;
	}
	for (int i = 0; i < n; i++)
	{
	    int pt = k - (q - p[i]);
	    if (pt > 0) WriteLine("Yes");
	    else WriteLine("No");
	}
    }
}


Measured memory_bytes: 18012
import heapq
X,Y,Z,K = map(int,input().split())

limit = [X,Y,Z]

nums = []
heapq.heapify(nums)
num = 0
abc = [[] for i in range(3)]

for i in range(3):
  abc[i] = sorted(list(map(int,input().split())),reverse = True)
  num += abc[i][0] * -1
  
heapq.heappush(nums,[num,0,0,0])
yet = []

for i in range(K):
  M = heapq.heappop(nums)
  for j in range(3):
    ID = M[1:]
    ID[j] += 1
    if ID[j] < limit[j]:
      a = ID[0]
      b = ID[1]
      c = ID[2]
      m = (abc[0][a] + abc[1][b] + abc[2][c]) * - 1
      if ID not in yet:
        heapq.heappush(nums,[m,a,b,c])
        yet.append(ID)
  print(M[0] * -1)
  


Measured memory_bytes: 4720
main = do
  s <- getLine
  _ <- getLine
  ss' <- getContents
  let ss = map words . lines $ ss'
  aux s ss

aux :: String -> [[String]] -> IO()
aux _ [] = return()
aux s (x:xs) = case (head x) of
  "print" -> let a = read (x!!1)
                 b = read (x!!2) in do
                     putStrLn $ substr a (b+1) s 
                     aux s xs 
  "reverse" ->  let a = read (x!!1)
                    b = read (x!!2) in
                aux ((take a s)++(reverse . substr a (b+1) $ s) ++(drop (b+1) s)) xs
  "replace" ->  let a = read (x!!1)
                    b = read (x!!2)
                    p = x!!3 in
                aux ((take a s)++p++(drop (b+1) s)) xs
  _        ->   aux s xs                


substr :: Int -> Int -> String -> String
substr n m s =  drop n . take m $ s 

Measured memory_bytes: 5388
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
    long long x;
public:
    mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream& operator<<(ostream& os, const mint& m) {
        os << m.x;
        return os;
    }
};

///////////////////////////


int main() {
    ll N;
    cin >> N;
    vector<ll> A(N + 1), B(N + 1);
    repn(i, N) cin >> A[i];
    repn(i, N) cin >> B[i];

    priority_queue<pair<ll,ll>> p;
    repn(i, N) p.push({B[i],i});

    ll ans = 0;
    while (!p.empty()) {
        auto x = p.top();
        p.pop();
        ll i = x.second;

        ll T= B[i % N + 1] + B[(i + N - 2) % N + 1];

        if (B[i] >= A[i] && (B[i] - A[i]) % T == 0) {
            ans += (B[i] - A[i]) / T;
            B[i] = A[i];
        }

        else {
            if (T > B[i]) { ans = -1; break; }
            ans += B[i] / T;
            B[i] %= T;
            p.push({ B[i],i });
            if (B[i] < A[i]) { ans = -1;  break; }
        }

        //repn(i, N) cout << B[i] << " ";
        //cout << endl;
    }

    cout << ans;

	system("PAUSE");
}

Measured memory_bytes: 9328
package main

import (
	"fmt"
	"reflect"
	"sort"
)

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

func abs(x int) int {
	if x > 0 {
		return x
	} else {
		return -x
	}
}

func main() {
	var n, a, b int
	fmt.Scan(&n)
	p := make([]int, n)
	for i := range p {
		fmt.Scan(&p[i])
	}
	q := make([]int, n)
	for i := range q {
		fmt.Scan(&q[i])
	}
	order := make([]int, n)
	for i := range order {
		order[i] = i + 1
	}
	for c := 0; ; c++ {
		if reflect.DeepEqual(order, p) {
			a = c
		}
		if reflect.DeepEqual(order, q) {
			b = c
		}
		if !NextPermutation(sort.IntSlice(order)) {
			break
		}
	}
	fmt.Println(abs(a - b))
}


Measured memory_bytes: 5504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Math;

namespace AtCoderProject
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadLineInt();
            var in2 = ReadLineIntArray();
            int D = in2[0];
            int X = in2[1];
            var input = ReadInputInt(N);
            var sum = input.Sum(d => 1 + (D - 1) / d) + X;
            Console.WriteLine(sum);
        }

        #region READER
        static int ReadLineInt() => int.Parse(Console.ReadLine());
        static int[] ReadLineIntArray() => Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        static IEnumerable<string> ReadInputEnumruble(int count = int.MaxValue)
        {
            for (int i = 0; i < count; i++)
            {
                yield return Console.ReadLine();
            }
        }
        static int[] ReadInputInt(int count = int.MaxValue)
        {
            return ReadInputEnumruble(count).Select(s => int.Parse(s)).ToArray();
        }
        #endregion
    }
}


Measured memory_bytes: 13396
#include <cstdio>
#include <algorithm>
using namespace std;

int dp(int, int);

int w[1001];
int v[101];
int memo[101][10001];

int main(){
    int N,W;
    scanf("%d %d",&N,&W);
    
    for(int i = 0; i < 101; i++){
        for(int j = 0; j < 10001; j++){
            memo[i][j] = -1;
        }
    }

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

    printf("%d\n",dp(N,W));

    return 0;
}


int dp(int i,int j){
    if(i == 0){
        return 0;
    }
    if(memo[i][j] >= 0){
        return memo[i][j];
    }
    if(j - w[i - 1] < 0){
        return memo [i][j] = dp(i - 1,j);
    }

    return memo[i][j] = max(dp(i - 1,j),dp(i - 1,j - w[i - 1]) + v[i - 1]);
}



Measured memory_bytes: 6700
#include<bits/stdc++.h>
using namespace std;
int main(){
/*一行目の表情報を代入
二行目以降が一行目にそのままそっくり何かの数を足したら再現できるかどうかをアルゴリズムで確認*/
vector<vector<int>> data(3,vector<int>(3));
for(int i = 0; i < 3; i++){
  for(int j = 0; j < 3; j++){
    cin >> data.at(i).at(j);
  }
}
bool b = true;
for(int i = 1; i < 3 ; i++){
  int x = data.at(0).at(0) - data.at(i).at(0);
  for(int j = 1; j < 3 ; j++){
  if(data.at(0).at(j) - data.at(i).at(j) != x){
    b = false;
  }
}
}
if(b == true)cout << "Yes" << endl;
else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

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

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

using namespace std;

typedef long long int64;

int N, K, A[100000], B[100000];

int64 rec(int idx, bool free, vector< int > &vs)
{
  if(idx == -1 || free) { // なんでもOK (0でも1でも)
    int64 ret = 0;
    for(int k = 0; k < vs.size(); k++) {
      ret += B[vs[k]];
    }
    return (ret);
  }

  if((K >> idx) & 1) {
    // 0 にするとfreeになる

    vector< int > nx;
    for(int k = 0; k < vs.size(); k++) {
      if((A[vs[k]] >> idx) & 1) continue;

      nx.push_back(vs[k]);
    }
    return (max(rec(idx - 1, true, nx), rec(idx - 1, false, vs)));
  } else {
    // 1 はダメ
    vector< int > nx;
    for(int k = 0; k < vs.size(); k++) {
      if((A[vs[k]] >> idx) & 1) continue;
      nx.push_back(vs[k]);
    }
    return (rec(idx - 1, free, nx));
  }
}

int main()
{
  cin >> N >> K;
  for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
  vector< int > vs(N);
  iota(begin(vs), end(vs), 0);
  cout << rec(30, false, vs) << endl;
}

Measured memory_bytes: 12792
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

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

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

   int suma = accumulate(a.begin(), a.end(), 0LL);
   int s = (n+1) * n / 2;
   if (suma % s != 0) {
      cout << "NO" << endl;
      return 0;
   }
   int k = suma / s;

   V<int> d(n);
   for (int i = 0; i < n; i++) {
      d[i] = a[(i+1) % n] - a[i] - k;
   }

   for (int i = 0; i < n; i++) {
      if (d[i] > 0 || d[i] % n != 0) {
         cout << "NO" << endl;
         return 0;
      }
   }
   cout << "YES" << endl;


   return 0;
}


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

int main () {
    char c;
    cin >> c;

    if (c == 'a' || c =='e' || c =='i' || c =='o' || c =='u') {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
   string s;cin>>s;
   int ans=INF;
   rep(i,0,siz(s)-2){
      int now=0;
      rep(j,i,i+3){
         now*=10;
         now+=s[j]-'0';
      }
      //cout<<now<<endl;
      chmin(ans,abs(now-753));
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
H, W = list(map(int, input().split()))
M = []
for i in range(H):
    M.append(input().rstrip())

for j in range(H):
    for i in range(W):
        if M[j][i]!='#':
            continue
        #up
        if j>0 and M[j-1][i]=='#':
            continue
        #down
        if j<H-1 and M[j+1][i]=='#':
            continue
        #left
        if i>0 and M[j][i-1]=='#':
            continue
        #right
        if i<W-1 and M[j][i+1]=='#':
            continue
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 3064
import java.util.Scanner;

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

    while (in.hasNext()) {
      int N = in.nextInt();
      int K = in.nextInt();

      if (K == 1) {
        System.out.println(0);
      } else {
        System.out.println(N - K);
      }
    }
  }
}

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

int main(){

	int m,n,r;
	int result;
	while(cin >> m >> n >> r, m >= 0 || n >= 0 || r >= 0){
		result=m+n;
		if(m == -1 || n == -1)
			cout << "F" << endl;
		else if(result>=80)
			cout << "A" << endl;
		else if(result<80 && result>=65)
			cout << "B" << endl;
		else if(result<65 && result>=50)
			cout << "C" << endl;
		else if(result<50 && result>=30){
			if(r == -1 || r <50)
				cout << "D" << endl;
			else if(r>=50)
				cout << "C" << endl;
		}
		else if(result<30){
			cout << "F" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3072
def main():
    s = input()
    ans = []
    for op in s:
        if op == '0':
            ans.append(op)
        elif op == '1':
            ans.append(op)
        else:
            if len(ans) > 0:
                ans.pop()
    print(*ans, sep='')
if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
	long int a,b,aa,ba,i,x,y,bb;
	aa=1;
	ba=1;
	while(scanf("%ld %ld",&a,&b)!=EOF){
		x=a;
		y=b;
		aa=1;
		ba=1;
		
		if(b<a){
			while(1){
				if(aa==0){
					break;
				}
				aa=a%b;
				a=b;
				b=aa;
			}
			ba=x*y/a;
			printf("%ld %ld\n",a,ba);
		}
		else{
			while(1){
				if(aa==0){
					break;
				}
				aa=b%a;
				b=a;
				a=aa;
			}
			ba=x*y/b;
			printf("%ld %ld\n",b,ba);
		}
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll K;
	cin >> K;
	if ((K % 2) * (K % 5) == 0) {
		cout << -1 << endl; return 0;
	}
	ll m = 7;
	ll an = 1;
	while (m % K != 0) {
		m = (m * 10 + 7) % K;
		an++;
	}
	cout << an << endl;

}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int get_id(int n, int m, int N){
  int fir, sec;
  fir = min(n, m);
  sec = max(n, m);

  int ans = 0;
  for(int i = 0; i < fir; i++){
    ans += (N-1)-i;
  }

  ans += sec - fir - 1;
  return ans;

};

bool visit(const vector<vector<int>> &G, int v, vector<int>& order, vector<int>& color){
  color[v] = 1;
  for(int u : G[v]){
    if(color[u] == 2) continue;
    if(color[u] == 1) return false;
    if(!visit(G, u, order, color)) return false;
  }
  order.push_back(v); color[v] = 2;
  return true;
}


bool TpSort(const vector<vector<int>> &G, vector<int>& order){
  int n = G.size();
  vector<int> color(n);
  for(int u = 0; u < n; u++) if(!color[u] && !visit(G, u, order, color)) return false;
  reverse(order.begin(), order.end());
  return true;
}

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

  int N;
  cin >> N;

  vector<vector<int>> A(N);
  int tmp;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N-1; j++){
      cin >> tmp;
      tmp--;
      A[i].push_back(tmp);
    }
  }

  vector<vector<int>> G(N*(N-1)/2);
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N-2; j++){
      G[get_id(i, A[i][j], N)].push_back(get_id(i, A[i][j+1], N));
    }
  }

  vector<int> order;
  if(!TpSort(G, order)){
    cout << -1 << endl;
  }else{
    vector<int> dp(N*(N-1)/2);
    for(const int el : order){
      for(const int child : G[el]){
        dp[child] = max(dp[child], dp[el]+1);
      }
    }

    cout << *max_element(dp.begin(), dp.end()) + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 35828
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<31;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0}; 
int main(){
    int n,m,c;cin>>n>>m>>c;
    vector<int> b(m);
    for(int i=0;i<m;i++)cin>>b[i];
    int ans=0;
    for(int i=0;i<n;i++){
        vector<int> a(m);
        int s=0;
        for(int j=0;j<m;j++){
            cin>>a[j];
            s+=a[j]*b[j];
        }
        if(s+c>0){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        Machi[] list;


        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            list = new Machi[N];
            for(int i =0;i<N;i++){
                long x = sc.nextLong();
                long y = sc.nextLong();
                list[i] = new Machi(x, y);
            }

        }
        long temp = 1;
        double result = 0;
        for(int i = 1;i<N;i++){
            temp *= N;
        }
        long sumPath = 0;
        for(int i =0;i<N;i++){
            for(int j =i+1;j<N;j++){
                long fromX = list[i].x;
                long fromY = list[i].y;

                long toX = list[j].x;
                long toY = list[j].y;

                long pp = ((fromX - toX) * (fromX - toX)) +((fromY - toY) * (fromY - toY));
                double path = Math.sqrt(pp);
                //System.out.println(path * temp);
                result += (2*path * temp);
            }
        }

        System.out.println(result / (temp *N));


    }

    public static class Machi{
        public long x;
        public long y;

        public Machi(long x,long y){
            this.x = x;
            this.y =y;
        }
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
using ll = long long;
const int INF = 0x3f3f3f3f;
const int MAX_N = 2000006;

int N;
multiset<int> a;
vector<int> cur, nxt;

void solve()
{
	cur.pb(*a.begin());
	a.erase(a.begin());
	for(int i=0; i<N; ++i){
		nxt = cur;
		for(int x : cur){
			auto it = a.upper_bound(x); //find its child
			if(it == a.end()){
				cout << "No\n";
				return;
			}
			nxt.pb(*it);
			a.erase(it);
		}
		cur = nxt;
	}
	cout << "Yes\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N;
	int x;
	for(int i=0; i<(1<<N);++i){
		cin >> x;
		a.insert(-x);
	}
	solve();
	return 0;
}

Measured memory_bytes: 14324
/*FBI WARNING
Federal law provides severe civil and criminal penalties for
the unauthorzed reproduction, distribution, or exhibition of
copyrighted motion pictures (Title 17 united states code
sections 501 and 508). The federal bureau of investigation
investigates allegations of criminal copyright infringement
(Title 17, united states code sections 506).*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long

template < typename tp > void read ( tp & dig ){
    char ch=getchar();dig=0;ll flag=0;
    while(!isdigit(ch)){ if(ch=='-')flag=1;ch=getchar(); }
    while(isdigit(ch))dig=dig*10+ch-'0',ch=getchar();
    if(flag)dig=-dig;
}

ll n,m,a[110];

int main()
{

    read(n);read(m);
    for(ll i=1;i<=n;++i)
	read(a[i]);
    sort(a+1,a+n+1);
    ll ans=0;
    for(ll i=1;i<=n;++i){
	m-=a[i];
	if(m>=0)ans=i;
	else break;
    }if(m>0&&ans)--ans;
    printf("%lld\n",ans);
    return 0;
    
}


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

class Pg
{
    static IEnumerable<List<int>> Read()
    {
        string n;
        while (!string.IsNullOrEmpty(n = Console.ReadLine()))
            yield return n.Split().Select(int.Parse).ToList();
    }
    public static void Main()
    {
        int[,] dp;
        Calq(0, 0, dp = new int[15, 350], new bool[10]);
        Read().ToList().ForEach(x => Console.WriteLine(x[1] > 330 ? 0 : dp[x[0], x[1]]));
    }
    private static void Calq(int cnt, int sum, int[,] dp, bool[] used)
    {
        if (cnt == 11)
            return;
        for (int i = 0; i < 10; ++i)
        {
            if (used[i])
                continue;
            used[i] = true;
            dp[cnt + 1, sum + i * (cnt + 1)]++;
            Calq((cnt+1), sum + i * (cnt+1), dp, used);
            used[i] = false;
        }
    }
}


Measured memory_bytes: 16280
A, B, C, D = map(int, input().split())

def getLCM(a, b):
    while True:
        r = a % b
        if r == 0:
            b = int(C*D//b)
            return b
        a = b
        b = r

E = 1
if C != D:
    if C > D:
        E = getLCM(C, D)

    elif D > C:
        E = getLCM(D, C)

    c = int(B // C)
    d = int(B // D)
    e = int(B // E)
    ans1 = (B-c-d+e)

    c = int((A-1) // C)
    d = int((A-1) // D)
    e = int((A-1) // E)
    ans2 = ((A-1)-c-d+e)
else:
    c = int(B // C)
    ans1 = (B-c)

    c = int((A-1) // C)
    ans2 = ((A-1)-c)

ans = ans1 - ans2
if ans < 0:
    ans = 0
print(ans)


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

int n, A[20];

bool solve(int i, int m){
  if (m==0){
    return true;
  }
  if (i>=n) {
    return false;
  }
  return solve(i+1, m) || solve(i+1, m-A[i]);
}

int main(){
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> A[i];
  }
  int q, m;
  cin >> q;
  for (int i=0; i<q; i++) {
    cin >> m;
    if (solve(0, m)){
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3068
s = raw_input()
K = input()

alpha = [chr(i) for i in range(97,97+26)]

i = 0
while K>=26 and i<len(s)-1:
	if alpha.index(s[i]) != 0:
		K = K - (26 - alpha.index(s[i]))
		s = s[:i] + 'a' + s[i+1:]
	i=i+1

for moji in range(i, len(s)):
	if alpha.index(s[moji]) != 0:
		if K >= 26-alpha.index(s[moji]):
			K = K - (26-alpha.index(s[moji]))
			s = s[:moji] + 'a' + s[moji+1:] 

if K>0:
	last_char = alpha[ alpha.index(s[-1]) + (K % 26) ]
	s = s[:-1] + last_char

print s

Measured memory_bytes: 5764
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 5100000
#define MOD 1000000007
#define INF 100000000000000

int main(){
  string S;
  cin>>S;
  if(S.at(3)==S.at(2)&&S.at(4)==S.at(5)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	ll ans = 0;
	if (k <= a) {
		ans += k;
		out(ans);
		return 0;
	}
	else {
		ans += a;
	}

	if (k <= a + b) {
		out(ans);
		return 0;
	}

	ans -= (k - a - b);

	out(ans);

	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector<pair<ll,ll>> a(n);
    rep(i, 0, n) {
        cin >> a[i].first;
        a[i].second = i + 1;
    }
    sort(a.begin(), a.end());
    for(auto e : a) cout << e.second << endl;
    return 0;
}

Measured memory_bytes: 4760