akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main(){
	fastio();
	int n;
	
	cin>>n;
	string s;
	cin>>s;
	if(n%2) cout<<"No";
	else{
		int k = n/2;
		string t = s.substr(0,k);
		string p = s.substr(k,n);
		if(t==p)cout<<"Yes";
		else cout<<"No";
	}
}

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

const int maxn = 100 + 10;
int a[maxn * maxn], ans[maxn][maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int h, w; cin >> h >> w;
    int n; cin >> n;
    int x = 1, y = 1, dir = 1;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        while (a[i]--) {
            ans[x][y] = i;
            y += dir;
            if (y == w + 1) y = w, ++x, dir = -1;
            else if (y == 0) y = 1, ++x, dir = 1;
        }
    }
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) cout << ans[i][j] << ' '; cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_C&lang=jp
#??????
if __name__ == "__main__":
    n_line = int(input())
    input_list = [tuple(input().split()) for i in range(n_line)]
    l = set([])
    for c, s in input_list:
        if c == "insert":
            l.add(s)
        else:
            if s in l:
                print("yes")
            else:
                print("no")

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int n;
void dfs(ll m,int match,ll &res){
    if(m>n)return;
    if(match == 0b111)res++;
    dfs(m*10+3,match | 0b001,res);
    dfs(m*10+5,match | 0b010,res);
    dfs(m*10+7,match | 0b100,res);
}

signed main()
{   
    gearup;
    cin >> n;
    ll res = 0;
    dfs(0,0,res);
    cout << res << endl;
}


Measured memory_bytes: 256
def solve(x):
	B=list(map(int,x))
	B.reverse()
	for i in range(len(B)):
		B[i]=B[i]*(2**i)
	#remove 0
	while 0 in B:
		B.remove(0)
	print(" ".join(map(str,B)))	


while True:
	try:
		x=int(input())
		solve(format(x,'b'))

	except EOFError:
		break

Measured memory_bytes: 7620
#include<bits/stdc++.h>
using namespace std;
void *wmem;
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void rd(string &x){
  char *buf=(char *)wmem;
  rd(buf);
  x = buf;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char memarr[96000000];
string S;
string T;
int main(){
  wmem = memarr;
  rd(S);
  rd(T);
  sort(S.begin(), S.end());
  sort(T.rbegin(), T.rend());
  if(S<T){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// string S, T;
// {
//   rd(S,T);
//   sort(S.begin(), S.end());
//   sort(T.rbegin(), T.rend());
//   wt( if[S<T, "Yes", "No"] );
// }


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

namespace AizuJudge
{
    class Program
    {
        static void Main(string[] args)
        {

            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    Console.WriteLine(i + "x" + j + "=" + i * j);
                }
            }
            
        }
    }
}

Measured memory_bytes: 5524
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N = 1e5 + 5;
int a[N][3];
int n, k;
int dp[N][3];
int oo = 1e9;
void iterative_dp(){
    dp[n][0] = dp[n][1] = dp[n][2] = 0;
    for(int i=n-1; i>=0; i--){
        dp[i][0] = max(dp[i+1][1], dp[i+1][2]) + a[i][0];
        dp[i][1] = max(dp[i+1][0], dp[i+1][2]) + a[i][1];
        dp[i][2] = max(dp[i+1][1], dp[i+1][0]) + a[i][2];
    }
}

int main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false), cin.tie(0);
#endif
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    iterative_dp();
    cout<<max({dp[0][0], dp[0][1], dp[0][2]})<<'\n';
}


Measured memory_bytes: 5964
var k = 0;
 
function route90(x,y,m){
    for(var i = 1;i <= m;i++){
        var a = x[i];
        var b = y[i] == 0 ? 0 : y[i] * (-1);
        x[i] = b;
        y[i] = a;
    }
}
 
 
function inline(x,y,n,m,input){
 
    m[n] = parseInt(input[k++],10);
    x[n] = [];y[n] = [];
    for(var i = 1;i <= m[n];i++){
        input[k] = input[k].split(" ");
        x[n][i] = parseInt(input[k][0],10);
        y[n][i] = parseInt(input[k++][1],10);
        if(i > 1){
            x[n][i] -= x[n][1];
            y[n][i] -= y[n][1];
        }
    }
    x[n][1] = y[n][1] = 0;
 
    if(y[n][2] > 0)
        route90(x[n],y[n],m[n]);
    if(x[n][2] < 0)
        route90(x[n],y[n],m[n]);
    if(y[n][2] < 0)
        route90(x[n],y[n],m[n]);
}
 
function inv(x,y,m){
    var x1 = [],y1 = [];
    for(var i = 1;i <= m;i++){x1[i] = x[i];y1[i] = y[i];}
 
    for(var i = 1;i <= m;i++){
        x[i] = x1[m - i + 1] - x1[m];
        y[i] = y1[m - i + 1] - y1[m];
    }
 
    if(y[2] > 0)
        route90(x,y,m);
    if(x[2] < 0)
        route90(x,y,m);
    if(y[2] < 0)
        route90(x,y,m);
 
}
 
function Main(input){
    input = input.split("\n");

    while(1){
        var n = parseInt(input[k++],10);
        if(n == 0)
            break;
        var m = [];
        var x = [],y = [];
        for(var i = 0;i <= n;i++)
            inline(x,y,i,m,input);
 
        for(var i = 1;i <= n;i++){
            if(m[0] == m[i]){
                var flag = true;
                for(var j = 1;j <= m[0];j++){
                    if(x[0][j] != x[i][j] || y[0][j] != y[i][j]){
                        flag = false;break;
                    }
                }
                if(flag)
                    console.log(i);
                else{
                    inv(x[i],y[i],m[i]);
                    var flag = true;
                    for(var j = 1;j <= m[0];j++){
                        if(x[0][j] != x[i][j] || y[0][j] != y[i][j]){
                            flag = false;break;
                        }
                    }
                    if(flag)
                        console.log(i);
 
                }
            }
        }

        console.log("+++++");
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

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

/*
<url:https://agc019.contest.atcoder.jp/tasks/agc019_a>
問題文============================================================
 あなたは行きつけの店、インフバリューにアイスティーを買いに来ています。
 
 この店では、様々なサイズのボトル入りアイスティーが様々な価格で売られています。
 具体的な価格は、0.25 リットルサイズが一つ Q 円、0.5 リットルサイズが一つ H 円、
 1 リットルサイズが一つ S 円、2 リットルサイズが一つ D 円です。各サイズの在庫は無限にあります。
 
 あなたはちょうど N リットルのアイスティーを買いたいです。これに必要な金額は何円でしょうか？
 
 ちょうど N リットルのアイスティーを買うのに必要な最小の金額を出力せよ。
=================================================================

解説=============================================================

 現在購入すべきリットル数により、購入の可能性のあるサイズにおいて、
 どれをまとめて買うと安いかどうかを決定して、購入していけばいい。
 まとめて買った時の最適なサイズはリットル数を一定にした時に一番小さい金額になるものである
 
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll Q,H,S,D; cin >> Q >> H >> S >> D;
    ll N; cin >> N; N*= 4; // Q 1l, H 2l, S 4l, D 8l
    ll Ans = 0;
    if(N >= 8){
        ll M = min({8*Q,4*H,2*S,D});
        Ans += N/8*M;
        N -= N/8*8;
    }
    if(N >= 4){
        ll M = min({4*Q,2*H,S});
        Ans += N/4*M;
        N -= N/4*4;
    }
    if(N >= 2){
        ll M = min({2*Q,H});
        Ans += N/2*M;
        N -= N/2*2;
    }
    Ans += N*Q;
    cout << Ans << endl;
	return 0;
}


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

int main(){
    int H,W;
    int i,ii;

    cin>>H>>W;

    char** a;
    a= new char* [H];
    for(i=0;i<H;i++){
        a[i]=new char[W];
    }
    for(i=0;i<H;i++){
        for(ii=0;ii<W;ii++){
            cin>>a[i][ii];
        }
    }

for(i=0;i<W+2;i++){
     cout<<"#";
}
cout<<endl;

        for(i=0;i<H;i++){
            cout<<"#";
        for(ii=0;ii<W;ii++){
            cout<<a[i][ii];
        }
        cout<<"#";
        cout<<endl;
    }
    for(i=0;i<W+2;i++){
     cout<<"#";
}
cout<<endl;



    for(i=0;i<H;i++){
        delete [] a[i];
    }
    delete [] a;



    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());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const ll MOD = 998244353;
const ll inf = 1e18;

template<typename T>
// return a ^ b % MOD
T mypow(T a, T b){
    if (b == 0)
        return 1;
    T tmp = mypow(a, b / 2);
    if (b % 2)
        return (((tmp * tmp) % MOD) * a) % MOD;
    else
        return (tmp * tmp) % MOD;
}

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

    ll n, s;
    cin >> n >> s;
    vll a(n);
    REP(i, n) cin >> a[i];

    // dp[i + 1][j] : i 番目まで見て和が j となる添え字集合を含む集合の個数
    vvll dp(3010, vll(3010));
    dp[0][0] = 1;
    REP(i, n) {
        REP(j, s + 1) {
            dp[i + 1][j] += 2 * dp[i][j];
            dp[i + 1][j] %= MOD;
            if (j + a[i] <= s) {
                dp[i + 1][j + a[i]] += dp[i][j];
                dp[i + 1][j + a[i]] %= MOD;
            }
        }
    }
    cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 74196
#define ll long long
#define ld long double
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#include <bits/stdc++.h>
using namespace std;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x %= p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll po(ll base, ll powerRaised)
{
    if (powerRaised != 0)
        return (base * po(base, powerRaised - 1));
    else
        return 1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, m;
    cin >> n >> m;
    cout << (n * (n - 1)) / 2 + (m * (m - 1)) / 2;
    return 0;
}


Measured memory_bytes: 256
/*
 It's better to sleep happy and tired rather than disappointed and frustrated
 There's only 1 thing that's impossible and that is defeating a man who doesn't give up
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mx2 102
#define mx3 1003
#define mx4 10004
#define mx5 100005
#define mx6 1000006
#define mod 1000000007
#define PI 3.14159265
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define Fo(i,k,n) for(int i=k ; i<n ; i++)
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pair<int,int>,int> piii;

const int inf=0x3f3f3f3f;
int n , ans , sum , a[mx5] , b[mx5] ,c[mx5],dp[mx5][3];
string str;
 
int main() {
	ios::sync_with_stdio(false);
	//int t;cin>>t;while(t--)
	{
		cin>>n;	
		fo(i,n)
		{
			cin>>a[i]>>b[i]>>c[i];
		}
		Fo(i,1,n+1)
		{
			dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i-1];
			dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i-1];
			dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i-1];
		}
		cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
	}
	return 0;
}


Measured memory_bytes: 2560
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];

    map<int, int> mp;
    REP(i, N) mp[A[i]]++;

    vector<pll> b;
    for(auto p : mp) {
        if (p.second >= 2) b.push_back(p);        
    }

    sort(b.begin(), b.end());
    int L = b.size();

    ll ans = 0;
    if (L > 0 && b[L - 1].second >= 4) ans = b[L - 1].first * b[L - 1].first;
    else if (L > 1) ans = b[L - 1].first * b[L - 2].first;

    cout << ans << endl;

    return 0;
}

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


int minecount(int h,int w,vector<string> &s,int y,int x){
  vector<int> dx = {-1,0,1,-1,1,-1,0,1};
  vector<int> dy = {1,1,1,0,0,-1,-1,-1};
  int cnt = 0;
  rep(i, 8){
    int ny = dy.at(i)+y, nx = dx.at(i)+x;
    if (nx<0 || nx>=w) continue;
    if (ny<0 || ny>=h) continue;
    if (s.at(ny).at(nx) == '#') cnt++;
  }
  return cnt;
}

void solve(int h,int w,vector<string> &s){
  rep(i, h){
    rep(j, w){
      if (s.at(i).at(j) == '#'){
        cout <<'#';
      }else{
        cout <<minecount(h,w,s,i,j);
      }
    }
    cout <<endl;
  }
  return;
}

int main() {
  int h,w; cin >>h >>w;
  vector<string> s(h);
  vector<string> ans(h);
  rep(i, h){
    cin >>s.at(i);
  }
  solve(h,w,s);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int ans = 0;
		for(int a = 1 ; a <= k ; a++) {
			for(int b = 1 ; b <= k ; b++) {
				for(int c = 1 ; c <= k ; c++) {
					ans += gcd(a,b,c);
				}
			}
		}
		System.out.println(ans);
		scan.close();
	}

	private static int gcd(int a, int b, int c) {
		int d = gcd2(a,b);
		
		return gcd2(c,d);
		
	}

	private static int gcd2(int a, int b) {
		if(b == 0) return a;
		
		return a % b == 0 ? b : gcd2(b , a % b);
	}

}


Measured memory_bytes: 35620
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CWalkOnMultiplicationTable solver = new CWalkOnMultiplicationTable();
        solver.solve(1, in, out);
        out.close();
    }

    static class CWalkOnMultiplicationTable {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long ans = n - 1;
            for (long i = 1; i * i <= n; i++) {
                if (n % i == 0)
                    ans = Math.min(ans, i + n / i - 2);
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn for(int i=0;i<n;i++)
int main()
{
  int a,b;
  cin>>a>>b;
  int n=a+b;
  int y=max(n,a-b);
  cout<<max(y,a*b);
  return 0;
   
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
using namespace std;
set <pair <int, int> > blocks;
vector <int> edges[100000];
int cc_no;
map <int, int> counts;
int cc_id[100000];
int not_connected_block[100000];
int block_no[100000];
void dfs(int cur){
    cc_id[cur] = cc_no;
    for(int i = 0; i < edges[cur].size(); i++){
        if(cc_id[edges[cur][i]] < 0){
            dfs(edges[cur][i]);
        }
    }
}

int main(void){
    int N;
    int M;
    int K;
    cin >> N >> M >> K;

    for(int i = 0; i < M; i++){
        int A;
        int B;
        cin >> A >> B;
        edges[A - 1].push_back(B - 1);
        edges[B - 1].push_back(A - 1);

    }

    for(int i = 0; i < K; i++){
        int C;
        int D;
        cin >> C >> D;
        blocks.insert(make_pair(C - 1, D - 1));
    }

    for(int i = 0; i < N; i++){
        cc_id[i] = -1;
    }

    for(int i = 0; i < N; i++){
        if(cc_id[i] < 0){
            dfs(i);
            cc_no ++;
        }
    }

    for(int i = 0; i < N; i++){
        if(counts.find(cc_id[i]) == counts.end()){
            counts[cc_id[i]] = 1;
        } else {
            counts[cc_id[i]] ++;
        }
    }

    for(auto it = blocks.begin(); it != blocks.end(); it++){
        int C = it->first;
        int D = it->second;
        block_no[C] ++;
        block_no[D] ++;
        if(cc_id[C] != cc_id[D]){
            not_connected_block[C] ++;
            not_connected_block[D] ++;
        }
    }

    for(int i = 0; i < N; i++){
        int ans = counts[cc_id[i]] - 1 - (int) edges[i].size() - (block_no[i] - not_connected_block[i]);
        if(i != N - 1){
            cout << ans << " ";
        } else {
            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 14336
#include <algorithm>
#include <cassert>
#include <functional>
#include <iostream>
#include <queue>
#include <tuple>
#include <vector>

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

template <typename M, typename L>
struct SegmentTree {
  int n;
  vector<M> dat;
  vector<L> laz;
  M em;
  L el;
  function<M(M, M)> multiply;
  function<L(L, L)> composite;
  function<M(L, M)> apply;
  SegmentTree(int n0, M em, L el, function<M(M, M)> mul, function<L(L, L)> com,
              function<M(L, M)> app)
      : em(em), el(el), multiply(mul), composite(com), apply(app) {
    n = 1;
    while (n < n0) {
      n *= 2;
    }
    dat.resize(n * 2 - 1, em);
    laz.resize(n * 2 - 1, el);
  }
  void set(int i, M a) {
    i += n - 1;
    dat[i] = a;
    while (i > 0) {
      i = (i - 1) / 2;
      dat[i] = multiply(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
  }
  void _update(int i, L f) {
    dat[i] = apply(f, dat[i]);
    laz[i] = composite(f, laz[i]);
  }
  void update(int ql, int qr, L f) { update(ql, qr, f, 0, 0, n); }
  void update(int ql, int qr, L f, int i, int il, int ir) {
    if (qr <= il or ir <= ql) return;
    if (ql <= il and ir <= qr) {
      _update(i, f);
      return;
    }
    auto m = (il + ir) / 2, lch = i * 2 + 1, rch = i * 2 + 2;
    _update(lch, laz[i]);
    _update(rch, laz[i]);
    laz[i] = el;
    update(ql, qr, f, lch, il, m);
    update(ql, qr, f, rch, m, ir);
    dat[i] = multiply(dat[lch], dat[rch]);
  }
  M query(int ql, int qr) { return query(ql, qr, 0, 0, n); }
  M query(int ql, int qr, int i, int il, int ir) {
    if (ql <= il and ir <= qr) return dat[i];
    if (qr <= il or ir <= ql) return em;
    auto m = (il + ir) / 2;
    // f(l + r) = f(l) + f(r)
    return apply(laz[i], multiply(query(ql, qr, i * 2 + 1, il, m),
                                  query(ql, qr, i * 2 + 2, m, ir)));
  }
  void tour() {
    cout << endl << "BEGIN";
    queue<pair<int, bool>> q;
    q.emplace(0, true);
    while (q.size() > 0) {
      int i;
      bool f;
      tie(i, f) = q.front();
      q.pop();
      if (f) cout << endl;
      cout << dat[i] << " ";
      if (i * 2 + 1 < (int)dat.size()) {
        q.emplace(i * 2 + 1, f);
        q.emplace(i * 2 + 2, false);
      }
    }
    cout << endl << "END" << endl;
  }
};

struct M {
  int64_t x, l;
  M(int64_t x, int64_t l) : x(x), l(l) {}
};

ostream &operator<<(ostream &os, M &m) {
  os << m.x;
  return os;
}

int main() {
  // DSL_2_G

  int n, q;
  cin >> n >> q;
  using L = int64_t;
  const L el = 0;
  SegmentTree<M, L> seg(
      n, M(0, 0), el, [&](M a, M b) -> M { return M(a.x + b.x, a.l + b.l); },
      [&](L f, L g) -> L { return f + g; },
      [&](L f, M a) -> M { return f == el ? a : M(a.x + f * a.l, a.l); });
  rep(i, n) { seg.set(i, M(0, 1)); }
  while (q--) {
    int t;
    cin >> t;
    if (t == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      seg.update(s - 1, t, x); // range add
    } else {
      int s, t;
      cin >> s >> t;
      cout << seg.query(s - 1, t).x << endl;
    }
    // seg.tour();
  }

  return 0;
}




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

int main() {
    int h, w, m = 1e9 + 7;
    cin>>h>>w;
    vector<string> grid(h);
    for(int i=0; i<h; i++) cin>>grid[i];
    vector<vector<int>> dp(h+1, vector<int> (w+1, 0));
    dp[h-1][w] = 1;
    for(int i = h-1; i >= 0; i--)
        for(int j = w-1; j >= 0; j--)
            dp[i][j] = grid[i][j] == '#' ? 0 : (dp[i+1][j] + dp[i][j+1]) % m;
    cout<< dp[0][0] <<endl;
    return 0;
}


Measured memory_bytes: 5248
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h1 = sc.nextInt();
        int m1 = sc.nextInt();
        int h2 = sc.nextInt();
        int m2 = sc.nextInt();
        int k = sc.nextInt();
        System.out.println((h2 * 60 + m2) - (h1 * 60 + m1) - k );
    }
}

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

using namespace std;

int a[100005],b[100005];

bool cmp(int a,int b)
{
    return a>b;
}

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int f;
        scanf("%d",&f);
        if(i&1) a[f]++;
        else b[f]++;
    }
    int mx=1;
    for(int i=1;i<=100000;i++) if(a[i]>a[mx]) mx=i;
    int mx1=1;
    for(int i=1;i<=100000;i++) if(b[i]>b[mx1]) mx1=i;
    sort(a,a+100001,cmp);
    sort(b,b+100001,cmp);
    if(mx!=mx1)
        printf("%d\n",n-a[0]-b[0]);
    else
        printf("%d\n",min(n-a[0]-b[1],n-a[1]-b[0]));
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<pair<int,int>>v(n);
    for(int i=0;i<n;i++){
        v[i].second=i+1;
        cin>>v[i].first;
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++)cout<<v[i].second<<(i==n-1?"\n":" ");
    return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <set>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;

const int ms = 200005;
int n;
string s;

bool check(int m)
{
    map<string, int>t;
    for (int i = 0; i + m <= n; ++i)
    {
        string st = s.substr(i, m);
        if (t.count(st) == 1)
        {
            if (t[st] <= i)
                return  true;
            continue;
        }
        t[st] = i + m;
    }
    return false;
}
int main()
{
    cin >> n;
    cin >> s;
    int l = 0, r = n - 1, mid, res = 0;
    while (l <= r)
    {
        mid = (l + r) / 2;
        if (check(mid))
        {
            res = max(res, mid);
            l = mid + 1;
        }
        else
        {
            r = mid - 1;
        }
    }
    cout << res;
}


Measured memory_bytes: 6672
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

class Printable a where
  format :: a -> String

instance Printable Int where
  format = show

instance Printable Integer where
  format = show

instance Printable Double where
  format = show

instance Printable Float where
  format = show

instance Printable Char where
  format = show

instance Printable String where
  format x = x

instance Printable Bool where
  format = show

put :: Printable a => a -> IO ()
put = putStr . format

putLn :: Printable a => a -> IO ()
putLn = putStrLn . format

putList :: Printable a => [a] -> IO ()
putList [a] = put a
putList (a:as) = do
  put a
  putStr " "
  putList as

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [k] <- readInt
  let (a, b) = (k `div` 2, k - a)
   in put $ a * b


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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
def main():
    s = input()

    if s[0] != "A" or s[1].isupper() or s[-1].isupper():
        print("WA")
        return

    num_c = 0
    num_cap = 0
    for l in s[2:-1]:
        if l == "C":
            num_c += 1
        if l.isupper():
            num_cap += 1
    if num_c == 1 and num_cap == 1:
        print("AC")
    else:
        print("WA")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 100000
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int dp[105][105][2][2];

int main(void) {
  int i,j,k,l;
  int h,w;
  int n=105;
  while(1){
    cin>>h>>w;
    if(h==0)break;
    rep(i,n)rep(j,n)rep(k,2)rep(l,2)dp[i][j][k][l]=0;
    dp[1][1][0][0]=1;
    dp[1][1][1][0]=1;
    loop(i,1,n)loop(j,1,n){
      //cout<<i<<" "<<j<<endl;
      (dp[i][j][0][0]+=dp[i-1][j][0][0]+dp[i-1][j][0][1])%=MOD;
      (dp[i][j][0][1]+=dp[i][j-1][1][0])%=MOD;
      (dp[i][j][1][0]+=dp[i][j-1][1][0]+dp[i][j-1][1][1])%=MOD;
      (dp[i][j][1][1]+=dp[i-1][j][0][0])%=MOD;
      //rep(k,2)rep(l,2)cout<<dp[i][j][k][l]<<endl;
    }
    cout<<(dp[h-1][w][0][1]+dp[h-1][w][0][0]+dp[h][w-1][1][1]+dp[h][w-1][1][0])%MOD<<endl;
  }
}



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

int main()
{
  int A, B, K;
  cin >> A >> B >> K;

  int n = 0;
  int ans;

  for (int i = A;; i--)
  {
    if (A % i == 0 && B % i == 0)
    {
      n++;
    }
    if (n == K)
    {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
sw_input = True
while sw_input == True:
    m,f,r  = map(int, input().split())
    if m < 0 and f < 0 and r < 0:
        sw_input = False
    else:
        if m < 0 or f < 0:
            EV = 'F'
        elif m + f >= 80:
            EV = 'A'
        elif m + f >= 65:
            EV = 'B'
        elif m + f >= 50 or r >= 50:
            EV = 'C'
        elif m + f >= 30:
            EV = 'D'
        else:
            EV = 'F'
        print(EV)


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

using namespace std;

const int N = 2e6;

const long long MOD = 1e9 + 7;

long long fact[N + 7];
long long invfact[N + 7];
long long inv[N + 7];

long long mul (long long x, long long y) {
	return ((x % MOD) * (y % MOD)) % MOD;
}

long long add (long long x, long long y) {
	return ((x % MOD) + (y % MOD)) % MOD;
}

long long fastpow (long long x, long long y) {
	if (y == 0) {
		return 1 % MOD;
	}

	if (y == 1) {
		return x % MOD;
	}

	if (y % 2 == 0) {
		return fastpow(mul(x, x), y / 2);
	}
	else {
		return mul(x, fastpow(mul(x, x), y / 2));
	}
}

void precalc () {
	fact[0] = 1;
	invfact[0] = 1;
	inv[0] = 1;

	fact[1] = 1;
	invfact[1] = 1;
	inv[1] = 1;

	for (int i = 2; i <= N; i++) {
		fact[i] = mul(fact[i - 1], i);
		// inv[i] = fastpow(i, MOD - 1);
		// invfact[i] = mul(invfact[i - 1], inv[i]);
		invfact[i] = fastpow(fact[i], MOD - 2);
	}
}

// long long calc (long long a_plus_b, long long a, long long b) {
// 	int lasttodivide = b;

// 	long long res = 1;

// 	for (int i = a + 1; i <= a_plus_b; ) {
// 		if (lasttodivide <= b) {
// 			if (i % lasttodivide == 0) {
// 				res = mul(res, i / lasttodivide);
// 				lasttodivide++;
// 			}
// 			else if ((res * i) % lasttodivide == 0) {
// 				res = ((res * i) / lasttodivide);
// 				lasttodivide++;
// 			}
// 			else {
// 				res = mul(res, i);
// 				continue;
// 			}
// 		}
// 		else {
// 			res = mul(res, i);
// 		}
// 	}

// 	while (lasttodivide <= b) {
// 		res /= lasttodivide;
// 		lasttodivide++;
// 	}

// 	return mul(res, 1);
// }

int main () {
	precalc();

	int X, Y;
	cin >> X >> Y;

	if ((X + Y) % 3 != 0) {
		cout << 0 << "\n";
	}
	else {
		long long ans = 0;

		for (int i = 0; i * 2 <= Y; i++) {
			if ((Y - (i * 2)) * 2 != X - i) {
				continue;
			}

			int j = Y - (i * 2);

			long long temp = 1;
			temp = mul(temp, fact[i + j]);
			temp = mul(temp, invfact[i]);
			temp = mul(temp, invfact[j]);

			ans = add(ans, temp);

			// cerr << i << " " << j << "\n";
			// cerr << fact[i + j] << "\n";
			// cerr << invfact[i] << " " << invfact[j] << "\n";
		}

		cout << ans << "\n";

		// long long i_plus_j = (X + Y) / 3;

		// X -= i_plus_j;
		// Y -= i_plus_j;

		// if (X < 0 || Y < 0) {
		// 	cout << 0 << "\n";
		// }
		// else {
		// 	long long ans = calc(X + Y, X, Y);

		// 	cout << ans << "\n";
		// }
	}

	return 0;
}

Measured memory_bytes: 32768
# ContestName
# URL
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def check(i, j, q, count, H, W, B, rec):
    if i < 0 or i >= H:
        return count
    if j < 0 or j >= W:
        return count
    if B[i][j] <= rec:
        return count
    B[i][j] = rec
    count += 1
    q.append((i, j))
    return count

def main():
    H, W = i2nn()
    A = ii2ss(H)
    HW = H * W
    B = [[3000] * W for _ in range(H)]
    q = []
    count = 0
    rec = 0
    for i in range(H):
        for j in range(W):
            if A[i][j] == '#':
                B[i][j] = 0
                q.append((i, j))
                count += 1
    while True:
        if count >= HW:
            print(rec)
            return
        rec += 1
        q2 = []
        for i, j in q:
            count = check(i-1, j, q2, count, H, W, B, rec)
            count = check(i+1, j, q2, count, H, W, B, rec)
            count = check(i, j-1, q2, count, H, W, B, rec)
            count = check(i, j+1, q2, count, H, W, B, rec)
        q = q2

main()


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

int main() {
  int N;
  cin >> N;
  if ((N/10)%111==0 || (N-(N/1000)*1000)%111==0) 
  {
    cout  << "Yes" << endl;
  }
  else  {
    cout << "No" << endl;
}
}


Measured memory_bytes: 256
import math
A,B,H,M = map(int,input().split())
if 0 < abs(0.5*(60*H+M) - 6*M) <180:
    ans = A**2 + B**2 -2*A*B*math.cos(math.radians(abs(0.5*(60*H+M) - 6*M)))
    ans**=(1/2)
elif abs(0.5*(60*H+M) - 6*M)==0:
    ans = abs(A-B)
elif abs(0.5*(60*H+M) - 6*M)==180:
    ans= A+B
else:
    ans= A**2 + B**2 -2*A*B*math.cos(math.radians(360-abs(0.5*(60*H+M) - 6*M)))
    ans**=(1/2)
print(ans)

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int n; cin>>n;
  while (n) {
    if (n%10==9) out("Yes");
    n=n/10;
  }
  out("No");

  return 0;
}


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

int main() {
    int n,k,q; cin >> n >> k >> q;
    vector<int> vec(n, k);
    for (int i = 0; i < q; i++) {
        int a;
        cin >> a;
        vec[a-1]++;
    }
    for (int i = 0; i < n; i++) {
        if (vec[i] - q > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1024
n,m,c = map(int,input().split())
b_line = [int(b) for b in input().split()]
a_lines = [[int(j) for j in input().split()] for i in range(n)]

count = 0
for a_line in a_lines:
    result = c
    for a,b in zip(a_line,b_line):
        result += a*b
    if result>0:
        count+=1
print(count)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int l = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        
        long min = 2019;
        long rem;
        for(long i = l; i <= r-1; i++){
            for(long j = i+1; j <= r; j++){
                rem = (i*j) % 2019;
                if(rem < min){
                    min = rem;
                    if(min == 0){
                        break;
                    }
                }
            }
            if(min == 0){
                break;
            }
        }
        
        System.out.println(min);
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s;
	cin>>s;
	int n=s.size();
	loop(t,2,min(n+1,100)){
		int co[26]={0};
		rep(i,t)co[s[i]-'a']++;
		rep(i,26)if(t/2<co[i]){
			cout<<1<<" "<<t<<endl;
			goto end;
		}
		loop(i,t,n){
			co[s[i]-'a']++;
			co[s[i-t]-'a']--;
			rep(j,26)if(t/2<co[j]){
				cout<<i-t+2<<" "<<i+1<<endl;
				goto end;
			}
		}
	}
	cout<<"-1 -1"<<endl;
	end:;
}
 
 







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

//Function Macros:
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main()
{
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N - 1);
    rep(i, N)
    {
        cin >> A[i];
    }
    rep(i, N)
    {
        cin >> B[i];
    }
    rep(i, N - 1)
    {
        cin >> C[i];
    }
    int mzk = 0;
    rep(i, N)
    {
        mzk += B[i];
        if (i>0 && A[i-1]+1 == A[i])
        {
            mzk += C[A[i-1]-1];
        }
    }
    cout << mzk << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int x; cin >> x;
  if (x) cout << 0 << endl;
  else cout << 1 << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

vector<int> kmp(string s) {
    vector<int> a(s.length() + 1);
    for (int i = 1; i <= s.length(); i++) {
        int x = i - 1;
        while (x && a[x] != i - 1 && s[a[x]] != s[i - 1]) x = a[x];
        if (x) a[i] = a[x] + 1;
    }
    return a;
}

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = (int)s.length(), z = 0;
    bool y = 0;
    for (int i = 1; i < n; i++) if (s[i] != s[i - 1]) y = 1;
    if (!y) {
        cout << n << '\n' << 1 << '\n';
        return 0;
    }
    vector<int> a = kmp(s);
    if (a[n] + a[n] < n || n % (n - a[n])) {cout << 1 << '\n' << 1 << '\n'; return 0;}
    reverse(s.begin(), s.end());
    vector<int> b = kmp(s);
    for (int i = 1; i < n; i++) if ((a[i] + a[i] < i || i % (i - a[i])) && (b[n - i] + b[n - i] < n - i || (n - i) % (n - i - b[n - i]))) z++;
    cout << 2 << '\n' << z << '\n';
}


Measured memory_bytes: 5168
#include<iostream>
#include<vector>
#include<map>
#include<numeric>
#define ll long long

using namespace std;

int main() {
  int n;
  cin >> n;
  map<int,int> d;
  for(int i=0;i<n;++i){
    int num;
    cin >> num;
    d[num]++;
  }
  int ans=0;
  for(auto i=d.begin();i!=d.end();++i){
    ans++; 
  }

  cout << ans << endl;
}

Measured memory_bytes: 888
from collections import defaultdict
from functools import lru_cache
import sys
input=sys.stdin.readline


class Reroot:
    def __init__(self, N, e, merge, f, g):
        self.G = defaultdict(list)
        self.parents = [-1]*(N+1)
        self.dp = defaultdict(lambda: defaultdict(int))
        self.merge = merge
        self.f = f
        self.g = g
        self.e = e

    def add_edge(self, s, t):
        self.G[s].append(t)

    def build(self):
        self.dfs1(1)
        self.dfs2(1)
        return self.dp

    def dfs1(self, s):
        l = []
        q = [1]
        while q:
            s = q.pop()
            l.append(s)
            for t in self.G[s]:
                if t == self.parents[s]:
                    continue
                self.parents[t] = s
                q.append(t)

        for s in l[::-1]:
            v = self.e
            for t in self.G[s]:
                if t == self.parents[s]:
                    continue
                v = self.merge(v, self.f(self.dp[s][t], s, t))
            self.dp[self.parents[s]][s] = self.g(v, self.parents[s], s)

    def dfs2(self, s):
        q = [(s, self.e)]
        while q:
            s, dp_p = q.pop()
            par = self.parents[s]
            self.dp[s][par] = dp_p

            size = len(self.G[s])
            ac_l = [self.e] * (size+1)
            ac_r = [self.e] * (size+1)
            for i, t in enumerate(self.G[s]):
                ac_l[i+1] = self.merge(ac_l[i], self.f(self.dp[s][t], s, t))
            for i, t in enumerate(self.G[s][::-1]):
                ac_r[size-i-1] = self.merge(ac_r[size-i], self.f(self.dp[s][t], s, t))
            self.dp[-1][s] = self.g(ac_l[size], -1, s)

            for i, t in enumerate(self.G[s]):
                if t == par:
                    continue
                q.append((t, self.g(self.merge(ac_l[i], ac_r[i+1]), t, s)))


def solve():
    N = int(input())

    MOD = 10**9+7
    n = N
    fac = [1]*(n+1)
    rev = [1]*(n+1)
    d = defaultdict(list)

    for i in range(1,n+1):
        fac[i] = i*fac[i-1]%MOD
        rev[i] = pow(fac[i], MOD-2, MOD)

    merge1 = lambda x,y:x+y
    f1 = lambda x, par, s:x
    g1 = lambda x, par, s:x+1
    e1 = 0
    tree1 = Reroot(N, e1, merge1, f1, g1)

    merge2 = lambda x,y:(x*y)%MOD
    f2 = lambda x, par, s:(x*rev[tree1.dp[par][s]])%MOD
    g2 = lambda x, par, s:(x*fac[tree1.dp[par][s]-1])%MOD
    e2 = 1
    tree2 = Reroot(N, e2, merge2, f2, g2)

    for _ in range(N-1):
        a, b = map(int, input().split())
        tree2.add_edge(a, b)
        tree2.add_edge(b, a)
        tree1.add_edge(a, b)
        tree1.add_edge(b, a)

    tree1.build()
    ans = tree2.build()

    for i in range(1, N+1):
        print(ans[-1][i])


if __name__ == "__main__":
    solve()


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

int main(){
	int x,y,z,n,r;
	float r1,r2,r3;
	while(cin>>x>>y>>z,x|y|z){
		r1 = sqrt(x*x+y*y)/2;
		r2 = sqrt(x*x+z*z)/2;
		r3 = sqrt(y*y+z*z)/2;
		for(cin>>n;n;--n){
			cin>>r;
			if(r>r1 || r>r2 || r>r3)cout<<"OK";
			else cout<<"NA";
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1156