akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-5;
const int inf=1e8;
int main(){
	int n,m;
	cin>>n>>m;
	vs in(n);
	rep(i,n)cin>>in[i];
	rep(i,2*n){rep(j,m)cout<<in[i/2][j];cout<<endl;}
}













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

int main() {

    string S, t;

    cin >> S;

    int N = S.size();

    int i, count = 0;

    for(i=0;i<N-1;++i){ 
      
        if(S.at(i+1) == S.at(i)){

            if(S.at(i+1) == '0'){
                S.at(i+1) = '1';
            }else{
                S.at(i+1) = '0';
            }
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll a,b,c,n;
    string s, t;
    ll ans;
    string answer = "No";

    cin  >> a;

    rep1(i, 9){
        rep1(j, 9){
            if(i*j == a) {
                answer = "Yes";
                break;
            }
        }
    }

    cout << answer << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

int main()
{
        string S;
        cin >> S;
        for (int i = 0; i < S.length(); ++i) {

                if (i % 2 == 0) {
                        cout << S[i];
                }

        }
        cout << endl;


}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
seed_seq seq{
        (uint64_t) chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count(),
        (uint64_t) __builtin_ia32_rdtsc(),
        (uint64_t) (uintptr_t) make_unique<char>().get()
};
mt19937 rng(seq);
int rnd(int l, int r) {return l + rng() % (r - l + 1);}
#define int long long
#define For(a, b, c) for(int a = b; a <= c; ++a)
#define Ford(a, b, c) for(int a = b; a >= c; --a)
#define Fv(a, b) for(auto &a : b)
#define ii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define vt vector<int>
#define vpi vector<pair<int, int>>
#define all(a) a.begin(), a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define vt vector<int>
#define vpi vector<pair<int, int>>
#define bit(x, i) (x >> (i - 1) & 1ll)
#define onbit(x, i) (x | (1ll << (i - 1)))
#define offbit(x, i) (x & ~(1ll << (i - 1)))
#define fixa(a) for(auto &i : a) cerr << i << ' '; cerr << '\n';
#define fixn(a, l, r) For(i, l, r) cerr << a[i]; cerr << '\n';
#define debug(x) cerr << #x << ' ' << x << '\n'
#define inp(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define fasty ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define fix(i) cerr << i << '\n';
#define task "npairs"
main(){
    int n;
    cin>>n;
    int ans=1e18;
    For(i,1,sqrt(n)){
        if(n%i==0){
            ans=min(ans, i-1+n/i-1);
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;

    int a = N * (N - 1) / 2 + M * (M - 1) / 2;
    cout << a << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



int main(){
  int x, n;
  cin >> x >> n;
  vi p(n);
  rep(i,n) cin >> p[i];
  sort(all(p));
  rep(i,100) {
    if(!binary_search(all(p),x-i)) {
      cout << x-i << endl;
      return 0;
    }
    if(!binary_search(all(p),x+i)) {
      cout << x+i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N = I()
A = LMI()

M = [tuple() for _ in range(N + 1)]
for i, a in enumerate(reversed(A)):
    i = N - i
    if i == N:
        M[i] = (a, a)
    else:
        n, m = M[i + 1]
        M[i] = (-(-n // 2) + a, m + a)

if M[0][0] != 1:
    print(-1)
    exit(0)

ans = 1
par = 1
for i in range(1, N + 1):
    least, most = par, par * 2
    minv, maxv = M[i]
    v = min(maxv, most)
    ans += v
    par = v - A[i]
print(ans)

Measured memory_bytes: 83444
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin{
	private: int _ch,_f;
	public: template<typename _Tp> inline fastin& operator>>(_Tp&_x){
		_x=0; while(!isdigit(_ch)) _f|=(_ch==45),_ch=getchar();
		while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
		_f&&(_x=-_x,_f=0); return *this;}
	fastin() {_ch=_f=0;}
}fin;
class fastout{
	private: int _num[32],_head;
	public: int SUF; template<typename _Tp> inline fastout& operator<<(_Tp _x){
		_Tp _k; if(_x==0) {putchar('0'),putchar(SUF);return *this;} if(_x<0) putchar('-'),_x=-_x;
		while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
		while(_head>0) putchar(_num[_head]),--_head; putchar(SUF); return *this;}
	fastout() {_head=0,SUF=' ';}
}fout;
// ----------------------------
// #define int ll
using namespace std;
const int maxn=200004;
const int mod=998244353,inf=1000000007;


long long a,b,c;
signed main()
{
	fin>>a>>b>>c;
	if(c<=a+b)
	{
		cout<<"No";
		return 0;
	}
	if(4ll*a*b<(c-a-b)*(c-a-b))
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}

// ----------------------------
// by imzzy

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int n; cin >> n;
	bool isFour = false;

	rep(i,n) {
		char s; cin >> s;
		if(s=='Y') isFour = true;
	}


	if(isFour) cout << "Four" << endl;
	else cout << "Three" << endl;



}


Measured memory_bytes: 256
//~#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//~#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//~#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

void solve(){
	int n,k;
	cin>>n>>k;
	vi a(n);
	cin>>a;
	double cr=0.0;
	for(int i=0;i<k;i++){
		cr+=(((a[i]+1))/2.0);
	}
	double ans=cr;
	for(int i=k;i<n;i++){
		cr-=(a[i-k]+1)/2.0;
		cr+=(a[i]+1)/2.0;
		ans=max(ans,cr);
	}
	cout<<setprecision(20)<<fixed<<ans;
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

int main(void) {
	char words[1200];
	char search[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	int applicable[26] = {0};
	//??????????????\???
	while (fgets(words, sizeof(words), stdin)) {
		if (words == NULL)break;
		int i;
		//????????°???????????????
		for (i = 0; i < strlen(words); i++) {
			//??¨????°????????????????
			if (words[i] <= 'Z') {
				words[i] = tolower(words[i]);
			}

			//??¢?????????????????????????????°?????????
			int j;
			for (j = 0; j < sizeof(search); j++) {
				if (words[i] == search[j]) {
					applicable[j]++;
					break;
				}
			}
			//??¢?????????????????????????????°???????????????
		}
	}
	int i;
	//??¨????????¢???????????????????????°???????????????
	for (i = 0; i < sizeof(search); i++) {
		printf("%c : %d\n",search[i],applicable[i]);
	}

	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, M; cin >> N >> M;
	if (N == 1 && M == 0) {
		cout << 0 << "\n";
		return 0;
	}
	map<int, int>mp;
	rep(i, M) {
		int a, b; cin >> a >> b;
		if (mp.count(a)) {
			if (mp[a] != b) {
				cout << -1 << "\n";
				return 0;
			}
		}
		else mp[a] = b;
	}
	vector<int>s(N, 0);
	s[0] = 1;
	for (auto p : mp) {
		s[p.first - 1] = p.second;
	}
	if (s[0] == 0 && N != 1) {
		cout << -1 << "\n";
		return 0;
	}
	rep(i, N) {
		cout << s[i];
		if (i == N - 1)cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int n,s,q,t,e,f,h=0;
  int c=0;
  scanf("%d",&n);
  int A[10001]={0};
  int B[10001]={0};
  for(s=0;s<n;s++){
    scanf("%d",&A[s]);
  }
  scanf("%d",&q);
  for(t=0;t<q;t++){
    scanf("%d",&B[t]);
  }
  for(f=0;f<q;f++){
    h=0;
    for(e=0;e<n;e++){
      if(A[e]==B[f]){
	if(h!=0)break;
	c=c+1;
	h=h+1;
      }
    }
  }
  printf("%d\n",c);
  return 0;
}

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

bool isOK(string &s){
	int n = s.size()/2;
	for(int i = 0;i < n;i++){
		if(s[i] != s[i+n]) return false;
	}
	return true;
}

signed main(){
	string s;
	cin >> s;
	while(1){
		s.pop_back();
		s.pop_back();
		if(isOK(s)){
			cout << s.size() << endl;
			break;
		}
	}

	return 0;
}


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

#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)

int main()
{
    string s;
    int X = 0;

    cin>>s;
    for(auto &x:s)
        X += x-'0';

    if( X%9 == 0 )
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
	string s;
	std::cin >> s;
	int le=s.size();
	if(le==2){if(s[0]==s[1])std::cout << 1<<' '<<2 << std::endl;else std::cout << -1<<' '<<-1 << std::endl;}
	else{
		rep(i,le-2){
			if(s[i]==s[i+1] ||s[i+1]==s[i+2]||s[i+2]==s[i]){
			std::cout << i+1<<' '<<i+3 << std::endl;
			exit(0);
			}
		}
		std::cout << -1<<' '<<-1 << std::endl;
	}
}

Measured memory_bytes: 512
sx, sy, tx, ty = map(int, input().split())

X = tx-sx
Y = ty-sy

print('R'*X+'U'*Y+'L'*X+'D'*Y+'D'+'R'*(X+1) +
      'U'*(Y+1)+'L'+'U'+'L'*(X+1)+'D'*(Y+1)+'R')


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n == 1) {
            System.out.println("Hello World");
        } else {
            int b = sc.nextInt();
            int a = sc.nextInt();
            System.out.println(a + b);
        }
        sc.close();
    }

}


Measured memory_bytes: 21588
fun main(args: Array<String>) = yorukatsu6E()

fun yorukatsu6E() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val xyList = (1..n).map { readLine()!!.split(' ').map { it.toLong() } }
        .map { Xy(it[0], it[1]) }

    val xList = xyList.map { it.x }.sorted()
    val yList = xyList.map { it.y }.sorted()

    var answer = Long.MAX_VALUE

    for ((index1, left) in xList.withIndex()) {
        for (right in xList.drop(index1 + 1)) {
            for ((index2, down) in yList.withIndex()) {
                for (up in yList.drop(index2 + 1)) {
                    val inRectangle = xyList.filter { it.y in down..up && it.x in left..right }
                    if (inRectangle.count() >= k) {
                        var minX = Long.MAX_VALUE
                        var maxX = Long.MIN_VALUE
                        var minY = Long.MAX_VALUE
                        var maxY = Long.MIN_VALUE
                        inRectangle.forEach {
                            minX = Math.min(minX, it.x)
                            maxX = Math.max(maxX, it.x)
                            minY = Math.min(minY, it.y)
                            maxY = Math.max(maxY, it.y)
                        }
                        val area = Math.abs(maxX - minX) * Math.abs(maxY - minY)
                        answer = Math.min(answer, area)
                    }
                }
            }
        }
    }

    println(answer)
}

private data class Xy(val x: Long, val y: Long)


Measured memory_bytes: 109232
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	long W, H, x, y;
  	cin >> W >> H >> x >> y;

  	cout << W*H/2.0 << " ";
  	if(2*x==W && 2*y==H){
  		cout << 1 <<endl;
  	}else{
  		cout << 0 <<endl;
  	}
    
  	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/12  Problem: ABC 081 A / Link: http://abc081.contest.atcoder.jp/tasks/abc081_a  ----- */


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

	string s; cin >> s;

	LL ans = 0LL;
	for (auto c : s)ans += c == '1';
	
	cout << (ans) << "\n";

	return 0;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    vi s(n); rep(i,n) cin >> s[i];
    int q; cin >> q;
    vi t(q); rep(i,q) cin >> t[i];

    ll ans = 0;
    rep(i,q){
        if(*lower_bound(all(s), t[i]) == t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3340
#include<stdio.h>
int main()
{
   int N,A[60],B[60],C[60],i,sum=0;
   scanf("%d",&N);
   for(i=0;i<N;i++)
   {
     scanf("%d",&A[i]);
   }
   for(i=0;i<N;i++)
   {
     scanf("%d",&B[i]);

   }
   for(i=0;i<N-1;i++)
   {
     scanf("%d",&C[i]);
     C[N-1]=0;
   }
   for(i=0;i<N;i++)
   {
     if((A[i]-A[i-1])==1 && A[i]!=1)
     {
          sum=sum+B[A[i]-1]+C[A[i]-2];
     }
     else
     {
          sum=sum+B[A[i]-1];
     }
   }
   printf("%d",sum);
   return 0;
}




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

using namespace std;

#pragma GCC optimize ("03")

#pragma GCC optimize ("unroll-loops")

#define ll long long

#define ms(a,b) memset(a,b,sizeof(a))

#define endl '\n'

#define pb push_back

#define mp(a,b) make_pair(a,b)

#define mpp(a,b,c) make_pair(a,make_pair(b,c))

#define fi first

#define se second

#define rep(a,b,c) for(int a=b;a<=c;a++)

#define repp(a,b,c) for(int a=b;a>=c;a--)

ll memo[100100],arr[100100];

ll n,k;

ll dp(ll idx){

	if(idx>n)return 1e9;

	else if(idx== n)return 0;

	else if(memo[idx]!=-1)return memo[idx];

	else{

		ll temp;

		temp =1e18;

		rep(i,1,k){

			if(i==1){

				temp = dp(idx+i) + abs(arr[idx]-arr[idx+1]);

			}else{

				temp = min(temp,(dp(idx+i)+abs(arr[idx]-arr[idx+i])));

			}

		}

//		cout << "-->" << temp << endl;

		return memo[idx] = temp;

	}	

}

int main(){

/////////////////////////////////////////////

	ios_base::sync_with_stdio(0);

	cin.tie(0); cout.tie(0);

/////////////////////////////////////////////

	ms(memo,-1);

	cin >> n >> k;

	rep(i,1,n)cin >> arr[i];

	ll res;

	res = dp(1);

	cout << res << endl;

	return 0;

}

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

using namespace std;

int main()
{
	bool prime[100001];
	int n, m;
	int c[100010] = {0};	
	prime[0] = prime[1] = 0;
	int ans[100001] = {0};

	for (int i = 2; i <= 100000; i++){
		prime[i] = true;
	}

	for (int i = 2; i <= 100000; i++){
		if (prime[i]) {
			for (int j = i * 2; j <= 100000; j += i){
				prime[j] = false;
			}
		}
	}

	for (int i = 2; i <= 100000; i++){
		if (prime[i] && prime[(i + 1) / 2]) c[i] = 1;
	}

	for (int i = 2; i <= 100000; i++){
		c[i] += c[i - 1];
	}

	int q;
	
	cin >> q;

	for (int i = 0; i < q; i++){
		int r, l;
		cin >> l >> r;

		ans[i] = c[r] - c[l - 1];
	}
	
	for (int i = 0; i < q; i++){
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 1536
function getLines(input){
	return input.split("\n").map((s)=>s.trim())
}
function parseLine(line){
	return line.split(" ").map((s)=>s.trim());
}
function parseLineToInt(line){
	return line.split(" ").map((s)=>parseInt(s.trim()));
}

// parameter "input" gets all data
function Main(input) {
	// the first line is assigned to input[0], the second line is assigned to input[1] similarly.	
	input = getLines(input).map(parseLineToInt);
	var X = input[0][0];
	var Y = input[0][1];
	var A = input[0][2]-1;
	var B = input[0][3]-1;
	var C = input[0][4]-1;
	var p = input[1];
	var q = input[2];	
	var r = input[3];
	p.sort(_sort);
	q.sort(_sort);
	r.sort(_sort);
	var ans = 0;
	for (var i = 0; i < X; i++) {
		ans += p[A-i];
	}
	var pa = A-X+1;
	for (var j = 0; j < Y; j++) {
		ans += q[B-j];
	}

	var pb = B-Y+1;

	for(var i=C;i>=0;i--){
		if(pa>A && pb>B)
			break;

		if(pa>A){
			if(r[i]>q[pb]){
				ans =ans +r[i]-q[pb];
				pb++;
				continue;
			}else{
				break;
			}
		}
		if(pb>B){
			if(r[i]>p[pa]){
				ans =ans +r[i]-p[pa];
				pa++;
				continue;
			}else{
				break;
			}
		}

		if(r[i]>Math.min(p[pa],q[pb])){
			if(q[pb]>p[pa]){
				ans =ans +r[i]-p[pa];
				pa++;
			}else{
				ans =ans +r[i]-q[pb];
				pb++;
			}
		}else{
			break;
		}
	}
	console.log(ans);
}
function _sort(a,b){
		 if (a > b) {
	        return 1;
	    }
	    if (b > a) {
	        return -1;
	    }
	    return 0;
	}
// Don't edit this line!
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 58112
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    if(a == b) {
        cout << c;
    }
    else if(b == c) {
        cout << a;
    }
    else if(c == a) {
        cout << b;
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n, k = 1;
	scanf("%lld", &n);
	for (int i = 1800; i >= 400; i -= 200){
		if (n >= i){
			printf("%lld\n", k);
			return 0;
		}
		k++;
	}
}

Measured memory_bytes: 3820
gets

a, b = 0, 0
ARGF.each do |line|
  ary = line.chomp.split
  if ary[0] == ary[1]
    a += 1
    b += 1
  elsif ary[0] < ary[1]
    b += 3
  else
    a += 3
  end
end

puts "#{a} #{b}"

Measured memory_bytes: 6100
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 100010;

string s;
int32_t main() {
	FAST	
	cin >> s;
	if (s == "ABC") cout << "ARC";
	else cout << "ABC";
	
}



Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int data1[101][101] = {};
int data2[101][101] = {};
int data3[101][101] = {};

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      cin >> data1[i][j];

  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      data3[i][j] = data2[i][j] =
          data1[i][j] + data2[i - 1][j] + data2[i][j - 1] - data2[i - 1][j - 1];

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      for (int k = 0; k <= i; ++k) {
        for (int l = 0; l <= j; ++l) {
          int v;
          if (k == i && l == j)
            break;
          else if (k == i || l == j)
            v = data2[i][j] - data2[k][l];
          else
            v = data2[i][j] - data2[k][j] - data2[i][l] + data2[k][l];
          if (data3[i][j] < v)
            data3[i][j] = v;
        }
      }
    }
  }

  int maxv = data1[1][1];
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (maxv < data3[i][j])
        maxv = data3[i][j];

  cout << maxv << endl;
}


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


long long int MinSum(string s)
{   
    int slen = s.size();
    int * arr = new int[slen+1];
    int count = 0;
    for(int i = 0;i<slen+1;i++)
    {
        arr[i] = 0;
    }
    if(s[0]=='<')
    arr[0] = 0;
    else
    {   
        int i  = 0;
        
        while(true)
        {   
            if(s[i]=='>')
            count++;
            else
            {
                break;
            }
            i++;
        }
        arr[0] = count;
    }
    
    for(int i = 0 ; i< slen;i++)
    {
        if(s[i]=='<')
        {
            count = 0;
            if((i<slen-1&&s[i+1]=='<')||(i==slen-1))
            {
                arr[i+1] = arr[i]+1;
            }
            else if(i<slen-1&&s[i+1]=='>')
            {   
                int j = i+1;
                
                while(j<slen)
                {
                    if(s[j]=='>')
                    count++;
                    else
                    {
                        break;
                    }
                    j++;
                }
                if(count>arr[i])
                arr[i+1] = count;
                else
                {
                    arr[i+1] = arr[i]+1;
                }
                
            }
            
        }
        else
        {   if(count<arr[i])
            {
                arr[i+1]=count-1;
                count --;
            }
            else
            {
                arr[i+1]=arr[i]-1;
            }
            
        }
    }
    long long int sum = 0;
    for(int i = 0;i<slen+1;i++)
    {   
        
        sum = sum+ arr[i];
    }
    

    delete [] arr;
    return sum;

}

int main()
{
    string s;
    cin>>s;
    cout<<MinSum(s);
}

Measured memory_bytes: 3332
#include <stdio.h>

int main()
{
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);
	
	int tmp = a;
	a = b;
	b = tmp;
	tmp = a;
	a = c;
	c = tmp;

	printf("%d %d %d\n", a, b, c);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 111;
int mat[N][N];
int n, k;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    int cur = (n - 1) * (n - 2) / 2;
    if(cur < k) {
        cout << -1 << endl;
        return 0;
    }
    rep(i, 2, n) {
        mat[1][i] = 1;
        mat[i][1] = 1;
    }
    rep(i, 1, n) {
        rep(j, i + 1, n) {
            if(!mat[i][j] && cur > k) {
                cur--;
                mat[i][j] = 1;
                mat[j][i] = 1;
            }
        }
    }
    vector<pair<int, int> > ans;
    rep(i, 1, n) {
        rep(j, i + 1, n) {
            if(mat[i][j]) {
                ans.pb({i, j});
            }
        }
    }
    cout << sz(ans) << endl;
    rall(p, ans) {
        cout << p.fi << " " << p.se << endl;
    }
    return 0;
}


Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn rot(vect: (i64, i64)) -> (i64, i64) {
    return (-vect.1, vect.0);
}

fn main() {
    let mut ps = vec![(0, 0); 4];
    for i in 0..2 {
        ps[i].0 = read::<i64>();
        ps[i].1 = read::<i64>();
    }
    let mut vect = (ps[1].0 - ps[0].0, ps[1].1 - ps[0].1);
    for i in 2..4 {
        vect = rot(vect);
        ps[i].0 = ps[i - 1].0 + vect.0;
        ps[i].1 = ps[i - 1].1 + vect.1;
        if i != 2 {
            print!(" ");
        }
        print!("{} {}", ps[i].0, ps[i].1);
    }
    println!("");
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int N; cin >> N;
    vector<int> a( N );
    int ma = 0;
    int id;
    REP( i, N ) {
        cin >> a[i];
        if( i != 0 ){
            if( chmax( ma, a[i] ) ) id = i;
        }
    }
    cout << ma << endl;

    int cnt = count( ALL( a ), ma );

    if( a[0] > ma ){
        REP( i, N - 1 ){
            cout << a[0] << endl;
        }
    }else if( cnt >= 2 ){
        REP( i, N - 1 ){
            cout << ma << endl;
        }
    }else{
        int ma2 = 0;
        REP( i, N ){
            if( i == id ) continue;
            chmax( ma2, a[i] );
        }

        REP( i, N ){
            if( i == 0 ) continue;
            if( i == id ) cout << ma2 << endl;
            else cout << ma << endl;
        }
    }

}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e6;
ll x;
ll a[N];
void bangngt()
{
    for(long i=2;i<=N;i++)
        a[i]=i;
    for(long i=2;i<=N;i++)
    {
        if(a[i]==i)
        {
            for(long j=2;i*j<=N;j++)
            {
                a[i*j]=i;
            }
        }
    }
}
int main()
{
    bangngt();
    cin>>x;
    for(long i=x;i<=N;i++)
    {
        if(a[i]==i)
        {
            cout<<i;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 8064
N, K = map(int, input().split())
x = list(map(int, input().split()))
d = 2 * (x[-1] - x[0])
for i in range(N-K+1):
    d = min(d, abs(x[i]) + abs(x[i + K - 1] - x[i]),abs(x[i + K -1]) + abs(x[i + K - 1] - x[i]))
print(d)

Measured memory_bytes: 14224
A,B,C,X,Y=map(int,input().split())
ans=5000*(10**5)*2+1

for i in range(max(X,Y)+1):
  total=0
  total=2*C*i+A*max(X-i,0)+B*max(Y-i,0)
  if ans>=total:
    ans=total
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
const int N=1e5+7;
typedef long long i64;
std::vector<int>e[N];
int n,flag=1,rt=1;
i64 a[N];
void f1(int w,int pa){
	if(w!=rt&&e[w].size()==1)return;
	i64 sum=0,mx=0;
	for(int i=0;i<e[w].size();++i){
		int u=e[w][i];
		if(u!=pa){
			f1(u,w);
			sum+=a[u];
			if(a[u]>mx)mx=a[u];
		}
	}
	if(sum<a[w]||sum>a[w]*2||(mx*2>sum?sum-mx:sum/2)<sum-a[w])flag=0;
	a[w]=a[w]*2-sum;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%lld",a+i);
	for(int i=1,a,b;i<n;++i){
		scanf("%d%d",&a,&b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	while(e[rt].size()!=1)++rt;
	i64 v0=a[rt];
	f1(rt,0);
	if(a[rt]!=v0)flag=0;
	puts(flag?"YES":"NO");
	return 0;
}

Measured memory_bytes: 14336
#include<stdio.h>
#define min(p,q)((p)<(q)?(p):(q))
#define max(p,q)((p)>(q)?(p):(q))

int n,p,dp[110][110],x[110],y[110];
int main(){
	scanf("%d%d",&n,&p);
	for(int i=0;i<n;i++)scanf("%d%d",x+i,y+i);
	for(int k=n-1;k>=0;k--)for(int m=0;m<=n-k;m++){
		int ans=1e9,s=0,pre=0;
		for(int i=k;i<=min(n,k+m);i++){
			if(m+k<n||i==n)ans=min(ans,dp[i+1][m-(i-k)]+s);
			s+=pre=max(0,y[i]-max(0,x[i]-pre));
		}
		dp[k][m]=ans;
	}
	while(dp[0][n]>p)n--;
	printf("%d\n",n);
}


Measured memory_bytes: 2148
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
const int maxn = 3005;
const int mo = 1e9 + 7;
using namespace std;
int f[2][maxn], s[maxn], Max[maxn];
int n, m;
int main(){
	scanf("%d%d", &n, &m); getchar();
	for (int i = 1; i <= n; i++) s[i] = s[i - 1] + getchar() - '0';
	for (int l, r, i = 1; i <= m; i++){
		scanf("%d%d", &l, &r);
		Max[l] = max(Max[l], r);
	}
	for (int i = 1; i <= n; i++) Max[i] = max(i, max(Max[i], Max[i - 1]));
	f[0][0] = 1; int T = 1;
	for (int i = 1; i <= n; T ^= 1, i++){
		memset(f[T], 0, sizeof f[T]);
		for (int j = 0; j <= n; j++){
			if (j - 1 + s[Max[i]] - s[Max[i - 1]] >= 0) (f[T][j - 1 + s[Max[i]] - s[Max[i - 1]]] += f[T ^ 1][j]) %= mo;
			if (j + s[Max[i]] - s[Max[i - 1]] < Max[i] - (i - 1)) (f[T][j + s[Max[i]] - s[Max[i - 1]]] += f[T ^ 1][j]) %= mo;
		}
	}
	printf("%d\n", f[T ^ 1][0]);
	return 0;
}

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

using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP(x)	make_pair(x)
 
#define debug(_x)		cerr << #_x << '=' << _x << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << _x << ' ' << #_y << '=' << _y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << _x << ' '; cerr << endl;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN/2;

int32_t main() {
	FAST_IO;
	
	int r;
	cin >> r;
	
	cout << setprecision(9) << 4.0*acos(0)*r << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 3800
import java.util.Scanner;

public class Main {

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

        int ans = 0;
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                for (int k = 0; k < 10; k++) {
                    int flag = 1;
                    for (int pos = 0; pos < n; pos++) {
                        // System.out.println("" + i + j + k);
                        // System.out.println("flag:" + flag);
                        // System.out.println("s.charAt(pos):" + String.valueOf(s.charAt(pos)));
                        if (flag == 1 && String.valueOf(s.charAt(pos)).equals(String.valueOf(i))) {
                            flag++;
                        } else if (flag == 2 && String.valueOf(s.charAt(pos)).equals(String.valueOf(j))) {
                            flag++;
                        } else if (flag == 3 && String.valueOf(s.charAt(pos)).equals(String.valueOf(k))) {
                            flag++;
                        }
                        if (flag == 4) {
                            // System.out.println("" + i + j + k);
                            ans++;
                            break;
                        }
                    }
                }
            }
        }
        System.out.println(ans);

        sc.close();
    }

}


Measured memory_bytes: 339400
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

template <typename T>
vector<T> divisor(T &n) {
    vector<T> res;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) {
                res.push_back(n / i);
            }
        }
    }
    return res;
}

signed main() {
    cin >> N;
    ans = LLINF;
    auto div = divisor(N);
    REP(i, div.size()) {
        ll a = div[i];
        ll b = N / div[i];
        ans = min(ans, a + b);
    }
    cout << ans - 2 << endl;
}


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

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

int main(void) {
    int n, cnt = 1;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    while (true) {
        if (pow(cnt, 2) > n) {
            cout << (int)pow(cnt - 1, 2) << "\n";
            break;
        }

        cnt++;
    }

    return 0;
}

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

if p == 2 or p == 5:
  ans = 0
  for i,s in enumerate(S):
    if int(s)%p == 0:
      ans += i+1
  print(ans)
  exit()

def MS(i,s,pre):
  return (int(s)*i+pre)%p
 
M = [0]*p
M[0] = 1
i = 1
pre = 0
for s in S[::-1]:
  pre = MS(i,int(s),pre)
  M[pre] += 1
  i = i*10%p

ans = sum(map(lambda m:(m*(m-1))//2, M))
print(ans)


Measured memory_bytes: 3500
#include <iostream>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int count = 0;
  if ( s.at(0) == '1' ){
  ++ count ;
  }
  if ( s.at(1) == '1' ){
  ++ count ;
  }
  if ( s.at(2) == '1' ){
  ++ count ;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import numpy as np

def main():
    n = int(input())
    l = list(map(int,input().split()))
    if 0 in l:
        print(0)
        exit()
    pro=1
    for num in l:
        pro = pro*num
        if pro > 10**18:
            print(-1)
            exit()
    else:
        print(pro)

if __name__ == '__main__':
    main()

Measured memory_bytes: 40068
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

struct S {
    int a,b,c,d;
    S(int a, int b, int c, int d): a(a), b(b), c(c), d(d) {}
};

void solve() {
    int h,w;
    cin >> h >> w;
    VVI a(h,VI(w));
    vector<S> c;
    REP(i,0,h) REP(j,0,w) cin >> a[i][j];
    REP(i,0,h) {
        REP(j,0,w-1) if (a[i][j] % 2 == 1) {
            a[i][j]--;
            a[i][j+1]++;
            c.emplace_back(i+1,j+1,i+1,j+1+1);
        }
        if (a[i][w-1] % 2 == 1 && i != h-1) {
            a[i][w-1]--;
            a[i+1][w-1]++;
            c.emplace_back(i+1,w-1+1,i+1+1,w-1+1);
        }
    }
    //int cnt = 0;
    //REP(i,0,h) REP(j,0,w) if (a[i][j] % 2 == 0) ++cnt;
    //cout << cnt << endl;
    cout << c.size() << endl;
    REP(j,0,c.size()) {
        cout << c[j].a << " " << c[j].b << " "<< c[j].c << " "<< c[j].d;
        cout << endl;
    }
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 5232
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>

#include <stdio.h>
#include <stdlib.h>
#include <climits>

using namespace std;

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

  int N;
  cin >> N;
  int F[N] = {};
  int P[N][11];
  int tmp = 0;


  for(int i = 0; i < N; i++){
    for(int j = 0; j < 10; j++){
      cin >> tmp;
      if( tmp == 1 ) F[i] += (1<<(9-j));
    }
  }
  //printf("F : %d\n", F[0]);
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 11; j++){
      cin >> P[i][j];
    }
  }

  int maximum_profit = INT_MIN;
  for(int i = 1; i < 1024; i++){
    int pro = 0;
    //printf("i : %d\n", i);

    for(int n = 0; n < N; n++){
      int field = F[n] & i;
      int count = 0;
      for(int j = 0; j < 10; j++){
        count += ((field>>j)&1);
      }
      //printf("count : %d\n", count);
      pro += P[n][count];

    }
    //printf("pro%d : %d\n", i, pro);
    if(maximum_profit < pro){
      maximum_profit = pro;
    }
  }
  printf("%d\n", maximum_profit);

  return 0;
}


Measured memory_bytes: 256
// E - Payment

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int dp[1000001][2]; // dp[i][j]: 左からi桁目（j:繰り上がりフラグ）までで使用する枚数の最小値

int main() {
	string N;
	cin >> N;
	int L = N.size();
	N = " " + N;

	dp[0][1] = 1;

	for (int i=1; i<=L; i++) {
		int n = N[i] - '0';
		dp[i][0] = min(dp[i-1][0] + n, dp[i-1][1] + 10 - n);
		if (n == 9) {
			dp[i][1] = dp[i-1][1];
		} else {
			dp[i][1] = min(dp[i-1][0] + n + 1, dp[i-1][1] + 10 - (n+1));
		}
	}

	int ans = dp[L][0];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<ll,ll>;
constexpr int MOD = 1e9+7;
int n, c;
ll a, b, d, z, ans = 1;
map<P, P> m;
ll exp(ll n){
	ll res = 1;
	for(ll b=2; n; n/=2,(b*=b)%=MOD) if(n%2) (res *= b) %= MOD;
	return res;
}
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%lld%lld", &a, &b);
		if(a == 0){
			if(b == 0) z++;
			else m[P{0,0}].first++;
		}else if(b == 0) m[P{0,0}].second++;
		else{
			c = 0;
			if(a < 0){
				c ^= 1;
				a = -a;
			}
			if(b < 0){
				c ^= 1;
				b = -b;
			}
			d = gcd(a,b); a /= d; b /= d;
			if(c) m[P{b,a}].first++;
			else m[P{a,b}].second++;
		}
	}
	for(pair<P,P> p: m){
		tie(a, b) = p.second;
		(ans *= (exp(a) + exp(b) - 1 + MOD) % MOD) %= MOD;
	}
	(ans += z - 1 + MOD) %= MOD;
	printf("%lld\n", ans);
}

Measured memory_bytes: 19264
r, c = map(int, raw_input().split())
ss = []
for i in range(r):
    ss.append(map(int, raw_input().split()))
    ss[i].append(sum(ss[i]))
    print ' '.join(map(str, ss[i]))
ss.append([])
for j in range(c+1):
    csum = 0
    for i in range(r):
        csum += ss[i][j]
    ss[r].append(csum)
print ' '.join(map(str, ss[r]))

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

string s,t;

void solve(){
    for(int i=0;i<s.size();i++){
        if(s[i]==t[i]){
            continue;
        }
        else{
            cout<<"No"<<endl;
            return;
        }
    }
    cout<<"Yes"<<endl;
}

int main(void){
    
    cin>>s>>t;
    solve();
    return 0;
}

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

string solve() {
    string S;
    cin >> S;
    ll Q;
    cin >> Q;
    int t, f, b = 0;
    char c;
    string r;
    for ( int i = 0; i < Q; i++ ) {
        cin >> t;
        if ( t == 1 ) {
            b = 1-b;
        } else {
            cin >> f >> c;
            if ( f-1 == b ) {
                r.push_back(c);
            } else {
                S.push_back(c);
            }
        }
    }
    string ans;
    if ( b == 0 ) {
        reverse(r.begin(), r.end());
        ans.append(r);
        ans.append(S);
    } else {
        reverse(S.begin(), S.end());
        ans.append(S);
        ans.append(r);
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1028