akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

struct Shift {
	ll n;
	vector<vector<ll>> mat;

	Shift(ll n) : n(n) {
		mat.assign(n, vector<ll>(n));
		REP(i, n) REP(j, n) mat[i][j] = i * n + j;
	}

	Shift(ll n, vector<vector<ll>> v) : n(n), mat(v) {
		REP(i, n) REP(j, n) mat[i][j] = v[i][j];
	}

	void left(ll m) {
		ll tmp = mat[m][0];
		REP(i, n - 1) mat[m][i] = mat[m][i + 1];
		mat[m][n - 1] = tmp;
		return;
	}

	void right(ll m) {
		ll tmp = mat[m][n - 1];
		for(ll i = n - 2; i >= 0; i--) mat[m][i + 1] = mat[m][i];
		mat[m][0] = tmp;
		return;
	}

	void up(ll m) {
		ll tmp = mat[0][m];
		REP(i, n - 1) mat[i][m] = mat[i + 1][m];
		mat[n - 1][m] = tmp;
		return;
	}

	void down(ll m) {
		ll tmp = mat[n - 1][m];
		for(ll i = n - 2; i >= 0; i--) mat[i + 1][m] = mat[i][m];
		mat[0][m] = tmp;
		return;
	}

	ll get(ll r, ll c) {
		return mat[r][c];
	}

	Shift operator * (Shift obj) {
		vector<vector<ll>> ret(n, vector<ll>(n, 0));
		REP(i, n) REP(j, n) {
			ll tmp1 = obj.get(i, j);
			ll tmp2 = mat[tmp1 / n][tmp1 % n];
			ret[i][j] = tmp2;
		}
		return Shift(n, ret);
	}
};

ll n, l;
string s;
ll pos = 0;

Shift operation();
Shift repetition();
Shift sequence();

ll number() {
	string numstr = "";
	while(pos < l && s[pos] >= '0' && s[pos] <= '9') {
		numstr += s[pos];
		pos++;
	}
	ll num = stol(numstr);
	return num;
}

Shift operation() {
	Shift ret(n);
	char shift = s[pos]; pos++;
	ll num = number();
	if(shift == 'L') ret.left(num - 1);
	if(shift == 'R') ret.right(num - 1);
	if(shift == 'U') ret.up(num - 1);
	if(shift == 'D') ret.down(num - 1);
	return ret;
}

Shift repetition() {
	Shift a(n);
	pos++; a = a * sequence(); pos++;
	ll num = number();
	Shift ret(n);
	while(num > 0) {
		if(num % 2) ret = ret * a;
		a = a * a;
		num /= 2;
	}
	return ret;
}

Shift sequence() {
	Shift ret(n);
	if(s[pos] == '(') ret = ret * repetition();
	else ret = ret * operation();
	if(pos == l || s[pos] == ')') return ret;
	else return ret * sequence();
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> l >> s;
	Shift ans = sequence();
	REP(i, n) REP(j, n) {
		cout << ans.get(i, j) + 1;
		if(j != n - 1) cout << " ";
		else cout << endl;
	}
 	return 0;
}

/* --------------------------------------- */




Measured memory_bytes: 58092
#include <iostream>

using namespace std;

int main(){
    int n, x, min = 1e9;
    cin >> n >> x;
    for (int i = 0; i < n; i++) {
        int m;
        cin >> m;
        x -= m;
        if (m < min) min = m;
    }
    cout << n + x / min << endl;
    return 0;
}


Measured memory_bytes: 256
void main(){
	int n, k;
	readf("%d %d\n", &n, &k);
	int[] p = _scanln();
	p.sort!("a<b");
	p[0..k].sum().writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2868
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1e9+7;

int main() {
  int n,m;
  cin>>n>>m;
  int revp=pow(2,m),t=m*1900+(n-m)*100;
  cout<<t*revp<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int d[5],k;
int main() {
	for(int i = 0; i < 5; i++)
		cin >> d[i];
	cin >> k;
	for(int i = 0; i < 4; i++)
		for(int j = i + 1; j < 5; j++)
			if (abs(d[i] - d[j]) > k) {
				cout << ":(";
				return 0;
			}

	cout << "Yay!" << endl;
	return 0;
}

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


int main() {
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        string s, t;
        cin >> s >> t;
        int sl = s.size(), tl = t.size();
        int dp[1010][1010];
        dp[0][0] = 0;
        for (int j = 1; j <= sl; ++j) {
            for (int k = 1; k <= tl; ++k) {
                if (s[j - 1] == t[k - 1]) {
                    dp[j][k] = dp[j - 1][k - 1] + 1;
                }
                else {
                    dp[j][k] = max(dp[j - 1][k], dp[j][k - 1]);
                }
            }
        }
        cout << dp[sl][tl] << "\n";
    }
    return 0;
}

Measured memory_bytes: 7120
#include <bits/stdc++.h>
#define maxn 3005
using namespace std;

int dp[maxn][maxn] = {};
char s[maxn], t[maxn];
int n, m;

void dfs(int x, int y) {
    if(!x || !y) return;
    if(s[x] == t[y]) {
        dfs(x - 1, y - 1);
        putchar(s[x]);
    }
    else {
        if(dp[x - 1][y] == dp[x][y]) dfs(x - 1, y);
        else dfs(x, y - 1);
    }
}

int main() {
    scanf("%s%s", s + 1, t + 1);
    n = strlen(s + 1);
    m = strlen(t + 1);
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(s[i] == t[j]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else {
                dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
            }
        }
    }
    dfs(n, m);
    return 0;
}


Measured memory_bytes: 39084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int K,X;cin>>K>>X;
    if(500*K>=X){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
}



Measured memory_bytes: 256
n = int(input())
arr = list(map(int, input().split()))

count = 0
for i in range(n):
    mini = i
    for j in range(i, n):
        if arr[j] < arr[mini]:
            mini = j
    if mini != i:
        arr[i], arr[mini] = arr[mini], arr[i]
        count += 1

print(*arr)
print(count)



Measured memory_bytes: 5612
#include<stdio.h>

int main(){
  int n,i,j;
  long a[100],min=4000000,cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%ld",&a[i]);
  for(i=-100;i<=100;i++){
    cnt=0;
    for(j=0;j<n;j++){
      cnt+=(a[j]-i)*(a[j]-i);
    }
    if(min>cnt)
      min=cnt;
  }
  printf("%ld\n",min);
}

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

int main(void){
  long long H;
  int N, K;
  cin >> N >> K;
  vector<long long> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  long long count = 0;
  for(int i = 0; i < N - K; i++){
    count += vec[i];
  }
  cout << count;
 return 0; 
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険                                   // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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 dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
int main(){
	long long N; cin >> N;
	long long A[N]; rep(i,0,N) cin >> A[i];

	long long res = 1;
	long long x[N], y[N], z[N];
	rep(i,0,N) x[i] = y[i] = z[i] = 0;
	rep(i,1,N){
		if(x[i-1] == A[i-1]){
			x[i] = x[i-1] + 1;
          	y[i] = y[i-1];
          	z[i] = z[i-1];
        }
		else if(y[i-1] == A[i-1]){
          	x[i] = x[i-1];
			y[i] = y[i-1] + 1;
          	z[i] = z[i-1];
        }
		else{
          	x[i] = x[i-1];
          	y[i] = y[i-1];
			z[i] = z[i-1] + 1;
        }
	}
	rep(i,0,N){
		long long tmp = 0;
      	//cout << x[i] << " " << y[i] << " " << z[i] << ednl;
		tmp += (x[i] == A[i] ? 1 : 0);
		tmp += (y[i] == A[i] ? 1 : 0);
		tmp += (z[i] == A[i] ? 1 : 0);
		res = (res * tmp) % MOD;
	}
	cout << res << endl;


}


Measured memory_bytes: 3328
#include<queue>
#include<cstdio>
#include<algorithm>

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

using namespace std;

typedef long long ll;

const ll M=1000000007;

ll dfs(int u,const vector<int> *T){
	if(T[u].empty()) return 2;
	ll res=1;
	rep(i,T[u].size()){
		int v=T[u][i];
		res=res*dfs(v,T)%M;
	}
	return (res+1)%M;
}

// ツ出ツ篠淞青板つェツ債つ々 1 ツづ?つ「ツつ、ツ青ァツ姪アツつゥツづァ, ツ連ツ個仰青ャツ閉ェツづ債δ仰ーツプツづ可姪伉つェツつュツづ?づつつ「ツつスツ形ツづ可づ按づゥ
// ツつアツづ個連ツ個仰青ャツ閉ェツづ可づつつ「ツづ?づ個嘉ーツづーツ仰?づ淞づゥ
ll solve(int n,const int *G){
	vector<int> G2[1000]; // G ツづ個陛督づ個古シツつォツづーツ逆ツ転ツつオツつスツグツδ可フ
	rep(u,n) if(G[u]!=-1) G2[G[u]].push_back(u);

	// ツδ仰ーツプツ個淞出
	rep(u,n){
		int v=u;
		bool vis[1000]={};
		while(G[v]!=-1 && !vis[v]){
			vis[v]=true;
			v=G[v];
		}
		if(v==u){ // ツδ仰ーツプorツ債ェツつェツ個ゥツづつつゥツづ?つス
			ll res=1;
			int v=u;
			do{
				// ツδ仰ーツプツ湘」ツづ個各ツ陳クツ点ツづーツ債ェツづ?つキツづゥツ姪伉づ可づつつ「ツづ?督堋つヲツづーツ仰?づ淞づ? ツつサツづェツづァツづーツつゥツつッツつ?づュツつケツづゥ
				rep(i,G2[v].size()){
					int w=G2[v][i];
					if(!vis[w]) res=res*dfs(w,G2)%M;
				}
				v=G[v];
			}while(v!=u && v!=-1);
			return (res+1)%M; // ツづ?づェツづ?選ツづ篠づ按つ「ツづ?つ「ツつ、ツ嘉ーツつェツつ?づゥツづ個づ?+1
		}
	}
	for(;;);
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	int to[1000];
	rep(u,n) to[u]=-1;
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		to[u]=v;
	}
	vector<int> G[1000]; // ツ鳴ウツ古シツグツδ可フ
	rep(u,n) if(to[u]!=-1) {
		int v=to[u];
		G[u].push_back(v);
		G[v].push_back(u);
	}

	ll ans=1;
	bool vis[1000]={};
	rep(u,n) if(!vis[u]) {
		vis[u]=true;

		vector<int> cc;
		queue<int> Q; Q.push(u);
		while(!Q.empty()){ // ツ偲」ツ連ツ個仰青ャツ閉ェツつイツづ?づ可陳イツづ猟づゥ
			int u=Q.front(); Q.pop();
			cc.push_back(u);
			rep(i,G[u].size()){
				int v=G[u][i];
				if(!vis[v]) vis[v]=true, Q.push(v);
			}
		}

		int N=cc.size();
		int D[1000]; // ツ偲」ツ連ツ個仰づ按有ツ古シツグツδ可フ
		rep(i,N) D[i]=-1;
		rep(i,N) rep(j,N) {
			int u=cc[i],v=cc[j];
			if(to[u]==v) D[i]=j;
		}
		ans=ans*solve(N,D)%M;
	}

	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

typedef struct{
  string name;
  int start;
  int goal;
} Data;

bool operator<(const Data &d1,const Data &d2){
  return (d1.start < d2.start);
}

int main(){
  int n,q;
  while(cin>>n>>q,n){
    vector<Data> vec(n);
    for(int i=0;i<n;i++){
      Data d;
      int diff;
      cin>>d.name>>diff>>d.goal;
      d.start=d.goal-diff+1;
      vec[i]=d;
    }
    sort(vec.begin(),vec.end());
    for(int i=0;i<q;i++){
      int num;
      cin>>num;
      if(vec[n-1].goal < num){
	cout<<"Unknown"<<endl;
	continue;
      }
      for(int j=0;j<n;j++){
	if(vec[j].start <= num){
	  if(num <= vec[j].goal){
	    cout<<vec[j].name<<" "<<num-vec[j].start+1<<endl;
	    break;
	  }
	}else{
	  cout<<"Unknown"<<endl;
	  break;
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1284
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
	int n, m;
	cin >> n >> m;
	vector<vector<char>> board(n, vector<char>(m));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++)
			cin >> board[i][j];
	}
	vector<vector<int>> dp(n, vector<int>(m));
	dp[0][0] = 1;
	for (int j = 1; j < m; j++) {
		if (board[0][j] == '#')
			dp[0][j] = 0;
		else
			dp[0][j] = dp[0][j - 1];
	}
	for (int i = 1; i < n; i++) {
		if (board[i][0] == '#')
			dp[i][0] = 0;
		else
			dp[i][0] = dp[i - 1][0];
	}
	for (int i = 1; i < n; i++) {
		for (int j = 1; j < m; j++) {
			if (board[i][j] == '#')
				dp[i][j] = 0;
			else
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
		}
	}
	cout << dp[n - 1][m - 1];
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}


Measured memory_bytes: 9088
#include <iostream>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  const int a[7] = {1,3,5,7,8,10,12};
  const int b[4] = {4,6,9,11};
  const int c[1] = {2};
  auto search = [&](int x){
    for(int i=0;i<7;++i){
      if (x == a[i])return 'a';
    }
    for(int i=0;i<4;++i){
      if (x == b[i])return 'b';
    }
    if (x == c[0])return 'c';
    return 'x';
  };
  if(search(n)==search(m)) cout <<"Yes"<< endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools, bisect
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def S(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

alphabets = "abcdefghijklmnopqrstuvwxyz"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    A, B, C = LI()
    K = I()

    while A >= B:
        B *= 2
        K -= 1
    while B >= C:
        C *= 2
        K -= 1
    print("Yes" if K >= 0 else "No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 72556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#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 per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N; cin >> N;
	map<int,V<int>,greater<int>> mp;
	V<ll> xs;
	rep(i,N){
		int x; cin >> x;
		mp[x].pb(i);
		xs.pb(x);
	}
	xs.pb(0); mkuni(xs);
	map<ll,ll> dif;
	rep(i,si(xs)-1) dif[xs[i+1]] = xs[i+1]-xs[i];

	V<ll> ans(N);
	ll n = 0, mn = N;
	for(auto it: mp){
		auto v = it.sc;
		n += si(v);
		chmin(mn,v[0]);
		ans[mn] += dif[it.fs] * n;
	}
	rep(i,N) cout << ans[i] << '\n';
}


Measured memory_bytes: 19828
#include "bits/stdc++.h"
using namespace std;

#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'

const int N = 3e3+1;
int dp[N][N];
int main()
{
	 #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	string s1 , s2 ;
	cin >> s1 >> s2;
	int n1 = s1.size() , n2 = s2.size() ;
	for(int i = 1 ; i <= n1 ; ++i)
	{
		for(int j = 1 ; j <= n2 ; ++j)
		{
			if(s1[i-1] == s2[j-1]) dp[i][j]  = 1 + dp[i-1][j-1];
			else dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
		}
	}
	string ans =""; int x = 0;
	int i = n1 , j = n2 ;
	while(i > 0 && j > 0)
	{
		if(s1[i-1] == s2[j-1]) ans = s1[i-1] + ans , --i , --j ;
		else
		{
			if(dp[i-1][j] > dp[i][j-1])
				--i;
			else --j;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 35456
#include<cmath>
#include<iostream>
#include<iomanip>
#include<algorithm>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
using namespace std;

class Point {
public:
    double x, y;

    Point(double x=0, double y=0): x(x), y(y) {}

    Point operator + (Point p) { return Point(x+p.x, y+p.y); }
    Point operator - (Point p) { return Point(x - p.x, y - p.y); }
    Point operator * (double a) { return Point(x*a, y*a); }
    Point operator / (double a) { return Point(x/ a, y/ a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x*x, y*y; }
    bool operator < (const Point &p) const {
	return x != p.x ? x<p.x : y < p.y;
    }
    
    bool operator == (const Point &p) const {
	return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
};

typedef Point Vector;

struct Segment {
    Point p0, p1;
};

typedef Segment Line;

double dot(Vector a, Vector b) {
    return a.x*b.x + a.y*b.y;
}

double norm(Vector a) {
    return a.x*a.x + a.y*a.y;
}

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

/*
  ???????????§??????????????¨??????????????°??????
  |a*b|=|a||b|sin(theta)
 */
double cross(Vector a, Vector b){ 
    return a.x*b.y - a.y*b.x;
}

/*const?????????????????????????????????*/
const int COUNTER_CLOCKWISE = 1;
const int CLOCKWISE = -1;
const int ON_SEGMENT = 0;
const int ONLINE_FRONT = -2;
const int ONLINE_BACK = 2;

int ccw(Point p0, Point p1, Point p2){
    if (cross(p1-p0, p2-p0) > EPS) return COUNTER_CLOCKWISE;
    else if (cross(p1-p0, p2-p0) < -EPS) return CLOCKWISE;
    else if (dot(p1-p0,p2-p0) < -EPS) return ONLINE_BACK;
    else if (norm(p1-p0) < norm(p2-p0)) return ONLINE_FRONT;
    else return ON_SEGMENT;
}

/*
  intersect
  ?????¨?????????????????¢???????????£????????????????????????
  ????????????????¨?????????????????¨???????????????????????????°OK
*/
bool intersect(Point p0, Point p1, Point p2, Point p3) {
    return ((ccw(p0,p1, p2) * ccw(p0,p1,p3) <= 0) && (ccw(p2, p3, p0) * ccw(p2,p3,p1) <=0));
}

int main() {
    int n,i,d;
    
    Point p0, p1, p2,p3;
    cin >> n;
    for(i=0;i<n;i++){
	cin >>  p0.x>> p0.y>>p1.x>>p1.y>>p2.x>>p2.y>>p3.x>>p3.y;
	if (intersect(p0,p1,p2,p3)) cout << "1" << endl;
	else cout << "0" << endl;
    }
    return 0;

}

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

using namespace std;

#define ll long long

const int N = 3010;

int dp[N][N*2];
int n,t;
struct node{
	int a,b;
}arr[N];
int cmp(node x,node y) {
	if(x.a == y.a)	return x.b < y.b;
	return x.a < y.a;
}

int main(){
	scanf("%d%d",&n,&t);
	for(int i=1;i<=n;++i){
		scanf("%d%d",&arr[i].a,&arr[i].b);
	}
	sort(arr+1,arr+1+n,cmp);
	for(int i=1;i<=n;++i){
        for(int j=1;j<=6000;++j)    dp[i][j] = dp[i-1][j];
        for(int j=1;j<=t;++j)
            dp[i][j+arr[i].a] = max(dp[i][j+arr[i].a] , dp[i-1][j] + arr[i].b);
	}

	int ans = 0; 
    for(int i=1;i<=n;++i){
        for(int j=1;j<=6000;++j)    ans = max(ans,dp[i][j]);
    }
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 70784
import collections

mod = 998244353
n = int(input())


def pow(n, p):
    if p == 1:
        return n
    if p % 2 == 0:
        return (pow(n, p // 2) ** 2) % mod
    else:
        return ((pow(n, p // 2) ** 2) * n) % mod


def main():

    d = list(map(int, input().split()))
    if d[0] != 0:
        return 0

    md = max(d)
    cd = collections.Counter(d)
    res = cd[0]
    if res != 1:
        return 0
    for i in range(1, md + 1):
        if cd[i] == 0:
            return 0
        res *= pow(cd[i - 1], cd[i])
        res %= mod
    return res


print(main() % mod)



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


int main(){
  int N,ans;
  cin>>N;
  vector<int> pt(N);
  for(auto it=pt.begin();it!=pt.end();++it) cin>>*it;
  sort(pt.begin(),pt.end());
  ans=accumulate(pt.begin(),pt.end(),0.0);  
  if(ans%10==0){
    for(auto it=pt.begin();it!=pt.end();++it){
      if(*it%10!=0) {ans=ans-*it;cout<<ans<<endl; return 0;}
      }
  	cout<<0<<endl;
  	return 0;
  	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <map>

#define ull unsigned long long
#define ll long long

using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    int flag=0;
    while(n){
        if(n%10==7){
            printf("Yes");
            flag=1;
            break;
        }
        n/=10;
    }
    if(flag==0){
        printf("No");
    }
    return 0;
}


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

int main() {
	string S;
  	cin >> S;
  
  	bool can = true;
  
  	if(S.at(0) == S.at(1)) can = false;
    if(S.at(1) == S.at(2)) can = false;
    if(S.at(0) == S.at(2)) can = false;
  
  	if(can) {
      cout << "Yes" << endl;
    }else {
      cout << "No" << endl;
    }
}


Measured memory_bytes: 256
S = input()
K = int(input())
 

ans = 0
if len(S) == 1:
    ans = S[0]
else:
    i = 0
    for i in range(len(S)):
        if S[i] != '1' and i < K:
            ans = S[i]
            break
        else:
            ans = S[0]
   
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>

int main()
{
    int P;
    int Q;
    int R;

    scanf("%d %d %d", &P, &Q, &R);
    if((P >= Q) && (P >= R)) {
        printf("%d\n", Q + R);
    } else if((Q >= P) && (Q >= R)) {
        printf("%d\n", P + R);
    } else {
        printf("%d\n", P + Q);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define NMAX 100005
#define MOD 998244353

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll lastpos[NMAX];
vector<ll> v;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n,x,m,s=0,i=1;
    cin>>n>>x>>m;
    while(i<=n && lastpos[x]==0){
        lastpos[x]=i++;
        v.push_back(x);
        s+=x;
        x=x*x%m;
    }
    v.push_back(x);
    if(i>n){
        cout<<s;
        return 0;
    }
    n-=v.size()-1;
    ll s2=0,cycleSize=0;
    for(ll j=lastpos[x];j<v.size();j++){
        s2+=v[j];
        cycleSize++;
    }
    s+=n/cycleSize*s2;
    n%=cycleSize;
    while(n--){
        s+=x;
        x=x*x%m;
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 4608
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;



int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n,m,k;
	cin >> n >> m>>k;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (n * m - i * j - (n - i) * (m - j)==k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<=n;i+=7)
		for(int j=0;j<=n;j+=4)
			if(i+j==n)
			{
				printf("Yes");
				return 0;
			}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
function main()
  
  N = chomp(readline())
  
  check1 = ['2', '4', '5', '7', '9']
  check2 = ['0', '1', '6', '8']
  
  if in(N[end], check1)
    println("hon")
  elseif in(N[end], check2)
    println("pon")
  else
    println("bon")
  end
  
end

main()

Measured memory_bytes: 162756
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> retu(N);
    for (int i = 0; i < N; i++) {
        cin >> retu.at(i);
    }
    int ans = 1000000000;
    int count = 0;
    for (int i = 0; i < 100; i++) {
        count = 0;
        for (int j = 0; j < N; j++) {
            count = count + (retu.at(j)-i)*(retu.at(j)-i);
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  string s,t,u;cin >> s>>t;
  int a,b;cin >> a>>b;
  cin >> u;
  if (u==s){
    cout << a-1 << " "<< b<< endl;
  } else {
    cout << a << " "<< b-1<< endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
const double EPS=1E-8;
////////////////////////////////////////



int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    
    ll a,b,c;cin>>a>>b>>c;
    if(a%2&&b%2&&c%2){
        if(a>b)swap(a,b);
        if(b>c)swap(b,c);
        cout<<a*b;
    }else cout<<0;
    
    return 0;
}

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

int main(){
    long long i,j,l,r,N,Q;
    long long ac_count=0;

    string S;

    cin>>N>>Q;
    vector<long long> AC(N);
    cin>>S;

    for(i=1;i<N;i++){
        if(S[i-1]=='A' && S[i]=='C'){
            ac_count+=1;
        }
        AC[i]=ac_count;
    }

    for(i=0;i<Q;i++){
        cin>>l>>r;
        cout<<AC[r-1]-AC[l-1]<<endl;
    }
}

Measured memory_bytes: 1792
sub A{my($y,$x)=@_;
	$o[$y][$x]='<';
	$o[$y][$x+1]='>';
	--$A
}
sub B{my($y,$x)=@_;
	$o[$y][$x]='^';
	$o[$y+1][$x]='v';
	--$B
}
($H,$W,$A,$B)=glob<>;
@o=map[('.')x$W],1..$H;
if($H%2){
	for($x=0;$x+1<$W;$x+=2){
		if($A){
			A(-1,$x)
		}
	}
}
if($W%2){
	for($y=0;$y+1<$H;$y+=2){
		if($B){
			B($y,-1)
		}
	}
}
for($y=0;$y+1<$H;$y+=2){
	for($x=0;$x+1<$W;$x+=2){
		if($A>=2){
			A($y,$x);
			A($y+1,$x)
		}elsif($B>=2){
			B($y,$x);
			B($y,$x+1)
		}elsif($A){
			A($y,$x)
		}elsif($B){
			B($y,$x)
		}
	}
}
if($H>=3&&$H%2 && $W>=3&&$W%2 && $A==0 && $B==1){
	if($o[-2][-2]eq'.'){
		++$A;
		A(-1,-2);
		B(-2,-3);
	}
}
if($A==0 && $B==0){
	print"YES\n";
	print@$_,$/for@o
}else{
	print"NO\n"
}


Measured memory_bytes: 80512
N,*D=map(int,open(0).read().split())
S=sorted(D,reverse=True)
if S[1]==S[0]:
  [print(S[0]) for i in range(N)]
else:
  import numpy as np
  max_i=np.arange(N)[np.array(D)==S[0]]
  for i in range(N):
    if i==max_i:
      print(S[1])
    else:
      print(S[0])

Measured memory_bytes: 39676
#include<iostream>
using namespace std;
int dp[501];

int main()
{
    int n;
    cin >> n;
    int c[501];
    int s[501];
    int f[501];
    for(int i = 1; i <= n - 1; i++){
        cin >> c[i];
        cin >> s[i];
        cin >> f[i];
    }
    for(int i = 1; i <= n; i++){
        int time = 0;
        for(int j = i; j <= n - 1; j++){
            if((time % f[j]) != 0){
                time = f[j] * ((time / f[j]) + 1);
            }
            time = max(time, s[j]);
            time += c[j];
        }
        cout << time << endl;
    }
    return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

const ll MOD = 1000000007ll;

int N, M;
std::string S;
int ls[300100], rs[300100];
ll _hash[300100];

struct RollingHash
{
    vector<ll> hash, pow;
    RollingHash(string s, ll _b = 1000000007)
    {
        _b = _b;
        int sz = s.length();
        hash.assign(sz+1, 0);
        pow.assign(sz+1, 0);

        pow[0] = 1;
        for(int i=0;i<sz;i++){
            pow[i+1] = pow[i] * _b;
        }
        for(int i=0;i<sz;i++){
            hash[i+1] = (hash[i]+s[i]) * _b;
        }
    }
    // s[l]s[l+1]....s[r-1]のハッシュ値を取得する
    // 半開区間
    ll get(int l,int r){
        return (hash[r]-hash[l]*pow[r-l]);
    }
};

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

    std::cin >> N >> M;
    std::cin >> S;

    RollingHash r_hash(S);
    vector<ll> v;
    
    int cl = 0, cr = 0;
    for(int i=0;i<M;++i){
        string query;
        std::cin >> query;

        if(query == "L++"){
            ++cl;
        }else if(query == "L--"){
            --cl;
        }else if(query == "R++"){
            ++cr;
        }else{
            --cr;
        }

        v.emplace_back(r_hash.get(cl, cr + 1));
    }

    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::cout << v.size() << std::endl;
}

Measured memory_bytes: 11988
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //cin,coutの高速化
    int n,m,q;
    cin>>n>>m>>q;
    vector<int> l(m),r(m),p1(q),p2(q);
    vector< vector<int>> score(n,vector<int> (n,0));
    map<pair<int,int>,int> p;
    rep(i,m){
        cin>>l[i]>>r[i];
        l[i]--,r[i]--;
        p[{l[i],r[i]}]++;
    }
    for(auto c:p){
        int start = c.first.first;
        int goal = c.first.second;
        int point = c.second;
        for(int i=start;i>=0;i--){
            for(int j=goal;j<n;j++){
                score[i][j] += point;
            }
        }
    }
    rep(i,q){
        cin>>p1[i]>>p2[i];
        p1[i]--,p2[i]--;
        cout<<score[p1[i]][p2[i]]<<endl;
    }
}

Measured memory_bytes: 13008
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
const int mod = 1e9 + 7;

vector<int>g[2005];
int d[2005][2005];
int pa[2005][2005];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    f (m) {
        int x, y;
        cin >> x >> y;
        g[x].pb(y);
    }
    memset(d, -1 ,sizeof(d));
    f1 (n) {
        queue<int>q;
        q.push(i);
        d[i][i] = 0;
        while (!q.empty()) {
            int now = q.front();
            q.pop();
            for (auto j:g[now]) {
                if (~d[i][j])continue;
                d[i][j] = d[i][now] + 1;
                pa[i][j] = now;
                q.push(j);
            }
        }
    }
    int mi = 1e9, x, y;
    f1(n) {
        for(auto j : g[i]) {
            int cur = d[j][i] + 1;
            if (d[j][i] == -1)continue;
            //cout << i <<' '<<j<<' '<<cur << endl;
            if (cur < mi) {
                mi = cur;
                x = i, y = j;
            }
        }
    }
    if (mi == 1e9) {
        cout << -1 << '\n';
        exit(0);
    }
    vector<int>ans;
    ans.pb(x);
    while(y != x) {
        x = pa[y][x];
        ans.pb(x);
    }
    cout << ans.size() << '\n';
    for (auto i:ans) {
        cout << i << '\n';
    }
}


Measured memory_bytes: 25600
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int dp[5005][5005];
int pw(int n,int k){
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
//main
signed main(){
  int N;string s;
  cin>>N>>s;
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  for(int i=0;i<N;i++){
    for(int j=1;j<=N;j++){
      dp[i+1][j]=(dp[i][j+1]+dp[i][j-1]*2)%MOD;
    }
    dp[i+1][0]=dp[i][0]+(dp[i][1])%MOD;
  }
  cout<<(dp[N][s.size()]*pw(pw(2,s.size()),MOD-2))%MOD<<endl;
}


Measured memory_bytes: 195968
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    char s;
    cin >> s;
    if(isupper(s)) {
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7,INF=1e18;
#define lld unsigned long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
vector<pll> a;
ll n,m;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        
  int n;
  cin>>n;
  vector<int> a,b;
  map<int,int> mp1,mp2;
  vector<pii> a1,a2;
  int ans1=0,ans2=0;
  for(int i=0;i<n;i++)
  {
    int d;
    cin>>d;
    if(i%2)
    {
      mp1[d]++;
      a.push_back(d);
    }
    else
    {
      mp2[d]++;
      b.push_back(d);
    }
  }
  int s[2][2]={{0,0},{0,0}},sp[2][2]={{0,0},{0,0}};
  int j=0;
  for(auto i=mp1.begin();i!=mp1.end();i++)
  {
      a1.push_back({i->second,i->first});
  }
  for(auto i=mp2.begin();i!=mp2.end();i++)
  {
      a2.push_back({i->second,i->first});
  }
  sort(a1.begin(),a1.end());
  reverse(a1.begin(),a1.end());
  sort(a2.begin(),a2.end());
  reverse(a2.begin(),a2.end());
  for(auto i=0;i<a1.size();i++)
  {
    if(j==2)
      break;
    s[j][1]=a1[i].first;
    s[j][0]=a1[i].second;
    j++;
  }
  j=0;
  for(auto i=0;i<a2.size();i++)
  {
    if(j==2)
      break;
    sp[j][1]=a2[i].first;
    sp[j][0]=a2[i].second;
    j++;
  }
  ans1=s[0][1]+sp[0][1];
  if(s[0][0]==sp[0][0])
  {
    ans1=max(s[0][1]+sp[1][1],s[1][1]+sp[0][1]);
  }
  cout<<n-ans1<<"\n";
    }
    return 0;
}

Measured memory_bytes: 9308
def main():
    S = input()
    for l2 in range(len(S)-1, 0, -1):
        if l2 % 2 == 0:
            l = l2 // 2
            if S[:l] == S[l:2*l]:
                return l2
    return -1


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 2940
x1, y1, x2, y2 = map(int, input().split())
X, Y = (x2 - x1, y2 - y1)
x3 = x2 - Y
y3 = y2 + X
x4 = x3 - X
y4 = y3 - Y
print(x3, y3, x4, y4)

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int deg[100005];
vi g[100005];
map<pi, int> col;

void dfs(int cur, int prev, int prevCol){
	int curCol = 0;
	for(int u : g[cur]) if(u != prev){
		while(curCol == prevCol) curCol++;
		col[mp(cur, u)] = curCol;
		dfs(u, cur, curCol);
		curCol++;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	memset(deg, 0, sizeof(deg));
	vi a(n - 1), b(n - 1);
	int maxDeg = 0;
	rep(i, n - 1){
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		g[a[i]].pb(b[i]);
		g[b[i]].pb(a[i]);
		deg[a[i]]++;
		deg[b[i]]++;
		maxDeg = max({maxDeg, deg[a[i]], deg[b[i]]});
	}
	cout << maxDeg << endl;
	dfs(0, -1, -1);
	rep(i, n - 1) cout << col[mp(a[i], b[i])] + 1 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/



Measured memory_bytes: 14464
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

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

  double val;
  string cur;
  double ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> val >> cur;
    if (cur == "JPY") {
      ans += val;
    } else {
      ans += val * 380000.0;
    }
  }

  cout << fixed << setprecision(7) << ans << endl;

  return 0;
}


Measured memory_bytes: 256
function parseInt(x) parse(Int, x) end
function main()
	n = parseInt.(split(readline()))
	x = Array{Int}(2, n[1])
	for i in 1:n[1]
		x[:,i] = map(parseInt, split(readline()))
	end
	maxa = maximum(x[1,:])
	useb = Int[]
	for i in 1:n[1]
		if x[2,i] > maxa
			push!(useb, x[2,i])
		end
	end
	useb = sort(useb, rev=true)
	hp = n[2]
	count = 0
	for i in 1:length(useb)
		if hp > 0
			hp -= useb[i]
			count += 1
		end
	end
	if hp > 0
		if hp%maxa == 0
			count += div(hp, maxa)
		else
			count += div(hp, maxa)+1
		end
	end
	print(count)
end

main()

Measured memory_bytes: 162280
import sys
input = sys.stdin.readline
def main():
    N, M = map( int, input().split())
    H = list( map( int, input().split()))
    E = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map( lambda x: int(x)-1, input().split())
        E[a].append(b)
        E[b].append(a)
    ans = 0
    for i in range(N):
        h = H[i]
        ans += 1
        for e in E[i]:
            if h <= H[e]:
                ans -= 1
                break
    print(ans)
if __name__ == '__main__':
    main()


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int n, k;
int a[200010];

int isOK(int num){
	int ans = 0;

	for(int i = 0;i < n;i++){
		ans += (a[i]+num-1)/num - 1;
	}

	return ans <= k;
}

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

	for(int i = 0;i < n;i++){
		cin >> a[i];
	}

	int l = 0, r = LLONG_MAX; 

	while(r-l > 1){
		int mid = (r+l)/2;
		if(isOK(mid)) r = mid;
		else l = mid;
	}

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 5136
S = input()
T = input()
len_T = len(T)

ans = 0
for i in range(len(S) -len_T+ 1):
    cnt = 0
    tmp = S[i : i + len_T]
    for j in range(len_T):
        if tmp[j] == T[j]:
            cnt += 1
    ans = max(ans, cnt)

print(len_T-ans)

Measured memory_bytes: 9120
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e10
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)

	x, y := nextInt(), nextInt()

	for i := 0; i <= x; i++ {
		if i*4 + 2*(x-i) == y {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

func intSlicePrint(el ...int) {
	first := true
	for _, v := range el {
		if v < 0 {
			continue
		}
		if !first {
			fmt.Printf(" ")
		}
		fmt.Printf("%v", v)
		first = false
	}
	fmt.Println("")
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


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


int main() {
  string s;
  cin >> s;
  string a = "SUN";
  string b = "MON";
  string c = "TUE";
  string d = "WED";
  string e = "THU";
  string f = "FRI";
  string g = "SAT";
  
  if(s == a){
    cout << 7;
  }
  if(s == b){
    cout << 6;
  }
  if(s == c){
    cout << 5;
  }
  if(s == d){
    cout << 4;
  }
  if(s == e){
    cout << 3;
  }
  if(s == f){
    cout << 2;
  }
  if(s == g){
    cout << 1;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int A,B;
	char op[10];
	scanf("%d",&A);
	scanf("%s",op);
	scanf("%d",&B);
	if(op[0]=='+') printf("%d",A+B);
	if(op[0]=='-') printf("%d",A-B);
	return 0;
}


Measured memory_bytes: 128
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; ++i)
#define int long long
const int N = 2005, mod = 0;
int a[N], val[N];
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, x;
    cin >> n >> x;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int res = 1e18;
    memset(val, 63, sizeof val);
    for (int use = 0; use <= n; ++use) {
        int sum = 0;
        for (int i = 0; i < n; ++i)
            val[i] = min(val[i], a[(i - use + n) % n]), sum += val[i];
        res = min(res, sum + use * x);
    }
    cout << res << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
int main(){
  ll n,k; cin >> n >> k;
  ll sum = 0;
  rep(b,1,n+1){
    sum += (n/b) * max(0LL, b-k);
    sum += max(0LL, n%b+1-k);
  }
  if(k == 0){
    sum -= n;
  }
  cout << sum << endl;
  return 0;

}


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

int main(){
  int n,k;
  cin>>n>>k;
  int count = 0;
  int arr[n];
  for (int i=0;i<n;++i){
    cin>>arr[i];
  }
  sort(arr,arr+n);
  for (int i=0;i<k;++i){
    count+=arr[i];
  }
  cout<<count;
}

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

const int N = 100 * 1000 + 5;

int a[N];
long long ps[N];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) {
		ps[i] = ps[i - 1] + a[i];
	}
	for (int i = n - 1; i; i--) {
		if (ps[i] * 2 < a[i + 1]) {
			cout << n - i << endl;
			return 0;
		}
	}
	cout << n << endl;
	return 0;
}


Measured memory_bytes: 1408