akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int dp[22][22][22][22];

string s[22];
int rec(int x1,int y1,int x2,int y2){
    if(x1>x2||y1>y2)return 0;
    if(dp[x1][y1][x2][y2]!=-1)return dp[x1][y1][x2][y2];
    vector<int> g;
    REP(i,x1,x2+1)REP(j,y1,y2+1){
        if(s[i][j]=='X')continue;
        int ret=0;
        ret^=rec(x1,y1,i-1,j-1);
        ret^=rec(x1,j+1,i-1,y2);
        ret^=rec(i+1,y1,x2,j-1);
        ret^=rec(i+1,j+1,x2,y2);
        g.push_back(ret);
    }
    sort(g.begin(),g.end());
    g.erase(unique(g.begin(),g.end()),g.end());
    g.push_back(inf);
    rep(i,g.size()){
        if(g[i]!=i){
            return dp[x1][y1][x2][y2]=i;
        }
    }
    return -1;
}

int main(){
    int h,w;
    cin>>h>>w;
    rep(i,h)cin>>s[i];
    rep(i,h)rep(j,w)rep(k,h)rep(l,w)dp[i][j][k][l]=-1;
    int ans = rec(0,0,h-1,w-1);
    cout<<(ans?"First" : "Second")<<endl;
    return 0;
}


Measured memory_bytes: 4020
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vi x(n),y(n),h(n);
  tuple<int,int,int> t;
  rep(i,n){
    cin >> x[i] >> y[i] >> h[i];
    if(0 < h[i]) t = make_tuple(x[i],y[i],h[i]);
  }

  int ans_x = -1, ans_y = -1, ans_h = -1;
  rep(i,101){
    rep(j,101){
      int candidate = get<2>(t)+abs(j-get<0>(t))+abs(i-get<1>(t));
      bool ok = true;
      rep(k,n) if(h[k] != max(0,candidate-abs(j-x[k])-abs(i-y[k]))) ok = false;
      if(ok){
        ans_h = candidate;
        ans_x = j;
        ans_y = i;
      }
    }
  }
  cout << ans_x << " " << ans_y << " " << ans_h;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(){
  int n,i,j,k,l,cnt;
  while(cin >> n){
    cnt=0;
    for(i=0;i<=9;i++){
      for(j=0;j<=9;j++){
	for(k=0;k<=9;k++){
	  for(l=0;l<=9;l++){
	    if(i+j+k+l==n) cnt++;
	  }
	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define mod 1000000007
#define rep(i,n) for(int i=0;(i)<(n);i++)
typedef long long ll;
using namespace std;
ll h_pow(ll x,ll n){
    ll ans = 1ll;
    while(n>0){
        if(n&1){
            ans = (ans*x)%mod;
        }
        n >>= 1;
        x = (x*x)%mod;
    }
    return ans;
}
int main (){
    int n; cin >> n;
    vector<int> c(n);
    rep(i,n) cin >> c[i];
    sort(c.begin(),c.end());
    ll coef = h_pow(2,n-1);
    ll diff = h_pow(2,n-2);
    ll ans = 0;
    for(int i=n-1;i>=0;i--){
        ans = (ans + coef*c[i])%mod;
        coef = (coef+diff)%mod;
    }
    cout << (ans*h_pow(2,n))%mod << endl;
}




Measured memory_bytes: 1024
h, w = map(int, input().split())
s = [input() for i in range(h)]

x = [-1, -1, 0, 1, 1, 1, 0, -1]
y = [0, 1, 1, 1, 0, -1, -1, -1]
for px in range(h):
    for py in range(w):
        if s[px][py] == '#': continue

        cou = 0
        for d in range(len(x)):
            tempx = px + x[d]
            tempy = py + y[d]

            if tempx < 0 or tempx >= h or tempy < 0 or tempy >= w:
                continue
            if s[tempx][tempy] == '#':
                cou += 1

        s[px] = s[px].replace('.', str(cou), 1)

for i in range(h):
    print(s[i])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll h,w;
  cin >> h >> w;
  mat a(h+1,vec(w+1));
  for(ll i=1;i<=h;i++) for(ll j=1;j<=w;j++) cin >> a[i][j];
  for(ll i=1;i<=h;i++) for(ll j=1;j<=w;j++) {
    ll b;
    cin >> b;
    a[i][j]=abs(a[i][j]-b);
  }
  bitset<6400*2> dp[h+1][w+1];
  dp[0][1][6400]=1;
  for(ll i=1;i<=h;i++) for(ll j=1;j<=w;j++) {
    dp[i][j]|=(dp[i-1][j]>>a[i][j])|(dp[i-1][j]<<a[i][j]);
    dp[i][j]|=(dp[i][j-1]>>a[i][j])|(dp[i][j-1]<<a[i][j]);
  }
  for(ll i=6400;;i++) {
    if(dp[h][w][i]) {
      cout << i-6400 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 10496
#include<unordered_map>
#include<iostream>
#include<algorithm>
#include<utility>
#include<climits>
#include<fstream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define inf 0x7f7f7f
#define p(x) (x)*(x)
#define PI 3.14159265358979
using namespace std;

typedef vector<vector<int> > vtype;
typedef long long ll;
int *a = nullptr;

int main()
{
	//ios::sync_with_stdio(false);
	int n = 0;
	bool istrue = true;
	cin >> n;
	a = new int[n+5]{0};
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	for(int i = 0; i < n; ++i)
		if(!(a[i] & 1) && ((a[i] % 3) && (a[i] % 5))){
			istrue = false;
			break;
		}
	if(istrue)
		cout << "APPROVED" << endl;
	else
		cout << "DENIED" << endl;
	delete[] a;
	a = nullptr;
    return 0;
}















Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
ll test[12345678];
signed main() {
	ll n = 0, m = 0, k, l, cnt = 0, z = 0; cin >> n;
	while (n >= 5) {
		if (n >= 500) { cnt += 1000; n -= 500; }
		else if (n >= 5) { cnt += 5; n -= 5; }
	}
	cout << cnt << endl;
	cin >> n; return 0;
}

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

int main() {
  int n, q;
  cin >> n;

  ll sum = 0;
  unordered_map<int, int> freq;

  rep(i, n) {
    int a;
    cin >> a;
    if (freq[a]) {
      freq[a]++;
    } else {
      freq[a] = 1;
    }

    sum += a;
  }

  cin >> q;

  // Operations
  rep(i, q) {
    int b, c;
    cin >> b >> c;

    int diff = (b - c) * freq[b];
    sum -= diff;

    if (freq[c]) {
      freq[c] += freq[b];
    } else {
      freq[c] = freq[b];
    }
    freq.erase(b);

    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 6704
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<bitset>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>
#include<bitset>


using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))

const ll MOD = 1e+9+7;
const double PI  = acos(-1.0);

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b>=c-1){
    cout<<(b+c)<<"\n";
  }else{
    cout<<b+(a+b+1)<<"\n";
  }

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
  string s;
  int n;
  cin>>n;
  cin>>s;
  long long r=0,b=0,g=0;
  for(auto c:s){
    if(c=='R') ++r;
    else if(c=='G') ++g;
    else ++b;
  }
  long long all=r*b*g;
  long long sub=0;
  for(int i=0;i<n;++i){
   for(int j=i+1;j<n;++j){
     if(s[i]==s[j]) continue;
     int k=j*2-i;
     if(k>=n||s[k]==s[i]||s[k]==s[j]) continue;
     ++sub;
   }
  }
  cout<<all-sub<<endl;
  return 0;
}


Measured memory_bytes: 3640
def pow(x, n, mod):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = ans*x % mod
    x = x*x % mod
    n = n >> 1
  return ans

def kaijou_k(n, k, mod):
    a = 1
    for i in range(k, n+1):
        a *= i
        a %= mod
    return a %mod

def main():
    n, a, b = map(int, input().split())
    mod = 10**9 +7
    allsum = pow(2, n, mod)-1
    abunbo = kaijou_k(n, n-a+1, mod)
    abunsi = kaijou_k(a, 1, mod)
    asum = abunbo * pow(abunsi, mod-2, mod) % mod
    bbunbo = kaijou_k(n, n-b+1, mod)
    bbunsi = kaijou_k(b, 1, mod)
    bsum = bbunbo * pow(bbunsi, mod-2, mod) % mod
    ans = (allsum - asum - bsum) % mod
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3192
fn solve() {
    let n: i64 = read();
    println!("{}", if n >= 30 { "Yes" } else { "No" });
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::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")
}

// =========


Measured memory_bytes: 2216
#include<cstdio>
#include<string>
main(){
	using namespace std;
	int i,j;
	string lv[8] = {"AAA","AA","A","B","C","D","E","NA"};
	double lvd5[7] = {35.5,37.5,40.0,43.0,50.0,55.0,70.0};
	int lvd1[7] = {71,77,83,89,105,116,148};
	double ind1,ind2;
	while(~scanf("%lf %lf",&ind1,&ind2)){
		i = j = 0;
		while(i<7){
			if(ind1 < lvd5[i])
				break;
			i++;
		}
		while(j<7){
			if(ind2 < lvd1[j])
				break;
			j++;
		}
		printf("%s\n", i <= j ? lv[j].c_str() : lv[i].c_str());
	}
	return 0;
}

Measured memory_bytes: 1064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int m,d,ans;
signed main(){
	cin>>m>>d;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=d;j++){
			if(j>=10&&j%10>=2&&j/10>=2&&(j%10)*(j/10)==i)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (int)(n); ++i)
#define fj(st,n) for (int j = (st); j <= (int)(n); ++j)
#define fk(st,n) for (int k = (st); k <= (int)(n); ++k)
#define fq(st,n) for (int q = (st); q <= (int)(n); ++q)
#define fw(st,n) for (int w = (st); w <= (int)(n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (int)(n); ++(i))
#define ei(st,n) for (int i = (st); i >= (int)(n); --i)
#define ej(st,n) for (int j = (st); j >= (int)(n); --j)
#define ek(st,n) for (int k = (st); k >= (int)(n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (int)(n); --(i))
#define ri(st,n) for (int i = (st); i < (int)(n); ++i)
#define rj(st,n) for (int j = (st); j < (int)(n); ++j)
#define rk(st,n) for (int k = (st); k < (int)(n); ++k)
#define rq(st,n) for (int q = (st); q < (int)(n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (int)(n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 2e5 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

ll a[maxn];

int main()
{
//    fin("t.in");
    sync;
    ll n, s, s1, ans;
    cin >> n;
    s = 0;
    fi(1, n)
    {
    	cin >> a[i];
    	s += a[i];
    }
    s1 = 0;
    ans = 1e18;
    fi(1, n - 1)
    {
    	s1 += a[i];
    	s -= a[i];
    	ans = min(ans, abs(s - s1));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t n;
    cin >> n;

    vector<pair<int64_t, int64_t>> p(n);
    for (auto&& pp : p) {
        cin >> pp.first >> pp.second;
    }

    double s = 0;
    for (auto pp : p) {
        for (auto qq : p) {
            s += sqrt((pp.first - qq.first) * (pp.first - qq.first) +
                      (pp.second - qq.second) * (pp.second - qq.second));
        }
    }

    cout << setprecision(10) << s / (double)n << endl;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
arr = [list(str(input())) for _ in range(n)]

for i in range(n):
  arr[i].sort()
ans = list(Counter([tuple(i) for i in arr]).values())

a = 0
for i in range(len(ans)):
  tmp = ans[i]
  a += tmp*(tmp-1)//2
  
print(a)
  


Measured memory_bytes: 47504
//In the name of ALLAH
#include <bits/stdc++.h>
using namespace std;

#define int int64_t
#define mod 1000000007


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,a,b,ans;
	cin>>n>>a>>b;
	if((b-a)%2==0)
			cout<<((b-a)/2)<<"\n";
	else{
		int d=min(a-1,n-b);
		ans=min(n-a,b-1);
		a-=d;
		b+=d;
		ans=min(ans,((b-a)/2)+1);
		cout<<ans<<"\n";
	}
}

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

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var in1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x.ToString())).ToList();
            var N = in1[0];
            var M = in1[1];
            var C = in1[2];
            var Bs = Console.ReadLine().Split(' ').Select(x => int.Parse(x.ToString())).ToList();

            var ans = 0;
            for (int i = 0; i < N; i++)
            {
                var As = Console.ReadLine().Split(' ').Select(x => int.Parse(x.ToString())).ToList();
                var sum = 0;
                for (int j = 0; j < M; j++)
                {
                    sum += As[j] * Bs[j];
                }
                ans += (sum + C > 0) ? 1 : 0; 
            }
            Console.WriteLine(ans.ToString());
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//
int main(){
    string s; cin>>s;
    int cnt0=0, cnt1=0;
    rep(i,0,s.size()){
        if(s[i]=='0') cnt0++;
        if(s[i]=='1') cnt1++;
    }
    cout<<2*min(cnt0,cnt1)<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>

using namespace std;

// 多次元配列の初期化方法確認
// 出力確認
//
void traceback (string x, string y, vector<vector<int>> L) {
	string lcs;
	int i = x.length();
	int j = y.length();
	while(i != 0 && j != 0) {
		if (L[i][j] == L[i-1][j-1] + 1) {
			lcs = x[i-1] + lcs;
			i--;
			j--;
		} else if (L[i][j-1] >= L[i-1][j]) {
			j--;
		} else if (L[i][j-1] <= L[i-1][j]) {
			i--;
		}
	}
	
	cout << lcs << endl;
}

int main(void) {
	int q;
	cin >> q;
	string x, y;
	
	while(q--) {
		cin >> x >> y;

	//	vector<vector<int>> L(max(x.length(), y.length()), 0);
		vector<vector<int>> L(x.length() + 1, vector<int>(y.length() + 1, 0));
		for (int i = 0; i <= x.length(); i++) {
			for (int j = 0; j <= y.length(); j++) {
				if (i == 0 || j == 0) L[i][j] = 0;
				else if (x[i-1] == y[j-1]) {
					L[i][j] = L[i-1][j-1] + 1;
				} else if (x[i-1] != y[j-1]) {
					L[i][j] = max(L[i-1][j], L[i][j-1]);
				}
			}
		}
		//出力がよくない状況
		cout << L[x.length()][y.length()] << endl;

		//traceback(x, y, L);
	}

}
// xi = yj
// Lij = Li-1j-1 + 1
// Lij = max(Li-1j, Lij-1)



Measured memory_bytes: 6776
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
const int MAX_C = 2010;
long long Com[MAX_C][MAX_C] = {0};

int main(){
  int H, W; cin >> H >> W;
  string S[H];
  rep(i, H){
    cin >> S[i];
  }
  bool can1 = true;
  rep(i, H){
    rep(j, W){
      bool can2=false;
      if(S[i][j]=='#'){
        if(j-1>=0) if(S[i][j-1]=='#') can2=true;
        if(i-1>=0) if(S[i-1][j]=='#') can2=true;
        if(i+1<=H-1) if(S[i+1][j]=='#') can2=true;
        if(j+1<=W-1) if(S[i][j+1]=='#') can2=true;
        if(!(can2)) can1=false;
      }
    }
  }
  if(can1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  int A,B;
  cin >>A >>B;
  if(A>12){
    cout <<B <<endl;
  }
  else if(A<13){
    if(A>5){
    cout <<B/2 <<endl;
    }
    else{
    cout <<0 <<endl;
    }
  }
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)                    \
  for (int i = 0; i < (int)(n); i++) \
    ;

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  int n;
  cin >> n;
  if (n >= 30) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3616
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = tuple(tuple(map(int, input().split())) for i in range(M)) #改行行列
    acc=[0]*N
    for l,r in S:
        l-=1;r-=1
        acc[l]+=1
        if r+1<N:
            acc[r+1]-=1
    acc=accumulate(acc)
    count=0
    for a in acc:
        if a==M:
            count+=1
    print(count)







if __name__ == "__main__":
    main()

Measured memory_bytes: 91988
#include <bits/stdc++.h>
    #define LOCAL
    using namespace std;
    template <typename A, typename B>
    ostream& operator <<(ostream& out, const pair<A, B>& a) {
    out << "(" << a.first << "," << a.second << ")";
    return out;
    }
    template <typename T, size_t N>
    ostream& operator <<(ostream& out, const array<T, N>& a) {
    out << "["; bool first = true;
    for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
    return out;
    }
    template <typename T>
    ostream& operator <<(ostream& out, const vector<T>& a) {
    out << "["; bool first = true;
    for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
    return out;
    }
    template <typename T, class Cmp>
    ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
    out << "{"; bool first = true;
    for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
    return out;
    }
    template <typename U, typename T, class Cmp>
    ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
    out << "{"; bool first = true;
    for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
    return out;
    }
    #ifdef LOCAL
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    #else
    #define trace(...) 42
    #endif
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
    }
    #define rep(i,n) for(int i=0; i<(n); i++)
    using ll = long long;
    #define int long long
    using P = pair<int,int>;
    //#########################################
    signed main(){
        int n,m;cin >> n >> m;
        vector<int> res(n,-1);
        rep(i,m){
            int a,b;cin >> a >> b;
            a--;
            if(res[a] != -1 && res[a] != b){
                cout << -1 << endl;
                return 0;
            }
            res[a] = b;
        }
        if(n == 1){
            if(res[0] == -1)cout << 0 << endl;
            else cout << res[0] << endl;
            return 0;
        }
        if(res[0] == 0){
            cout << -1 << endl;
            return 0;
        }
        if(res[0] == -1)res[0] = 1;
        rep(i,n){
            if(res[i] == -1)res[i] = 0;
        }
        int ret = 0;
        rep(i,res.size()){
            ret *= 10;
            ret += res[i];
        }
        cout << ret << endl;

        return 0;
    }

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

#define N 500005
#define maxN 1000000007
#define PI 3.14159265358979
#define bb __builtin_popcount
#define ll long long
int a[N], b[N], c[N], tr[N], d[1000][1000];
vector<int> q;
string s, ss;
bool check() {
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != ss[i]) {
            char ch = s[i];
            char ch2 = ss[i];
            if (d[s[i]][ss[i]]) return false;
            d[s[i]][ss[i]] = 1;
            d[ss[i]][s[i]] = 1;
            for (int j = 0; j < s.size(); j++) {
                if (s[j] == ch) s[j] = ch2;
                else if (s[j] == ch2) s[j] = ch;

            }
        }
    }
    for (int i = 0; i < s.size(); i++)
        if (s[i] != ss[i]) return false;
    return true;
}
void solve() {
    cin >> s >> ss;
    bool ans = check();
    //cout << s << endl;
    //cout << ss << endl;
    if (ans) cout << "Yes";
    else cout << "No";
}
int main() {
    //freopen("main1.in", "r", stdin);
    //freopen("main.in", "w", stdout);
    //freopen("main.out", "w", stdout);
    solve();
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}
///Hamita


Measured memory_bytes: 904
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N,M = map(int,input().split())
    shirube = [None]*(N+1)
    shirube[1] = (1,0)
    mmap = [[] for _ in range(N+1)]
    for _ in range(M):
        a,b = map(int,input().split())
        mmap[a].append(b)
        mmap[b].append(a)
    queue = deque()
    queue.appendleft((1,0))
    while queue:
        current_node, distance = queue.pop()
        for next_node in mmap[current_node]:
            new_distance = distance+1
            if shirube[next_node] is None:
                shirube[next_node] = (current_node, new_distance)
                queue.appendleft((next_node, new_distance))
            elif shirube[next_node][1] > new_distance:
                shirube[next_node] = (current_node, new_distance)
                queue.appendleft((next_node, new_distance))
    shirube = shirube[1::]
    if None in shirube:
        print("No")
        return
    print("Yes")
    for s in shirube[1::]:
        print(s[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 46116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<(int)c;++i)
int main(){
  int a,b;
  cin >> a>> b;
  vector<string>c(a);
  rep(i,a){
    cin >> c[i];
  }
  sort(c.begin(),c.end());
  rep(i,a){
  cout << c[i];
  }
  cout << endl;
  return 0;
}

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

int main()
{
  int n;
  cin>>n;
  vector<int> v(n);
  long long int sum=0;
  for(int &i:v) {cin>>i;sum+=i;}
  if(sum%10!=0)
  {
    cout<<sum<<"\n";
    return 0;
  }
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++)
  {
    if((sum-v[i])%10!=0)
    {
      cout<<(sum-v[i])<<"\n";
      return 0;
    }
  }
  cout<<"0\n";
  return 0;
}


Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;


bool isOdd(int64_t v) {
    return v & 1;
}

int main()
{
    std::vector<int64_t> V(3);
    std::cin >> V[0] >> V[1] >> V[2];

    std::sort(std::begin(V), std::end(V));

    int64_t count = 0;
    for (;;) {
        if (isOdd(V[0]) || isOdd(V[1]) || isOdd(V[2])) {
            break;
        }

        std::vector<int64_t> VV(3);
        VV[0] = V[1]/2 + V[2]/2;
        VV[1] = V[0]/2 + V[2]/2;
        VV[2] = V[0]/2 + V[1]/2;

        std::sort(std::begin(VV), std::end(VV));

        if (V[0] == VV[0] &&
            V[1] == VV[1] &&
            V[2] == VV[2]) {
            count = -1;
            break;
        }

        V = VV;
        count ++;
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void swap(double& x, double& y)
{
	double tmp = x; x = y; y = tmp;
}

int main()
{
	double xa[2], ya[2], xb[2], yb[2];
	
	while ( cin >> xa[0] >> ya[0] >> xa[1] >> ya[1] >> xb[0] >> yb[0] >> xb[1] >> yb[1] ) {
		if ( (xb[1] < xa[0]) || (xa[1] < xb[0]) || (yb[1] < ya[0]) || (ya[1] < yb[0]) ) cout << "NO";
		else cout << "YES";
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3104
using System;

class MainClass
{
    public static void Main(string[] args)
    {
        var abk = Console.ReadLine().Split();
        var a = long.Parse(abk[0]);
        var b = long.Parse(abk[1]);
        var k = long.Parse(abk[2]);

        var x = Math.Max(0, a - k);
        var y = Math.Max(0, a + b - k - x);

        Console.WriteLine(x);
        Console.WriteLine(y);
    }
}


Measured memory_bytes: 11092
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
vector<int> par,sz;
int find(int x){while(x!=par[x])x=par[x]; return x;}
void uni(int a,int b)
{
	a=find(a);b=find(b);
	if(a==b)return;
	if(sz[a]<sz[b])swap(a,b);
	par[b]=a;sz[a]+=sz[b];
}
bool same(int a,int b)
{
	return find(a)==find(b);
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("in","r",stdin);
		freopen("out","w", stdout);
	#endif
	int n,m;scanf("%lld%lld",&n,&m);
	sz=vector<int>(n+1,1);
	par=vector<int>(n+1);iota(par.begin(),par.end(),0);
	
	vector<int> p(n+1);
	for(int i=1;i<=n;i++)scanf("%lld",&p[i]);

	int u,v;
	for(int i=0;i<m;i++)
	{
		scanf("%lld%lld",&u,&v);
		uni(u,v);
	}

	int ct=0;
	for(int i=1;i<=n;i++)
	{
		if(same(i,p[i]))ct++;
	}
	printf("%lld\n",ct );

	

}

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

int main() {
    string W;
    string Ti;
    int count = 0;
    cin >> W;
    for (int i=0;i<W.size();i++) {
        if (isupper(W[i])) {
            W[i] = tolower(W[i]);
        }
    }
    while(1) {
        cin >> Ti;
        if (Ti == "END_OF_TEXT") break;
        for (int i=0;i<Ti.size();i++) {
            if (isupper(Ti[i])) {
                Ti[i] = tolower(Ti[i]);
            }
        }
        if (Ti == W) {
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
using namespace std;
int main() {
	int n;
	cin >>n;
	vec b(n);
	vec a(n);
	rip(i, n-1) {
		cin >> a[i];
		b[a[i]-1]++;
	}
	rip(i, n) cout << b[i] << endl;
}

Measured memory_bytes: 4840
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll N;cin>>N;
    vector<ll> a(N);
    REP(i,N)cin>>a[i];
    ll cnt=0;
    ll idx=1;
    REP(i,N){
        if(a[i]==idx){
            idx++;
        }
        else{
            cnt++;
        }
    }
    if(idx==1)cout<<-1<<"\n";
    else cout<<cnt<<"\n";
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

int main() {
  string s;
  cin >>s;
  int sl=sz(s);
  vector<pair<char,int>>a;
  vector<int>ans(sl);
  char tmp='R';
  int cnt=1;
  for(int i=1;i<=sl;i++){
   	if(i==sl) a.push_back(make_pair(tmp,cnt)); 	
  	else if(tmp==s.at(i)) cnt++;
  	else {
  		a.push_back(make_pair(tmp,cnt)); 
  		tmp=s.at(i);
  		cnt=1;
  	}
  }
  int ind=-1,i=0,bl=sz(a);
  while(i<bl){
  	cnt=a[i].second+a[i+1].second;
    ind+=a[i].second;
    ans.at(ind)=(a[i].second-1)/2+1;
    ans.at(ind)+=(a[i+1].second)/2;
    ans.at(ind+1)=cnt-ans.at(ind);
    ind+=a[i+1].second;
    i=i+2;
  }
  rep(j,sl) cout << ans.at(j) << " "; 
}


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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  
  int count5 = 0;
  int count7 = 0;
  
  if (A == 5) {
    count5++;
  } else if (A == 7) {
    count7++;
  } 
  if (B == 5) {
    count5++;
  } else if (B == 7) {
    count7++;
  } 
  if (C == 5) {
    count5++;
  } else if (C == 7) {
    count7++;
  }   
  
  if (count5 == 2 && count7 == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return 0;
}
    

Measured memory_bytes: 256
#include <iostream>

int main() {
    //freopen("D.out", "wt", stdout);
    unsigned long long steps = 0;
    std::cin >> steps;
    if (steps <= 100) {
        std::cout << "2\n" << (steps + 3) / 2 << " " << steps / 2 << "\n";
    }
    else {
        std::cout << "50\n";
        if (steps % 50) {
            for (int i = 0; i < steps % 50; ++i) {
                std::cout << 49 + steps / 50 + 1 << " ";
            }
            for (int i = steps % 50; i < 50; ++i) {
                std::cout << 49 + steps / 50 - steps % 50 << " ";
            }
            std::cout << "\n";
        }
        else {
            for (int i = 0; i < 50; ++i) {
                std::cout << 49 + steps / 50 << " ";
            }
            std::cout << "\n";
        }
        /*
        for (int i = 0; i < 49; ++i) {
            std::cout << 49 + steps / 50 - steps % 50 << " ";
        }
        std::cout << 49 + steps / 50 + 50 * (steps % 50) << "\n";
        */
    }
   // system("pause");
    return 0;
}

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

cnt = 0
for i in range(n - 2):
    for j in range(i, n - 1):
        for k in range(j, n):
            a, b, c = ls[i], ls[j], ls[k]
            if a == b or b == c or c == a:
                continue
            if a + b > c and b + c > a and c + a > b:
                cnt += 1

print(cnt)


Measured memory_bytes: 9128
n = int(input())
a = list(map(int, input().split()))

dp = [0] * (n + 1000)
dp[0] = 1000

for i in range(1, n):
    for j in range(i):
        stock = dp[j] // a[j] * a[i] + dp[j] % a[j]
        dp[i] = max(dp[i - 1], stock)
print(dp[n-1])

Measured memory_bytes: 8876
using System;

namespace Aizu
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var inputs = input.Split(' ');
            var a = int.Parse(inputs[0]);
            var b = int.Parse(inputs[1]);

            if (a < b)
            {
                Console.WriteLine("a < b");
            }
            else if (a > b)
            {
                Console.WriteLine("a > b");

            }
            else
            {
                Console.WriteLine("a == b");

            }
        }
    }
}

Measured memory_bytes: 9020
#include<iostream>
#include<string>
using namespace std;
int result[200]={};
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int i,M,N,a,b;
	cin >> N;
    cin >> M;
    for(i=0;i<M;i++){
        cin >> a;
        cin >> b;
        result[a]=result[a]+1;
        result[b]=result[b]+1;
    }
    for(i=0;i<N;i++){
        cout << result[i+1] << "\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

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

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

    ll a, b;
    cin >> a >> b;
    if(a == 1 || b == 1) {
        cout << 1 << endl;
        return 0;
    }
    ll c = a * b + 1;
    cout << c / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long int
#define FAST ios_base::sync_with_stdio(false);
#define INPT cin.tie(NULL);
#define OUTPT cout.tie(NULL);
#define fori(i,a,b) for(i=a;i<b;i++)
#define forireverse(i,a,b) for(i=a;i>=b;i--)
#define full(x) x.begin(),x.end()
#define sortV(x) sort(full(x))
#define sortVgr(x) sort(full(x),greater<LL>()) // x -> vector
#define reverse(x) reverse(full(x)) // x -> string
#define go(t) while(t--)
#define endl cout<<"\n"
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define M 1e9+7
 
LL gcd(LL a, LL b)
{
	if(a==0) return b;
	else return gcd(b%a,a);
}
 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("inputAtC.txt","r",stdin);
	freopen("outputAtC.txt","w",stdout);
	#endif
	FAST INPT OUTPT
	LL t=1;
	//cin>>t;
	go(t)
	{
		string s;
      	cin>>s;
		LL i,maxm=0,cnt=0;
      	char A[4];
        strcpy(A,s.c_str());
        cnt=count(A,A+3,'R');
        if(cnt==0) cout<<0;
        else if(cnt==3) cout<<3;
        else if(cnt==2)
        {
            if(A[1]=='S') cout<<1;
            else cout<<2;
        }
        else cout<<1;
        endl;
	}
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	string S;
	cin >> N >> S;
	int count = 0;
	for (int i = 0; i < N - 2; i++)
	{
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
			count++;
	}
	cout << count << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int A, B, C, D, mx;

int Mx(int a, int b, int t) {
    if(t) {
        if(a == 0) return 1e9;
        if(a >= b) return (a + b) / (b + 1);
        else return (a + b - 1) / a;
    }
    else {
        if(b == 0) return 1e9;
        if(a >= b) return (a + b - 1) / b;
        else return (a + b) / (a + 1);
    }
}

int f(int a, int b) {
    int s = 0, e = min(mx, a), p;
    while(s <= e) {
        int m = (s + e)>>1;

        if(a - m >= b) {
            if(Mx(a - min(a - b, mx), b, 0) <= mx) {
                p = m;
                s = m + 1;
            }
            else e = m - 1;
        }
        else {
            if(Mx(a - m, b, 0) <= mx) {
                p = m;
                s = m + 1;
            }
            else e = m - 1;
        }
    }
    return p;
}

int g(int a, int b) {
    int s = 1, e = min(mx, b), p;
    while(s <= e) {
        int m = (s + e)>>1;

        if(a >= b - m) {
            if(Mx(a, b - max(1, b - a), 1) <= mx || (a == 0 && b - max(1, b - a) == 0)) {
                p = m;
                e = m - 1;
            }
            else s = m + 1;
        }
        else {
            if(Mx(a, b - m, 1) <= mx || (a == 0 && b - m == 0)) {
                p = m;
                e = m - 1;
            }
            else s = m + 1;
        }
    }
    return p;
}

int h(int a, int b, int an, int bn) {
    int s = 1, e = min((an == 0? (int)1e9 : a / an), (bn == 0? (int)1e9 : b / bn)), p;
    while(s <= e) {
        int m = (s + e)>>1;

        if(Mx(a - m * an, b - m * bn, 1) <= mx || (a - m * an == 0 && b - m * bn == 0)) {
            p = m;
            s = m + 1;
        }
        else e = m - 1;
    }

    return p;
}

struct Seg {
    int l, r, da, db;
};
vector<Seg> seg;
vector<int> psum;

void main2() {
    scanf("%d %d %d %d", &A, &B, &C, &D);

    mx = min(Mx(A, B, 0), Mx(A, B, 1));

    seg.clear();

    int a = A, b = B, an, bn, n, pos = 0;
    while(1) {
        if(b == 0) {
            if(a) seg.push_back({ pos, pos + a - 1, a, 0 });
            break;
        }
        an = f(a, b);
        bn = g(a - an, b);
        n = h(a, b, an, bn);

        if(an == 0) {
            seg.push_back({ pos, pos + bn - 1, 0, bn });
            pos += bn;
            b -= bn;
            continue;
        }

        seg.push_back({ pos, pos + (an + bn) * n - 1, an, bn });
        pos += (an + bn) * n;
        a -= an * n;
        b -= bn * n;
    }

    psum.clear();
    psum.resize(seg.size());

    for(int i = 0; i < seg.size(); i++) {
        psum[i] = seg[i].r - seg[i].l + 1;
        if(i) psum[i] += psum[i - 1];
    }

    int s = 0, e = (int)seg.size() - 1, p;
    while(s <= e) {
        int m = (s + e)>>1;

        if(psum[m] >= C) {
            p = m;
            e = m - 1;
        }
        else s = m + 1;
    }

    C--; D--;
    for(int i = C; i <= D; i++) {
        if(seg[p].r < i) p++;
        printf("%c", ((i - seg[p].l) % (seg[p].da + seg[p].db) < seg[p].da? 'A' : 'B'));
    }
    printf("\n");
}

int TC;
int main() {
    scanf("%d", &TC);
    while(TC--) main2();
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
#define SIZE 201
int table[SIZE+1][SIZE+1];

int gcd(int a, int b){
    while(1){
        if(a < b) swap(a, b);
        if(!b) break;
        a %= b;
    }
    return a;

}

int main()
{
    int k;  cin >> k;
    long long int sum = 0;

    for(int i=1; i<=k; i++){
        for(int j=1; j<=k; j++){
            for(int l=1; l<=k; l++){
                sum += gcd(gcd(i,j),l);
            }
        }
    }

    cout << sum << endl;
    return 0;

}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1);
int sig(double r){return (r<-EPS)?-1:(r>+EPS)?+1:0;}
struct Pt{
	double x,y;
	Pt(){}
	Pt(double x,double y):x(x),y(y){};
	Pt operator+(const Pt &a)const{return Pt(x+a.x,y+a.y);}
	Pt operator-(const Pt &a)const{return Pt(x-a.x,y-a.y);}
	Pt operator*(const Pt &a)const{return Pt(x*a.x-y*a.y,x*a.y+y*a.x);}
	Pt operator-()const{return Pt(-x,-y);}
	Pt operator*(const double &k)const{return Pt(x*k,y*k);}
	Pt operator/(const double &k)const{return Pt(x/k,y/k);}
	double abs()const{return sqrt(x*x+y*y);}
	double abs2()const{return x*x+y*y;}
	double arg()const{return atan2(y,x);}
	double dot(const Pt&a)const{return x*a.x+y*a.y;}
	double det(const Pt&a)const{return x*a.y-y*a.x;}
};
inline bool operator<(const Pt&a,const Pt&b){
	if(sig(a.x-b.x))return a.x<b.x;
	return a.y<b.y;
}
double tri(const Pt&a,const Pt&b,const Pt&c){return (b-a).det(c-a);}
 
int iSP(Pt a,Pt b,Pt c){
	int s=sig((b-a).det(c-a));
	if(s)return s;
	if(sig((b-a).dot(c-a))<0)return -2;
	if(sig((a-b).dot(c-b))<0)return +2;
	return 0;
}
int iLL(Pt a,Pt b,Pt c,Pt d){
	if(sig((b-a).det(d-c)))return 1;
	if(sig((b-a).det(c-a)))return 0;
	return -1;
}
bool iSS(Pt a,Pt b,Pt c,Pt d){
	return (iSP(a,b,c)*iSP(a,b,d)<=0&&iSP(c,d,a)*iSP(c,d,b)<=0);
}
Pt pLL(Pt a,Pt b,Pt c,Pt d){
	b=b-a;d=d-c;return a+b*(c-a).det(d)/b.det(d);
}
int sGP(int n,Pt p[],Pt a){
	int side=-1,i;
	p[n]=p[0];
	for(i=0;i<n;i++){
		Pt p0=p[i]-a,p1=p[i+1]-a;
		if(sig(p0.det(p1))==0&&sig(p0.dot(p1))<=0)return 0;
		if(p0.y>p1.y)swap(p0,p1);
		if(sig(p0.y)<=0&&0<sig(p1.y)&&sig(p0.det(p1))>0)side=-side;
	}
	return side;
}
 
int g[100][100];
long long to[100];
Pt poly[100];
int wolf;
int N;
int dfs(int a,int b,long long c){
	if(a==N){
		if(c==(1LL<<N)-1)return 1;
		return 0;
	}
	int val=dfs(a+1,b,c);
	if(val)return 1;
	
	if(b==wolf)return 0;
	
	val=dfs(a+1,b+1,c|to[a]);
	
	if(val)return 1;
	return 0;
}
int X[100];
int Y[100];
pair<double,Pt> pts[1000];
int main(){
	int a;
	scanf("%d",&a);
	N=a;
	for(int i=0;i<a;i++)scanf("%d%d",X+i,Y+i);
	for(int i=0;i<a;i++)g[i][i]=1;
	for(int i=0;i<a;i++)poly[i]=Pt(X[i],Y[i]);
	for(int i=0;i<a;i++)
		for(int j=0;j<a;j++){
			if(i==j)continue;
			int sz=0;
			
			//printf("%d %d:\n",i,j);
			for(int k=0;k<a;k++){
				if(iLL(poly[i],poly[j],poly[k],poly[(k+1)%a])!=-1&&iSS(poly[i],poly[j],poly[k],poly[(k+1)%a])){
					Pt point=pLL(poly[i],poly[j],poly[k],poly[(k+1)%a]);
					pts[sz++]=make_pair(point.x*114514+point.y,point);
				}
			}
			if(sz<2){
				g[i][j]=1;
				continue;
			}
			std::sort(pts,pts+sz);
			bool ok=true;
			for(int k=0;k<sz-1;k++){
				Pt M=(pts[k].second+pts[k+1].second)/2.0;
				//printf("(%f, %f)",M.x,M.y);
				if(!~sGP(a,poly,M)){
					ok=false;
				//	printf("---!!!---");
				}
				//printf("\n");
			}
			if(ok)g[i][j]=1;
		}
	
	//for(int i=0;i<a;i++){
	//	for(int j=0;j<a;j++)printf("%d ",g[i][j]);
	//	printf("\n");
	//}
	for(int i=0;i<a;i++)
		for(int j=0;j<a;j++)
			if(g[i][j])to[i]+=(1LL<<j);
	for(int i=1;i<=9;i++){
		wolf=i;
		if(dfs(0,0,0)){
			printf("%d\n",i);
			return 0;
		}
	}
	printf("10\n");
}

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

using namespace std;

typedef long long ll;

main(){
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  if(k==0) ans = n*n;
  else{
    ans += ((n-k)*(n-k+1)/2);
    for(int i=k+1;i<=n;++i){
      ll val = (n/i) - 1;
      ans += (val*(i-k));
      ans += max(0LL,(n%i) - k+ 1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<climits>
#include<vector>
using namespace std;
#define LL long long
#define N 5005
#define M 205
#define INF LL(1e18)
/*
一个区间[l,r]确定的时候,答案就确定了 就是每个m的最大值减去路程
这个可以用st表来做 每个m都建一个st表
如果n^2枚举左右端点的话，复杂度太高
而且[l,r],[l,r+1]的答案可能会是一样的，存在重复计算的情况 
然后对于一个区间[l,r],如果l是r的最优的左端点
那么当r往右移时，l一定不会往左移
可以理解为r的决策点满足单调性 就可以用分治做了
定义dp[r]表示以r作为区间右端点的最优的值 
*/
int rd()
{
	int f=1,x=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return f*x;
}
int n,m;
LL s[N],dp[N],ans;
int lg[N],st[M][N][20];
int Max(int i,int l,int r)
{
	int l1=lg[r-l+1];
	return max(st[i][l][l1],st[i][r-(1<<l1)+1][l1]);
}
void dfs(int l,int r,int optl,int optr)
{
	if(l>r) return ;
	int mid=(l+r)>>1,optm;
	LL res=0;
	for(int i=optl;i<=min(optr,mid);i++)
	{//枚举mid的左端点 
		LL tot=s[i]-s[mid];//先减去路程 
		for(int j=1;j<=m;j++)
			tot+=Max(j,i,mid);//i~mid的食物j的最大值
		if(tot>res) res=tot,optm=i;
	}
	dp[mid]=res;
	dfs(l,mid-1,optl,optm);
	dfs(mid+1,r,optm,optr);
}
int main()
{
	//freopen("restaurants.in","r",stdin);
	//freopen("restaurants.out","w",stdout);
	n=rd(),m=rd();
	for(int i=2;i<=n;i++)
	{
		scanf("%lld",&s[i]);
		s[i]+=s[i-1];
		lg[i]=lg[i>>1]+1;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			st[j][i][0]=rd();
	for(int i=1;i<=m;i++)
		for(int k=1;k<20;k++)
			for(int j=1;j+(1<<(k-1))<=n;j++)
				st[i][j][k]=max(st[i][j][k-1],st[i][j+(1<<(k-1))][k-1]);
	dfs(1,n,1,n);
	for(int i=1;i<=n;i++)
		ans=max(ans,dp[i]);
	printf("%lld\n",ans);
}

Measured memory_bytes: 79872