akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
const int N=2*1e5;
ll ara[200005];
map<ll,ll>mp;
int main()
{
    ll n;
    scanf("%lld",&n);
    for(int i=0;i<n;i++)
        scanf("%lld",&ara[i]);
    mp[0]=1;
    ll cnt=0;
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        sum+=ara[i];
        if(mp[sum])cnt+=mp[sum];
        mp[sum]++;
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 14336
#include <stdio.h>
int main(void) {
	int H, W;
	int n, i, j;
	while(n<1000000){
	scanf("%d %d",&H, &W);
	if(H == 0 && W == 0){
	    break;
	}
		for(i=0; i<H; i++){
			for(j=0; j<W; j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2104
#-*-coding:utf-8-*-

def digit_sum(n):
    s = str(n)
    array = list(map(int, s))
    return sum(array)

def main():
    n = input()
    digit=len(n)
    nine_numbers=n.find('9')
    limit=0

    if int(n)<=9:
        print(n)

    elif digit==nine_numbers:
        print(9*int(nine_numbers))

    else:
        max_ans = digit_sum(n)
        head=int(n[0])-1
        limit=str(head)+'9'*(digit-1) 
        ans = max(max_ans,digit_sum(limit))
        print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 3064
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,w,z;
    char ca,cb,cc;
    cin>>str;
    sum=700;
    if(str[0]=='o')sum+=100;
    if(str[1]=='o')sum+=100;
    if(str[2]=='o')sum+=100;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>

int main(int argc,const char * argv[])

{
    int x,y,a,b,c,d;
    char op;
    while(1){
        scanf("%d %c %d", &x, &op, &y);
    
        if (op == '?')break;
        if (op == '-') {
            b = x - y;
            printf("%d\n",b);
    }else if (op == '*') {
        c = x * y;
        printf("%d\n",c);
    }else if (op == '/') {
        d = x / y;
        printf("%d\n",d);
    }else if (op == '+') {
        a = x + y;
        printf("%d\n",a);
    }
    }
    return 0;
}


Measured memory_bytes: 2080
import sys
sys.setrecursionlimit(10**9)

MOD=10**9+7
n,a,b=map(int,input().split())

def pow_mod(x,n):
  if n==0:
    return 1
  elif n==1:
    return x
  else:
    xn2=pow_mod(x,n//2)
    if n%2==0:
      return (xn2*xn2)%MOD
    else:
      return (xn2*xn2*x)%MOD

def fact_mod(a):
  if a<=1:
    return 1
  else:
    return a*fact_mod(a-1)%MOD
  
def perm_mod(n,a):
  if a==1:
    return n
  else:
    return (n*perm_mod(n-1,a-1))%MOD

def inv_mod(a):
  return pow_mod(a,MOD-2)%MOD
  
def comb_mod(na,fa):
  ainv=inv_mod(fa)
  return (na*ainv)%MOD
  
num_all=pow_mod(2,n)-1
perm_na=perm_mod(n,a)
fact_a=fact_mod(a)
comb_na=comb_mod(perm_na,fact_a)
#print(perm_na,fact_a,comb_na)
perm_nb=perm_mod(n,b)
fact_b=fact_mod(b)
comb_nb=comb_mod(perm_nb,fact_b)
#print(perm_nb,fact_b,comb_nb)
#print(num_all,comb_na,comb_nb)
print((num_all-comb_na-comb_nb+MOD)%MOD)

Measured memory_bytes: 181236
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
  //しょっぱなやばい、とけなそう感･･･
  //方針たたんな
  //最後から見るか。
  //連結数はN(N-1)/2。最後は-1;
  //毎回すべての連結確認する、はむりむり
  //1[2,3,,,10] 2[3,4,,,10] 3[4,5,,,10]みたいな
  //和を足せばいい？
  //んなことないか。1-2,1-3,2-3で1-2きれても3連結
  //孤立した島の積をとるか
  //1-2-3,4-5-6だったら3*3=9がだめ 3+3+3
  //1,2,3,4,5だったら？5*4/2 4+4+4+4+4)/2
  //1-2,3-4,5だったら8 3+3+3+3+4)/2
  //はしを1本折るごとに探索してたんじゃ絶対むりむりちん10^5でしょ
  //DP,どんなふうに・・・。
  //俺のもってる知識じゃまったくあてにならなそうだな。
  //解答みちゃう。
  //ミカサがどうしたって?
  //Union-Findすげえ。sizeを調べるのはどうしたらいいか
  //子どものsizeの配列をつねに用意。親に+1しとく
  //1-2でS[1]=2 S[2]=1
  //1-2-3 1-2-4 で、S[4]=1 S[3]=1 S[2]=3 S[1]=4みたいな感じか
  //S[親]+=S[子1]+S[子2]か
struct UnionFind{
  vector<ll> par;
  vector<ll> siz;
  
  UnionFind(ll N):par(N),siz(N,1){
    for(int i=0; i<N; i++){
      par[i]=i;
    }
  }
  
  ll root(ll x){
    if(par[x]==x)
       return x;
    return par[x] = root(par[x]);
  }
  
  void unite(ll x, ll y){
    ll rx=root(x), ry=root(y);
    if(rx==ry)
      return;
    par[ry] = rx;//x<yとしたい
    siz[rx]+=siz[ry];//小さい数に集める
  }
  
  bool issame(ll x, ll y){
    return root(x)==root(y);
  }
  
  ll size(ll x){
    return siz[root(x)];
  }
};

int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll> A(M,0), B(M,0);
  for(int i=0; i<M; i++){
    ll a,b;
    cin>>a>>b;
    A[i]=a-1;
    B[i]=b-1;
  }  
  UnionFind tree(N);
  ll all=N*(N-1)/2;  
  vector<ll> ans(M,0);
  for(int i=M-1; i>=0; i--){
    ans[i]=all;
    if(all==0)
      break;
    //連結成分の大きさってなんだ
    //all-N1*N2をしたい
    //いみわかった。
    //1 2-3 4 5 9 10-1*1
    //1 2-3 4-5 8 9-1*1
    //1-2-3 4-5 6 8-1*2
    //1-2-3-4-5 0 6-3*2
    if(tree.issame(A[i],B[i])==false){
      all-=tree.size(A[i])*tree.size(B[i]);
    }
    tree.unite(A[i],B[i]);
  }
  for(int i=0; i<M; i++)
    cout<<ans[i]<<endl;
}


Measured memory_bytes: 5248
s = input()

if s == "SUN":
   print(7)

elif s == "MON":
   print(6)

elif s == "TUE":
   print(5)

elif s == "WED":
   print(4)

elif s == "THU":
   print(3)

elif s == "FRI":
   print(2)

elif s == "SAT":
   print(1)


Measured memory_bytes: 2940
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	while (cin >> n >> m, n) {
		vector<string> p(n), q(m);
		REP(i, n)cin >> p[i];
		REP(i, m)cin >> q[i];
		vi ind(n);
		REP(i, n) {
			int cnt = 0;
			REP(j, p[i].size()) {
				if (p[i][j] != '.')break;
				cnt++;
			}
			ind[i] = cnt;
		}
		vi res(m, -1);
		REP(i, 20)REP(j, 20)REP(k, 20) {
			int r = 0, c = 0, s = 0;
			bool ok = true;
			REP(a, n) {
				if (ind[a] != (i + 1)*r + (j + 1)*c + (k + 1)*s)ok = false;
				REP(b, p[a].size()) {
					if (p[a][b] == '(')r++;
					else if (p[a][b] == ')')r--;
					else if (p[a][b] == '{')c++;
					else if (p[a][b] == '}')c--;
					else if (p[a][b] == '[')s++;
					else if (p[a][b] == ']')s--;
				}

			}
			if (!ok)continue;
			r = 0, c = 0, s = 0;
		
			REP(a, m) {
				if(res[a]==-1)res[a] = (i + 1)*r + (j + 1)*c + (k + 1)*s;
				else if(res[a]!=(i + 1)*r + (j + 1)*c + (k + 1)*s)res[a] = INF;
				REP(b, q[a].size()) {
					if (q[a][b] == '(')r++;
					else if (q[a][b] == ')')r--;
					else if (q[a][b] == '{')c++;
					else if (q[a][b] == '}')c--;
					else if (q[a][b] == '[')s++;
					else if (q[a][b] == ']')s--;
				}
			}

		}
		REP(i, m) {
			if (i)cout << " ";
			if (res[i] == INF)cout << -1;
			else cout << res[i];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define nn 2008
char a[nn],b[nn];int n;
int tol[nn],tor[nn];

int ans=1e9;

int faq[nn];
void chkmax(int &x,int y) {x=max(x,y);}
void solve()
{
		
	for(int i=0;i<n;i++)
	{
		tol[i]=tor[i]=0;
		for(int j=0;j<=n;j++,tol[i]=j)
			if(b[(i-j+n)%n]-'0') break;
			
		for(int j=0;j<=n;j++,tor[i]=j)
			if(b[(i+j)%n]-'0') break;
		
	}
	
	for(int x=0;x<n;x++)
	{
		memset(faq,0,sizeof faq);int chg=0;
		for(int i=0;i<n;i++)
			if(b[(i+x)%n]!=a[i]) 
			{
				if(tol[i]>=n) chg=1e9;
				chkmax(faq[tol[i]],tor[i]),chg++;
			}
		
		int ss=x;	
		for(int l=n-1;l>=0;l--)
		{
			chkmax(ss,faq[l+1]);
			ans=min(ans,ss*2-x+l*2  +chg);
		}
		
	}
	
}

int main()
{
	scanf("%s%s",a,b);n=strlen(a);
	
	solve();
	
	reverse(a,a+n);reverse(b,b+n);
	solve();
	
	if(ans>1e8) ans=-1;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,count=0;
    cin >> n;
    vector<int> h(n);
    int maxv=1;
    for(int i=0;i<n;i++) cin >> h[i];
        for(int i=0;i<n;i++){
            maxv = max(maxv, h[i]);
            if(maxv-h[i]>=2){
                cout << "No";
                return 0;
            }
        }
        cout << "Yes";
        return 0;
 
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
	string str;
	map<char,bool> map;
	bool flag=true;
	cin >> str;
	for(int i=0;i<str.length();i++){
		if(map[str[i]]==true){
			flag=false;
			break;
		}
		map[str[i]]=true;
	}
	if(flag==true){
		cout << "yes" << endl;
	}else{
		cout << "no" << endl;
	}
	return 0;
}

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

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

	int n, m; cin >> n >> m;
	vector<int> h(n+1);
	for (int i = 1; i <= n; i++) cin >> h[i];

	vector<int> good(n+1, 1);
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		if (h[x] <= h[y]) good[x] = 0;
		if (h[y] <= h[x]) good[y] = 0;
	}

	int ans = 0;
	for (int i = 1; i <= n; i++) ans += good[i];
		cout << ans;

	return 0;
}


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl

using namespace std;

typedef long long ll;
typedef string str;

const ll MAXN = 1e5 + 10;
const ll MOD = 1000000000000037;

ll n, a[MAXN], ps[MAXN];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	str s;
	cin >> s;
	ll cnt = 0;
	for(auto x : s) if(x == 'x') cnt ++;
	cout << (cnt >= 8 ? "NO" : "YES");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<int,int>cnt;
  for (int i = 1; i <= n; ++i) {
    int num;
    cin >> num;
    cnt[num]++;
  }
  int ans = 0;
  for(auto it : cnt) ans += (it.second % 2);
  cout << ans;
  return 0;
}

Measured memory_bytes: 8096
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int maxi = 0;
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++)
    {
        cin >> p[i];
        maxi = max(maxi, p[i]);
    }
    cout << accumulate(p.begin(), p.end(), 0) - maxi + maxi / 2;

    return 0;
}


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

namespace Internship
{
    class Program
    {
        static void Main(string[] args)
        {
           string[] str =Console.ReadLine().Split(' ');
           int a = int.Parse(str[0]);
           int b = int.Parse(str[1]);
           Console.WriteLine("{0} {1}", a * b, 2 *(a + b));
        }

    }
}

Measured memory_bytes: 9168
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define va vector<long long int> a 
#define vb vector<long long int> b
#define M 1000000007
using namespace std;
ll t;
void fast(){cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);}
ll power(ll x,ul y,ll p){ll res = 1;x = x % p;if(x == 0)return 0;while (y > 0){if (y & 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res%p;}
void solve(){
	ll n;
	cin>>n;
	for(ll i=-1000;i<1000;i++){
		for(ll j=-1000;j<1000;j++){
			 //cout<<(power(i,5,M)-power(i,5,M))%M<<"\n";
			 if((i*i*i*i*i)-(j*j*j*j*j)==n){ cout<<i<<" "<<j<<"\n"; 
				 i=1000; j=1000;}
		 }
	 }
	
}
int main(){
	fast();
	solve();
	return 0;
}



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

const int KK = 12, RT = 6, X = 800;
int f[X], p3[KK+1];

void pre() {
    p3[0] = 1;
    for (int i=1; i<=KK; i++)    p3[i] = p3[i-1]*3;

    for (int i=0; i<X; i++) {
        for (int k=0; k<KK; k++) {
            int d = (i/p3[k])%3;
            if (d == 1)      f[i] += p3[k]*2;
            else if (d == 2) f[i] += p3[k];
        }
    }

}

int aa[X*X], bb[X*X];
vector<int> v[X];
int asol[X], temp[X], vid[X];

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

    pre();

    int n;
    string s;
    cin>>n>>s;


    int mx = p3[max(0, n-RT)];
    int my = p3[min(RT, n)];
    int all = p3[n];


    for (int i=0; i<mx; i++)
        for (int j=0; j<my; j++)
            v[i].push_back(my*i + j);

    for (int j=0; j<my; j++)    asol[j] = j;
    for (int i=0; i<mx; i++)    vid[i] = i;

    for (char c: s) {
        if (c == 'R')  {
            for (int i=0; i<mx; i++)    temp[i] = v[vid[i]][asol[my-1]];

            int st = asol[my-1];
            for (int i=my-1; i>0; i--)    asol[i] = asol[i-1];
            asol[0] = st;

            for (int i=1; i<mx; i++)    v[vid[i]][asol[0]] = temp[i-1];
            v[vid[0]][asol[0]] = temp[mx-1];
        }
        else {
            for (int i=0; i<my; i++)
                if (f[i] > i)
                    swap(asol[i], asol[f[i]]);

            for (int i=0; i<mx; i++)
                if (f[i] > i)
                    swap(vid[i], vid[f[i]]);
        }

//        for (int i=0; i<my; i++)    cout<<asol[i]<<" "; cout<<":::"<<endl;
//        for (int i=0; i<my; i++)    cout<<v[0][i]<<" "; cout<<"---"<<endl;
    }

    for (int i=0; i<mx; i++)
        for (int j=0; j<my; j++)
            aa[i*my+j] = v[vid[i]][asol[j]];


    for (int i=0; i<all; i++) bb[aa[i]] = i;
    for (int i=0; i<all; i++) cout<<bb[i]<<" ";
    cout<<endl;
}


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

using namespace std;

int main(){
    long long int N,M,ans=0,pp=0;
    cin >> N >> M;

    vector<long long int> p(M),ac(N,0),pena(N,0);
    vector<string> S(M);

    for(int i=0;i<M;i++){
        cin >> p[i] >> S[i];
        p[i]--;
        if(ac[p[i]]==0 && S[i]=="AC"){
            ac[p[i]] = 1;
        }else if(ac[p[i]]==0 && S[i] == "WA"){
            pena[p[i]]++;
        }
    }

    for(int i=0;i<N;i++){
        if(ac[i]==1){
            ans++;
            pp += pena[i];
        }
    }

    cout << ans << " " << pp << endl;
}

Measured memory_bytes: 8064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc131/tasks/abc131_c>
 問題文============================================================
 =================================================================
 解説=============================================================
 
 calc(n) := 0以上n以下の整数でCでもDでも割り切れない数
 とした関数を作る
 calc(B)とcalc(A-1)の差分を取ることで答えを求められる。

 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll A,B,C,D;
    cin >> A >> B >> C>> D;
    
    auto calc = [&](ll n){
        return n - n/C - n/D + n/lcm(C,D);
    };
    
    res = calc(B) - calc(A-1);
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL){
        y = x;
        if(z->key < x->key) x = x->left; 
        else x = x->right;
    }

    z->parent = y;

    if(y == NIL) root = z;
    else if(z->key < y->key) y->left = z;
    else y->right = z;
}

void inorder(Node *u){
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

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

    char com[10];
    int x;

    

    rep(i,n){
        scanf("%s",com);
        if(com[0] == 'i'){
            scanf("%d", &x);
            insert(x);
        }else{
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 26656
s = input()
t = input()
dp = [[0]*(len(s)+1) for i in range(len(t)+1)]
for i in range(len(s)+1):
    dp[0][i] = i
for j in range(len(t)+1):
    dp[j][0] = j
for i in range(len(t)):
    for j in range(len(s)):
        cost = 0
        if t[i]!=s[j]:
            cost+=1
        dp[i+1][j+1] = min(dp[i][j]+cost, dp[i+1][j]+1, dp[i][j+1]+1)
print(dp[-1][-1])


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

#define ll long long
#define endl "\n"

int main ()
{

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #define int ll
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    
    int n;
    cin >> n;

    int cont[10][10];
    memset(cont, 0, sizeof(cont));

    int ans = 0;
    for (int i=1; i<=n; i++){
        string now = to_string(i);
        int first = now[0] - '0';
        int second = i%10;
        cont[first][second]++;
    }

    for (int i=1; i<=9; i++){
        for (int j=1; j<=9; j++){
            ans += cont[i][j]*cont[j][i];
        }
    }

    cout << ans << endl;
    cerr << "Sadat" << endl;

    return 0;

}


Measured memory_bytes: 3740
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := readInt()
	K := readInt()

	c := make([][]int, 4000)
	for i := 0; i < 4000; i++ {
		c[i] = make([]int, 4000)
	}
	c[0][0] = 1
	for i := 0; i < 4000; i++ {
		c[i][0] = 1
		for j := 1; j < i+1; j++ {
			c[i][j] = (c[i-1][j-1] + c[i-1][j]) % 1000000007
		}
	}

	f := func(n, k int) int {
		return c[n+k-1][k-1]
	}

	for i := 1; i <= K; i++ {
		fmt.Println(f(K-i, i) * f(N-K-(i-1), i+1) % 1000000007)
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


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

int main(int argc, char const *argv[]) {
	int N;
	int count = 1;
	int a[101] = {0};
	int ans = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		if (a[i-1] == a[i] && i>0) {
			count++;
		}else{
			if(count%2 == 0) {
				ans = ans + count/2;
				count = 1;
			}else{
				ans = ans + count/2;
				count = 1;
			}
		}
	}
	if(count%2 == 0 && count > 0) {
		ans = ans + count/2;
		count = 1;
	}else if(count%2 == 1 && count > 1){
		ans = ans + count/2;
		count = 1;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;
bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}
void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}
int main(void){
   int N;
   cin>>N;
   vector<int> p(N+1);
   for(int i=0;i<N;i++){
      cin>>p[i];
   }
   int ans=0;
   for(int i=0;i<N;i++){
      if(p[i]==i+1) {
         ans++;
         swap(&p[i],&p[i+1]);
      }
      if(p[i]==i+1&&p[i+1]==i+2){
         ans--;
         swap(&p[i],&p[i+1]);
      } 
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	string s; cin >> s;
	vi a(n + 1), b(n + 1);
	REP(i, n) {
		a[i + 1] = a[i];
		b[i + 1] = b[i];
		if (s[i] == '#')a[i + 1]++;
		else b[i + 1]++;
	}
	int ans = INF;
	REP(i, n + 1) {
		chmin(ans, a[i] + b[n] - b[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 2704
import java.util.Arrays;
import java.util.Scanner;

//B
public class Main {


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

		int N=sc.nextInt();
		double[]v=new double[N];
		for(int i=0;i<N;i++) {
			v[i]=sc.nextDouble();
		}
		Arrays.sort(v);

		//for(int i=0;i<N;i++)
		//System.out.println(v[i]);

		double ans=v[0];
		for(int i=1;i<N;i++) {
			ans=(ans+v[i])*0.5;
		}
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <map>
#include <set>
#include <bitset>
#include <fstream>
#include <iomanip>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){
    long long int n, k;
    cin >> n >> k;
    vector<long long int> v(n),w(n);
    REP(i,n){
        cin >> v[i];
    }
    long long int max_high,tmp_price, result = linf,mieru_num;
    REP(i,1<<n){
        copy(v.begin(), v.end(), w.begin());
        tmp_price = 0;
        max_high = w[0];
        mieru_num = 1;
        FOR(j,1,n){
            if(i&(1<<j)){
                if(w[j]<=max_high){
                    tmp_price += max_high + 1 - w[j];
                    w[j] = max_high + 1;
                }
                
            }
            if(max_high<w[j]){
                max_high = w[j];
                mieru_num++;
            }
        }
        if(mieru_num>=k){
            result = min(result, tmp_price);
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N, A, B;
	int DigitSum = 0;
	int Sum = 0;

	scanf("%d %d %d", &N, &A, &B);
	
	for(int Num = 1; Num <= N; Num++){
		DigitSum = Num/10000 + (Num/1000-(Num/10000)*10) + (Num/100 - (Num/1000)*10) + (Num/10 - (Num/100)*10) + (Num - (Num/10)*10);
		if((A <= DigitSum) && (DigitSum <= B))	Sum += Num;
	}

	printf("%d\n", Sum);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int a, b;

int main() {
	cin >> a >> b;
	if (a + b < 10)cout << a + b << endl;
	else cout << "error" << endl;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

// ====================================================================

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> v(n), rui(n + 1);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.rbegin(), v.rend());  // 大きい順に並べる！
  for (int i = 0; i < n; i++) rui[i + 1] = rui[i] + v[i];

  // 幸福度上昇がi以上のやつがM通り以上ある、という境界を探す
  ll left = -1, right = INF;
  while (right - left > 1) {
    ll mid = (left + right) / 2;

    ll count = 0;                  // 個数をO(NlogN)で数える
    for (int l = 0; l < n; l++) {  // 左手を全探索して右手はにぶたん、個数を数える
      count += v.rend() - lower_bound(v.rbegin(), v.rend(), mid - v[l]);
    }

    if (count >= m)
      left = mid;
    else
      right = mid;
  }

  // leftが条件を満たすギリギリの幸福度上昇になっている

  ll ans = 0, count = 0;
  for (int i = 0; i < n; i++) {
    int right = v.rend() - lower_bound(v.rbegin(), v.rend(), left - v[i]);
    // cout << "r = " << right << " add = " << right * v[i] + rui[m] << endl;
    ans += right * v[i] + rui[right];
    count += right;
  }

  ans -= (count - m) * left;

  cout << ans << endl;
}


Measured memory_bytes: 1792
from typing import List


def answer(n: int, t: int, cts: List[List[int]]) -> int:
    costs = [route[0] for route in cts if route[1] <= t]
    if not costs:
        return -1

    return min(costs)


def main():
    n, t = map(int, input().split())
    cts = [list(map(int, input().split())) for _ in range(n)]
    ans = answer(n, t, cts)
    print(ans if ans != -1 else 'TLE')


if __name__ == '__main__':
    main()


Measured memory_bytes: 10200
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A, B, C;
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();

		for (int i = 0; i <= B * A; i += A) {
			if(i % B == C) {
				System.out.print("YES");
				return;
			}
		}
		System.out.print("NO");
	}
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,n;
pll ans[202020];
ll ans2;
ll i,j;



int main(){
    scanf("%lld", &N);
    if(N==3){
        printf("Yes\n1 2\n2 3\n3 4\n4 5\n5 6\n");
        return 0;
    }
    for (n = 1; n <= N;n*=2)
        ;
    n /= 2;
    if(N==n){
        printf("No");
        return 0;
    }
    ans2 = 0;
    fornum(i,1,n-1){
        ans[ans2++] = {i, i + 1};
        ans[ans2++] = {i+N, i+N + 1};
    }
    ans[ans2++] = {n-1, N + 1};
    if(N%2==1){
        fornum(i,n,N+1){
            ans[ans2++] = {i, i + 1};
            ans[ans2++] = { i + 1,1};
            ans[ans2++] = {1, N + i};
            ans[ans2++] = {N + i, N + i + 1};
            i++;
        }
    }else{
        ll a = N & (n - 1);
        fornum(i,n,N){
            ans[ans2++] = {i+1, i};
            ans[ans2++] = { i,a};
            ans[ans2++] = {a+1, N + i+1};
            ans[ans2++] = {N + i+1, N + i};
            i++;
        }
        ans[ans2++] = {N, n};
        ans[ans2++] = {a, N * 2};
    }
    printf("Yes\n");
    fornum(i,0,ans2){
        printf("%lld %lld\n", ans[i].first, ans[i].second);
    }

    return 0;
}

Measured memory_bytes: 5888
import sys
import math

def main():
    input = sys.stdin.readline
    #1行に複数の入力の時は.split()使う
    AB = input().split()
    A, B = int(AB[0]),int(AB[1].replace(".",""))
    print(A*B // 100)
    return


if __name__ == '__main__':
    main()


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

int main(){
    int n; cin>>n;
    map<ll, int> problems;
    for(int i=0; i<n; i++){
        ll d; cin>>d;
        if(problems.count(d)){
            problems[d]++;
        }
        else problems[d] = 1;
    }
    int m; cin>>m;
    for(int i=0; i<m; i++){
        ll t; cin>>t;
        if(problems.count(t) && (problems[t]>=1)) problems[t]--;
        else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 16004
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  k = int(input())
  numbers = [i for i in range(1,10)]
  n = 0
  while True:
    n += len(numbers)
    if k <= n:
      break
    _numbers = []
    for number in numbers:
      if number % 10 != 0:
        _numbers.append(10*number + number%10 - 1)  
      _numbers.append(10*number + number%10)
      if number % 10 != 9:
        _numbers.append(10*number + number%10 + 1)
      numbers = _numbers
      
  print(numbers[k-n-1])
    
if __name__=='__main__':
  main()



Measured memory_bytes: 10688
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(); 
        int b = 0;
		for(int i=0;i<a;i++){int c = sc.nextInt();
                            if(c!=i+1){b++;}
                            }     
        if(b<=2){System.out.println("YES");}
		else{System.out.println("NO");}
	}
}


Measured memory_bytes: 21844
package main

import (
  "fmt"
  "sort"
)

func main() {
  var a = make([]int, 3)
  for i := 0; i < 3; i++ {fmt.Scan(&a[i])}
  sort.Ints(a)
  var ans int
  if a[0] == a[1] {
    ans = a[2]
  } else {
    ans = a[0]
  }
  fmt.Println(ans)
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main() {
	int n, q, ans = 0, c[1100], b[1100];
	cin >> n; for (int i = 1; i <= n; i++) { cin >> c[i]; b[i] = 0; }cin >> q;
	bool flag = true;
	for (int i = 0; i < q; i++) {
		int t, d, x; cin >> t >> x >> d;
		if (flag) {
			if (t == 1) {
				b[x] += d;
				if (b[x] > c[x]) {
					ans = x;
					flag = false;
				}
			}
			else {
				b[x] -= d;
				if (b[x] < 0) {
					ans = x;
					flag = false;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b){
    if(a!=c){
      cout << "Yes";
    }else{
      cout << "No";
    }
  }else if(b==c){
    if(b!=a){
      cout << "Yes";
    }else{
      cout << "No";
    }
  }else if(a==c){
    if(a!=b){
      cout << "Yes";
    }else{
      cout << "No";
    }
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
 long X;
 long Y = 100;
 long C = 0;
 cin >> X;
 while( Y < X ){
	Y += Y / 100;
	C++;
 }
 cout << (C) << endl;
}

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

int main() {

  vector<int> b1(3);
  vector<int> b2(3);
  vector<int> b3(3);
  int N;
  vector<bool> a1(3);
  vector<bool> a2(3);
  vector<bool> a3(3);

  for(int i=0; i<3; i++){
    cin >> b1.at(i);
    a1.at(i) = false;
  }

  for(int i=0; i<3; i++){
    cin >> b2.at(i);
    a2.at(i) = false;
  }

  for(int i=0; i<3; i++){
    cin >> b3.at(i);
    a3.at(i) = false;
  }

  cin >> N;

  for(int i=0; i<N; i++){
    int num = 0;
    cin >> num;

    for(int j=0; j<3; j++){
      if(b1.at(j)==num){
        a1.at(j)=true;
      }
      if(b2.at(j)==num){
        a2.at(j)=true;
      }
      if(b3.at(j)==num){
        a3.at(j)=true;
      }
    }
    
  }

  bool bingo = false;

  if(a1.at(0)){
    if(a1.at(1)&&a1.at(2)){
      bingo = true;
    }else if(a2.at(0)&&a3.at(0)){
      bingo = true;
    }else if(a2.at(1)&&a3.at(2)){
      bingo = true;
    }
  }

  if(a1.at(1)&&a2.at(1)&&a3.at(1)){
    bingo = true;
  }

  if(a1.at(2)){
    if(a2.at(2)&&a3.at(2)){
      bingo = true;
    }else if(a2.at(1)&&a3.at(0)){
      bingo = true;
    }
  }

  if(a2.at(0)&&a2.at(1)&&a2.at(2)){
    bingo = true;
  }

  if(a3.at(0)&&a3.at(1)&&a3.at(2)){
    bingo = true;
  }

  if(bingo){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x; i++) {
        int j = x - i;
        if (i * 2 + j * 4 == y) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3608
// Problem : B - ... (Triple Dots)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long

string s;
int k;

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    cin>>k>>s;
    if(sz(s)<=k) cout<<s<<endl;
    else cout<<s.substr(0,k)<<"..."<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>

long long heap[100000],sz=0;
void push(int x){
	int i=sz++;
	while(i>0){
		int p=(i-1)/2;
		if(heap[p]>=x)break;
		heap[i]=heap[p];
		i=p;
	}
	heap[i]=x;
}
int pop(){
	int ret=heap[0];
	int x=heap[--sz];
	int i=0;
	while(i*2+1<sz){
		int a=i*2+1,b=i*2+2;
		if(b<sz&&heap[b]>heap[a])a=b;
		if(heap[a]<=x)break;
		heap[i]=heap[a];
		i=a;
	}
	heap[i]=x;
	return ret;
}

int main(){
	int n,m,i,j;
	long long a[100000];
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)scanf("%lld",&a[i]);
	for(i=0;i<n;i++)push(a[i]);
	for(i=0;i<m;i++){
		long long tm=pop();
		tm/=2;
		push(tm);
	}
	long long ans=0;
	for(i=0;i<n;i++)ans+=heap[i];
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
  int n;
  char str[1002],cmp[8]="Hoshino";
  scanf("%d%c",&n,&str[0]);
  for(int i=0;i<n;i++){
    gets(str);
    int cnt=0;
    int j=0;
    while(str[j]!='\0'){
      if(str[j]==cmp[cnt])cnt++;
      else cnt=0;
      if(str[j]==cmp[cnt])cnt++;
      if(cnt==7){str[j]='a';cnt=0;}
      j++;
    }
    puts(str);
  }
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
   ll k,a,b;cin >>k >>a >>b;
   ll ans=1;
   if(k<=a-1){
    cout << ans+k<< endl;
    return 0;
   }
   else {
    if(b-a<=2){
         cout << ans+k<< endl;
        return 0;
    }
    ans=a;k-=(a-1);
        ans+=(b-a)*(k/2)+k%2;
        cout << ans << endl;
   }
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include <algorithm>
#include <math.h>
using namespace std;
int main(void)
{

	vector<char> data(4);
	for (int i = 0; i < 4; i++)
	{
		cin >> data[i];
	}

	int cnt = 0;
	for (int i = 0; i < 3; i++)
	{
		if (data[i] == data[i + 1])
		{
			cnt++;
		}
	}
	if (cnt >= 1)
	{
		cout << "Bad" << endl;
	}
	else
	{
		cout << "Good" << endl;
	}
	
}

Measured memory_bytes: 256
import itertools as ite
import math

INF = 10 ** 18
try:
    while True:
        x1, y1, x2, y2, x3, y3, x4, y4 = map(float, raw_input().split())
        if (x1 <= x3 <= x2 or x1 <= x4 <= x2) and (y1 <= y3 <= y2 or y1 <= y4 <= y2):
            print "YES"
        elif (x3 <= x1 <= x4 or x3 <= x2 <= x4) and (y3 <= y1 <= y4 or y3 <= y2 <= y4):
            print "YES"
        elif (x1 <= x3 <= x2 and x1 <= x4 <= x2) and (y3 <= y1 <= y4 and y3 <= y2 <= y4):
            print "YES"
        elif (x3 <= x1 <= x4 and x3 <= x2 <= x4) and (y1 <= y3 <= y2 and y1 <= y4 <= y2):
            print "YES"
        else:
            print "NO"
except:
    pass



Measured memory_bytes: 4788
#include <iostream>
#define MAX 500000
#define INFINITY 2000000000
using namespace std;

int cnt = 0;
int arr[MAX];

void print(int arr[], int len) {
	for (int i = 0; i < len; i++) {
		if (i > 0) {
			cout << " ";
		}
		cout << arr[i];
	}
}

void merge(int arr[], int left, int mid, int right)
{
	//right是数组最后一个位置的下一个 
	int n1 = mid - left;	//左边元素的个数,不包括mid,从0~mid-1 
	int n2 = right - mid;	//右边元素的个数,mid~right-1
	
	int L[n1], R[n2];	//将来自上一层的数组一分为二（其中，左右两边分别有序）
	for (int i = 0; i < n1; i++) {
		L[i] = arr[left+i];	
	}
	for (int i = 0; i < n2; i++) {
		R[i] = arr[mid+i];
	}
	
	//标记，用于简化算法 
	L[n1] = INFINITY;
	R[n2] = INFINITY;
	
	//test-def
//	printf("n1: ");
//	print(L, n1);
//	printf("\nn2: ");
//	print(L, n2);
//	printf("\n\n");
	//test-end
	
	//归并为一个有序数组，放入上层数组中 
	int i = 0;
	int j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			arr[k] = L[i];
			i++;
		}
		else {
			arr[k] = R[j];
			j++;
		}
	}
	
	//test-def
//	printf("n1: ");
//	print(L, n1);
//	printf("\nn2: ");
//	print(L, n2);
//	printf("\n\n");
	//test-end
}

void MergeSort(int arr[], int left, int right)
{
	//至少有两个元素 arr[left],arr[left+1]
	//(arr[right]为最后一个元素的下一个，已越界) 
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		MergeSort(arr, left, mid);
		MergeSort(arr, mid, right);
		merge(arr, left, mid, right);
	}
}



int main(void)
{

	int n;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	MergeSort(arr, 0, n);
	print(arr, n);
	cout << endl << cnt << endl;
	
	return 0;
 } 


Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define rep0(i, n) for (int i = 1; i <= (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LO
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
int main(){
    long long l,r;
    cin>>l>>r;
    if (r-l>=2019){
        cout<<0<<endl;
    }
    else{
        int ans = 2019;
        for (long long i=l; i<r; i++){
            for(long long j=i+1; j<=r; j++){
                chmin(ans,i*j%2019);
            }
        }
        cout<<ans<<endl;

    }
    return 0;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
using namespace std;
int main(){
  int a1,a2,a3;
  cin >> a1 >> a2 >> a3;
  if(a1+a2+a3>=22){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import fractions
mod=10**9+7
def lcm(m,n):return m//fractions.gcd(m,n)*n
n=int(input())
a=list(map(int,input().split()))
l=a[0]
ans=0
for i in a:l=lcm(i,l)
for i in a:ans+=l*pow(i,mod-2,mod)%mod
print(ans%mod)

Measured memory_bytes: 6072
#include <bits/stdc++.h>
#define inf 1000000000000000007LL
#define mod 1000000007
//#pragma GCC optimize(2)
#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n,k,p[5005],c[5005];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>p[i];
	for(int i=1;i<=n;i++)
		cin>>c[i];
	int ans=-inf;
	for(int i=1;i<=n;i++)
	{
		vector<int> v;
		int x=p[i];
		while(x!=i)
		{
			v.push_back(x);
			x=p[x];
		}
		v.push_back(i);
		if(v.size()==1)
		{
			ans=max(ans,max(c[i],c[i]*k));
			continue;
		}
		int res=-inf,sum=0;
		for(int j=0;j<min(k,(long long)v.size());j++)
		{
			sum+=c[v[j]];
			res=max(res,sum);
		}
		if(k<=v.size())
		{
			ans=max(ans,res);
			continue;
		}
		int cyc=k/v.size(),rem=k%v.size();
		if(sum<0)
		{
			ans=max(ans,res);
			continue;
		}
		sum*=cyc;
		res=max(res,sum);
		for(int j=0;j<rem;j++)
		{
			sum+=c[v[j]];
			res=max(res,sum);
		}
		for(int j=0;j<rem;j++)
			sum-=c[v[j]];
		for(int j=v.size()-1;j>=0;j--)
		{
			sum-=c[v[j]];
			res=max(res,sum);
		}
		ans=max(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define D                double
#define F                first
#define S                second
#define pb               push_back
#define pf               push_front
#define MP               make_pair
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define it(it,mp)        for(auto it=mp.begin() ; it!=mp.end() ; it++)
#define IOS              ios_base :: sync_with_stdio(false); cin.tie(NULL);
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
typedef long long int                   ll;
typedef pair<int,int>                   PII;
char curr_val ;
int main()
{
    IOS
    // READ("test.txt");
    //WRITE("");
    ll n , a ;
    bool flag = true ;
    cin >> n ;
    while(n--)
    {

        cin >> a;
        if(a%2 == 0 && a%3 && a%5){
            flag = false ;

        }
    }
    (flag)?cout<<"APPROVED":cout<<"DENIED";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll p(n), q(n), sp(n + 1, 0), sq(n + 1, 0);
    REP(i, n){
        cin >> p[i];
        sp[i + 1] = sp[i] + p[i];
    }
    REP(i, n){
        cin >> q[i];
        sq[i + 1] = sq[i] + q[i];
    }
    ll res = -1;
    REP(j, n){
        ll tmp = sp[j + 1] + (sq[n] - sq[j]);
        res = max(res, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll n, k;
ll ans = 0;

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

	for (int b = k+1; b <= n; b++) {
		int pull = n / b * k + (k - 1);

		if (n / b*b + k - 1 > n)pull -= n / b*b + (k - 1) - n;

		ans += n - pull;
	}


	if (k == 0)ans = n*n;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

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

int main() {
  vector<vector<int> > a(3, vector<int>(3));
  rep(i, 3){
    rep(j, 3){
      cin >> a[i][j];
    }
  }
  int N;
  cin >> N;
  int b;
  vector<vector<bool> > c(3, vector<bool>(3, false));
  rep(i, N){
    cin >> b;
    rep(i, 3){
      rep(j, 3){
        if (a[i][j]==b){
          c[i][j] = true;
        }
      }
   }
  }

  bool flag =false;
  int cnt = 0;
  // 横のビンゴをみていく
  rep(i, 3){
    cnt = 0;
      rep(j, 3){
        if(c[i][j]) cnt++;
      }
    if (cnt == 3) flag = true;
  }
  // たてのビンゴ
  rep(i, 3){
    cnt = 0;
      rep(j, 3){
        if(c[j][i]) cnt++;
      }
    if (cnt == 3) flag = true;
  }
  // 斜めのビンゴ
  if (c[0][2] == 1 && c[1][1] == 1 && c[2][0] == 1) flag = true;
  if (c[0][0] == 1 && c[1][1] == 1 && c[2][2] == 1) flag = true;
  
  // rep(i, 3){
  //   rep(j, 3){
  //     cout << c[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  // cout << c[0].at(2) << c[1][1] << c[2][0] << endl;
  // cout << c[2][0] << c[1][1] << c[0][2] << endl;
  if(flag){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }

}


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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int main() {
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
    return 0;
}


Measured memory_bytes: 3584