akhauriyash/Code-Regression huggingface dataset:
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int strsortfncsj(const void *a,const void *b){return strcmp((char *)a,(char *)b);}
int strsortfnckj(const void *a,const void *b){return strcmp((char *)b,(char *)a);}

int main(void){
    int i,j,n,m,k,a[262144],b,c,w,r=0,l,t;
    double d;
    char s[262144];
    scanf("%d%d%d",&n,&k,&r);
    //l=strlen(s);
    //for(i=0;i<n;i++){scanf("%d",&a[i]);}
    //qsort(a,n,sizeof(int),sortfncsj);
    if(n<=r && r<=n+k){printf("YES\n");}
    else{printf("NO\n");}
    return 0;
}

Measured memory_bytes: 256
//Between a and b...
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf=1e18;
const int N=2e5+10;
ll factorial(ll x){
    if(x==0||x==1) return 1;
    return x*factorial(x-1);
}
ll gcd(ll a ,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

int main(){
    ll a,b;
    ll x;
    cin >> a >> b >> x;

    ll ans=1;

    if(a==0){
        ans = b/x +1;
        cout<<ans<<endl;
        return 0;
    }
    ans = b/x - (a-1)/x;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DBP
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fst first
#define snd second
#define fore(x,a,b) for(int x=(a), qwerty=(b); x<qwerty; x++)
#define pb push_back
#define mset(a,v) memset((a),(v),sizeof(a))
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const int N=3000;
bool vis[N][N];
double dp[N][N],ps[N];
int n;

int main(){FIN;cout<<fixed<<setprecision(12);
	cin >> n;
	fore(x,0,n)cin>>ps[x];
	fore(x,0,n+1)dp[x][n-x]=x>n-x?1:0;
	for(int x=n-1; x>=0; x--)fore(i,0,x+1){
		int j=x-i;
		dp[i][j]=dp[i+1][j]*ps[x]+dp[i][j+1]*(1-ps[x]);		
	}
	cout << dp[0][0] << "\n";
}

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

string S;
long long int K;
int main (){
    cin >> S >> K;
    K--;
    for(int i=0; i<S.length(); i++){
        if( S[i] != '1' ) {
            cout << S[i] << endl;
            return 0;
        }
        if( K <= i ) {
            cout << 1 << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
string to_string(char c) {
	return string(1, c);
}
string to_string(bool b) {
	return b ? "true" : "false";
}
string to_string(const char* s) {
	return string(s);
}
string to_string(string s) {
	return s;
}
string to_string(vector<bool> v) {
	string res;
	for(int i = 0; i < (int) v.size(); i++)
		res += char('0' + v[i]);
	return res;
}
 
template<size_t S> string to_string(bitset<S> b) {
	string res;
	for(int i = 0; i < S; i++)
		res += char('0' + b[i]);
	return res;
}

template<class T> string to_string(T v) {
    bool f = 1;
    string res;
    for(auto& x : v) {
		if(!f)
			res += ' ';
		f = 0;
		res += to_string(x);
	}
    return res;
}
 
void DBG() {
	cerr << "]" << endl;
}

template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h);
	if(sizeof...(t))
		cerr << ", ";
	DBG(t...);
}

#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

const int d4i[4] = {-1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1};
const int d8i[8] = {-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};

long long mod = 1e9 + 7;

long long power(long long a, long long b){
	long long res = 1;
	while(b > 0){
		if(b & 1) (res *= a) %= mod;
		b >>= 1;
		(a *= a) %= mod;
	}
	return res;
}

void solve() {
	int n;
	long long ans = 0;
	cin >> n;
	for(int c = 1; c < n; c++){
		int x = n - c;
		int z = sqrt(x);
		for(int ab = 1; ab <= z; ab++){
			if(x % ab == 0){
				if(ab * ab == x) ans++;
				else ans += 2;
			}
		}	
	}
	cout << ans;
}	
 
int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
 	
	int t = 1;
	//cin >> t;
	for(int i = 1; i <= t; i++) {
		//cout << "Case #" << i << ": ";
		solve();
	}
}

Measured memory_bytes: 3672
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long LL;
typedef double db;
inline LL read() {
    LL x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-')f = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int a, b, c;
int ans[1005], cnt;
int main() {
    a = read(); b = read(); c = read();
    int upp = min(a, b);
    for (int i = 1; i <= upp; ++i) {
        if (a % i == 0 && b % i == 0) ans[++cnt] = i;
    }
    printf("%d\n", ans[cnt - c + 1]);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	vector<int> h(10); cin >> h;
	sort(ALL(h), greater<int>());
	REP(i, 3) cout << h[i] << endl;
}

Measured memory_bytes: 3116
def rank(m, e, j):
  if 100 in (m, e, j) or (m + e) / 2 >= 90 or (m + e + j) / 3 >= 80:
    return "A"
  elif (m + e + j) / 3 >= 70 or ((m + e + j) / 3 >= 50 and (m >= 80 or e >= 80)):
    return "B"
  return "C"

while True:
  n = int(input())
  if n == 0:
    break
  for _ in range(n):
    m, e, j = map(int, input().split())
    print(rank(m, e, j))


Measured memory_bytes: 5616
#include<stdio.h>
int main(void)
{
    int n,v[21],c[21],i,vs=0,cs=0,ans;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&v[i]);
    for(i=1;i<=n;i++)
        scanf("%d",&c[i]);
    for(i=1;i<=n;i++)
        if(v[i]>c[i]){
            vs+=v[i];
            cs+=c[i];
        }
    ans=vs-cs;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
    ll x, y;
    while(1){
        cin >> x >> y;
        if(x == 0 && y == 0) return 0;
        else if(x < y){
            cout << x << " " << y << endl;
        }
        else cout << y << " " << x << endl;
    }
    return 0;
}


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

int main()
{
  int n;
  cin>>n;
  double ans=0;
  vector<pair<double,string>> a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a.at(i).first>>a.at(i).second;
    if(a.at(i).second=="JPY")
      ans+=a.at(i).first;
    else
      ans+=a.at(i).first*380000;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include<stdio.h>

int main(void){
	int N;
	scanf("%d",&N);
	int i,j,count=0;
	for(i=0;i<=32;i++){
	for(j=0;j<=32;j++){
		if(N==4*i+7*j){
			count++;
		}
	}
	}
	
	if(count>0){
		printf("Yes");
	}
	else{
		printf("No");
	}
		
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=1;i<s.length();i++)
	{
		if(s[i]==s[i-1])
		{
			cout<<i<<" "<<i+1<<endl;
			return 0;
		}
	}
	for(int i=2;i<=s.length();i++)
	{
		if(s[i]==s[i-2])
		{
			cout<<i-1<<" "<<i+1<<endl;
			return 0;
		}
	}
	cout<<-1<<" "<<-1<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
typedef long long ll;
const int mod=998244353;
int cnt[100050];
inline int fp(int a,int p){
	int s=1;
	while(p){
		if(p&1)s=(ll)s*a%mod;
		a=(ll)a*a%mod;
		p>>=1;
	}
	return s;
}
int main(){
	int n,i,x,maxn=0,ans=1;
	scanf("%d",&n);
	for(i=0;i<n;++i){
		scanf("%d",&x);
		if(!i&&x){
			puts("0");
			return 0;
		}
		if(x>maxn)maxn=x;
		++cnt[x];
	}
	if(cnt[0]!=1){
		puts("0");
		return 0;
	}
	for(i=2;i<=maxn;++i)ans=(ll)ans*fp(cnt[i-1],cnt[i])%mod;
	printf("%d\n",ans);
	return 0;
}

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

bool Check(int A, int B, int C){
    return (A <= C && C <= B);
}

int main(void){
    int A, B, C;
    cin >> A >> B >> C;
    
    if(Check(A,B,C) ) 
        cout << "Yes";
    else 
        cout << "No";
}


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

int main(){

    //データ定義
    int data_x;
    int data_y;

    //主処理
    while(1){
        
        //データ読み込み
        cin >> data_x >> data_y;

        //どちらも0の時、終了
        if(data_x == 0 && data_y == 0) break;

        //小さい順に並べて出力
        if(data_x > data_y){
            cout << data_y << " " << data_x << endl;
        }else{
            cout << data_x << " " << data_y << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3008
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };


int main()
{
  int N;
  cin >> N;
  vll a(N);
  rep(i,N) cin >> a[i];
  
  vll x(N,0);
  
  
  rep(i,N){
      //奇数の時は-、偶数の時は+することでx1が求まる
      if(i%2 == 0) x[0]+=a[i];
      else x[0] -= a[i];
  }


  for(int i=1;i<=N-2;i++){
     x[i] = 2*a[i-1]-x[i-1];
     
  }

  x[N-1] = 2*a[N-1] - x[0]; 
 

  for(auto i:x){
      cout << i << " ";
  }

  cout << endl;

}



Measured memory_bytes: 2944
#include <iostream>

long long a;

int main(){
  int n;
  std::cin>>n;
  int ans=0;
  for(int i=0;i<n;++i){
    std::cin>>a;
    while(a%2==0){
      ans++;
      a/=2;
    }
  }
  std::cout<<ans<<std::endl;
  return 0;
}


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

long long i, j, n, k, mod = 1e9 + 7, ans = 0;
int main(){
	cin >> n >> k;
	vector<long long> a(n);
	vector<long long> b;
	for (i = 0; i < n; i++){
		cin >> a[i];
	}
	for (i = 0; i < n; i++){
		for (j = 0; j < n; j++){
			if(a[i] > a[j] && i < j){
				b.push_back((k * (k + 1) / 2) % mod);
			}
			else if(a[i] > a[j] && i > j){
				b.push_back((k * (k - 1) / 2) % mod);
			}
		}
	}

	for (auto xe = b.begin(); xe != b.end(); xe++){
		//cout << *xe << endl;
		ans += *xe;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 18284
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
int main(){
    int64_t n,num;
    cin >>n;
    vector<int> a(n+1);
    for(int i=2;i<n+1;i++){
        cin >>num;
        a[num]++;
    }

    for(int j=1;j<n+1;j++){
        cout << a[j] <<endl;
    }
}

Measured memory_bytes: 4052
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main(){
  string str;
  int alp[26]={};
  while(getline(cin,str)){
    for(int i=0,l=str.size();i<l;i++){
      if(str[i]>='a'&&str[i]<='z') alp[str[i]-'a']++;
      else  if(str[i]>='A'&&str[i]<='Z') alp[str[i]-'A']++;
    }
  }
  for(int i=0;i<26;i++){
    printf("%c : %d\n",i+'a',alp[i]);
  }
}

Measured memory_bytes: 1188
if_debag = False

input_texts = """5 25000
20 1000
40 1000
50 1000
30 1000
1 1000"""

input_texts = input_texts.split('\n')
it = iter(input_texts)
#next(it)

def my_input():
    if if_debag:
        return next(it)
    else:
        return input()

d, g = map(int, my_input().split())
ps = list()
cs = list()
for i in range(d):
    p, c = map(int, my_input().split())
    ps.append(p)
    cs.append(c)

minv = 2000
for i in range(1 << d):
    toita_mondai = 0
    sougou_tensu = 0
    for j in range(d):
        if (i >> j) & 1:
            toita_mondai += ps[j]
            sougou_tensu += (j + 1) * 100 * ps[j] + cs[j]
    if sougou_tensu >= g:
        minv = min(minv, toita_mondai)
    else:
        nokori = g - sougou_tensu
        flag = False
        for j in range(d - 1, -1, -1):
            if (i >> j) & 1:
                continue
            for _ in range(ps[j]):
                nokori -= 100 * (j + 1)
                toita_mondai += 1
                if nokori <= 0:
                    minv = min(minv, toita_mondai)
                    flag = True
                    break
            if (flag): break        
print(minv)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  ll a, b, k ;
  cin >> a >> b >> k ;
  int i = 1 ;
  while(i<=k){
    if(i%2==1){
      if(a%2==1){
        a-- ;
      }
      b += a/2 ;
      a /= 2 ;
    }
    else if(i%2==0){
      if(b%2==1){
        b-- ;
      }
      a += b/2 ;  
      b /= 2 ;
    }
    i++ ;
  }
  
  cout << a <<endl ;
  cout << b <<endl ;
    
    
      


  return 0 ;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        double pi = 3.1415926536;
	        double R = sc.nextDouble();

	        System.out.println(R*pi*2);
	 }

}

Measured memory_bytes: 37496
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;

    // B→Dへの移動
    for(int i=B;i<D-1;i++){
        if(S[i-1] == '#' && S[i] == '#'){
            cout << "No" << endl;
            return 0;
        }
    }

    // A→Cへの移動
    bool flag = true;
    for(int i=A;i<C-1;i++){
        if(S[i-1] == '#' && S[i] == '#'){
            cout << "No" << endl;
            return 0;
        }
        // 移動中にDが障害となる
        if(S[i-1] == '#' && i == D-1)
            flag = false;
        if(i-1 == D-1 && S[i] == '#')
            flag = false;
    }

    if(flag){
        cout << "Yes" << endl;
        return 0;
    }else{
        // Aを先に動かす
        // AがBを追い越せるか？→3マス連続で空きが必要
        for(int i=B-1;i<=D-1;i++){
            if(S[i-1] == '.' && S[i] == '.' && S[i+1] == '.'){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 640
N = int(input())
L = sorted(map(int, input().split()))

ans = 0

for i in range(N-2):
    a = L[i]

    for j in range(i+1, N-1):
        b = L[j]
        if a == b:
            continue

        for k in range(j+1, N):
            c = L[k]
            if  b == c:
                continue

            if a + b <= c:
                continue

            ans += 1

print(ans)


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

#include <iomanip>
int main() {
    cout << fixed << setprecision(12);
    int W, H, w, h, x, y; cin >> W >> H >> w >> h >> x >> y;
    int left   = max(-W / 2, x - w / 2),
        right  = min( W / 2, x + w / 2),
        bottom = max(-H / 2, y - h / 2),
        top    = min( H / 2, y + h / 2);
    double cx = (left + right) / 2.0,
           cy = (bottom + top) / 2.0;
    cout << cy / cx << endl;
    return 0;
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int r;
  cin >> r; 

  int ans = 3 * r * r;

  cout << ans << endl;
}

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

int main(){
    int n;
    scanf("%d",&n);
    int d[n];
    for(int i=0;i<n;i++) scanf("%d",&d[i]);

    int ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans+=d[i]*d[j];
        }
    }

    printf("%d\n",ans);
}

Measured memory_bytes: 256
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef pair<int, int> pii;

void solve() {
	int N;
	cin >> N;
	vector<bool> input;
	input.resize(N);
	string S; cin >> S;
	for (int n = 0; n < N; n++) {
		if (S[n] == 'o')input[n] = true;
		else input[n] = false;
	}
	vector<bool> res;   //true -> S,false -> W
	res.resize(N);
	bool flag = false;
	for (int i1 = 0; i1 <= 1 && !flag; i1++) {
		for (int i2 = 0; i2 <= 1 && !flag; i2++) {
			res[0] = i1;
			res[1] = i2;
			for (int n = 2; n < N; n++) {
				res[n] = ~(res[n-1] ^ ~(res[n-2] ^ input[n-1]));
			}
			if (res[0] == ~(res[N - 1] ^ ~(res[N - 2] ^ input[N - 1]))) {
				if (res[1] == ~(res[N - 1] ^ ~(res[0] ^ input[0]))) {
					flag = true;
					for (int n = 0; n < N; n++) {
						cout << (res[n]?"S":"W");
					}
					cout << endl;
				}
			}
		}
	}
	if (!flag)cout << -1 << endl;
	return;
}

Measured memory_bytes: 640
A,B = list(map(int,input().split()))
S = input()

hantei = 1

for i in range(A+B+1):
    if S[i] == "-" and i != A:
        hantei = 0
        break

if hantei == 1 and S[A] == "-":
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a , b;
  cin >> a >> b;
  if ((a + b) % 2 == 1){
    cout << (a + b) / 2 + 1 << endl;
  } else {
    cout << (a + b) / 2 << endl;
  }
}

Measured memory_bytes: 256
import sys
# input関係の定義
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def si(): return input().rstrip()
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template

# BEGIN CUT HERE
class RollingHash():
    """ロリハ。容易に衝突するので注意。"""
    BASE1 = 1007
    BASE2 = 2009
    MOD1 = 1000000007
    MOD2 = 1000000009

    def __init__(self, s, opt=2):
        self.n = len(s)
        self.opt = opt
        self.hash1 = [0] * (self.n + 1)
        self.power1 = [1] * (self.n + 1)
        if opt == 2:  # rollinghash by 2 mod
            self.hash2 = [0] * (self.n + 1)
            self.power2 = [1] * (self.n + 1)

        for i, e in enumerate(s):
            self.hash1[i + 1] = (self.hash1[i] * self.__class__.BASE1 + ord(e)) % self.__class__.MOD1
            self.power1[i + 1] = (self.power1[i] * self.__class__.BASE1) % self.__class__.MOD1
        if opt == 2:  # rollinghash by 2 mod
            for i, e in enumerate(s):
                self.hash2[i + 1] = (self.hash2[i] * self.__class__.BASE2 + ord(e)) % self.__class__.MOD2
                self.power2[i + 1] = (self.power2[i] * self.__class__.BASE2) % self.__class__.MOD2

    def get(self, l: int, r: int):
        res1 = self.hash1[r] - self.hash1[l] * self.power1[r - l] % self.__class__.MOD1
        if(res1 < 0):
            res1 += self.__class__.MOD1
        if self.opt == 2:
            res2 = self.hash2[r] - self.hash2[l] * self.power2[r - l] % self.__class__.MOD2
            if(res2 < 0):
                res2 += self.__class__.MOD2

        if self.opt == 2:
            return (res1, res2)
        else:
            return res1
# END CUT HERE

def ABC131E():
    N = ii()
    S = si()
    rh = RollingHash(S)
    def check(n: int):
        d = dict()
        for i in range(N - n + 1):
            p = rh.get(i, i + n)
            if p in d:
                if(i - d[p] >= n):
                    return True
            else:
                d[p] = i
        return False
    ok, ng = 0, N // 2 + 1
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if check(mid):
            ok = mid
        else:
            ng = mid
    print(ok)



if __name__ == '__main__':
    ABC131E()


Measured memory_bytes: 45040
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h;
    cin >>h;
    int a[h];
    for(int i=0;i<h;i++)
        cin>>a[i];
    int dp[h];
    dp[0]=0;
    for(int i=1;i<h;i++)
    {
        if(i==1)
            dp[i]=abs(a[1]-a[0]);
        else
        {
            dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
        }
    }
    cout <<dp[h-1];
}



Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

const int INF = INT_MAX / 5;

int pow(const int base, const int n) {
    assert(n >= 0);
    if (n == 0) {
        return 1;
    } else {
        return base * pow(base, n - 1);
    }
}

int cost_for(const int target, const vector<int> xs) {
    int n = (int) xs.size();
    if (n == 0) {
        return INF;
    }

    int s = 0;
    for (int i = 0; i < n; i++) {
        s += xs[i];
    }

    return (n - 1) * 10 + abs(s - target);
}

vector<int> ls;

int main(void) {
    int N, A, B, C;
    cin >> N >> A >> B >> C;

    ls.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> ls[i];
    }

    int ans = INF;
    for (int i = 0; i < pow(4, N); i++) {
        int bits = i;
        vector<vector<int>> ss(4); // {for A, for B, for C, not used}
        for (int j = 0; j < N; j++) {
            ss[bits % 4].push_back(ls[j]);
            bits /= 4;
        }
        int cost_a = cost_for(A, ss[0]);
        int cost_b = cost_for(B, ss[1]);
        int cost_c = cost_for(C, ss[2]);
        // printf("cost_a: %d, cost_b: %d, cost_c: %d\n", cost_a, cost_b, cost_c);
        chmin(ans, cost_a + cost_b + cost_c);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3556
import sys
sys.setrecursionlimit(10 ** 6)

N, A, B, C = map(int, input().split())

L = [int(input()) for _ in range(N)]
INF = 10 ** 12


def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + L[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + L[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + L[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


print(dfs(0, 0, 0, 0))


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

int main (void){
    int a, b;
    cin >> a >> b;
    if(a * b * 3 % 2 == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
import sys
input = sys.stdin.readline
N, X = map(int, input().split())
a = list(map(int, input().split()))
res = 0
for i in range(N - 1):
  if a[i] + a[i + 1] > X:
    if a[i] <= X:
      res += a[i] + a[i + 1] - X
      a[i + 1] -= a[i] + a[i + 1] - X
    else:
      res += a[i] + a[i + 1] - X
      a[i + 1] = 0
print(res)

Measured memory_bytes: 84728
#include<cstdio>
#include<iostream>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
int dp[100010];
int main(){
	int N;
	cin>>N;
	dp[0]=0;
	for(int i=1;i<=100000;i++){
		int min=1+dp[i-1];
		int j=6;
		while(i>=j){
			//if(i-j<0)break;
			min=min(min,(1+dp[i-j]));
			j*=6;
		
		}
		j=9;
		while(i>=j){
			
			//if(i-j<0)break;
			min=min(min,(1+dp[i-j]));
			j*=9;
		
		}
		dp[i]=min;
	}
	cout<<dp[N];
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

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

        int[] H = new int[N];

        for (int i = 0; i < N; i++) {
            H[i] = sc.nextInt();
        }
        Arrays.sort(H);
        long h = 0;

        for (int i = 0; i < Math.max(0,N-K); i++) {
            h += H[i];
        }


        System.out.println(Math.max(0,h));

    }



}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n,a,b;cin>>n>>a>>b;
    cout<<min(a*n,b)<<endl;
}


Measured memory_bytes: 256
import java.util.*;


class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt(),y = sc.nextInt();
        String ans = "No";
        for(int i = 0;i<=x;i++){
            for(int j = 0;i+j<=x;j++){
                if(i*2+j*4==y&&i+j==x){
                    ans = "Yes";
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35780
N = int(input())
X = list(map(int, input().split()))

HP = []
for p in range(1, 101, 1):
    P = [p] * len(X)
    delta = sum([(i - j) ** 2 for (i, j) in zip(X, P)])
    HP.append(delta)

print(min(HP))


Measured memory_bytes: 9120
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

ll sqrt(ll x){
	ll lp = 1;
	ll rp = INF;
	while(lp<rp){
		ll mid = (lp + rp) >> 1;
		if(mid * mid <= x){
			lp = mid + 1;
		}else{
			rp = mid;
		}
	}
	return lp - 1;
}

ll func(){
	ll a,b;
	cin >> a >> b;
	if(a>b){
		swap(a,b);
	}

	if(a==b){
		return (ll)sqrt(a*a) * 2 - 2;
	}
	
	ll sqr = sqrt(a*b-1);
	ll res = sqr * 2 - 1;
	if(sqr*(sqr+1)>=a*b){
		--res;
	}


	return res;
}

int main(){
	int q;
	cin >> q;
	rep(i,q){
		cout << func() << endl;
	}
	return 0;
}


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

using namespace std;

int n, a[(int)1e5+1], b[(int)1e5];
long long ans;

int main(){
	cin >> n;
	for(int i = 0; i < n + 1; ++i) cin >> a[i];
	for(int i = 0; i < n; ++i) cin >> b[i];
	
	int hunt;
	for(int i = 0; i < n; ++i){
		hunt = min(a[i], b[i]);
		ans += hunt;
		a[i] -= hunt;
		b[i] -= hunt;
		
		hunt = min(a[i+1], b[i]);
		ans += hunt;
		a[i+1] -= hunt;
		b[i] -= hunt;
	}
	cout << ans << endl;
}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
using namespace std; 

int main(void)
{
    string s;
    cin >> s;
    int n = s.size();
    
    bool ok = true;
    irep(i, n/2) {
        if(s[i] != s[n-1-i]) {
            ok = false;
        }
    }
    
    string t = s.substr(0, (n-1)/2);
    irep(i, t.size()/2) {
        if(t[i] != t[t.size()-1-i]) {
            ok = false; 
        }
    }

    string u = s.substr(((n+3)/2)-1);
    irep(i, u.size()/2) {
        if(u[i] != u[u.size()-1-i]) {
            ok = false; 
        }
    }

    if(ok) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
    
}
/** tcoder **/


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, k, ans;
string s;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k >> s;
	int i = 0, j = 0, cnt = 0, len = s.length();
	s = s + "#";
	s = "#" + s;
	while (1) {
		while (i <= len && s[i] == '0') i++;
		if (i == 0) j = i + 1;
		while (1) {
			while (j <= len + 1 && s[j] == '1') j++;
			if (s[j] == '0') cnt++;
			while (j <= len + 1 && s[j] == '0') j++;
			if (j == len + 1 || cnt == k) break;
		}
		while (j <= len + 1 && s[j] == '1') j++;
		int tmp = j - i;
		if (i == 0) tmp--;
		ans = max(ans, tmp);
		if (j == len + 1) break;
		if (i == 0) i++;
		while (i <= len && s[i] == '1') i++;
		cnt--;
	}
	cout << ans << "\n";
	//system("pause");
	return 0;
}

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

int main(){
  int n; cin >> n;
  vector<int> a(n), b(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    b.at(i) = a.at(i);
  }
  sort(b.begin(), b.end());
  int cnt1 = b.at(n/2-1), cnt2 = b.at(n/2);
  for(int i = 0; i < n; i++){
    if(cnt1 == cnt2) cout << cnt1 << endl;
    else if(a.at(i) <= cnt1) cout << cnt2 << endl;
    else if(a.at(i) >= cnt2) cout << cnt1 << endl;
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 131072
#define ll long long
#define dmp make_pair
#define dpb push_back
#define P pair<int,int>
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);
const int inf = 2147483647;

int n, dat[2*MAX];
void init(int m){
	n = 1;
	while(n < m)n *= 2;
	for(int i = 0;i < 2*n;i++)dat[i] = 0;
}

void change(int x, int y){
	x += n-1;
	dat[x] += y;
	while(x > 0){
		x = (x-1)/2;
		dat[x] += y;
	}
}

int query(int a, int b, int k, int l, int r){
	if(b <= l || r <= a)return 0;
	if(a <= l && r <= b)return dat[k];
	int vl = query(a, b, 2*k+1, l, (l+r)/2);
	int vr = query(a, b, 2*k+2, (l+r)/2, r);
	return vl+vr;
}

int add(int a, int b, int x,  int k, int l, int r){
	if(b <= l || r <= a)return 0;
	if(a <= l && r <= b){
		dat[k] += x;
		return 0;
	}
	add(a, b, x, k*2+1, l, (l+r)/2);
	add(a, b, x, k*2+2, (l+r)/2, r);
	return 0;
}

int get(int k){
	int ans = 0;
	k += n-1;
	ans += dat[k];
	while(k > 0){
		k = (k-1)/2;
		ans += dat[k];
	}
	return ans;
}

int main(){
	int m, q, c, s, t, x, ans;
	scanf("%d%d", &m, &q);
	init(m);
	while(q--){
		scanf("%d", &c);
		if(!c){
			scanf("%d%d%d", &s, &t, &x);
			add(s-1, t, x, 0, 0, n);
		}else{
			scanf("%d", &x);
			printf("%d\n", get(x-1));
			//printf("%d\n", get(x-1, y, 0, 0, n));
		}
	}
	//for(int i = 0;i < 2*n-1;i++)printf("%d ", dat[i]);
	return 0;
}

Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {if (b == 0) {return a;}return gcd(b, a%b);}

bool pairwise=true, setwise=false;
int pot[1000001], N, arr[1000000];
bool vis[1000001];
bool chk[1000001];
void sieve() {
    int i, j;
    pot[0]=1;
    pot[1]=1;
    for (i=2; i <= 1000000; i+=2) {
        pot[i] = 2;
    }
    for (i=3; i <= 1000000; i+=2) {
        if (!pot[i]) {
            for (j=1; i*j <= 1000000; j++) {
                if (!pot[i*j]) {
                    pot[i*j] = i;
                }
            }
        }
    }
}
int main(void) {
    sieve();
    scanf("%d", &N);
    int i;
    for (i=0; i < N; ++i) {
        scanf("%d", arr+i);
    }
    int pairgcd = gcd(arr[0], arr[1]);
    for (i=2; i < N; i++) {
        pairgcd = gcd(pairgcd, arr[i]);
    }
    if (pairgcd == 1) setwise=true;
    //struct Vector vec[N];
    unordered_set<int> st[N];
    for (i=0; i < N; i++) {
        int x = *(arr+i);
        //memset(chk, false, sizeof(chk));
        //init(&vec[i], 1000001);
        while(x > 1) {
          //  if (!chk[pot[x]]) {
          //      chk[pot[x]] = true;
          //      push_back(&vec[i], pot[x]);// check this whole & vs !& thing
            //}
            st[i].insert(pot[x]);
            x /= pot[x];
        }
        for (int y: st[i]) {
            if (vis[y]) {
                pairwise=false;
            }
            vis[y] = true;
        }
        //delete(&vec[i]);
    }
    if (pairwise) {
        printf("pairwise coprime\n");
    } else if (setwise) {
        printf("setwise coprime\n");
    } else {
        printf("not coprime\n");
    }
    return 0;
}


/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?)
    * do smth instead of nothing and stay organized
    * WRITE STUFF DOWN
    * CHECK IF DEBUGGING OUTPUT BLOCKS ANSWER
*/



Measured memory_bytes: 278416
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;
// typedef pair<ll, ll> P;
typedef pair<int, int> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

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

int main()
{
  int H, W, N;
  cin >> H >> W >> N;
  vector<int> a(N), b(N);
  REP(i, N)
  cin >> a[i] >> b[i];
  map<P, ll> mp;
  REP(i, N)
  {
    REP(j, 9)
    {
      int y = a[i] + dy[j];
      int x = b[i] + dx[j];
      if (2 <= y && y <= H - 1 && 2 <= x && x <= W - 1)
        mp[P(y, x)]++;
    }
  }
  map<ll, ll> mp2;
  for (auto a : mp)
    mp2[a.second]++;
  ll sum = 0;
  for (auto a : mp2)
    sum += a.second;
  mp2[0] = 1ll * (H - 2) * (W - 2) - sum;
  REP(i, 10)
  cout << mp2[i] << endl;
  return 0;
}

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

using namespace std;

long long MOD = 1e9+7;
int main() {
  // U: 3^N fits, which hints towards a fancy subset DP
  // i.e. the one that is magically 3^n when it looks like
  // it should be 2^2n

  cin.tie(0);
  cin.sync_with_stdio(0);
  int n; cin >> n;

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

  // first, compute the costs of every subset (if grouped)
  long long costs[1<<n];
  for(int i = 0; i<(1<<n); ++i) {
    vector<int> in_group;
    for(int j = 0; j<n; ++j) {
      if((i >> j) & 1) {
        in_group.push_back(j);
      }
    }
    costs[i] = 0;
    for(int j = 0; j<in_group.size(); ++j) {
      for(int k = j+1; k<in_group.size(); ++k) {
        costs[i] += a[in_group[j]][in_group[k]];
      }
    }
  }

  // next, magic
  long long dp[1<<n];
  for(int i = 0; i<(1<<n); ++i) {
    dp[i] = LLONG_MIN;
  }
  dp[0] = 0;
  for(int i = 0; i<(1<<n); ++i) {
    // ugh I can't quite remember it...
    int j = i;
    do {
      j = (j - 1) & i; // go through all masks containing i as a submask...
      dp[i] = max(dp[i], dp[j] + costs[i^j]);
    } while (j != i);
  }

  cout << dp[(1<<n)-1] << endl;
}


Measured memory_bytes: 1280
package main
import (
  "fmt"
  "regexp"
)
 
func main(){
  var a string
  fmt.Scan(&a)
  r := regexp.MustCompile(`[A-Z]`)
  if r.MatchString(a) {
    fmt.Print("A\n")
  } else {
    fmt.Print("a\n")
  }
}

Measured memory_bytes: 2000
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
int N, K, Q, A[2010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K >> Q;
    rep(i, 0, N) cin >> A[i];

    int ans = inf;
    rep(y, 0, N) { // Y=A[y]として取っていく
        int Y = A[y];

        vector<int> v;
        v.push_back(-1);
        rep(i, 0, N) if (A[i] < Y) v.push_back(i);
        v.push_back(N);

        int n = v.size();
        min_priority_queue<int> qu;
        rep(i, 0, n - 1) {
            int l = v[i] + 1;
            int r = v[i + 1];

            // [l,r)
            min_priority_queue<int> buf;
            rep(i, l, r) buf.push(A[i]);
            while (K <= buf.size()) {
                qu.push(buf.top());
                buf.pop();
            }
        }

        int X = Y;
        int q = Q;
        while (0 < q && !qu.empty()) {
            chmax(X, qu.top());
            qu.pop();
            q--;
        }

        if (q == 0) chmin(ans, X - Y);
    }
    cout << ans << endl;
}

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

int main(){
    using namespace std;

    unsigned long N, K;
    char s[5000];
    scanf("%lu%lu %s", &N, &K, s);
    string S(s, s + strlen(s));

    string T(S.begin(), S.end());
    T += string(S.rbegin(), S.rend());
    for(unsigned long i = 0; i < N; ++i)S = min(S, string(T.begin() + i, T.begin() + i + N));
    unsigned long k{static_cast<unsigned long>(find_if_not(S.begin(), S.end(), [&S](auto i){return i == S[0];}) - S.begin())};
    --K;
    unsigned long l = K > 13 ? N : min(N, (k << K) - k);
    string A(l, S[0]);
    A += string(S.begin(), S.begin() + N - A.size());

    puts(A.data());

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio() ios_base::sync_with_stdio(false);
#define rmod(x, y) ((((x)%(y))+(y))%(y))
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<typename T, typename R = null_type, typename C = less<T>>
tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update> ordered_set(){
	return tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update>();
}

struct box{
	int w, s; ll v;
	bool operator<(box&b){return w+s<b.w+b.s;}
};

const int maxn = 1e3+5, maxs = 2e4+5;
int n;
box a[maxn];
ll dp[maxn][maxs];

int main(){
	scanf("%d", &n);
	for(int i = 1; i<=n; i++) scanf("%d %d %lld", &a[i].w, &a[i].s, &a[i].v);
	sort(a+1, a+n+1);
	for(int i = 1; i<=n; i++){
		for(int s = 0; s<maxs; s++){ // weight
			dp[i][s] = dp[i-1][s];
			if (s>=a[i].w && s-a[i].w<=a[i].s) 
				dp[i][s] = max(dp[i][s], dp[i-1][s-a[i].w]+a[i].v);
		}
	}
	
	printf("%lld\n", *max_element(dp[n], dp[n]+maxs));
	return 0;
}


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

int main()
{
	int N, i, j;
	scanf("%d", &N);
	char W[N][11];
	for (i = 0; i < N; i++) {
		scanf("%s", W[i]);
	}
	
	int flag = 0;
	for (i = 0; i < N - 1; i++) {
		if (W[i][strlen(W[i]) - 1] != W[i+1][0])
			flag = 1;
//		printf("%d", flag);
	}
//	putchar('\n');
//	putchar('\n');

	for (i = 0; i < N - 1; i++) {
		for (j = i + 1; j < N; j++) {
			if (strcmp(W[i], W[j]) == 0)
				flag = 1;
//			printf("%d", flag);
		}
//		putchar('\n');
	}

	if (flag == 1)
		printf("No\n");
	else
		printf("Yes\n");

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
char str[200000 + 10];
int main() {
	scanf("%s", str);
	int len = strlen(str);
	int pos = 0,p=0;
	int num_t = 0,num_s=0;
	for (int i = 0;i < len;i++) {
		if (str[i] == 'S') num_s++;
		else if (num_s) {
			num_s--;
			p++;
		}
	}
	printf("%d", len-2*p);
	return 0;
}

Measured memory_bytes: 384