akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
typedef long long ll;
typedef vector<ll> poly;
ll C[11][11];
poly operator+(poly x,poly y){
	poly ret(21,0);
	rep(i,21){
		ret[i]=x[i]+y[i];
	}
	return ret;
}
poly operator-(poly x,poly y){
	poly ret(21,0);
	rep(i,21){
		ret[i]=x[i]-y[i];
	}
	return ret;
}
poly operator*(poly x,poly y){
	poly ret(21,0);
	rep(i,21) rep(j,21){
		if(i+j>20) continue;
		ret[i+j]+=x[i]*y[j];
	}
	return ret;
}
poly operator*(ll x,poly y){
	poly ret(21,0);
	rep(i,21){
		ret[i]=x*y[i];
	}
	return ret;
}
void Answer(poly p){
	int w=0;
	for(int i=20;i>=0;i--){
		if(w!=0||p[i]!=0){
			if(w==0){
				if(p[i]==1) w=1;
				else w=-1;
			}
			cout<<p[i]*w;
			if(i==0) cout<<endl;
			else cout<<" ";
		}
	}
}
int main(){
	rep(i,11){
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;j++) C[i][j]=C[i-1][j-1]+C[i-1][j];
	}
	while(true){
		ll a,m,b,n;
		cin>>a>>m>>b>>n;
		if(m==0) break;
		if(m>n) swap(m,n),swap(a,b);
		poly co[4];
		rep(i,4) co[i].assign(21,0);
		if(m==4){
			co[0][0]=-b;
			ll now=1;
			rep(i,n+1){
				co[i%4][n-i]+=C[n][i]*now*(i%2==0 ? 1 : -1);
				if(i%4==3) now*=a;
			}
			poly p=co[3],q=co[2],r=co[1],s=co[0];
			poly ans=a*a*a*p*p*p*p+a*a*(-4*p*p*q*s-2*p*p*r*r+4*p*q*q*r-q*q*q*q)+a*((4*p*r+2*q*q)*s*s-4*q*r*r*s+r*r*r*r)-s*s*s*s;
			Answer(ans);
		}else if(m==3){
			co[0][0]=-b;
			ll now=1;
			rep(i,n+1){
				co[i%3][n-i]+=C[n][i]*now*(i%2==0 ? 1 : -1);
				if(i%3==2) now*=a;
			}
			poly p=co[2],q=co[1],r=co[0];
			poly ans=a*a*p*p*p+a*(q*q*q-3*p*q*r)+r*r*r;
			Answer(ans);
		}else if(m==2){
			co[0][0]=-b;
			ll now=1;
			rep(i,n+1){
				co[i%2][n-i]+=C[n][i]*now*(i%2==0 ? 1 : -1);
				if(i%2==1) now*=a;
			}
			poly p=co[1],q=co[0];
			poly ans=a*p*p-q*q;
			Answer(ans);
		}
	}
}

Measured memory_bytes: 1244
#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;

/////////////////////////////////////////////////////
#define INF 1e15
ll N, A[101010];
ll Asum[101010];
ll ans[101010],ans2;
ll i, j, k,l;


int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }
    sort(A, A + N);
    ans2 -= A[0];
    fornum(i,1,N-1){
        if(A[i]>0){
            ans2 += A[i];
        }else{
            ans2 -= A[i];
        }
    }
    ans2 += A[N - 1];
    printf("%lld\n", ans2);
    if(A[N-1]<0){
        j = A[N - 1];
        fornum(i,0,N-1){
        printf("%lld %lld\n", j, A[i]);
            j = j - A[i];
        }
    }
    else{
        j = A[0];
        ll flg = 0;
        fornum(i,0,N-1){
        if(i<N-2&&A[N-2-i]>0||flg){
            printf("%lld %lld\n", j, A[N - 1 - i]);
            j = j - A[N - 1 - i];
        }else{
            printf("%lld %lld\n", A[N - 1 - i], j);
            j = A[N - 1 - i] - j;
            flg = 1;
        }
    }
    }
    
    
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); 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 ifaxb(a, x, b) if (a < x && x < b)
#define toInt(x) (x - '0')
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vvs vector<vs>
#define all(x) x.begin(), x.end()
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  cout << ((N % K) ? 1 : 0) << endl;
  return 0;
}

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

int N,X;

// *********************************************************
int main(){

    cin >>  N ;

    int a;

    a= N%1000;

    if(a==0){
        cout << 0<<endl;
    }else{

    cout<< 1000 - a <<endl;

    }



    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b, c;
  cin >> a >> b >> c;
  cout << (a - c <= 0 && a + b >= c ? "YES" : "NO") << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll; 
 
using namespace std;
 
int main() {
	int K, S;
	cin >> K >> S;

	int res = 0;
	for (int x = 0; x <= K; ++x) {
		for (int y = 0; y <= K; ++y) {
			int z = S - (x + y);

			if ((z >= 0) && (z <= K)) {
				++res;
			}
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_A&lang=jp
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	a := nextInt(sc)
	b := nextInt(sc)

	d := a / b
	r := a % b
	f := float64(a) / float64(b)

	fmt.Printf("%d %d %f\n", d, r, f)
}

func nextInt(sc *bufio.Scanner) int64 {
	sc.Scan()
	i64, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i64
}


Measured memory_bytes: 1104
#include <cstdio>
#include <cstring>
int buc[100001],n,q;
int main()
{
	scanf("%d",&n);long long sum=0;
	for(int i=1;i<=n;++i){int x;scanf("%d",&x);sum+=x;++buc[x];}scanf("%d",&q);
	while(q--)
	{
		int b,c;scanf("%d%d",&b,&c);sum-=1ll*buc[b]*b;sum+=1ll*buc[b]*c;
		buc[c]+=buc[b];buc[b]=0;printf("%lld\n",sum);
	}return 0;
}

Measured memory_bytes: 2116
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;
 
int main(){
    ll N;
    string S;
    cin >> N >> S;
    ll R,G,B;
    R = G = B = 0;
    for (int i = 0; i < N; i++)
    {
        if(S[i] == 'R') R++;
        else if(S[i] == 'G') G++;
        else B++;
    }
    ll ans = R*G*B;
    for (int i = 0; i < N; i++)
    {
        for (int j = i+1; j < N; j++)
        {
            ll k = 2*j-i;
            if(k >= N) continue;
            else if(S[i] != S[j] && S[i] != S[k] && S[k] != S[j]) ans -= 1;
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 1e+5+5;

int n;
int a[3][N];
int id[N],inv[N];
bool vis[N];

int main(){
	n=get();
	fo(i,0,2)fo(j,1,n)a[i][j]=get();
	fo(i,1,n){
		int x=(a[0][i]-1)/3+1;
		if (a[0][i]==x*3-2&&a[1][i]==x*3-1&&a[2][i]==x*3)id[i]=x,inv[i]=0;
		if (a[2][i]==x*3-2&&a[1][i]==x*3-1&&a[0][i]==x*3)id[i]=x,inv[i]=1;
		if (!id[i])return printf("No\n"),0;
		if (i%2!=id[i]%2)return printf("No\n"),0;
	}
	int inv0=0,inv1=0;
	fo(i,1,n)
	if (i&1)inv1^=inv[i];else inv0^=inv[i];
	int flip0=(n/2)&1,flip1=(n&1)^((n/2)&1);
	fo(i,1,n)
	if (!vis[i]){
		if (i&1)flip1^=1;else flip0^=1;
		vis[i]=1;
		for(int x=id[i];x!=i;x=id[x])vis[x]=1;
	}
	if (flip1!=inv0||inv1!=flip0)printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    V<int> cc(26, 0);
    for (int i = 0; i < s.size(); i++) cc[s[i] - 'a']++;
    
    int ans = INF;
    for (int i = 0; i < 26; i++) {
        if (cc[i] == 0) continue;
        char tc = 'a' + i;
        string tmps = s;
        int tmpans = 0;
        while (true) {
            bool ok = true;
            for (int i = 1; i < tmps.size(); i++) {
                if (tmps[i - 1] != tmps[i]) {
                    ok = false;
                    break;
                }
            }
            if (ok) break;
            string tsts;
            for (int i = 1; i < tmps.size(); i++) {
                if (tmps[i - 1] == tc || tmps[i] == tc) {
                    tsts.push_back(tc);
                } else tsts.push_back(tmps[i]);
            }
            tmpans++;
            tmps = tsts;
        }
        chmin(ans, tmpans);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); 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)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  int len = 0;
  rep(i, n) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') len++;
    else {
      ans = max(ans, len);
      len = 0;
    }
  }
  ans = max(ans, len);
  cout << ans << endl;
}

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

const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll dp[400][400][400];
int a[400];
int d[400];

int main(){
	string s;cin>>s;
	int K;cin>>K;
	int n=0;
	int cnt=0;
	for(char c:s){
		if(c=='0')cnt++;
		else a[n++]=cnt;
	}
	rep(i,n){
		d[a[i]]++;
	}
	K=min(K,n);
	dp[cnt+1][0][0]=1;
	for(int i=cnt+1;i>=1;i--)rep(j,K+1)rep(k,n+1){
		if(dp[i][j][k]==0)continue;
		for(int t=0;t<=d[i-1]+k;t++){
			int nj=j+max(0,d[i-1]-t);
			//~ if(nj>K)break;
			(dp[i-1][nj][d[i-1]+k-t]+=dp[i][j][k])%=MOD;
		}
	}
	ll ans=0;
	rep(i,K+1){
		(ans+=dp[0][i][0])%=MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 40096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


int main()
{
    int n,h,w;
    cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1);
}


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


using namespace std;

using ll = long long;


int main() {
    ll N, K, C;
    string S;
    cin >> N >> K >> C;
    cin >> S;

    vector<ll> work_left, work_right;
    for (ll i = S.size() - 1; i >= 0; i--) {
        if (S[i] == 'x')
            continue;
        if (work_right.size() == 0 || *work_right.rbegin() - i > C) {
            work_right.push_back(i);
        }
    }

    for (ll i = 0; i < S.size(); i++) {
        if (S[i] == 'x')
            continue;
        if (*work_right.rbegin() == i) {
            work_right.pop_back();
        }
        ll total = work_left.size() + work_right.size();
        if (work_left.size() > 0 && work_right.size() > 0 && *work_right.rbegin() - *work_left.rbegin() <= C) {
            total--;
        }
        if (total < K) {
            cout << i + 1 << endl;
        }

        if (work_left.size() == 0 || i - *work_left.rbegin() > C) {
            work_left.push_back(i);
        }
    }
}


Measured memory_bytes: 8056
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
vector<pair<int,int> >a;
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		a.push_back(make_pair(y,x));
	}
	sort(a.begin(),a.end());
	int x=0,ans=0;
	for(int i=0;i<m;i++){
		if(a[i].second<=x)continue;
		x=a[i].first-1;
		ans++;
	}
	cout<<ans<<endl;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n,k;
	cin>>n>>k;
	lli sum = 1;

	REP(i,0,n){
		if(i==0)sum *= k;
		else sum *= (k-1);
	}
	cout<<sum<<endl;

	return 0;
}

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

int main(){
	int n,i,j,f=0;
	
	cin>>n;
	
	string w[n+1];
	
	for(i=1;i<=n;i++){
		cin>>w[i];
		if(i>=2){
			if(w[i-1][w[i-1].size()-1]!=w[i][0]){
				f=1;
			}else{
				for( j=1;j<i;j++){
					if(w[j]==w[i]){
						f=1;
					}
				}
		}
	}
	}
	if(f==0){
		cout<<"Yes"<<endl;
		}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int n, k, s = 0; cin >> n >> k;
  vector<unordered_set<int>> v(n);
  rep(i, k){
    int a; cin >> a;
    rep(j, a){
      int b; cin >> b;
      v[b-1].insert(j);
    }
  }
  rep(i, n) if(v[i].empty()) ++s;
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3640
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val nk = sc.nextLine().split(" ")
    val s = sc.nextLine()
    val t = nk(1).toInt-1

    println(s.updated(t, s(t).toLower))
  }
}

Measured memory_bytes: 25404
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,m,w[MAXN];
bool vise[MAXN],visv[MAXN],valid[MAXN];
struct edge
{
    int u,v,w,id;
}E[MAXN],E2[MAXN];
struct ee
{
    int to,w,id;
};
vector<ee> G[MAXN];
bool cmp(edge x,edge y)
{
    return x.w<=y.w;
}
int p[MAXN],r[MAXN];
ll sum[MAXN];
void init(int n)
{
    for(int i=1;i<=n;i++)
    {
        p[i]=i;
        r[i]=0;
        sum[i]=w[i];
    }
}
int find(int x)
{
    if(p[x]==x) return x;
    else return p[x]=find(p[x]);
}
void unite(int x,int y)
{
    x=find(x);
    y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) {p[x]=y; sum[y]+=sum[x];}
    else
    {
        p[y]=x;
        if(r[x]==r[y]) r[x]++;
        sum[x]+=sum[y];
    }
}
bool same(int x,int y)
{
    return find(x)==find(y);
}
void dfs(int v,int w)
{
    if(visv[v]) return;
    for(auto e:G[v])
    {
        if(vise[e.id]) continue;
        if(visv[e.to]) continue;
        if(e.w>w) continue;
        vise[e.id]=true;
        dfs(e.to,w);
    }
    visv[v]=true;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",&w[i]);
    for(int i=0;i<m;i++)
    {
        scanf("%d%d%d",&E[i].u,&E[i].v,&E[i].w);
        E[i].id=i;
        int u=E[i].u,v=E[i].v,w=E[i].w;
        G[u].push_back((ee){v,w,i});G[v].push_back((ee){u,w,i});
    }
    memset(visv,false,sizeof(visv));
    memset(vise,false,sizeof(vise));
    memset(valid,true,sizeof(valid));
    sort(E,E+m,cmp);
    init(n);
    for(int i=0;i<m;i++)
    {
        unite(E[i].u,E[i].v);
        if(E[i].w>sum[find(E[i].u)]) valid[E[i].id]=false;
    }
    int ans=0;
    for(int i=m-1;i>=0;i--)
    {
        if(vise[E[i].id]) continue;
        if(!valid[E[i].id]) ans++; else dfs(E[i].u,E[i].w);
    }
    printf("%d\n",ans);
    return 0;
}



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

int left(int n){
  while (n/10 > 0) n = n/10;
  return n;
}

int right(int n){
  return n % 10;
} 

int main() {
  int N;
  cin >> N;
  
  int num[10][10];
  for (int i = 0; i < 10; i++){
    for (int j = 0; j < 10; j++){
      num[i][j] = 0; 
      for (int k = 1; k <= N; k++){
        if (i == left(k) && j == right(k)) num[i][j]++;
      }
    }
  }
  
  int ans = 0;
  for (int i = 0; i < 10; i++){
    for (int j = 0; j < 10; j++){
      ans = ans + num[i][j] * num[j][i];
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
long long N;
long long X[1000], Y[1000], H[1000];
vector<tuple<long long, long long, long long>> vec;
void solve() {
    tuple<long long, long long, long long> G = make_tuple(-1, -1, -1);
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i] >> H[i];
        if (H[i] >= 1) G = make_tuple(X[i], Y[i], H[i]);
    }
    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            long long V = get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j);
            bool flag = true;
            for (int k = 0; k < N; k++) {
                long long VV = V - abs(X[k] - i) - abs(Y[k] - j);
                VV = max(VV, 0LL);
                if (H[k] != VV) flag = false;
            }
            if (flag == true) vec.push_back(make_tuple(i, j, V));
        }
    }
    cout << get<0>(vec[0]) << " " << get<1>(vec[0]) << " " << get<2>(vec[0]) << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

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

using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int K;
  cin >> K;

  vector<ll> a(K);
  for (int i = 0; i < K; i++) {
    cin >> a[i];
  }
  reverse(a.begin(), a.end());

  vector<ll> L(K + 1), R(K + 1);
  L[0] = R[0] = 2;
  for (int i = 0; i < K; i++) {
    if (L[i] > R[i] / a[i] * a[i]) {
      cout << -1 << endl;
      return 0;
    }
    L[i + 1] = (L[i] + a[i] - 1) / a[i] * a[i];
    R[i + 1] = R[i] / a[i] * a[i] + a[i] - 1;
  }
  cout << L[K] << " " << R[K] << endl;

  return 0;
}

Measured memory_bytes: 2560
n,m,s = map(int,input().split())
road = [[] for _ in range(n)]
#print(road)
for _ in range(m):
  u,v,a,b = map(int,input().split())
  u -= 1
  v -= 1
  road[u].append([v,a,b])
  road[v].append([u,a,b])
#print(road)
coin = []
for _ in range(n):
  c,d = map(int,input().split())
  coin.append([c,d])
if s >= 2500:
  s = 2499
inf = 10**18
#print('#')
arr = [[inf for _ in range(2500)] for _ in range(n)]
c,d = coin[0]
#print(c,d)
#print(len(arr[0]))
for i in range(2500):
  if i <= s:
    arr[0][i] = 0
  elif i - c < 0:
    arr[0][i] = arr[0][0]+d
  else:
    arr[0][i] = arr[0][i-c]+d
now = {0}
#print(road)
for _ in range(100):
  #print(now)
  last = now
  now = set()
  for x in last:
    for y in road[x]:
      #print('#',x,y)
      v,a,b = y
      now.add(v)
      c,d = coin[v]
      for i in range(2500):
        if i + a < 2500:
          arr[v][i] = min(arr[v][i],arr[x][i+a]+b)
      for i in range(2500):
        if i - c < 0:
          arr[v][i] = min(arr[v][i],arr[v][0]+d)
        else:
          arr[v][i] = min(arr[v][i],arr[v][i-c]+d)
for ii in range(1,n):
  print(arr[ii][0])
#print(arr[0])

Measured memory_bytes: 70216
#include <iostream>
using namespace std;
 
int main() {
int N;
  cin >>  N;
  if(N %10 ==3){
  cout << "bon" <<endl;
  }
  else if(N %10 ==0 || N %10 ==1 || N %10 ==6 || N %10 ==8){
    cout << "pon" <<endl;}
  else{
    cout <<"hon"<<endl;}
}

Measured memory_bytes: 3636
n = int(input())
ans = 0

def get_yakusu_num(n):
    m = int(n ** (1/2))
    rep_list = []
    for i in range(1, m + 2):
        if n % i == 0:
            p = n // i
            rep_list.append(i)
            rep_list.append(p)
    return len(set(rep_list))

for i in range(1, n + 1):
    if get_yakusu_num(i) == 8 and i % 2 == 1:
        ans += 1
print(ans)


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

int a, b;

int main()
{
    cin >> a >> b;
    if (a <= 0 && 0 <= b) { printf("Zero\n"); return 0; }
    bool pos;
    if (a > 0) pos = true;
    else pos = (b - a + 1) % 2 == 0;
    printf("%s\n", pos? "Positive": "Negative");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, a, b;
  int ans = 0;
	
	scanf("%d %d", &a, &b);
	
  for (i = 0; i < 2; i++){
    if(a >= b){
      ans += a;
      a--;
    } else {
      ans += b;
      b--;
    }
  }
      
	printf("%d", ans);
	
	return 0;
	
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
typedef long long int ll;
typedef std::pair<int, int> PA;
#define rep(i,n) for(int i=0;i<(int)n;i++)

bool my_compare(pair<pair<string, int>,int> a, pair<pair<string, int>,int> b) {
	//first優先比較
	if (a.first.first != b.first.first) {
		return a.first.first < b.first.first; // 昇順
		//return a.first.first > b.first,first; // 降順
	}

	// それ以外はsecondで比較
	if (a.first.second != b.first.second) {
		//return a.first.second < b.first.second;//昇順
		return a.first.second > b.first.second;//降順
	}
	else {
		// どちらも同じ
		return true;
	}
}

int main(void){
	int a;
	cin >> a;
	cout << a * a * a << endl;
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

ll mod = 1e9+7;
ll dp[100000][2];

void dfs(int i, vector <vector<int>> &graph, int parent) {
  dp[i][0] = 1;
  dp[i][1] = 1;

  for (int j = 0; j < graph[i].size(); j++) {
    int child = graph[i][j];
    if (child == parent) {
      continue;
    }
    dfs(child, graph, i);
    dp[i][0] = (dp[i][0] * (dp[child][0] + dp[child][1])) % mod;
    dp[i][1] = (dp[i][1] * dp[child][0]) % mod;
  }
}

int main() {
  int n;
  cin >> n;
  vector<vector<int>> graph(n);
  for (int i = 0; i < n -1; i++) {
    int j, k;
    cin >> j >> k;
    graph[j-1].push_back(k-1);
    graph[k-1].push_back(j-1);
  }
  dfs(0, graph, -1);
  cout << (dp[0][0] + dp[0][1]) % mod << endl;
}


Measured memory_bytes: 14208
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<bitset>
using namespace std;
int ans;
char a[10000];
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
		if(ch=='-')
			f=-1;
		ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
    }
    return x*f;
}
inline void write(int a)
{
    if(a<0)
    {
		char a='-',b='1';
		putchar(a);
		putchar(b);
    }
    else
    {
		if(a>=10)
			write(a/10);
		putchar(a%10+'0');
    }
}

int main()
{
    cin>>a;
	int len=strlen(a);
	for(int i=0;i<=(len-1)/2;++i)
		if(a[i]!=a[len-i-1])
			++ans;
	write(ans);
    return 0;
}


Measured memory_bytes: 256
def main():
    from collections import Counter
    H,W,M = list(map(int,input().split()))

    counterH = Counter()
    counterW = Counter()
    targets = set()
    for i in range(M):
        h,w = list(map(int,input().split()))
        counterH[h] += 1
        counterW[w] += 1
        targets.add((h,w))

    most_commonH = counterH.most_common()
    most_commonW = counterW.most_common()
    max_w = most_commonW[0][1]
    max_h = most_commonH[0][1]
    if M == 1:
        print(1)
    else:
        ans = 2
        flg = False
        for count_H in most_commonH:
            if max_h != count_H[1]:
                break
            for count_W in most_commonW:
                if max_w != count_W[1]:
                    break
                # print(count_H,count_W)
                if (count_H[0],count_W[0]) in targets:
                    ans = max(ans,count_H[1]+count_W[1]-1)
                else:
                    ans = max(ans,count_H[1]+count_W[1])
                    flg = True
                if flg:
                    break
            if flg:
                break
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 185128
#include <cstdio>
int main(){
    int h, w;
    int i, j;
    scanf("%d%d", &h, &w);
    int sheet[101][101] = {};
    for (i = 0; i < h; i++){
        for (j = 0; j < w; j++){
            scanf("%d", &sheet[i][j]);
            sheet[i][w] += sheet[i][j];
            sheet[h][j] += sheet[i][j];
            sheet[h][w] += sheet[i][j];
        }
    }
    for (int i = 0; i < h + 1; i++){
        for (int j = 0; j < w + 1; j++){
            printf("%d", sheet[i][j]);
            if (j != w) printf(" ");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2756
#include <iostream>

using namespace std;

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define DEBUG(a, i, j) cout << #a << "[" << i << "][" << j << "]: " << a[i][j] << '\t'

const int MAXN = 2005;
bool S[MAXN][MAXN];
int v[MAXN][MAXN];
int e[MAXN][MAXN];
int rowe[MAXN][MAXN];
int cole[MAXN][MAXN];
int N, M, Q;
int x1, y1, x2, y2;

void vdsp() {
	REP(i, 1, N + 1) {
		REP(j, 1, M + 1) {
			DEBUG(v, i, j);
		}
		cout << '\n';
	} 
	cout << '\n';
}

void edsp() {
	REP(i, 1, N + 1) {
		REP(j, 1, M + 1) {
			DEBUG(e, i, j);
		}
		cout << '\n';
	} 
	cout << '\n';
	REP(i, 1, N + 1) {
		REP(j, 1, M + 1) {
			DEBUG(rowe, i, j);
		}
		cout << '\n';
	} 
	cout << '\n';
	REP(i, 1, N + 1) {
		REP(j, 1, M + 1) {
			DEBUG(cole, i, j);
		}
		cout << '\n';
	} 
	cout << '\n';
}

void sdsp() {
	REP(i, 1, N + 1) {
		REP(j, 1, M + 1) {
			DEBUG(S, i, j); 
		}
		cout << '\n';
	} 
	cout << '\n';
}

int main() {
	cin >> N >> M >> Q;
	char c;
	int crow_vsum;
	REP(i, 1, N + 1) {
		crow_vsum = 0;
		REP(j, 1, M + 1) {
			cin >> c;
			S[i][j] = c - '0';
			crow_vsum += S[i][j];
			v[i][j] = crow_vsum + v[i - 1][j];
			e[i - 1][j] += (S[i - 1][j] & S[i][j]);
			rowe[i - 1][j] = rowe[i - 1][j - 1] + (S[i - 1][j] & S[i][j]);
			e[i][j - 1] += (S[i][j - 1] & S[i][j]);
			cole[i][j - 1] = cole[i - 1][j - 1] + (S[i][j - 1] & S[i][j]);
		}
	}
	int crow_esum;
	REP(i, 1, N + 1) {
		crow_esum = 0;
		REP(j, 1, M + 1) {
			crow_esum += e[i][j];
			e[i][j] = crow_esum + e[i - 1][j];
		}
	}
//	sdsp();
//	vdsp();
//	edsp();
	int vsum, esum;
	REP(i, 0, Q) {
		cin >> x1 >> y1 >> x2 >> y2;
		vsum = v[x2][y2] - v[x1 - 1][y2] - v[x2][y1 - 1] + v[x1 - 1][y1 - 1];
		esum = e[x2][y2] - e[x1 - 1][y2] - e[x2][y1 - 1] + e[x1 - 1][y1 - 1];
		esum -= rowe[x2][y2] - rowe[x2][y1 - 1] + cole[x2][y2] - cole[x1 - 1][y2];
//		cout << vsum << '\t' << esum << '\t';
		cout << vsum - esum << '\n';
	}
	return 0;
}

Measured memory_bytes: 68480
H,W = map(int,input().split())
src = [input() for i in range(H)]
dxy = [(0,1),(1,0),(0,-1),(-1,0),(-1,1),(1,1),(1,-1),(-1,-1)]
ans = [[] for i in range(H)]
for i in range(H):
    for j in range(W):
        if src[i][j] == '#':
            ans[i].append('#')
            continue
        bomb = 0
        for dx,dy in dxy:
            x,y = dx+j,dy+i
            if not 0 <= x < W: continue
            if not 0 <= y < H: continue
            if src[y][x] == '#':
                bomb += 1
        ans[i].append(str(bomb))
for row in ans:
    print(*row,sep='')

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

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

    int cou = 0;

    for(int i = 0; i < 3; i++){
        if(s[i] == t[i]){
            cou++;
        }
    }

    cout << cou << endl;
}

Measured memory_bytes: 256
from heapq import heapify, heappush, heappop

X, Y, A, B, C = map(int, input().split())
Ps = list(map(int, input().split()))
Qs = list(map(int, input().split()))
Rs = list(map(int, input().split()))

Ps.sort(reverse=True)
Qs.sort(reverse=True)
Rs.sort(reverse=True)

PQRed = Ps[:X]
PQGreen = Qs[:Y]
sumRed = sum(PQRed)
sumGreen = sum(PQGreen)
heapify(PQRed)
heapify(PQGreen)
#print('PQRed:', PQRed)
#print('PQGreen:', PQGreen)
ans = sumNow = sumRed + sumGreen
#print('sumNow:', sumNow)
for R in Rs:
#    print('\n##### R:', R)
    r = PQRed[0]
    g = PQGreen[0]
#    print('r:', r, '/ g:', g)
    if r <= g:
        d = heappop(PQRed)
        heappush(PQRed, R)
    else:
        d = heappop(PQGreen)
        heappush(PQGreen, R)
    if R <= d:
        break
    sumNow += R-d
#    print('sumNow:', sumNow, '/ d:', d)
    if sumNow > ans:
        ans = sumNow

print(ans)


Measured memory_bytes: 23456
import sys

n, m, X, Y = map(int, input().split())

x = list(map(int, (input().split())))
y = list(map(int, input().split()))
xlist = []
ylist = []

for j in range(X+1, Y):
    if max(x) < j:
        xlist.append(j)
    if min(y) >= j:
        ylist.append(j)

for k in range(len(xlist)):
    if xlist[k] in ylist:
        print("No War")
        sys.exit()
    
print("War")



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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, m;
string s[101], t[101];
map<string, int> mp;
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s[i];
		mp[s[i]]++;
	}
	cin >> m;
	for(int i = 0; i < m; i++){
		cin >> t[i];
		mp[t[i]]--;
	}
	
	int cnt = 0;
	for(int i = 0; i < n; i++){
		chmax(cnt, mp[s[i]]);
	}
	cout << cnt << endl;
}

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

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	long ans, x = 2;
	ans += (RD - 1);
	foreach (i; 1..N)
	{
		auto A = RD;
		ans += (A - 1) / x;
		if (A == x)
		{
			x = A+1;
		}
		debug writeln("ans:", ans, " x:", x);
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 1276
#![allow(unused_imports, non_snake_case)]
use proconio::{
    input, fastout,
    marker::{Chars, Bytes, Usize1}
};

fn factorize(N: u64) -> Vec<(u64, usize)> {
    let mut X = N;
    let mut res = Vec::new();
    for i in 2..N {
        if i * i > N { break; }
        if X % i == 0 {
            let mut v = 0;
            while X % i == 0 {
                v += 1;
                X /= i;
            }
            res.push((i, v));
        }
    }
    if X > 1 {
        res.push((X, 1));
    }
    res
}

fn extended_euclidean(u: i64, v: i64) -> i64 {
    let mut r0 = u;
    let mut r1 = v;
    let mut s0 = 1;
    let mut s1 = 0;
    let mut t0 = 0;
    let mut t1 = 1;
    while r1 != 0 {
        let q = r0 / r1;
        let r = r0 - q * r1;
        let s = s0 - q * s1;
        let t = t0 - q * t1;
        r0 = r1;
        s0 = s1;
        t0 = t1;
        r1 = r;
        s1 = s;
        t1 = t;
    }
    // println!("{} * {} + {} * {} = {}", s0, u, t0, v, r0);
    if t0 < 0 {
        t0 + u
    } else {
        t0
    }
}

#[fastout]
fn main() {
    input!{
        N: u64
    }
    let mut out = vec![];
    for &(p, k) in &factorize(N * 2) {
        let mut v = 1;
        for _ in 0..k {
            v *= p;
        }
        out.push(v);
    }
    let mut ans = N * 2;
    let m = out.len();
    for bit in 0..(1 << m) {
        let mut x = 1;
        for i in 0..m {
            if (bit >> i) & 1 == 0 {
                x *= out[i];
            }
        }
        let y = N * 2 / x;
        let mut t = extended_euclidean(x as i64, y as i64) as u64;
        if t * y < 2 {
            t += x;
        }
        ans = std::cmp::min(ans, y*t-1);
    }
    println!("{}", ans);
}


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

int main() {
    string s, p;
    cin >> s >> p;
    s += s;
    if(s.find(p) != -1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <algorithm>
const int inf=0x3f3f3f3f;
using namespace std;

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

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

    vector <int> dp(n + 1,inf);
    dp[1]=0;
    for(int i = 2; i <= n; i++)
    {
        for(int k=i-1;k>=max(1,i-temp);k--)
        {
        dp[i] = min(dp[k] + abs(arr[i] - arr[k]),dp[i]);
        }
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=1e9;
const int MOD=1e9+7;
string s;
pii p;
ll ans=0;
int main(void)
{
    int N,M,A;
    priority_queue<int,vector<int> > pq;
    cin >> N >> M;
    for(int i=0;i<N;i++)
    {
        cin >> A;
        pq.push(A);
    }
    for(int i=0;i<M;i++)
    {
        int tmp=pq.top();pq.pop();
        tmp/=2;
        pq.push(tmp);
    }
    while(!pq.empty())
    {
        ans+=pq.top();
        pq.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
using System;

public class Test
{
	public static void Main()
	{
		string line;
		int arrayLength = 0; 
		string[] array =new string[arrayLength];
		int a = 0;	
		
		line = Console.ReadLine();
		
		string[] buffer = line.Split(' ');
			
		foreach (string s in buffer)
		{
		++arrayLength; 
		Array.Resize(ref array, arrayLength); 
		
		array[a] = s;
		++a;
		}       
    
        string x = array[1].Substring(0,1);
        Console.WriteLine("A"+x+"C");
	}
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
#define ll long long
 
using namespace std;
 
 
int main() {
    
     string s,t;
     cin>>s>>t;
     ll l1=s.length(),l2=t.length();
     ll mat[l1+1][l2+1];
     for(ll i=0;i<=l2;++i)mat[0][i]=0;
     
     for(ll i=1;i<=l1;i++)
     {
         mat[i][0]=0;
         for(ll j=1;j<=l2;++j)
         {
             if(s[i-1]==t[j-1])mat[i][j]=1+mat[i-1][j-1];
             else mat[i][j]=max(mat[i][j-1],mat[i-1][j]);
         }
     }
     for(ll i=0;i<=l2;++i)mat[0][i]=0;
     
    /*for(ll i=0;i<=l1;i++)
     {
        
         for(ll j=0;j<=l2;++j)
         {cout<<mat[i][j]<<" ";
         }
         cout<<endl;
     }*/
     
     string ans="";
     ll i=l1,j=l2;
     while(mat[i][j])
     {
         if(s[i-1]==t[j-1]){ans+=s[i-1];i--;j--;}
         else if(mat[i][j-1]<mat[i-1][j])
         {
             i--;
         }
         else j--;
     }
    if(ans!="")reverse(ans.begin(),ans.end());
     cout<<ans;
    
    
 
     
    
     
     
}

Measured memory_bytes: 70656
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

vl v;
void sosu_generate(){
	int ans=0;
	v.push_back(2);
	rep(i,3,55556){
		rep(j,0,v.size()){
			if(i%v[j]==0)break;
			if(j==v.size()-1)v.push_back(i);
		}
	}
}

int main(){
	sosu_generate();
	int n;cin>>n;
	int x=0;
	rep(i,0,6000){
		if(v[i]%5==1)cout<<v[i]<<" ",x++;
		if(x==n)break;
	}
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

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

        int price = 700;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'o') price += 100;
        }

        System.out.println(price);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>

using namespace std;
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  string s;
  cin >> n >> s >> k;
  int ans = 0;
  char tar = s[k-1];
  for (int i = 0; i < n; i++) {
    if (s[i] != tar) s[i]='*';
  }

  cout << s << "\n";
  return 0;
}

Measured memory_bytes: 256
//package solution;

import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
    
    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }
    
    void run() throws Exception {
        int n = ni(), m = ni();
        int pairs = ((n * (n - 1)) / 2) + ((m * (m - 1)) / 2);
        pl(pairs);
    }
    
    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

    int ni() throws Exception {
        return Integer.parseInt(nextToken());
    }

    long nl() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nd() throws Exception {
        return Double.parseDouble(nextToken());
    }

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
    
    void selector() {
        Random rd = new Random();
        String[] s = new String[] {"Strings", "Sorting", "Search"
                , "Graph theory", "Greedy", "Dynamic programming"
                , "Constructive algos", "Bit manipulation", "Recursion"};
        pl(s[rd.nextInt(s.length)] + " " + (rd.nextInt(5)+1));
    }
}

Measured memory_bytes: 21716
# coding: utf-8
import sys
import copy

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def main():
    n,k = na()
    a = na()
    memo = [0]*(n+1)
    for i in range(n):
        ai = a[i]
        memo[max(0, i-ai)] += 1
        memo[min(n, i+ai+1)] -= 1
    k -= 1
    if k == 0:
        tmp = 0
        for i in range(n):
            tmp += memo[i]
            print(tmp, end=' ')
        return
    while k != 0:
        flag = 0
        memo2 = [0]*(n+1)
        tmp = 0
        for i in range(n+1):
            tmp += memo[i]
            if tmp >= max(i, n-i-1):
                flag += 1
            memo2[max(0, i-tmp)] += 1
            memo2[min(n, i+tmp+1)] -= 1
        if flag == n:
            memo2[0] = n
            memo2[-1] = -1*n
            break
        memo = copy.copy(memo2)
        k -= 1
    tmp = 0
    for i in range(n):
        tmp += memo2[i]
        print(tmp, end=' ')
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 135884
#include <bits/stdc++.h>
#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 sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
const ll inf=1e9;
int main(void){
    int n;cin>>n;
    vector<vector<ll>> a(n,vector<ll>(n,inf));
    rep(i,n)rep(j,n)cin>>a[i][j];
    rep(k,n)rep(j,n)rep(i,n)if(chmin(a[i][j],a[i][k]+a[k][j])){
        cout<<-1<<endl;
        return 0;
    }
    ll res=0;
    rep(i,n){
        rep(j,n){
            if(i>=j)continue;
            bool ok=true;
            ll buf=a[i][j];
            rep(k,n){
                if(i==k||j==k)continue;
                if(buf>=a[i][k]+a[k][j]){
                    ok=false;
                    break;
                }
            }
            if(ok)res+=buf;
        }
    }
    cout<<res<<endl;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;



int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> data(n);
    rp(i, 0, n) {
        scanf("%d", &data.at(i));
    }
    int ans = 1e9;
    if (n == 1) {
        printf("%d", data.at(0));
        return 0;
    }
    for (int i = 0; i <= n - k; i++) {
        int time = 0;
        int l = data.at(i);
        int r = data.at(i+k-1);
        if(l < 0) {
            if(r < 0) time = l*-1;
            else time = min(r*2+l*-1, l*-2+r);
        } else time = r;
        if (ans > time) ans = time; 
    }
    printf("%d", ans);
    return 0;
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
string s;
int dp[100010][3];
signed main(){
	cin>>s;
	for(int i=s.size();i>=0;i--){
		rep(j,4){
			if(i==s.size()){
				if(j==3)dp[i][j]=1;
			}
			else{
				if(j==3){
					if(s[i]=='?')dp[i][j]=dp[i+1][j]*3;
					else dp[i][j]=dp[i+1][j];
				}
				else if(s[i]=='?'){
					dp[i][j]=3*dp[i+1][j]+dp[i+1][j+1];
				}
				else if(s[i]=='A'+j){
					dp[i][j]=dp[i+1][j]+dp[i+1][j+1];
				}
				else dp[i][j]=dp[i+1][j];
			}
			dp[i][j]%=moder;
		}
	}
	cout<<dp[0][0]<<endl;
	return 0;
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

struct UnionFind {
    //各要素が属する集合の代表(根)を管理する
    //もし、要素xが根であればdata[x]は負の値を取り、-data[x]はxが属する集合の大きさに等しい
    vector<int> data;

    UnionFind(int sz) : data(sz, -1) {}

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        bool is_union = (x != y);
        if (is_union) {
            if (data[x] > data[y]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return is_union;
    }

    int find(int x) {
        if (data[x] < 0) { //要素xが根である
            return x;
        } else {
            data[x] = find(data[x]); //data[x]がxの属する集合の根でない場合、根になるよう更新される
            return data[x];
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return -data[find(x)];
    }
};

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

    int n, m;
    cin >> n >> m;

    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf.unite(a, b);
    }

    int ans = -1;
    for (int i = 0; i < n; i++) {
        ans += (uf.find(i) == i);
    }
    cout << ans << newl;

    return 0;
}

Measured memory_bytes: 3760