akhauriyash/Code-Regression huggingface dataset:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
INIT_VAL = 0
def DD2(d1,d2): return [[INIT_VAL]*d2 for _ in range(d1)]
def DD3(d1,d2,d3): return [DD2(d2,d3) for _ in range(d1)]
## math ##
MOD=10**9+7
def divc(x,y): return -(-x//y)
def divf(x,y): return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers"""
    is_prime = [True] * MAX_NUM
    is_prime[0] = False
    is_prime[1] = False
    primes = []
    for i in range(MAX_NUM):
        if is_prime[i]:
            primes.append(i)
            for j in range(2*i, MAX_NUM, i):
                is_prime[j] = False
    return primes
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

#======================================================#

def main():
    a, b, c, d = MII()
    if a+b>c+d: print('Left')
    elif a+b<c+d: print('Right')
    else: print('Balanced')

if __name__ == '__main__':
    main()

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

s = 0
last = a[-1]

for i in range(n-1):
    if a[i] <= last:
        tmp = a[i]
        a[i] = a[s]
        a[s] = tmp
        s += 1
tmp = a[-1]
a[-1] = a[s]
a[s] = tmp

for i in range(0, s):
    print(a[i], end=' ')
print('[' + str(a[s]) + '] ', end='')
for i in range(s+1, n-1):
    print(a[i], end=' ')
print(a[n-1])


Measured memory_bytes: 16380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b,h[100005],ans[100005];
bool check(ll x)
{
	for(int i=1;i<=n;i++)
	{
		ll val=h[i];
		val-=x*b;
		if(val>0)
		{
			ans[i]=(val-1)/(a-b)+1;
		}
		else ans[i]=0;
	}
	ll tot=0;
	for(int i=1;i<=n;i++) tot+=ans[i];
	return tot<=x;
}
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	for(int i=1;i<=n;i++) scanf("%lld",&h[i]);
	ll l=1,r=1e9;
	while(r-l>1)
	{
		//printf("l=%lld r=%lld\n",l,r);
		ll mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid;
	}
	if(check(l)) printf("%lld\n",l);
	else printf("%lld\n",r);
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>

void printFrame(int x, int y) {
    int i, j;
    for(i=0;i<y;i++) printf("#");
    printf("\n");
    for(i=2;i<x;i++) {
        printf("#");
        for(j=2;j<y;j++) printf(".");
        printf("#\n");
    }
    for(i=0;i<y;i++) printf("#");
    printf("\n\n");
}

int main() {
    int x=-1, y=-1;
    for(;;) {
        scanf("%d %d", &x, &y);
        if (x==0 && y==0) break;
        printFrame(x, y);
    }
    return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int c = 0;
  int ans = s.size();
  rep(i,s.size()){
    if(s[i] == 'S'){
      c++;
    }
    else{
      if(c){
        ans--;
        ans--;
        --c;
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 720
n,c=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
for i in range(n):
  if a[i]>c:
    print(i)
    break
  else:
    c-=a[i]
else:
  if c>0:
    print(n-1)
  else:
    print(n)

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

struct SegmentTree{
    int n;
    vector<int> node;

    SegmentTree(vector<int> a){
        int n_ = a.size();

        n = 1;
        while(n<n_) n *= 2;

        node.resize(2*n-1, 0);
        rep(i,n_) node[n-1+i] = a[i];
        for(int i=n-2; i>=0; i--) node[i] = max(node[2*i+1], node[2*i+2]);
    }

    int RMQ(int a, int b, int k=0, int l=0, int r=0){
        if(l>=r) r = n;
        if(a>=r || b<=l) return 0;
        if(a<=l && r<=b) return node[k];

        int vl = RMQ(a, b, 2*k+1, l, (l+r)/2);
        int vr = RMQ(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }

    void setvalue(int i, int x){
        int k = n-1+i;
        node[k] = x;

        while(true){
            k = (k-1)/2;
            node[k] = max(node[2*k+1], node[2*k+2]);
            if(k == 0) break;
        }
    }
};

int main()
{
    int n, k; cin >> n >> k;
    int a[n];
    int max_a = 0;
    rep(i,n) cin >> a[i], max_a = max(max_a, a[i]);

    vector<int> v(max_a+1);
    rep(i,max_a+1) v[i] = 0;

    SegmentTree seg = SegmentTree(v);

    rep(i,n){
        int l = max(0,a[i]-k);
        int r = min(max_a, a[i]+k);
        int temp = seg.RMQ(l,r+1);
        seg.setvalue(a[i], temp+1);
    }
    cout << seg.RMQ(0,max_a+1) << endl;
}

Measured memory_bytes: 10904
s = input ()
x = 0
l = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range (len(l)):
  if s.count(l[i]) == 0:
    print (l[i])
    x = 1
    break
if x == 0:
  print ('None')

Measured memory_bytes: 9060
S = input().split(" ")
N = int(S[0])
M = int(S[1])
ARR = []

for i in range(M):
    ARR.append([int(s) for s in input().split(" ")])


def calculate(n,m,arr):
    tmp = []
    tmp2 = {}

    for ar in arr:
        f = ar[0]
        t = ar[1]
        if f == 1:
           tmp.append(t)

        tmp2.__setitem__((f,t),True)

    if tmp2.get((1,N)) == True:
        print("POSSIBLE")
        return

    for tm in tmp:
        if tmp2.get((tm,N)) == True:
            print("POSSIBLE")
            return


    print("IMPOSSIBLE")



calculate(N,M,ARR)



Measured memory_bytes: 68972
#include <stdio.h>
#include <string.h>

char s[10000];
char s1[10000];


int main()
{
    while(gets(s)!=NULL&&gets(s1)!=NULL)
    {
     int j=0;
     int length=strlen(s);
     //printf("%c\n",s[length]);
     for(int i=length-1;i>=0;i--)
     {
         if(s1[j]!=s[i])
         {
             printf("NO\n");
             return 0;
         }
         j++;
     }
     printf("YES\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using namespace std;
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)
using ipair = std::pair<ll,ll>;


//素数判定
bool prime_number(int a){
    int flag = true;
    for(int i=2;i<sqrt(a)+1;i++){
        if(a%i==0){flag=false;break;}
    }
    return flag;
}

int main(){
    int Q,l,r;
    bool flag1;
    vector<bool> pVec(50100,false);
    vector<int> sumVec(50100,0);
    pVec[1] = true;
    sumVec[1] = 1;
    for(int i=5;i<(int)1e5+1;i=i+2){
        flag1 = prime_number(i);
        pVec[(i-1)/2] = flag1;
        int tmp = (i+1)/2;
        if (flag1 && tmp%2 ==1 && pVec[(tmp-1)/2]){
            sumVec[(i-1)/2] = sumVec[(i-1)/2-1]+1; 
        }else sumVec[(i-1)/2] = sumVec[(i-1)/2-1];
    }

    cin >> Q;
    int ans[Q];

    rep(i,0,Q){
        cin >> l >> r;
        if(l==1) ans[i]= sumVec[(r-1)/2];
        else  ans[i]=sumVec[(r-1)/2]-sumVec[(l-1)/2-1];
    }
    for(auto x:ans) cout << x << endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;

const ll INF = pow(10,18)+1;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

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

ll N, res;

void dfs(string str){
    if(str != "" && stoll(str) > N) return;
    ll three = 0, five = 0, seven = 0;
    for(ll i = 0; i < str.size(); ++i){
        if(str[i]=='7') seven++;
        if(str[i]=='5') five++;
        if(str[i]=='3') three++;
        if(seven > 0 && five > 0 && three > 0){
            res++;
            break;
        }
    }
    dfs(str+'7');
    dfs(str+'5');
    dfs(str+'3');
}
int main(){
    cin >> N;
    dfs("");
    cout << res << endl;
    return 0;
}

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

int calc(string a, string b) {
    int n = a.size();
    b += b + b;
    vector<int> sum(3*n+1, 0);
    for (int i = 0; i < 3*n; i++) {
        sum[i+1] = sum[i] + (b[i] == '1');
    }
    int ret = 1e9;
    for (int i = 0; i <= n; i++) {
        vector<int> v;
        for (int j = 0; j < n; j++) {
            if (a[j] != b[i+j]) v.emplace_back(j);
        }
        if (v.empty()) {
            ret = min(ret, n - i);
            continue;
        }
        auto right = [&](int j) {
            int l = -1; int r = n;
            while (r - l > 1) {
                int m = (l + r) / 2;
                if (sum[n+j+1+m] - sum[i+j] == 0) l = m;
                else r = m;
            } 
            return r;
        };
        auto left = [&](int j) {
            int l = 0; int r = i+1;
            while (r - l > 1) {
                int m = (l + r) / 2;
                if (sum[n+j+1] - sum[m+j] == 0) r = m;
                else l = m;
            }
            return i - l;
        };
        vector<pair<int, int>> s;
        for (auto &x: v) {
            s.emplace_back(left(x), right(x));
        }
        sort(s.rbegin(), s.rend());
        int maxi = 0, tmp = 1e9;
        for (int i = 0; i < s.size(); i++) {
            tmp = min(tmp, maxi + s[i].first);
            maxi = max(maxi, s[i].second);
        }
        tmp = min(tmp, maxi) * 2 + n - i + v.size(); 
        ret = min(ret, tmp);
    }
    return ret;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string a, b; cin >> a >> b;
    if (a == b) {
        cout << 0 << "\n";
        return 0;
    }
    string d = b;
    sort(d.begin(), d.end());
    if (d.back() == '0') {
        if (a == b) cout << 0 << "\n";
        else cout << -1 << "\n";
        return 0;
    }
    int ans = 1e9;
    ans = min(ans, calc(a, b));
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    ans = min(ans, calc(a, b));
    cout << ans << "\n";
    return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  int a[100100];
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
  int kekka;
  if(n == k){
    cout << 1 << endl;
  }
  else if((n-k) % (k-1) == 0){
    kekka = (n-k)/(k-1) + 1;
    cout << kekka << endl;
  }
  else{
    kekka = (n-k)/(k-1) + 2;
    cout << kekka << endl;
  }
}

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

int main()
{
  ll n;
  string s;
  cin >> n;
  cin >> s;
  if(n%2==1)
  {
    cout << "No" << endl;
    return 0;
  }
  for (ll i = 0; i < n/2; i++)
  {
    if(s[i]!=s[i+n/2]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define Fast_IO() ios_base::sync_with_stdio(false);cin.tie(0)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define _ <<" "<<
const int MOD = 1000 * 1000 * 1000 + 7; // odd modulus
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
const int N = 1000 * 1000 ;
int main()
{
    Fast_IO();

ll a , b ;
cin >> a>> b ;
cout << max ({a+b , a- b , a * b });

    return 0 ;
}










Measured memory_bytes: 256
//02-03-2020

#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,r;
    cin>>n>>r;

    if(n>=10)
        cout<<r<<"\n";
    else
        cout<<r+(100*(10-n))<<"\n";
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    if(s[0] >= 'a' && s[0] <= 'z'){
        cout<<'a'<<endl;
    }
    else{
        cout<<'A'<<endl;
    }

    return 0;
}


Measured memory_bytes: 3648
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class ESequenceDecomposing {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        vector<ll> a(n, 0);
        rep(i, n){
            in >> a[i];
        }

        vector<ll> head;
        rep(i, n){
            int ind = distance(head.begin(), lower_bound(all(head), a[i]));
            if(ind == 0){
                head.insert(head.begin(), a[i]);
            }else{
                head[ind-1] = a[i];
            }
        }

        out << head.size() << endl;
	}
};


int main() {
	ESequenceDecomposing solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

string l,r,ans;
int lnow = 0,rnow = 0;
void dfs(){
	if(l[lnow]==')'&&r[rnow]==')')return;
	else if(l[lnow]==')'){
		int t = 2,cnt = 0;
		while(1){
			if(r[rnow]=='(')cnt++;
			else if(r[rnow]==')'){
				cnt--;
				if(cnt==0)t--;
				if(t==0){
					rnow++;
					return;
				}
			}
			rnow++;
		}
		return;
	}
	else if(r[rnow]==')'){
		int t = 2,cnt = 0;
		while(1){
			if(l[lnow]=='(')cnt++;
			else if(l[lnow]==')'){
				cnt--;
				if(cnt==0)t--;
				if(t==0){
					lnow++;
					return;
				}
			}
			lnow++;
		}
		return;
	}
	lnow++;
	rnow++;
	ans += '(';
	dfs();
	lnow++;
	rnow++;
	ans += ')';
	lnow++;
	rnow++;
	ans += '[';
	int lroot = 0;
	while(isdigit(l[lnow])){
		lroot = lroot*10 + (l[lnow]-'0');
		lnow++;
	}
	int rroot = 0;
	while(isdigit(r[rnow])){
		rroot = rroot*10 + (r[rnow]-'0');
		rnow++;
	}
	ans += to_string(lroot+rroot);
	lnow++;
	rnow++;
	ans += ']';
	lnow++;
	rnow++;
	ans += '(';
	dfs();
	lnow++;
	rnow++;
	ans += ')';
}
 
signed main(){
	IOS();
	cin>>l>>r;
	dfs();
	cout<<ans<<endl;
}


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

int main()
{
    //freopen("test.txt","r",stdin);
    string s;
    cin>>s;
    bool flag =false;
    bool is_find = false;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='C'&&!flag)
        {
            flag = true;
        }else if(s[i]=='F'&&flag)
        {
            is_find = true;
            cout<<"Yes"<<endl;
            break;
        }
    }
    if(!is_find)
    {
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    void solve() {
        Scanner sc = new Scanner(System.in);
        int number = sc.nextInt(); // N
        int initialPoint = sc.nextInt(); // K
        int roundCount = sc.nextInt(); // Q
        int[] winners = new int[roundCount]; // A[i]
        for (int i = 0; i < roundCount; i++) {
            winners[i] = sc.nextInt() - 1;
        }
        int[] points = new int[number];
        for (int winner : winners) {
            points[winner]++;
        }
        for (int i = 0; i < number; i++) {
            if((initialPoint - (roundCount - points[i])) > 0) {
                System.out.println("Yes");
            }
            else {
                System.out.println("No");
            }
        }
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 59956
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
//inv [ i ] = (modn - modn/i)*inv[ modn%i ] %modn;
const int N = 100005;
LL f[N];
LL calc(LL a, LL b){
    LL sum = 1;
    while(b){
        if(b&1) sum = sum * a % modn;
        a = a * a % modn;
        b >>=1;
    }
    return sum % modn;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int n,k;
    cin >> n >> k;
    f[k] = 1;
    LL ans = k;
    for(int i = k - 1; i >= 1; --i){
        LL m = k / i;
        LL sum = calc(m, n);
        for(int j = 2 * i; j <= k; j += i){
            sum = ((sum - f[j])% modn + modn) % modn;
        }
        f[i] = (sum % modn + modn) % modn;
        ans = (ans +  i * f[i] % modn) % modn;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3948
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),a=nxt();
    cout<<n*n-a<<endl;
    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; i<n; i++)
#define REP2(i, a, b) for(int i=a; i<b; i++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

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

    vector<int> lr(2*N);
    REP(i, 2*N){
        int parity = i%2;
        int par = (S[i]=='W'?0:1);
        if((parity^par) == 0) lr[i] = 1;
        else lr[i] = 0;
    }
    long long ans = 1;
    long long l = 0;
    REP(i, 2*N){
        if(lr[i] == 0) l++;
        else{
            ans *= l;
            ans %= MOD;
            l--;
        }
    }
    if(l != 0) ans = 0;
    REP(i, N){
        ans *= (i+1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1412
import math

def a():
    s = input()
    print(s[:3])


def b():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())
    if v > w:
        if abs(a-b) / (v -w) <= t:
            print('YES')
        else:
            print('NO')
    else:
        print('NO')


def c():
    print('')



def d():
    print('')


b()

Measured memory_bytes: 9040
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var a int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		if a%2 == 1 {
			continue
		}
		if a%3 == 0 || a%5 == 0 {
			continue
		}

		fmt.Println("DENIED")
		return
	}
	fmt.Println("APPROVED")
}


Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
ans=0

for i in a:
    if i%2==0:
        if i%3==0 or i%5==0:
            continue
        else:
           ans+=1
           break
if ans==0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 38256
while n = gets.to_i
  break if n == 0
  min = 0
  a_max = -1.0 / 0.0 
  sum = 0
  d = []
  n.times{
    a = gets.to_i
    a_max = a if a_max < a
    sum += a
    min = sum if min > sum
    d << sum - min
  }
  if a_max < 0
    puts a_max
  else
    puts d.max
  end
end

Measured memory_bytes: 8792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int a,b,t;
  cin>>a>>b>>t;
  cout<<(t/a)*b<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>
 
using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> PL;
typedef long double ldouble;
 
void solve(){
	int N; scanf("%d", &N);
	ll s = 0;
__int128 X;
	for(int i=1;;i++){
		s += i;
		if(s >= N){
			printf("%d\n", i);
			return;
		}
	}
}
 
int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int a;
  cin >> a;
  bool flag = false;
    for(int i=1; i<=9; i++){
      if(a%i == 0 && (a/i >=1 && a/i <=9)){
        flag = true;
        cout << "Yes" << endl;
        break;
      }
    }
  if(!flag) cout << "No" << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 1e6 + 5;
const int INF = 1e9 + 7;

ll n;
int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    if(n >= 30){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3604
import Data.List

isLeap year
  | year `mod` 400 == 0 = True
  | year `mod` 100 == 0 = False
  | year `mod`   4 == 0 = True
  | otherwise           = False

ans (from:to:_) =
  filter isLeap [from..to]

toStr :: [Int] -> String
toStr [] = "NA\n"
toStr x = unlines $ map show x

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      i'= takeWhile (/= [0,0]) i
      o = map ans i'
--  print o
--  print [2001..2010]
  putStr $ intercalate "\n" $ map toStr o

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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define TEST_CASE int tc;cin>>tc;while(tc--)

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

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::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...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define JD



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

    #ifndef JD
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif

    int a;
    cin>>a;
    cout<<(a+a*a+a*a*a);

    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

using lint = long long;
using ldouble = long double;

bool solve() {
    string S;
    cin >> S;
    if (S == "#") return false;

    int Y, M, D;
    cin >> Y >> M >> D;

    if (Y > 31 || (Y == 31 && M > 4)) {
        S = "?";
        Y -= 30;
    }

    cout << S << " " << Y << " " << M << " " << D << endl;
    return true;
}

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



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

void replace(int& a, int& b)
{
    int temp = a;
    a = b;
    b = temp;
}

int main()
{
    int a = 0, b = 0;
    while(true)
    {
        cin >> a >> b;
        if (a == 0 && b == 0)   break;
        
        if (a > b)  replace(a, b);
        cout << a << " " << b << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int i = 1;
		for (;;) {

			if (ni() == 0) {
				out(i);
				break;
			}
			i++;

		}
	}

	/*
	 * 以下メソッド集
	 */

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int abcount(String str) {
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if ("AB".equals(str.substring(i, i + "AB".length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
constexpr auto ctz(int x) { return __builtin_ctz(x);      } constexpr auto ctz(ll x) { return __builtin_ctzll(x);      }
constexpr auto clz(int x) { return __builtin_clz(x);      } constexpr auto clz(ll x) { return __builtin_clzll(x);      }
constexpr auto pop(int x) { return __builtin_popcount(x); } constexpr auto pop(ll x) { return __builtin_popcountll(x); }
const int N = 16;
int a[N][N];
ll opt[1 << N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    for(int mask = 0; mask < 1 << n; mask++) {
        for(int ii = mask, i = ctz(ii); ii > 0; ii &= ~(ii & -ii), i = ctz(ii)) {
            for(int jj = mask, j = ctz(jj); jj > 0; jj &= ~(jj & -jj), j = ctz(jj)) {
                if(i < j) {
                    opt[mask] += a[i][j];
                }
            }
        }
    }
    for(int mask = 0; mask < 1 << n; mask++) {
        for(int x = mask; x > 0; x = (x - 1) & mask) {
            opt[mask] = max(opt[mask], opt[mask ^ x] + opt[x]);
        }
    }
    cout << opt[(1 << n) - 1] << endl;
    return 0;
}

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

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	int H, W; cin >> H >> W;
	vector<string>vec(H);
	rep(i, 0, H)cin >> vec[i];
	rep(i, 0, H) {
		rep(j, 0, 2) {
			cout << vec[i] << "\n";
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	ll e,f;
	e=a*b;
	f=c*d;
	if(e>=f) cout<<e<<endl;
	else cout<<f<<endl;
	
return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;
import std.math;
import std.container;
import std.numeric;
import std.bigint;


void main() {
  auto input = readln.split.map!(to!int);
  auto N = input[0];
  auto M = input[1];
  auto X = readln.split.map!(to!int).array;
  auto cnt = new int[][](M);
  foreach (x; X) cnt[x%M] ~= x;
  auto amari = new int[](10^^5+1);

  int ans = 0;
  foreach (m; 0..M/2+1) {
    int minm, mm;
    if (m == 0 || (m == M/2 && M % 2 == 0)) {
      ans += cnt[m].length/2;
    }
    else {
      minm = min(cnt[m].length, cnt[M-m].length).to!int;
      mm = cnt[m].length > cnt[M-m].length ? m : M-m;
      int[int] same;
      foreach (x; cnt[mm]) {
        if (x in same) same[x] += 1;
        else same[x] = 1;
      }
      ans += minm + min((cnt[mm].length-minm)/2, same.values.map!(x => x/2).sum);
    }
  }

  writeln(ans);
}


Measured memory_bytes: 16316
var debug = false;

function Main(input) {
    console.log(input.startsWith('ARC') ? 'ABC' : 'ARC');
}




//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
if (debug) {
    Main(require("fs").readFileSync("./input", "utf8")); 
} else { 
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}

Measured memory_bytes: 29608
Q, H, S, D = map(int, input().split())
N = int(input())
L = [S,H*2,Q*4]
if min(L)*2 < D:
    print(min(L)*N)
else:
    if N % 2 == 0:
        print(D*(N//2))
    else:
        print(D*(N//2)+min(L))

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef char* String;

String string_input(void){
    int i,len;
    char buf[5001];
    String str;
    scanf("%s",buf);//buf=入力した文字列が入るchar型の配列
    
    len=strlen(buf);//len=文字列の長さを表すint型変数
    NEW(str,len+1);//strはただのポインタだから、ここでNEWを使ってメモリを確保しなくちゃいけない
    for(i=0;i<len;i++){
        str[i]=buf[i];
    }
    str[len]=0;
    
    return str;
}

int string_compare(const void* a, const void* b){
    String p=*(String*)a;
    String q=*(String*)b;

    return strcmp(p,q);
}


int main(void){
    String S=string_input();
    int K;
    scanf("%d",&K);

    int N=strlen(S);

    String* A;
    NEW(A,N*K);

    //K文字以下の部分文字列を全て列挙
    int a=0;
    for(int k=1;k<=K;k++){
        for(int i=0;i<N+1-k;i++){
            String tmp;
            NEW(tmp,k+1);
            for(int j=0;j<k;j++){
                tmp[j]=S[i+j];
            }
            A[a]=tmp;
            a++;
        }
    }
    qsort(A,a,sizeof(String),string_compare);

    //配列Aの中で重複をなくす
    String* B;
    NEW(B,N*K);
    B[0]=A[0];
    int b=1;
    for(int i=1;i<a;i++){
        if(strcmp(A[i],B[b-1])){
            B[b]=A[i];
            b++;
        }
    }

    printf("%s\n",B[K-1]);

    return 0;
}

Measured memory_bytes: 1276
N,M=map(int,input().split())
l=[]
for i in range(M):
    l.append(tuple(map(int,input().split())))

l.sort(key=lambda x:x[1])
ans=0
x=0
for li in l:
    a,b=li
    if x<=a:
        x=b
        ans+=1

print(ans)

Measured memory_bytes: 61528
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<vector<char>> MAP(22,vector<char> (22,'#'));
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

int bfs(int a,int b){
    vector<vector<int>> dist(22,vector<int> (22,-1));

    queue<int> X;
    queue<int> Y;
    X.push(a);Y.push(b);

    dist[a][b]=0;   //スタート地点の距離0
    int maximum=0;

    while(!X.empty()){
        int x = X.front(); X.pop();
        int y = Y.front(); Y.pop();
        for(int i=0;i<4;i++){   //上下左右を調べる
            if(MAP[x+dx[i]][y+dy[i]]!='#' && dist[x+dx[i]][y+dy[i]]==-1){   //未訪問
                X.push(x+dx[i]);
                Y.push(y+dy[i]);
                dist[x+dx[i]][y+dy[i]]=dist[x][y]+1;
                maximum=max(maximum,dist[x+dx[i]][y+dy[i]]);
            }
        }
    }
    return maximum;
}

int main(){
    int H,W;    cin>>H>>W;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin>>MAP[i][j];
        }
    }
    int maximam=0;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(MAP[i][j]!='#'){
                maximam=max(bfs(i,j),maximam);
            }
        }
    }
    cout<<maximam;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define mx 200005
#define inf 2e9
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
//i  = current stair
int ans = 0;
int dp[mx];
int fun(int *h,int n,int i)
{
    if(i==(n-1))
        return 0;
    else if(dp[i]!=(-1))
        return dp[i];
    else if((i+1) <n && (i+2)<n)
        return dp[i] = min( (abs(h[i+1] - h[i])+fun(h,n,i+1) ) , (abs(h[i+2] - h[i])+fun(h,n,i+2) ) );
    else if( (i+1)<n )
        return dp[i] = (abs(h[i+1] - h[i])+fun(h,n,i+1));
    else if((i+2)<n)
        return dp[i] = (abs(h[i+2] - h[i])+fun(h,n,i+2));
}
int main()
{
    memset(dp,-1,sizeof(dp));
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    cout<<fun(h,n,0)<<endl;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> d1(n), d2(n);
    rep(i, n)cin >> d1[i] >> d2[i];
    vector<int> z(n);
    rep(i, n)z[i] = (d1[i] == d2[i]);
    bool ok = false;
    rep(i, n-2){
        if(z[i] && z[i+1] && z[i+2])ok = true;
    }
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
const long long MOD=1e9+7;
long long quipow(int i,long long x){
	long long res=1;
	while(i>0){
		if(i&1) res=res*x%MOD;
		x=x*x%MOD;
		i>>=1;
	}
	return res;
}
long long dp1[105],dp2[105],ndp1[105],ndp2[105];      //dp2[i]:到第i行为止依然有序的情况 
int h[105];
vector<int> v;
map<int,int> mp;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>h[i];
		v.push_back(h[i]);
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	for(int i=0;i<v.size();i++) mp[v[i]]=i;
	for(int i=0;v[i]<=h[0]&&i<v.size();i++){
		dp2[i]=2*quipow(h[0]-v[i],2)%MOD;
		dp1[i]=(quipow(h[0],2)-dp2[i]+MOD)%MOD;
	}
	for(int i=1;i<n;i++){
		for(int j=0;v[j]<=min(h[i],h[i-1])&&j<v.size();j++) {
			ndp1[j]=dp1[j]%MOD;
			ndp2[j]=(dp2[j]+dp2[min(mp[h[i-1]],mp[h[i]])])%MOD;
			dp1[j]=ndp1[j]*quipow(h[i]-h[i-1],2)%MOD;
			dp2[j]=ndp2[j]*quipow(h[i]-h[i-1],2)%MOD;
		}
		int idx=mp[h[i-1]];
		if(h[i]>h[i-1]){
			for(int j=idx+1;v[j]<=h[i]&&j<v.size();j++){
				ndp1[j]=((ndp1[j-1]+ndp2[j-1])%MOD*quipow(v[j]-v[j-1],2)%MOD-ndp2[j-1]+MOD)%MOD;
				ndp2[j]=ndp2[j-1]%MOD;
				dp1[j]=ndp1[j]*quipow(h[i]-v[j],2)%MOD;
				dp2[j]=ndp2[j]*quipow(h[i]-v[j],2)%MOD;
			}
		}
	}
	long long res=0;
	res=(dp1[mp[h[n-1]]]+dp2[mp[h[n-1]]])%MOD;
	cout<<res;
}

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


using namespace std;

#define f first
#define s second


using ll = long long;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n;
    cin >> n;
    vector<double> p(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    vector<vector<double> > dp(n+1, vector<double>(n+1, 0.0));
    dp[1][0]=1-p[1];
    dp[1][1]=p[1];
    for (int i = 2; i <=n; i++) {
        for (int j = 1; j <= n; j++) {
            dp[i][j] = max(dp[i][j], dp[i-1][j-1] * p[i] + dp[i-1][j] * (1.0-p[i]));
            dp[i][0] = max(dp[i][0], dp[i-1][0] * (1.0-p[i]));
        }
    }
    double ans=0;
    for (int i = (n+1)/2; i <= n; i++) {
        ans += dp[n][i];
    }
    cout << setprecision(9) << fixed;
    cout << ans << '\n';
}



Measured memory_bytes: 73748
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String str = scanner.next();

        for (int i = 0; i < str.length()-1; i++) {
            if (str.substring(i,i+2).equals("AC")) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 24276
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
#include <functional>

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define rep(i,a,n) for (int i=a ; i<n ; i++)
#define per(i,a,n) for (int i=n-1 ; i>=a ; i--)
#define LLINF (llong)1e18+5
#define INF 1e9+1
#define endl '\n'

using namespace std;
using llong = long long;
using VI = vector<int>;
using VLL = vector<long long>;
using PII = pair<int, int>;

//struct cmp {
//	bool operator() (pair<PII, int> a, pair<PII, int> b)
//	{
//		return a.ss > b.ss;
//	}
//};

int main()
{
	IOS;
	
	VI ans(240001);
	rep(i, 1, 101)
	{
		rep(j, 1, 101)
		{
			rep(k, 1, 101)
			{
				ans[((i + j) * (i + j) + (j + k) * (j + k) + (k + i) * (k + i)) / 2] ++;
			}
		}
	}
	int n;
	cin >> n;
	rep(i, 1, n+1)
	{
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 4152
import math
n = input()
p = [int(i) for i in input().split()]

left = 0
right = 0
pre = 1000000
for i in range(len(p)):
    left = sum(p[:i + 1])
    right = sum(p[i + 1:])
    ans = abs(left - right)
    if ans > pre:
        print(pre)
        break
        
    pre = ans

Measured memory_bytes: 3064