akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
#define INF 2<<29

int main(){
  int ans=INF,n,k,h[100005];
  scanf("%d %d",&n,&k);
  for(int i=0;i<n;i++){
    scanf("%d",&h[i]);
  }

  sort(h,h+n);

  for(int i=0;i<n-k+1;i++){
    if(h[i+k-1]-h[i]<ans) ans=h[i+k-1]-h[i];
  }

  printf("%d\n",ans);
  
  return 0;
}


Measured memory_bytes: 640
def main():
    N = int(input())
    A = input()
    B = input()
    C = input()
    retval = 0
    for i in range(N):
        diff = 0
        if A[i] != B[i]:
            diff += 1
        if B[i] != C[i]:
            diff += 1
        if C[i] != A[i]:
            diff += 1
        if diff >= 1:
            retval += diff - 1
    print(retval)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38424
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);

//		ArrayList<Integer> p=new ArrayList<Integer>();
		int N = scanner.nextInt();
		int p[] = new int[N];
		int counter=0;

		for(int i=0;i<N;i++) {
			p[i]=scanner.nextInt();
		}

		if(p[0]-p[1]!=-1) counter++;
//		System.out.println(counter);

		for(int i=1;i<N-2;i++) {
			if(p[i]-p[i+1]!=-1) {
				counter++;
				i++;
			}
		}

		if(p[N-2]-p[N-1]!=-1) counter++;
//		System.out.println(counter);

//		System.out.println(counter);
		if(counter==0||counter==2) System.out.println("YES");
		else System.out.println("NO");

		scanner.close();


	}

}


Measured memory_bytes: 22612
import heapq

def djsktra(node,edges,dist):
    heap = []
    heapq.heappush(heap,(0,node))
    visited = set()
    while heap:
        curr = heapq.heappop(heap)
        d,node = curr[0],curr[1]
        if node not in visited:
            visited.add(node)
            dist[d] += 1
            for kid in edges[node]:
                heapq.heappush(heap,(d+1,kid))

def main():
    n,x,y = map(int,input().split())
    edges = {}
    for i in range(1,n):
        if i not in edges.keys():
            edges[i] = []

        if i+1 not in edges.keys():
            edges[i+1] = []
            
        edges[i].append(i+1)
        edges[i+1].append(i)
        
    edges[x].append(y)
    edges[y].append(x)
    dist = [0]*n
    for i in range(1,n+1):
        djsktra(i,edges,dist)

    dist.pop(0)
    for i in dist:
        print(i//2)

main()


Measured memory_bytes: 120156
i = 0
a = []
while True:
    x = raw_input().split()
    if int(x[0]) == 0:
        break
    else:
        a.append(x)
f=[]    
for j in range(len(a)):
    f = str(j+1)+":"
    print "Case",f, " ".join(map(str,a[j]))
    

Measured memory_bytes: 8708
#include <stdio.h>
int main() {
  int n;
  int i;
  scanf ("%d", &n);
  char s[n], t[n];
  scanf ("%s %s", s, t);

  for (i = 0; i < n; i++) {
    printf ("%c%c", s[i], t[i]);
  }

  return 0;
}


Measured memory_bytes: 128
INF = int(1e9 + 7)


def modmulti(a, b):
    # aとbを掛けた値をmodする(a * b mod p)
    return a * b % INF


def factorial(x):
    FCT = 1
    for i in range(2, x + 1):
        FCT = modmulti(i, FCT)
    return FCT


def main():
    N, M = map(int, input().split())
    MIN_NM = factorial(min(N, M))
    if N == M or N + 1 == M or N == M + 1:
        print(modmulti(2, modmulti(MIN_NM, MIN_NM))
              if N == M else modmulti(MIN_NM, modmulti(MIN_NM, max(N, M))))
    else:
        print(0)

    return


main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define M 200005
int read() {
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
	{
	    if(ch=='-') w=-1;
	    ch=getchar();
	}
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
    return s*w;
}
struct edge {
    int t,nxt;
} e[M*2];
int head[M],tot;
void add(int st,int t) {
    e[++tot].nxt=head[st],e[tot].t=t,head[st]=tot;
}
int n,ans[M];
int f[M],sz[M];
int find(int x) {
    if(f[x]==x) return x;
    return f[x]=find(f[x]);
}
int g[M],s[M],dfn1[M],dfn2[M],cnt,F[M];
vector<int> tol[M];
int c[M];
#define lowbit(x) (x&-x)
void modify(int p,int k) {
    if(!p) return ;
    while(p<=n) c[p]+=k,p+=lowbit(p);
}
int ask(int p) {
    int s=0;
    while(p) s+=c[p],p-=lowbit(p);
    return s;
}
void dfs0(int x,int fa,int mx) {
    dfn1[x]=dfn2[x]=++cnt,F[x]=fa;
    if(mx>x) tol[mx].push_back(x);
    for(int i=head[x];i;i=e[i].nxt)
	{
	    int to=e[i].t;
	    if(to==fa) continue ;
	    dfs0(to,x,max(mx,fa));
	    dfn2[x]=max(dfn2[x],dfn2[to]);
	}
}
void dfs(int x,int fa,int val,int dep) {
    ans[x]=val+dep+s[x];
    for(int i=head[x];i;i=e[i].nxt)
	{
	    int to=e[i].t;
	    if(to==fa) continue ;
	    dfs(to,x,val+s[x]-g[to],dep+1);
	}
}
void work() {
    dfs0(1,0,0);
    for(int i=1;i<=n;i++) f[i]=i,sz[i]=1;
    for(int i=1;i<=n;i++)
	{
	    for(int j=0;j<tol[i].size();j++)
		{
		    int to=tol[i][j];
		    g[to]=ask(dfn2[to])-ask(dfn1[to]-1);
		}
	    for(int j=head[i];j;j=e[j].nxt)
		{
		    int to=e[j].t;
		    if(to==F[i]) continue ;
		    if(to<i) sz[i]+=sz[find(to)],f[find(to)]=i;
		}
	    int top=find(F[i]);
	    if(top&&top<i)
		{
		    modify(dfn1[i],sz[i]);
		    modify(dfn1[F[top]],-sz[i]);
		    sz[top]+=sz[i],f[i]=top;
		}
	    else modify(dfn1[i],sz[i]),modify(dfn1[F[i]],-sz[i]);
	}
    for(int i=1;i<=n;i++)
	for(int j=head[i];j;j=e[j].nxt)
	    {
		int to=e[j].t;
		if(to==F[i]) continue ;
		s[i]+=g[to];
	    }
    dfs(1,0,0,0);
    for(int i=2;i<=n;i++) cout<<ans[i]<<' ';
    cout<<'\n';
}
int main() {
    n=read();
    for(int i=1,x,y;i<n;i++)
	{
	    x=read();
	    y=read();
	    add(x,y),add(y,x);
	}
    work();
    return 0;
}

Measured memory_bytes: 30580
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)

int main() {
    int x,ans = 0;
    cin >> x ;
    x = x / 100;
    if (x % 2 == 0) {
        ans = 8 - (x - 4) / 2;
   }
    else {
        ans = 8 - (x - 5) / 2;
    }

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

Measured memory_bytes: 3188
import sys
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def s(A):
 for i in range(n-1):
  if A[i][1]==A[i+1][1]and A[i][2]>A[i+1][2]:return'Not s'
 return'S'
def m():
 A=[(e[0],int(e[2:]),i)for i,e in enumerate(sys.stdin)]
 k(A,0,n-1)
 print(s(A)+'table')
 print('\n'.join(f'{a} {b}'for a,b,_ in A))
if'__main__'==__name__: n=int(input());m()


Measured memory_bytes: 26992
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    string S;
    cin >> S;
    int cnt = 0;
    for(int i=0; i<N; i++){
        if(S[i] == 'R') cnt++;
        else cnt--;
    }
    if(cnt > 0){
        cout << "Yes" << enld;
    }else{
        cout << "No" << enld;
    }
    return 0;
}

Measured memory_bytes: 256
h,w=gets.split.map(&:to_i)
dx=[1, 0, -1, 0,  1, -1, -1, 1]
dy=[0, 1, 0,  -1, 1,  1, -1,-1]
s=[]
h.times do
  s << gets.chomp.chars
end
(0...h).each do |i|
  (0...w).each do |j|
    if s[i][j]=="#"
      next
    end
    num = 0
    8.times do |d|
      ni = i+dy[d]
      nj = j+dx[d]
      
      if ni < 0 || ni >= h
        next
      end
      
      if nj < 0 || nj >= w
        next
      end
      
      num+=1 if s[ni][nj]=="#"
    end
    s[i][j] = num.to_s
  end
end

(0...h).each do |i|
  (0...w).each do |j|
    printf("%s",s[i][j])
    printf("\n") if j==w-1
  end
end

Measured memory_bytes: 2172
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

int main()
{
  string s;
  cin >> s;
  int x = stoi(s.substr(0, 2));
  int y = stoi(s.substr(2, 2));
  bool a = false;
  if (x > 0 && x <= 12)
  {
    a = true;
  }
  bool b = false;
  if (y > 0 && y <= 12)
  {
    b = true;
  }
  if (a && b)
  {
    cout << "AMBIGUOUS" << "\n";
  }
  else
  if (!a && b)
  {
    cout << "YYMM" << "\n";
  }
  else
  if (a && !b)
  {
    cout << "MMYY" << "\n";
  }
  else
  {
    cout << "NA" << "\n";
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define mk make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
using namespace std;
const int MAXN=1e5+9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,k;
	cin>>n>>k;
	bool ans[n+1];
	memset(ans,true,sizeof(ans));
	for(int i=1;i<=k;i++)
	{
		int cnt;
		cin>>cnt;
		for(int j=0;j<cnt;j++)
		{
			int x;
			cin>>x;
			ans[x]=false;
		}
	}
	int fans=0;
	for(int i=1;i<=n;i++)
	{
		if(ans[i])
		{
			fans++;
		}
	}
	cout<<fans<<endl;
	return 0;
}

Measured memory_bytes: 3612
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef  long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素



int main(){
  int N;
  cin>>N;
  ll A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  ll ans=A[0];
  ll max=pow(10,18);
  int ok=false;
  for(int i=0;i<N;i++){
    if(A[i]==0){
      ans=0;
      cout<<ans<<endl;
      ok=true;
      break;
    }
  }
  if(!ok){
    for(int i=1;i<N;i++){
      if(log10(A[i])+log10(ans)>19){
        ans=-1;
        break;
      }
      ans*=A[i];
      if(ans>max){
        ans=-1;
        break;
      }
    }

    cout<<ans<<endl;
  }

}

Measured memory_bytes: 4664
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
typedef long double LD;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=55;
int n;
int a[N][N],b[N];
bool check(int a,int b,int k){
	static int dp[N];
	clr(dp);
	dp[b]=1;
	For(i,1,k)
		For(j,0,50)
			dp[j]|=dp[j%i];
	return dp[a];
}
bool check(int a[N][N],int k){
	For(i,1,n){
		int flag=0;
		For(j,0,50)
			if (a[i][j]&&check(j,b[i],k))
				flag=1;
		if (!flag)
			return 0;
	}
	return 1;
}
int main(){
	n=read();
	For(i,1,n)
		a[i][read()]=1;
	For(i,1,n)
		b[i]=read();
	if (!check(a,50))
		return puts("-1"),0;
	LL ans=0;
	Fod(i,50,1)
		if (!check(a,i-1)){
			ans+=1LL<<i;
			For(j,1,n)
				For(k,0,50)
					a[j][k%i]|=a[j][k];
		}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
   char s[200000];scanf("%s",s);
   char *p1,*p2;
   p1 = strchr(s, 'A');
   for(int i = 0;i < strlen(s);i++)
      if(s[i] == 'Z')p2 = &s[i];
   printf("%d\n",p2-p1+1);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >>N>>M;
  
  vector<int> X(M);
  for(int i=0;i<M;i++){
    cin >>X.at(i);
  }
  sort(X.begin(), X.end());
  
  vector<int> S(M-1);
  for(int j=0;j<M-1;j++){
    S.at(j)=X.at(j+1)-X.at(j);
  }
  sort(S.begin(), S.end());
  int sum;
  //for(int k=0;k<M-1;++k){cout<<S.at(k)<<endl;}
  
  for(int k=0;k<M-N;k++){
    sum+=S.at(k);
  }
  cout <<sum<<endl;
}
  

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
using namespace std;
int n,x,c;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		for(int j=2;j<=(int)pow(x,0.5);j++){
			if(x%j==0){
				c++;
				break;
			}
		}
	}
	cout<<n-c<<endl;
	return 0;
}

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








int main()
{
	long long int N;
	cin >> N;
	if (N % 2 == 0)
	{
		cout << N / 2 << " " << N << " " << N;
	}
	else
	{
		long long t2;
		for (long long int a = 1; a <= 3500; a++)
		{

			for (long long int b = 1; b <= 3500; b++)
			{
				long long int temp1 = a *b *N;
				long long int temp2 = 4 * a*b - a*N - b * N;
				if (temp2 > 0 && temp1 % temp2 == 0)
				{
					cout << a << " " << b << " " << temp1 / temp2;
					return 0;
				}
			}
		}
	}


}

Measured memory_bytes: 256
func gcd(x:Int,_ y:Int)->Int{return y>0 ?gcd(y,x%y):x}
func lcm(x:Int,_ y:Int)->Int{return x/gcd(x,y)*y}
print((0..<Int(readLine()!)!).reduce(1){i,_ in lcm(Int(readLine()!)!,i)})

Measured memory_bytes: 896
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

int main() {
  ll q;
  cin >> q;
  rep(i_q, q) {
    string s, t;
    cin >> s >> t;
    ll ns = (ll)s.size(), nt = (ll)t.size();
    vvll dp(ns + 1, vll(nt + 1, 0));
    rep(i, ns) rep(j, nt) {
      if(s[i] == t[j]){
        dp[i + 1][j + 1] = dp[i][j] + 1;
      } else {
        dp[i + 1][j + 1] = max(dp[i+1][j], dp[i][j+1]);
      }
    } // j, i
    cout << dp[ns][nt] << endl;
  }  // q

  return 0;
}



Measured memory_bytes: 10812
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
visited = {}
r = []
p = 1
i = 0
while i <= n:
    if p in visited:
        s = r[0:r.index(p)]
        r = r[r.index(p):]
        break
    else:
        visited.update({p: i})
        r.append(p)
        s = r
        p = a[p - 1]
        i += 1
if k < visited[p]:
    ans = s[k]
else:
    ans = r[(k - i) % len(r)]
print(ans)


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

int main(){
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i,n) cin >> p[i];
	int ans = 0;
	rep(i,n-2){
		if(p[i+1] > min(p[i],p[i+2]) && p[i+1] < max(p[i], p[i+2])) ans++;
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
import numpy as np
read = sys.stdin.read

N, A, B, *h = map(int, read().split())

h = np.array(h, np.int64)

# 2部探索する。n回の爆発で魔物をすべて倒せるか否や
l = 0
r = (max(h) // B) * N
a = A - B
while l + 1 < r:
    mid = (l + r) // 2
    w = B * mid
    tmp = h - w
    tmp = tmp[tmp > 0]
    tmp = tmp // a + np.minimum(tmp % a, 1)
    if tmp.sum() <= mid:
        r = mid
    else:
        l = mid

print(r)

Measured memory_bytes: 23112
# 最大流
NUMERIC_LIMITS = 10 ** 18
import queue
class maxFlow:
  class edge:
    def __init__(s, frm, to, cap, flow):
      s.frm, s.to = frm, to
      s.cap, s.flow = cap, flow

  def __init__(s, n):
    s._n = n
    s.g = [[] for _ in range(n)]
    s.pos = []

  def add_edge(s, frm, to, cap):
    m = len(s.pos)
    s.pos.append([frm, len(s.g[frm])])
    s.g[frm].append(s._edge(to, len(s.g[to]), cap))
    s.g[to].append(s._edge(frm,len(s.g[frm]) - 1, 0))
    return m

  def get_edge(s, i):
    m = len(s.pos)
    _e = s.g[s.pos[i][0]][s.pos[i][1]]
    _re = s.g[_e.to][_e.rev]
    return s.edge(s.pos[i][0], _e.to, _e.cap + _re.cap, _re.cap)

  def edges(s):
    m = len(s.pos)
    result = []
    for i in range(m):
      result.append(s.get_edge(i))
    return result

  def change_edge(s, i, new_cap, new_flow):
    m = len(s.pos)
    _e = s.g[s.pos[i].to][s.pos[i].rev]
    _re = s.g[_e.to][_e.rev]
    _e.cap = new_cap - new_flow
    _re.cap = new_flow

  def flow(self, s, t, flow_limit = NUMERIC_LIMITS):
    level = [0] * self._n
    iter = [0] * self._n 

    def bfs():
      for i in range(self._n):
        level[i] = -1
      level[s] = 0
      que = queue.Queue()
      que.put(s)
      while not que.empty():
        v = que.get()
        for e in self.g[v]:
           if e.cap == 0 or level[e.to] >= 0: continue
           level[e.to] = level[v] + 1
           if e.to == t: return
           que.put(e.to)
    def dfs(this, v, up):
      if v == s: return up
      res = 0
      level_v = level[v]
      for i in range(iter[v], len(self.g[v])):
        e = self.g[v][i]
        if level_v <= level[e.to] or self.g[e.to][e.rev].cap == 0: continue
        d = this(this, e.to, min(up - res, self.g[e.to][e.rev].cap))
        if d <= 0: continue
        self.g[v][i].cap += d
        self.g[e.to][e.rev].cap -= d
        res += d
        if res == up: break
      return res

    flow = 0
    while flow < flow_limit:
      bfs()
      if level[t] == -1: break
      for i in range(self._n): iter[i]
      while flow < flow_limit:
        f = dfs(dfs, t, flow_limit - flow)
        if not f: break
        flow += f
    return flow

  def min_cut(self, s):
    visited = [False] * self._n
    que = queue.Queue()
    que.put(s)
    while not que.empty():
      p = que.get()
      visited[p] = True
      for e in self.g[p]:
        if e.cap and not visited[e.to]:
          visited[e.to] = True
          que.put(e.to)
    return visited

  class _edge:
    def __init__(s, to, rev, cap):
      s.to, s.rev = to, rev
      s.cap = cap

H, W = list(map(int, input().split()))
a = [list(input()) for _ in range(H)]

flow = maxFlow(H + W + 2)
s = H + W
t = H + W + 1
for h in range(H):
  for w in range(W):
    if a[h][w] == "S":
      flow.add_edge(s, h, H + W + 1)
      flow.add_edge(s, H + w, H + W + 1)
    elif a[h][w] == "T":
      flow.add_edge(h, t, H + W + 1)
      flow.add_edge(H + w, t, H + W + 1)
    if a[h][w] != ".":
      flow.add_edge(h, H + w, 1)
      flow.add_edge(H + w, h, 1)

ans = flow.flow(s, t)
if ans > H + W:
  print(-1)
else:
  print(ans)


Measured memory_bytes: 79972
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG

vin dy={-1,0,0,1};
vin dx={0,-1,1,0};
int h=1000;
int w=1000;
vvch a(h,vch(w));
int bfs(){
    queue<pair<int,int>> q;
    queue<pair<int,int>> r;
    int sum=0;
    rep(i,h){
        rep(j,w){
            if(a[i][j]=='#')q.push(mp(i,j));
        }
    }
    while(q.size()){
        while(q.size()){
            auto p=q.front();
            q.pop();
            rep(i,4){
                int ny=p.first+dy[i];
                int nx=p.second+dx[i];
                if(0<=ny&&ny<h&&0<=nx&&nx<w&&a[ny][nx]!='#'){
                    a[ny][nx]='#';
                    r.push(mp(ny,nx));
                }
            }
        }
        sum++;
        while(r.size()){
            q.push(r.front());
            r.pop();
        }
    }
    return sum;
}
int main(){
    cin>>h>>w;
    rep(i,h){
        rep(j,w)cin>>a[i][j];
    }
    cout<<bfs()-1<<endl;
}

Measured memory_bytes: 9488
long S(long n)
{
  long x=0;
  while(n)
  {
    x+=n%10;n/=10;
  }
  return x;
}
main()
{
  int k;scanf("%d",&k);
  puts("1");
  long n=1,a=1;
  for(int i=2;i<=k;i++)
  {
    if((n+a*10)*S(n+a)<(n+a)*S(n+a*10))a*=10;
    n+=a;
    printf("%ld\n",n);
  }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define N 2020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

struct node{
	int x,y,num,k;
	bool operator < (node a)const{
		if ( x == a.x ) return y < a.y;
		return x < a.x;
	}
}dt[maxn],dt2[maxn];

int n,D,tot;
int sum[2][N][N],a[N][N];
int m,b;

inline int cal(int x1,int y1,int x2,int y2,int t){
	if ( x1 > x2 || y1 > y2 ) return 0;
	int res = sum[t][x2][y2];
	if ( x1 > 0 ) res -= sum[t][x1 - 1][y2];
	if ( y1 > 0 ) res -= sum[t][x2][y1 - 1];
   	if ( x1 > 0 && y1 > 0 ) res += sum[t][x1 - 1][y1 - 1];
	return res;
}
bool check(int x,int y,int b){
	return cal(x + b + 1,y + b + 1,x + D - 1,y + D - 1,0) == 0 && cal(x,y + b + 1,x + b,y + D - 1,1) == 0 && cal(x + b + 1,y,x + D - 1,y + b,1) == 0;
}
int main(){
	
	scanf("%d %d",&n,&D);
	rep(i,1,n) scanf("%d %d",&dt[i].x,&dt[i].y) , dt[i].x %= D , dt[i].y %= D;
	sort(dt + 1,dt + n + 1);
	dt[0] = (node){-1,-1,-1,-1};
	rep(i,1,n){
		if ( dt[i].x == dt[i - 1].x && dt[i].y == dt[i - 1].y ){
			dt2[tot].num++;
		}
		else{
			dt2[++tot] = dt[i];
			dt2[tot].num = 1;
		}
	}
	rep(i,1,tot){
		int x = dt2[i].x , y = dt2[i].y;
		a[x][y] = dt2[i].num;
		m = max(m,dt2[i].num);
	}
	m = ceil(sqrt(m) - 1) , b = D - 1;
	rep(i,0,2 * D - 1){
		rep(j,0,2 * D - 1){
			rep(k,0,1){
				if ( j > 0 ) sum[k][i][j] += sum[k][i][j - 1];
				if ( i > 0 ) sum[k][i][j] += sum[k][i - 1][j];
				if ( i > 0 && j > 0 ) sum[k][i][j] -= sum[k][i - 1][j - 1];
			}
			sum[0][i][j] += (a[i % D][j % D] > m * m);
			sum[1][i][j] += (a[i % D][j % D] > m * (m + 1));
		}
	}
	rep(i,0,D - 1){
		rep(j,0,D - 1){
			while ( b && check(i,j,b - 1) ) b--;
			if ( !b ) break;
		}
	}
	cout<<m * D + b<<endl;
}


Measured memory_bytes: 45056
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	ans=k;
	n--;
	while(n--)
		ans*=(k-1);
	cout<<ans;
	return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;

int main() {
	int N;
	int b[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> b[i];
	}
	int log[100];
	for (int i = 0; i < N; i++) {
		int k = N - i;
		for (; k >= 0; k--) {
			if (b[k - 1] == k) {
				log[i] = k;
				for (int j = k - 1; j < N - i - 1; j++) {
					b[j] = b[j + 1];
				}
				break;
			}
		}
		if (k < 0) { cout << -1 << endl; return 0; }
	}

	for (int i = N - 1; i >= 0; i--) {
		cout << log[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
matrix = [[0 for i in range(W)] for j in range(H)]

for i in range(H):
  inp = input()
  for j, square in enumerate(inp):
    if square == '#':
      matrix[i][j] = 1
      
hw = [0, 0]
matrix[0][0] = 0
while True:
  # 右に行ければ右に行く
  if hw[1] + 1 < W and matrix[hw[0]][hw[1] + 1] == 1:
    matrix[hw[0]][hw[1] + 1] = 0
    hw = [hw[0], hw[1] + 1]
    continue
  
  # 右に行けない時、下に行ければ下に行く
  if hw[0] + 1 < H and matrix[hw[0] + 1][hw[1]] == 1:
    matrix[hw[0] + 1][hw[1]] = 0
    hw = [hw[0] + 1, hw[1]]
    continue
  
  # 右にも下にも行けなくなったらbreak
  else:
    break
    
flag = sum([sum(row) for row in matrix])
print("Impossible" if flag else "Possible")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    deque<int> deq;
    int N,A;
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> A;
        if(i%2){
            deq.push_front(A);
        }else{
            deq.push_back(A);
        }
    }
    if(N % 2){
        auto itr = deq.rbegin();
        for(int i = 0;i < N;i++){
            cout << *itr << " ";
            itr++;
        }
    }else{
        auto itr = deq.begin();
        for(int i = 0;i < N;i++){
            cout << *itr << " ";
            itr++;
        }
    } 
    cout << endl;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d,cnt=0;
    cin>>n>>d;

    while(n--)
    {

        double x,y;
        cin>>x>>y;

        double result = sqrt(pow(x,2)+pow(y,2));

        if(result<=d)
        {
            cnt++;
        }


    }
 cout<<cnt<<endl;




    return 0;
}


Measured memory_bytes: 3804
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let h = get!(usize);
    let w = get!(usize);
    let mut csum = vec![vec![0; w]; h+1];
    let mut rsum = vec![vec![0; w+1]; h];
    for r in 0..h {
        let line = get().as_bytes();
        for c in 0..w {
            if line[c] == b'.' {
                rsum[r][c+1] = rsum[r][c] + 1;
                csum[r+1][c] = csum[r][c] + 1;
            }
        }
    }
    for r in 0..h {
        let r = h-r;
        for c in 0..w {
            let c = w-c;
            if rsum[r-1][c-1] > 0 && rsum[r-1][c] > 0 {
                rsum[r-1][c-1] = rsum[r-1][c];
            }
            if csum[r-1][c-1] > 0 && csum[r][c-1] > 0 {
                csum[r-1][c-1] = csum[r][c-1];
            }
        }
    }
    let mut ans = 0;
    for r in 0..h {
        for c in 0..w {
            if csum[r+1][c] > 0 && rsum[r][c+1] > 0 {
                ans = std::cmp::max(ans, csum[r+1][c]+rsum[r][c+1]-1); 
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 41208
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var X = ReadLong();

            var year = 0L;
            var yen = 100L;
            while (yen < X)
            {
                yen = (long)Math.Floor(yen * 1.01D);
                year++;
            }

            return year;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27556
/*
    Ujjawal Pabreja [cuber_coder]
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
using ll = long long;
using ld = long double;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define rev             reverse
#define Y               "YES"
#define N               "NO"
#define nl              "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;
 
// ====== BigInt begins ======
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// ====== BigInt ends ======
 
// ====== PBDS begins ======
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, 
//         tree_order_statistics_node_update> 
//         pbds; 
// ====== PBDS ends ======
 
// ====== Useful functions begin ======
inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}
ll pwr(ll x,ll n){
    if(n == 0){
        return 1;
    }
    if(n&1){
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    } else {
        return pwr(mul(x, x), n / 2);
    }
}
ll modinv(ll n){ 
    return pwr(n, mod - 2); 
}
ll gcd(ll a,ll b) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
// ====== Useful functions end ======
 
// ====== Variables begin ======
void speed_solve(){
    string s, t;
    cin >> s >> t;
    ll ans = 0;
    rep(i,s.length()) {
        ans += (s[i] != t[i]);
    }
    cout << ans << nl;
}
 
int main(){
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

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

int main() {
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	int x,y;
	x=A>C?A:C;
	y=B<D?B:D;
	if(y-x>=0)cout<<y-x<<endl;
	else cout<<0<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
int n, m;
long long x;
int main() {
    scanf("%d%d", &n, &m);
    x = 1900 * m + 100 * (n - m);
    for (int i = 1; i <= m; i++) x = x * 2;
    printf("%lld\n", x);
    return 0;
}

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

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

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

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

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

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

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

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

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

fn main() {
  input! {
    n: usize,
    m: usize,
    a: [usize; m],
  }
  let mut a = a;
  a.sort();
  let digit_cost = vec![0, 2, 5, 5, 4, 5, 6, 3, 7, 6];
  let mut dp = vec![-(1i32 << 30); n+1];
  dp[0] = 0;
  for used_match in 1 .. n + 1 {
    for &digit in a.iter() {
      let cost = digit_cost[digit];
      if let Some(prev_used) = used_match.checked_sub(cost) {
        dp[used_match] = cmp::max(dp[used_match], dp[prev_used] + 1);
      }
    }
  }
  let mut ans = String::new();
  let mut used_match = n;
  for _ in 0 .. dp[n] {
    for &digit in a.iter().rev() {
      let cost = digit_cost[digit];
      if let Some(prev_used) = used_match.checked_sub(cost) {
        if dp[prev_used] + 1 == dp[used_match] {
          ans.push(std::char::from_digit(digit as u32, 10).unwrap());
          used_match = prev_used;
          break;
        }
      }
    }
  }

  println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int,int> P;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int map[110][110];
bool maze[110][110];
int xs,ys,xg,yg,w,h;

bool bfs(int col){
	queue<P> que;
	que.push(P(ys,xs));
	maze[ys][xs]=true;

	while(que.size()){
		P p=que.front();que.pop();
		if(p.first==yg && p.second==xg) return true;
		
		for(int i=0;i<4;i++){
			int ny=p.first+dy[i],nx=p.second+dx[i];
			if(ny>0 && ny<=h && nx>0 && nx<=w && !maze[ny][nx] && map[ny][nx]==col){
				maze[ny][nx]=true;
				que.push(P(ny,nx));
			}
		}
	}

	return false;
}

int main(){
	while(cin>>w>>h){
		if(w==0 && h==0) break;
		
		for(int i=0;i<110;i++){
			for(int j=0;j<110;j++){
				map[i][j]=0;
				maze[i][j]=false;
			}
		}

		int n;
		cin>>xs>>ys>>xg>>yg>>n;
		
		for(int i=0;i<n;i++){
			int c,d,x,y;
			cin>>c>>d>>x>>y;
			
			if(d==0){
				for(int j=y;j<y+2;++j){
					for(int k=x;k<x+4;++k){
						map[j][k]=c;
					}
				}
			}else{
				for(int j=y;j<y+4;++j){
					for(int k=x;k<x+2;++k){
						map[j][k]=c;
					}
				}
			}
		}

		if(bfs(map[ys][xs])) cout<<"OK"<<endl;
		else cout<<"NG"<<endl;
	}
	return 0;
}

			

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007
#define endl "\n"
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;



int32_t main(){
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int f=1;
    for(int i=0;i<s.size();i++){
        char g=s[i];
        if(g=='7'){
            f=0;
        }
    }
    if(f==0){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s; cin >> s;
	int n = s.size();
	if(n&1) cout << "No\n";
	else{
		for(int i = 0; i < n; i += 2) if(s[i] != 'h' || s[i + 1] != 'i'){
			cout << "No\n";
			return 0;
		}
		cout << "Yes\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int c=0;
    char S[4];
    scanf("%s",S);
    if(S[0]=='o') c+=100;
    if(S[1]=='o') c+=100;
    if(S[2]=='o') c+=100;
    printf("%d\n",700+c);
    
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AIZU {
	class Program {
		#region Reserve
		static int cin() { return cin(-1); }
		static int cin(int D) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return int.Parse(s);
		}
		static int[] cins(char spliter) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return new int[] { };
			string[] ss = s.Split(spliter);
			int[] Res = new int[ss.Length];
			for (int i = 0; i < ss.Length; i++)
				Res[i] = int.Parse(ss[i]);
			return Res;
		}
		static int[] cins() { return cins(' '); }
		static void print(object j) { Console.WriteLine(j.ToString()); }
		static void print(string j) { Console.WriteLine(j); }
		#endregion
		
		static void Main(string[] args) {
			int[] I = cins();
			int a = I[0], b = I[1];
			bool res = a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0;
			print(res ?"Possible":"Impossible");

		}

	}
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int main(){

long long int n,k,q;
cin >> n >> k >> q;
long long int a[q];
rep(i,q)cin >> a[i];
long long int p[n];
rep(i,n)p[i]=k-q;

rep(i,q){
p[a[i]-1]+=1;
}

rep(i,n){
  if(p[i]<=0)cout << "No" << endl;
  else cout << "Yes" << endl;
}
return 0;

}




Measured memory_bytes: 2176
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
#define MAX 100000
using namespace std;
typedef long long ll;
int a[20],n;
bool solve(int pos,int t){
	int mid;
	bool ans;
	if(t==0) return true;
	if(pos>=n) return false;
	mid=a[pos];
	ans=solve(pos+1,t)||solve(pos+1,t-mid);
	return ans;
}
int main(int argc, char *argv[]) {
	int q,t;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	scanf("%d",&q);
	for(int i=0;i<q;i++)
	{
		scanf("%d",&t);
		if(solve(0,t)) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}


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

int main() {
  int n, ans=2000000000;
  cin >> n;
  int a, b;
  for(int i=0; i<n; i++){
    cin >> a >> b;
    if(a+b<ans)ans=a+b;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
using ull = unsigned long long;

ull Pow(int a, int b){
  ull ans = 1;
  for(int i = 0; i < b; i++)
    ans *= a;
  return ans;
}

int main(){
  int n, k;
  ull ans = 0;
  int odd, even;
  cin >> n >> k;
  if(k%2==0){
    even = n/(k/2);
    if(even%2) even++;
    ans += Pow(even/2, 3);
  }
  odd = n/k;
  ans += Pow(odd, 3);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, w, wi[105], vi[105];
long long dp[105][100005];

int main(){
	scanf("%d%d", &n, &w);
	for (int i=1;i<=n;i++){
		scanf("%d%d", &wi[i], &vi[i]);
	}
	
	for (int i=1;i<=n;i++){
		for (int j=1;j<=w;j++){
			if (j < wi[i]){
				dp[i][j] = dp[i-1][j];
			} else {
				dp[i][j] = max(dp[i-1][j-wi[i]] + vi[i], dp[i-1][j]);
			}
		}
	}
	
	printf("%lld\n", dp[n][w]);
}

Measured memory_bytes: 79360
import sys
import numpy as np

sys.setrecursionlimit(10**7)

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

LEN = 1 << N
H = np.zeros(LEN,dtype = np.int64)
cost = np.zeros(LEN,dtype = np.int64)
# print(N,K)
# print(A)
for i,a in enumerate(A):
    bit = 1 << i
    H[bit:2*bit] = np.maximum(H[:bit]+1,a)
    H[:bit] = np.maximum(H[:bit],a)
    cost[bit:2*bit] = (H[bit:2*bit] - a) + cost[:bit]

pop_count = np.zeros(LEN,dtype=np.int32)
for i in range(LEN):
    pop_count[i] = bin(i).count('1')


print(cost[pop_count >= K].min())

Measured memory_bytes: 13196
#include <cmath>
#include <iostream>
#include <vector>

void warshall_floyd(std::vector<std::vector<int>>& dist){
  int N = dist.size();
  for(int k = 0; k < N; k++){
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
        dist[i][j] = std::min(dist[i][j], dist[i][k]+dist[k][j]);
        dist[j][i] = dist[i][j];
      }
    }
  }
}

int main(){
  int H,W;
  std::cin >> H >> W;

  std::vector<std::vector<int>> dist(H*W, std::vector<int>(H*W, 10000));
  std::vector<std::vector<char>> map(H, std::vector<char>(W));
  for(int i = 0; i < H*W; i++) dist[i][i] = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      char c;
      std::cin >> map[i][j];
      if(j > 0){
        if(map[i][j] == '.' && map[i][j-1] == '.'){
          dist[i*W+j][i*W+j-1] = 1;
          dist[i*W+j-1][i*W+j] = 1;
        }
      }
      if(i > 0){
        if(map[i][j] == '.' && map[i-1][j] == '.'){
          dist[i*W+j][(i-1)*W+j] = 1;
          dist[(i-1)*W+j][i*W+j] = 1;
        }
      }
    }
  }
  warshall_floyd(dist);

  int max_dist = 0;
  for(int i = 0; i < H*W; i++){
    for(int j = 0; j < H*W; j++){
      if(dist[i][j] != 10000){
        max_dist = std::max(max_dist, dist[i][j]);
      }
    }
  }
  std::cout << max_dist << std::endl;

  return 0;
}



Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<unsigned long long> list;
	for (auto i = 0; i < N; ++i)
	{
		auto a = 0ull;
		cin >> a;
		list.push_back(a);
	}

	sort(list.begin(), list.end());

	vector<pair<unsigned long long, unsigned long long>> op;
	for (auto i = 0; i < M; ++i)
	{
		unsigned long long b, c;
		cin >> b >> c;
		op.push_back(make_pair(c, b));
	}

	sort(op.begin(), op.end(), greater<pair<unsigned long long, unsigned long long>>());

	auto ai = 0;
	auto result = 0ull;
	for(auto j = 0; j < op.size(); ++j)
	{
		auto& p = op[j];
		for (auto k = 0; k < p.second; ++k)
		{
			if (list[ai] < p.first)
			{
				++ai;
				result += p.first;
			}
			else
			{
				j = op.size();
				break;
			}
			if (ai >= N)
			{
				j = op.size();
				break;
			}
		}
	}

	for (; ai < N; ++ai)
	{
		result += list[ai];
	}

	cout << result << endl;

	return 0;
}


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

using namespace std;
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
ll sum(ll n){

return ((n*(n+1))/2);

}
int main(){

fast();

int a,b,c;
cin>>a>>b>>c;

if(a<b){
     if(b<c){
         if(c>a){
             cout<<"Yes"<<endl;
         }
         else cout<<"No"<<endl;
     }
     else cout<<"No"<<endl;
}
else cout<<"No"<<endl;

return 0;
}



Measured memory_bytes: 3168
import heapq
n,m = map(int,input().split())
d = [0] * m
a = list(map(int,input().split()))
s = sum(a)
for i in range(n):
  c = a[i]
  while True:
    c,p = c//2,c
    if p-c > d[0]:
      heapq.heappushpop(d,p-c)
    else:
      break
print(s-sum(d))

Measured memory_bytes: 14920
#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 endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

int dx[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] = { 0, 0, 1, -1, 1, -1, 1, -1 };

ll n, t, ans;
vector<ll> v;
queue<ll> Q;

int main() {
	fastio;
	cin >> n;
	FOR(i, n) {
		cin >> t;
		v.pb(t);
	}
	sort(all(v), greater<ll>());
	Q.push(v[0]);
	for(int i=1; i<sz(v); i++){
		ans += Q.front(); Q.pop();
		Q.push(v[i]);
		Q.push(v[i]);
	}
	cout << ans;
}

Measured memory_bytes: 6364