akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,T,ans=0;
  cin>>N>>T;
  vector<pair<ll,ll>> AB;
  REP(i,N){
    ll a,b;
    cin>>a>>b;
    AB.PB(MP(a,b));
  }
  SORT(AB);
  
  ll DP[N+1][T]; // DP[i][j]=i番目までの料理をj分以内に食べる時の美味しさの最大値
  REP(i,N+1){
    REP(j,T){
      DP[i][j]=0;
    }
  }
  RREP(i,N){
    REP(j,T){
      DP[i][j]=DP[i-1][j];
      if(j>=AB[i-1].first) chmax(DP[i][j],DP[i-1][j-AB[i-1].first]+AB[i-1].second);
    }
  }
  
  RREP(i,N){
    chmax(ans,DP[i-1][T-1]+AB[i-1].second);
  }
  co(ans);
  return 0;
}

Measured memory_bytes: 74096
def main(): 
  N = int(input())
  p = list(map(float, input().split()))
  
  if N == 1:
    print(p[0])
    return 
  Ans = N // 2 + 1
  
  DP = [[0 for i in range(N + 1)] for j in range(N)]
  DP[0][0] = 1 - p[0]
  DP[0][1] = p[0]
  
  for i in range(1, N):
    DP[i][0] = DP[i - 1][0] * (1 - p[i])
    for j in range(1, N // 2 + 1):
      DP[i][j] = (DP[i - 1][j - 1] * p[i] + DP[i - 1][j] * (1 - p[i]))
    DP[i][Ans] = DP[i - 1][Ans - 1] * p[i] + DP[i - 1][Ans]
  print(DP[i][Ans])
  
main()


Measured memory_bytes: 283000
import scala.io.StdIn
object Main {
  def main(args: Array[String]): Unit = {
    val N = StdIn.readLine().split(" ").map(_.toInt)
    val A = N(1)
    val B = N(2)
    val S = StdIn.readLine()
    var aCounter = 0
    var bCounter = 0
    S.toCharArray.foreach{
      case 'a' =>
        if((aCounter + bCounter) < A + B) {
          println("Yes")
          aCounter += 1
        } else
          println("No")
      case 'b' =>
        if(bCounter < B && (aCounter + bCounter) < A + B) {
          println("Yes")
          bCounter += 1
        } else {
          println("No")
        }
      case _ => println("No")
    }
  }

}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  int n,q;
  cin>>n>>q;
  vector<vector<ll>> adj1(n);
  rep(i,n-1){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    adj1[a].emplace_back(b);
    adj1[b].emplace_back(a);
  }
  vector<ll> ans(n);
  rep(i,q){
    ll p,x;
    cin>>p>>x;
    p--;
    ans[p]+=x;
  }

  ll root = 0;
  auto to_DAG = [](auto adj,int root){
    ll n = adj.size();
    queue<ll> que;
    vector<int> seen(n);
    vector<vector<ll>> dag(n);
    que.emplace(root);
    while(que.size()){
      ll cur = que.front();
      que.pop();
      if(seen[cur])continue;
      seen[cur] = 1;
      for(auto nxt:adj[cur]){
        dump(cur,nxt);
        if(seen[nxt])continue;
        dag[cur].emplace_back(nxt);
        que.emplace(nxt);
      }
    }
    return dag;
  };

  auto adj2 = to_DAG(adj1,root);

  queue<ll> que;
  que.emplace(root);
  while(!que.empty()){
    ll cur = que.front();
    que.pop();
    for(auto nxt:adj2[cur]){
      dump(cur,nxt);
      ans[nxt] += ans[cur];
      que.emplace(nxt);
    }
  }

  for(auto a:ans)cout<<a<<endl;

}

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

int main() {
    int q, x;
    char com[20];
    
    list<int> v;
    scanf("%d", &q);
    for (int i=0; i<q; i++) {
        scanf("%s", &com);
        if (com[0] == 'i') {
            scanf("%d", &x);
            v.push_front(x);
        } else if (com[6] == 'L') {
            v.pop_back();
        } else if (com[6] == 'F') {
            v.pop_front();
        } else if (com[0] == 'd') {
            scanf("%d", &x);
            for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
                if (*it == x) {
                    v.erase(it);
                    break;
                }
            }
        }
    }
    
    int i=0;
    for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
        if (i++) printf(" ");
        printf("%d", *it);
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 33896
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;






int main() {
	string s[8];
	for (int i = 0; i < 8; i++) {
		cin >> s[i];
	}
	cout << "90" << endl;
	for (int j = 0; j < 8; j++) {
		for (int i = 7; i >= 0; i--) {
			cout << s[i][j];
		}
		cout << endl;
	}
	cout << "180" << endl;
	for (int i = 7; i >= 0; i--) {
		for (int j = 7; j >= 0; j--) {
			cout << s[i][j];
		}
		cout << endl;
	}
	cout << "270" << endl;
	for (int j = 7; j >= 0; j--) {
		for (int i = 0; i < 8; i++) {
			cout << s[i][j];
		}
		cout << endl;
	}
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	string S;
	
	cin >> S;
	
	if(S == "SAT")
		cout << 1;
	else if(S == "FRI")
		cout << 2;
	else if(S == "THU")
		cout << 3;
	else if(S == "WED")
		cout << 4;
	else if(S == "TUE")
		cout << 5;
	else if(S == "MON")
		cout << 6;
	else
		cout << 7;
	
	return 0;
}

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

#define int long long int
#define double long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define inf LLONG_MAX
#define mod 1000000007


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

	int n,i,ans=0;
	cin>>n;
	inp(a,n,0);
	int suf[n];
	suf[n-1]=a[n-1];
	for(i=n-2;i>=0;i--)
		suf[i]=suf[i+1]+a[i];
	for(i=0;i<n-1;i++)
	{
		suf[i+1]%=mod;
		int temp=(a[i]*suf[i+1])%mod;
		ans=(ans+temp)%mod;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 6732
'use strict'

function main(input) {
  const inputList = input.split('\n');
  const n = inputList[0]
  const list = inputList.slice(1)
  let result = true 

  let prevt = 0
  let prevx = 0
  let prevy = 0
  let nextt = 0
  let nextx = 0
  let nexty = 0

  for (let i=0; i<list.length; i++) {
    const tmpList = list[i].split(' ')
    nextt = tmpList[0]
    nextx = tmpList[1]
    nexty = tmpList[2]

    const difft = nextt - prevt
    const diffx = nextx - prevx 
    const diffy = nexty - prevy
    const tmp = difft - (diffx+diffy)
    if ( tmp<0 || tmp%2 === 1) {
      result = false 
      break
    }

    prevt = nextt 
    prevx = nextx 
    prevy = nexty
  }

  if (result) {
    console.log('Yes')
  } else {
    console.log('No')
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29944
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=998244353;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e9+7;
const long double PI=acos(-1);



void solve(int T){
    ll l,r;
    cin>>l>>r;
    ll ans=20200;
    for(ll i=l;i<=min(r,l+2019);i++){
        for(ll j=i+1;j<=min(r,l+2019);j++){
            ans=min(ans,(i*j)%2019);
        }
    }
    cout<<ans<<"\n";
}

int main() {
    fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>

#define NIL -1
#define N 41

typedef struct {
  int pid;
  int leftc;
  int rightc;  
} Node;

int findSubtreeRoot (Node*, int*, int*, int*, int, int);
void traverse (Node*, int);

int main () {
  int n;
  Node tree[N];
  int preorder[N];
  int inorderID[N];
  int inorderInfo[N];
  
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    tree[i].pid = NIL;
    tree[i].leftc = NIL;
    tree[i].rightc = NIL;
  }

  for (int i = 1; i <= n; i++) {
    scanf("%d", &preorder[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &inorderID[i]);
    inorderInfo[inorderID[i]] = i;
  }
  
  int pid = findSubtreeRoot(tree, preorder, inorderID, inorderInfo, 1, n + 1);

  traverse(tree, pid);
  
  return 0;
}

int findSubtreeRoot (Node* tree, int* preorder, int* inorderID, int* inorderInfo, int left, int right) {
  static int cnt = 1;
  int length = right - left;

  if (length < 1) {
    return NIL;    
  }

  int pid    = preorder[cnt++];
  int pivot  = inorderInfo[pid];
  int leftc  = findSubtreeRoot(tree, preorder, inorderID, inorderInfo, left, pivot);
  int rightc = findSubtreeRoot(tree, preorder, inorderID, inorderInfo, pivot + 1, right);

  tree[pid].leftc  = leftc;
  tree[pid].rightc = rightc;
  tree[leftc].pid  = pid;
  tree[rightc].pid = pid;
  
  return pid;
}

void traverse (Node* tree, int id) {
  if (tree[id].leftc != NIL) {
    traverse(tree, tree[id].leftc);
  }
  if (tree[id].rightc != NIL) {
    traverse(tree, tree[id].rightc);
  }
  if (tree[id].pid != NIL) {
    printf("%d ", id);
  } else {
    printf("%d\n", id);
  }

  return;
}



Measured memory_bytes: 2108
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
signed main()
{
	int n = in();
	string res;
	while (n != 0)
	{
		res += '0' + (n % 2 == 0 ? 0 : 1);
		n = (n - (n % 2 == 0 ? 0 : 1)) / (-2);
	}
	if (res.length() == 0)cout << '0';
	else for (auto itr = res.rbegin(); itr != res.rend(); itr++)cout << *itr;
	cout << endl;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  double sum=0;
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    double k;
    k=1.0/a.at(i);
    sum+=k;
  }
  cout<<1.0/sum<<endl;
}

Measured memory_bytes: 256
/*
oruegg19 - Arundhati Bhattacharya
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<unsigned ll>
#define mp make_pair
#define F first
#define S second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const unsigned ll l=1000000007;
const int MAX_=2000;
int T;

void solve(int t)
{
  int n;
  cin >> n;
  vii a(n), b(n);
  for(int i=0; i<n; i++)
  {
    cin >> a[i];
  }

  b[1] = abs( a[0]-a[1] );

  for(int i=2; i<n; i++)
  {
    b[i] = min( b[i-2] + abs(a[i-2]-a[i]) , b[i-1] + abs(a[i-1]-a[i]) );
  }

  cout << b[n-1] << endl;
}

int main()
{
  IOS
  int t,testCases;
  testCases=1;

  while(testCases--)
  {
    t=1;
    // cin >> t; //comment this in case of singular test case
    T = t;
    while(t--)
    {
      // cout << "HERE" << endl;
      solve(t);
    }
  }
  return 0;

}



Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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 dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    string s; cin >> s;
    rep(i,3) {
        if (s[i]==s[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = sorted([int(i) for i in input().split()])
ans = 0
for i in range(n-2):
    k = i + 2
    for j in range(i+1, n):
        while k < n and l[i] + l[j] > l[k]:
            k += 1
        if k > j:
            ans += k-j-1
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
int p[100001],r[100001],h[100001];
void init(){rep(i,100001)p[i]=i,r[i]=0,h[i]=0;}
int find(int x){return (p[x]==x)?x:(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;
  else{p[y]=x;if(r[x]==r[y])r[x]++;}
}
bool same(int x,int y){return find(x)==find(y);}

vector<int> v[111111];
bool u[111111][2];
void dfs(int x,int t,int p) {
  if(u[x][t]) return;
  u[x][t]=1;
  rep(i,v[x].size()) {
    int y=v[x][i];
    if(y==p) continue;
    dfs(y,t^1,x);
  }
}

void Main() {
  init();
  ll n,m;
  cin >> n >> m;
  rep(i,m) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    v[x].pb(y);
    v[y].pb(x);
    unite(x,y);
  }
  rep(i,n) {
    if(u[i][0]||u[i][1]) continue;
    dfs(i,0,-1);
    if(u[i][0]&&u[i][1]) h[find(i)]=1;
  }
  ll ans=n*n;
  map<ll,ll> ma;
  rep(i,n) ma[find(i)]++;
  ll sum=0,cnt=0,cnt2=0;
  tr(it,ma) {
    ll x=it->S;
    if(x<=1) continue;
    ll y=x*x+sum*x*2;
    ans-=y;
    ans+=cnt*2+1;
    if(!h[it->F]) ans+=cnt2*2+1;
    sum+=it->S;
    cnt++;
    if(!h[it->F]) cnt2++;
  }
  pr(ans);
}

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


Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

int main(){
    int n,m; cin >> n >> m;
    ves a(n), b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];

    rep(l,n-m+1){
        rep(k,n-m+1){
            bool xcheck = true;
            bool ycheck = true;
            rep(i,m) {
                rep(j,m){
                    if(b[i][j] != a[i+l][j+k]) xcheck = false;
                    if(b[i][j] != a[i+k][j+l]) ycheck = false;
                }
            }
        if(xcheck or ycheck) {
            cout << "Yes" << endl;
            return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n; R(n);
    W(n*(n-1LL)/2);
    return 0;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

i64 cnt[2200000];

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

  var(i64, N, K);

  vector<pii> vec;
  vector<i64> a(N);
  rep(i, N) {
    input(a[i]);
    cnt[a[i]]++;
  }

  map<pii, bool> exist;
  rep(i, N) {
    if (!exist[pii(cnt[a[i]], a[i])]) {
      vec.emplace_back(cnt[a[i]], a[i]);
      exist[pii(cnt[a[i]], a[i])] = true;
    }
  }

  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());

  i64 loop = vec.size() - K;
  i64 res = 0;
  rep(i, loop) {
    res += vec[i].first;
  }

  outl(res);

  return 0;
}


Measured memory_bytes: 19692
#include <iostream>
#include <cstdio>

using namespace std;

int counter;

int gcd(int a, int b){
      if (b == 0) return a;
      counter++;
      return gcd(b, a%b);
  }

int main(void){
  int a, b, x;
   while(cin>>a>>b){
       if(a < b){
           x = a;
           a = b;
           b = x;
       }
       if(a == 0 && b == 0)    return 0;
       counter = 0;
       cout<<gcd(a,b)<<" ";
       cout<<counter<<endl;
   }
   return 0;
}


Measured memory_bytes: 3036
import itertools

n = int(input())
x, y, h = [], [], []
for _ in range(n):
    xi, yi, hi = map(int, input().split())
    if hi != 0:
        x.append(xi)
        y.append(yi)
        h.append(hi)
candidate_cx = list(range(min(x), max(x) + 1))
candidate_cy = list(range(min(y), max(y) + 1))
candidate_ch = list(range(max(h), max(max(x) - min(x), max(y) - min(y)) + max(h) + 1))

for cx, cy, ch in list(itertools.product(candidate_cx, candidate_cy, candidate_ch)):
    adapted = True
    for xi, yi, hi in zip(x, y, h):
        if hi != ch - abs(xi - cx) - abs(yi - cy):
            adapted = False
            break
    if adapted == False:
        continue
    print(cx, cy, ch, sep = ' ')
    exit(0)

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

typedef pair<double, double> pdd;
pdd a[10];

double pow(double x){
    return x*x;
}

int main(){
    int n;
    cin>>n;
    int sum=1;
    for(int i = 1; i <= n; i++){
        sum*=i;
        cin>>a[i].first>>a[i].second;
    }
    double ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            ans += sqrt(pow(a[i].first-a[j].first)+pow(a[i].second-a[j].second));
        }
    }
    //cout<<ans<<endl;
    printf("%.10f", ans/(n*1.0));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, k, x, y;
    cin >> n >> k >> x >> y;
    k = min(n, k);
    ll ans = x * k + (n - k) * y;
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>

using namespace std;

int main()
{
    int n;
    typedef set<string> hoge;
    hoge H;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string str;
        cin >> str;
        if (str == "insert") {
            string fuga;
            cin >> fuga;
            H.insert(fuga);
        } else {
            string fuga;
            cin >> fuga;
            if (H.count(fuga) == 0) {
                cout << "no" << endl;
            } else {
                cout << "yes" << endl;
            }
        }
    }
}


Measured memory_bytes: 32068
import java.util.*;
public class Main {

	static int flower[] = new int[100];
	static int flower_h[] = new int[100];
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int count = 0;
		
		for(int i = 0; i < num; i++) {
			flower_h[i] = sc.nextInt();
		}
		
		if(num == 1) {
			System.out.println(flower_h[0]);
			return;
		}
	
		while(!isHeight(num)) {
			for(int i = 0; i < num; i++) {
				
				//現在の花の高さが既に同じの場合はスキップ
				if(flower_h[i] == flower[i]) { 
					continue;
				}
				
				//水やり
				flower[i]++;
				
				//右端の場合はbreak
				if(i == num -1 ) {
					break;
				}
				
				//右隣の高さが同じの場合はbreak;
				if(flower_h[i+1] == flower[i+1]) {
					break;
				}
			}
			count++;
		}
		
		System.out.println(count);

	}
	
	public static boolean isHeight(int len) {
		
		for(int i = 0; i < len; i++) {
			if(flower_h[i] != flower[i]) {
				return false;
			}
		}
		return true;
	}
}



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

int main() {
	string s;
	cin>>s;
	int cnt=0,n=s.length(),maxi=0;
	for(int i=0;i<n;i++)
	{
	    if(s[i]=='R')
	    cnt++;
	    else
	    {
	        maxi=max(maxi,cnt);
	        cnt=0;
	    }
	}
	cout<<max(maxi,cnt);
	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
#define X real()
#define Y imag()
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using Point = complex<double>;
using Vector = complex<double>;
using Segment = pair<Point, Point>;
using Line = pair<Point, Point>;
using Polygon = vector<Point>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

namespace std{
    bool operator<(const Point &a, const Point &b){
        return !equals(a.X, b.X) ? a.X < b.X : a.Y < b.Y;
    }
}

double dot(Vector a, Vector b){
    return a.X * b.X + a.Y * b.Y;
}

double cross(Vector a, Vector b){
    return a.X * b.Y - a.Y * b.X;
}

double norm(Vector a){
    return a.X * a.X + a.Y * a.Y;
}

double abs(Vector a){
    return sqrt(norm(a));
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a, b) > EPS) return COUNTER_CLOCKWISE;
    if(cross(a, b) < -EPS) return CLOCKWISE;
    if(dot(a, b) < -EPS) return ONLINE_BACK;
    if(norm(a) < norm(b)) return ONLINE_FRONT;

    return ON_SEGMENT;
}

Polygon convexHull(Polygon ps){
    int n = ps.size();
    sort(ps.begin(), ps.end());
    int k = 0;
    Polygon convex(n * 2);
    for(int i=0; i<n; i++){
        while(k >= 2 && ccw(convex[k-2], convex[k-1], ps[i]) == CLOCKWISE) k--;
        convex[k++] = ps[i];
    }
    for(int i=n-2, t=k; i>=0; i--){
        while(k > t && ccw(convex[k-2], convex[k-1], ps[i]) == CLOCKWISE) k--;
        convex[k++] = ps[i];
    }
    convex.resize(k-1);
    return convex;
}

int main(){
    int h, w; cin>>h>>w;
    vector<string> c(h);
    Polygon pol;
    for(int i=0; i<h; i++){
        cin>>c[i];
        for(int j=0; j<w; j++){
            if(c[i][j] == 'B'){
                pol.emplace_back(i, j);
            }
        }
    }

    pol = convexHull(pol);

    int n = pol.size();
    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            Point p1 = pol[i];
            Point p2 = pol[j];
            chmax(ans, (int)(abs(p1.X - p2.X) + abs(p1.Y - p2.Y)));
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 42256
#include<stdio.h>
#define ll long long 
int b[1000100] = {0};
int main(){
    int n;
    scanf("%d",&n);
    int a[n + 1];
    for(int i = 2; i <= n; i++)
        scanf("%d",&a[i]);
    for(int i = 2; i <= n; i++)
        b[a[i]] ++;
    for(int i = 1; i <= n; i++)
        printf("%d\n",b[i]);
    return 0;
}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::cin >> N;

  int ans = 0, sub = 10;
  while(N >= sub) {
    ans += sub - sub / 10;
    sub *= 100;
  }
  int d = 1;
  sub = 1;
  while(10 * sub <= N) {
    sub *= 10;
    ++d;
  }
  if(d & 1) {
    ans += N - sub + 1;
  }

  std::cout << ans << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 3009;

string s, t;
int dp[SIZE][SIZE];

int main() {
    cin >> s >> t;
    int sl = s.size();
    int tl = t.size();    
    fill(dp[0], dp[SIZE], 0);
    s = "#" + s;
    t = "#" + t;

    for(int si = 1; si <= sl; si++) {
        for(int ti = 1; ti <= tl; ti++) {
            if(s[si] == t[ti])
                dp[si][ti] = dp[si-1][ti-1] + 1;
            else
                dp[si][ti] = max(dp[si-1][ti], dp[si][ti-1]);
        }
    }

    string ans = "";
    int si = sl;
    int ti = tl;
    while(si != 0 && ti != 0) {
        if(s[si] == t[ti]) {
            ans = s[si] + ans;
            si--;
            ti--;
        }
        else
            (dp[si][ti] == dp[si-1][ti] ? si : ti)--;
    }
    cout << ans << endl;
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

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

ll safemod(ll a,ll m){
	return (a%m+m)%m;
}

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

	auto M=in(),K=in();
	vll P,Z,N;
	REP(i,M){
		auto A=in();
		if(A==0) Z.push_back(A);
		else if(A>0) P.push_back(A);
		else N.push_back(A);
	}
	ll PS=P.size(),ZS=Z.size(),NS=N.size();
	if(PS+NS<K){
		out(0);
		return 0;
	}
	if(!(K%2)){
		sort(ALL(P),greater<ll>());
		sort(ALL(N));
		ll PP=0,NP=0;
		while(true){
			if(PP+2<=PS && PP+2<=K) PP += 2;
			else break;
		}
		NP=K-PP;
		if(NP>NS){
			NP=NS;
			PP=K-NP;
			if(NP%2 && ZS>0){
				out(0);
				return 0;
			}
		}
		while(PP>0 && NP+1<NS){
			ll A=P[PP-1]*P[PP-2];
			ll B=N[NP]*N[NP+1];
			if(A<B){
				PP-=2;
				NP+=2;
			}
			else break;
		}
		ll X=1;
		REP(i,PP){
			X *= P[i];
			X = safemod(X,atcoder_mod);
		}
		REP(i,NP){
			X *= N[i];
			X = safemod(X,atcoder_mod);
		}
		out(X);
	}
	else{
		if(PS==0){
			if(ZS>0){
				out(0);
				return 0;
			}
			sort(ALL(N),greater<ll>());
			ll X=1;
			REP(i,K){
				X *= N[i];
				X = safemod(X,atcoder_mod);
			}
			out(X);
		}
		else{
			sort(ALL(P),greater<ll>());
			sort(ALL(N));
			ll PP=1,NP=0;
			while(true){
				if(PP+2<=PS && PP+2<=K) PP += 2;
				else break;
			}
			NP=K-PP;
			if(NP>NS){
				NP=NS;
				PP=K-NP;
				if(NP%2 && ZS>0){
					out(0);
					return 0;
				}
			}
			while(PP>1 && NP+1<NS){
				ll A=P[PP-1]*P[PP-2];
				ll B=N[NP]*N[NP+1];
				if(A<B){
					PP-=2;
					NP+=2;
				}
				else break;
			}

			ll X=1;
			REP(i,PP){
				X *= P[i];
				X = safemod(X,atcoder_mod);
			}
			REP(i,NP){
				X *= N[i];
				X = safemod(X,atcoder_mod);
			}

			out(X);
		}
	}
	return 0;
}


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

int n,pd[100002],k;
vector<int> A;
inline void mmin(int &a,int b){
    a = min(a,b);
}
int main(){

    cin >> n >> k;
    A = vector<int> (n);
    for(auto &a:A) cin >> a;
    memset(pd,63,sizeof pd);
    pd[n-1]=0;
    for(int i=n-2;i>=0;i--){
        for(int j=1;j<=k and j+i<=n-1;j++)
            mmin(pd[i],pd[i+j]+abs(A[i]-A[i+j]));
    }
    cout << pd[0] << '\n';
}


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

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

Measured memory_bytes: 3580
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	char a; CI a;
	if (a == 'A') CO 'T' EN;
	else if (a == 'T') CO 'A' EN;
	else if (a == 'G') CO 'C' EN;
	else CO 'G' EN;
	return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let mut b: usize = iterator.next().unwrap().parse().unwrap();
    let mut c: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();

    let mut n: usize = 0;
    while b <= a {
        b *= 2;
        n += 1;
    }
    while c <= b {
        c *= 2;
        n += 1;
    }

    if n <= k {
        "Yes".to_string()
    } else {
        "No".to_string()
    }
}


Measured memory_bytes: 2132
#参考：http://at274.hatenablog.com/entry/2020/01/24/060000

N = int(input())
# cnt[i][j] := 先頭がi, 末尾がjで始まるような数
# 個数を格納できる行列の準備
cnt = [[0] * 10 for i in range(10)]
# Nまでカウントする（11>(1,1) 10231>(1,1))
for n in range(1, N + 1):
    cnt[int(str(n)[0])][int(str(n)[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]

print(ans)

Measured memory_bytes: 3060
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word
// also tink all answers possible for a question
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long double ld;
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
#define sz 100005
ll inf = 1e9;
ll power(ll x, ll n, ll mod)
{
  ll res = 1;
  x %= mod;
  while (n)
  {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res%mod;
}
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  ll n,m,t;
  cin>>n>>m>>t;
  ll row[n+1];
  ll col[m+1];
  for(ll i=0;i<=n;i++)
  {
    row[i]=0;
  }
  for(ll j=0;j<=m;j++)
  {
    col[j]=0;
  }
  map<pair<ll,ll>,ll> m1;
  for(ll i=0;i<t;i++)
  {
    ll x,y;
    cin>>x>>y;
    m1[{x,y}]++;
    row[x]++;
    col[y]++;
  }
  ll maxr,maxc,ansr=-1*(1e9),ansc=-1*(1e9);
  ll ans=-1*(1e9);
  vector<ll> r;
  vector<ll> c;
  bool f=0;
  for(ll i=1;i<=n;i++)
    ansr=max(ansr,row[i]);
  for(ll i=1;i<=m;i++)
    ansc=max(ansc,col[i]);
  for(ll i=1;i<=n;i++)
  {
    if(row[i]==ansr)
      r.push_back(i);
  }
  for(ll i=1;i<=m;i++)
  {
    if(col[i]==ansc)
      c.push_back(i);
  }
  for(ll i=0;i<r.size();i++)
  {
    for(ll j=0;j<c.size();j++)
    {
      if(m1.find({r[i],c[j]})==m1.end())
      {
        f=1;
        break;
      }
    }
  }
  if(f)
    cout<<ansr+ansc;
  else
    cout<<ansr+ansc-1;

  return 0;
}

Measured memory_bytes: 28508
from collections import Counter

def main():
    N = int(input())
    A = list(map(int,input().split()))
    for a in A:
        if (a + N + 1)%2:
            return 0
    for k,v in Counter(A).items():
        if k == 0 and v != 1:
            return 0
        if k != 0 and v != 2:
            return 0
    ans = 1
    mod = 10**9 + 7
    for i in range(N//2):
        ans *= 2
        ans %= mod
    return ans

print(main())



Measured memory_bytes: 14812
a, b, k = map(int, input().split())

if b - a + 1 <= k * 2:
    for i in range(a, b + 1):
        print(i)
else:
    for i in range(a, a + k):
        print(i)
    for i in range((b - k + 1), (b + 1)):
        print(i)


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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; }
// int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int n; cin >> n;
  deque<int> dq;
  FOR(i,0,n-1){
    int a; cin >> a;
    int t = lower_bound(dq.begin(), dq.end(), a) - dq.begin();
    if(t==0) dq.push_front(a);
    else dq[t-1] = a;
  }

  cout << SZ(dq) << endl;

}



Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).Distinct().ToArray();
        Console.WriteLine(a.Length - ((n - a.Length) % 2 == 0 ? 0 : 1));
    }
}

Measured memory_bytes: 21984
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void)
{
	int h;
	cin >> h;
	int *a = new int[h];
	for (int i = 0; i < h; i++) cin >> a[i];

	for (int i = 0; i < h; i++) {
		cout << "node " << i + 1 << ": ";
		cout << "key = " << a[i] << ", ";
		if (i != 0) {
			cout << "parent key = " << a[(i + 1) / 2 - 1] << ", ";
		}
		int j;
		if ((j = (i + 1) * 2 - 1) < h) {
			cout << "left key = " << a[j] << ", ";
			if (j + 1 < h) {
				cout << "right key = " << a[j + 1] << ", ";
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const long long INF = 1LL << 60;

template<typename T>
class RangeUpdateQuery {
public:
    explicit RangeUpdateQuery(int n, T def) : N(calcN_(n)) {
        mVal.assign(2*N+1, make_pair(-1, def));
    }
    void update(int l, int r, T value, int ts){
        l = max(0, l);
        r = min(N, r);
        int offset = N;
        while(offset > 0){
            if(l >= r) break;
            if(l&1){ mVal[offset+l-1].first = ts; mVal[offset+l-1].second = value; l++; }
            if(r&1){ mVal[offset+r-2].first = ts; mVal[offset+r-2].second = value; }
            l /= 2;
            r /= 2;
            offset /= 2;
        }
    }
    T get(int idx){
        int i = N + idx - 1;
        auto res = mVal[i];
        while(i > 0){
            i = (i-1)/2;
            res = max(mVal[i], res);
        }
        return res.second;
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    const int N;
    vector<pair<int,T>> mVal;
};

int main(){
    int N, M;
    while(cin >> N >> M){
        vector<pair<pair<int,int>, int>> vp(M);
        for(auto& p : vp){
            cin >> p.first.first >> p.first.second >> p.second;
            --p.first.first;
            --p.first.second;
        }
        sort(vp.begin(), vp.end());
        RangeUpdateQuery<long long> ruq(N, INF);
        ruq.update(0, 1, 0, 0);
        for(int i=0;i<M;i++){
            auto& p = vp[i];
            auto next = ruq.get(p.first.first) + p.second;
            if(ruq.get(p.first.second) <= next) continue;
            int L = p.first.first, R = p.first.second;
            while(R-L > 1){
                int mid = (L+R)/2;
                if(ruq.get(mid) > next) R = mid;
                else L = mid;
            }
            ruq.update(R, p.first.second+1, next, i+1);
        }
        auto res = ruq.get(N-1);
        cout << (res == INF ? -1 : res) << endl;
    }
}

Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		scan.close();
		for(int i=0;i<s.length();i=i+2) {
			System.out.print(s.charAt(i));
		}
		System.out.println();
	}

}

Measured memory_bytes: 27696
#include<bits/stdc++.h>
 using namespace std;
 int main(){
   string s;
   cin >> s;
   long long k;
   cin >>k;
   for(int i = 0;i < k; i++){
     if(s[i] != '1'){
       cout << s[i] <<endl;
       return 0;
     }
   }
     cout << 1 <<endl;
     return 0;
  
  
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    string S;cin>>S;
    REP(i,S.size()-1){
        if(S[i]==S[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
        if(i!=S.size()-2&&S[i]==S[i+2]){
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 512