akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int maxN = int(1e3)*8; 
int xdp[(maxN+1)/2][int(1e4)*2];
int ydp[(maxN/2)+1][int(1e4)*2];

int main() {
    string s;
    cin >> s;
    vector<ll> move;
    for(int i=0;i<s.size();i++){
        ll temp =0;
        while(i<s.size() && s[i] == 'F'){
            temp++;
            i++;
        }
        move.push_back(temp);
    }
    int x,y;
    cin >> x >>y;
    ll N = move.size();
    // if(N==1){
    //     if(x == move[0] && y ==0){
    //         cout << "Yes" << endl;
    //     }else{
    //         cout <<"No" << endl;
    //     }
    //     return 0;
    // }
    // for(int i=0;i<N;i++){
    //     cerr <<"i="<<i <<"move[i]=" <<move[i] << endl;
    // }

    ;
    xdp[0][10000+move[0]] = 1;
    for(int i=2;i<N;i+=2)for(int j=0;j<int(1e4)*2;j++){
        if(xdp[(i/2)-1][j] == 1){
            xdp[(i/2)][j+move[i]]=1;
            xdp[(i/2)][j-move[i]]=1;
        }
    }
   
    ydp[0][10000] = 1;
    for(int i=1;i<N;i+=2)for(int j=0;j<int(1e4)*2;j++){
        if(ydp[(i/2)][j] == 1){
            ydp[(i/2) +1][j+move[i]]=1;
            ydp[(i/2) +1][j-move[i]]=1;
        }
    }
    if(xdp[(N-1)/2][10000+x] && ydp[N/2][10000+y]){
        cout <<"Yes" << endl;
    }else{
        cout <<"No" << endl;
    }


    return 0;
}

Measured memory_bytes: 62972
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define pb 	push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define mod 1000000007LL
#define F first
#define S second
#define speed ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)

main()
{
	speed;
	int k,x;
	cin>>k>>x;
	int k2=k;
	vector<int>a;
	for(int i=x;i>=-1000000&&k2>0;i--)
	{
		a.pb(i);
		k2--;
	}
	reverse(all(a));
	for(auto i:a)cout<<i<<" ";
	for(int i=x+1;i<1000000&&k>1;i++)
	{
		cout<<i<<" ";k--;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll MOD=1e9+7;
const ll N=3e5+5;
const ld pi=3.14159265359;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()

ll n,x,cnt[N],p[N],ans[N],rans[N];
vector<ll> v;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	REP(i,n){cin>>x;cnt[x]++;}
	REP1(i,n)v.pb(cnt[i]);
	sort(v.begin(),v.end());
	REP(i,n)p[i]=(i?p[i-1]:0)+v[i];
	for(ll m=n;m>=1;m--){
		ll id=lwb(v.begin(),v.end(),m)-v.begin();
		ans[m]=(n-id+p[id-1]/m);
	}
	REP1(i,n){rans[ans[i]]=i;}
	for(ll i=n-1;i>=1;i--)rans[i]=max(rans[i+1],rans[i]);
	REP1(i,n)cout<<rans[i]<<"\n";	
	return 0;
}




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

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



void solve() {
    ll a, b, c, d, n, k, x,l,r;
    string s, t;
    ll ans = 0;
    double dans = 0;
    string sans = "Good";

    cin  >> a >> b >> c;

    ans = (c/a) * b;


    std::cout << ans << endl; 
    // std::cout << sans << endl; 
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define Set set<int>
#define int long long
#define P pair<int,int>
const int maxn = 1e6+5;
const int INF = 1e17 +6;
using namespace std;
//int n,m,a[maxn],b[maxn],ans;
int n;
void over()
{
    cout<<"No";
    exit(0);
}
int a,b,c,d,len;
string k;
bool if_have(int num,int kinds,int st,int zhong)
{
    //kinds:0-#,1-. ,包括st
    int times=0;
    if(kinds)
    {
        fu(i,st,zhong)
        {
            if(k[i]=='.')
            {
                times++;
                if(times==num)return 1;
            }else{
                times=0;
            }
        }
    }else{
        fu(i,st,zhong)
        {
            if(k[i]=='#')
            {
                times++;
                if(times==num)return 1;
            }else{
                times=0;
            }
        }
    }
    return 0;
}
int32_t main()
{
    IOS;
    cin>>n>>a>>b>>c>>d;
    cin>>k;
    len=k.length();
    int time1=0;
    if(c<d)//b
    {
        if(if_have(2,0,b-1,d-1))over();
        if(if_have(2,0,a-1,c-1))over();
        cout<<"Yes";
    }else{
        //看看能不能先走a

        //看看b能不能挪
        if(if_have(3,1,b-2,d-1)){//可以挪
            if(if_have(2,0,a-1,c-1))over();
            if(if_have(2,0,b-1,d-1))over();
            cout<<"Yes";
        }else{
            if(if_have(2,0,b-1,d-1))over();
            k[d-1]='#';
            if(if_have(2,0,a-1,c-1))over();
            cout<<"Yes";
        }
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[n - 1 - i];
  }
  for (int i = 0; i < n; i++) {
    if (i % n == 0)
      cout << arr[i];
    else
      cout << " " << arr[i];
  }
  cout << endl;
}



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

int main(){
  int N, X, minx;
  cin >> N >> X;
  vector<int> m(N);
  for(int i=0; i<N; i++){
    cin >> m.at(i);
  }
  minx=m.at(0);
  for(int i=0; i<N; i++){
    X -= m.at(i);
  }
  for(int i=0; i<N; i++){
    if (minx > m.at(i)){
      minx = m.at(i);
    }
  }
  cout << N + X / minx << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)


using namespace std;

char d[20][30];

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

int main(){
  int h, w;

  while(scanf("%d%d", &h, &w), h + w){
    map<string, int> m;

    REP(i,h) scanf("%s", d[i]);

    REP(i,h) REP(j,w){
      REP(k,8){
        int x = j;
        int y = i;
        string tmp = "";

        do{
          tmp += d[y][x];
          x = (x + w + dx[k]) % w;
          y = (y + h + dy[k]) % h;
          m[tmp]++;
        }while(i != y || j != x);
      }
    }

    string ans = "";

    FOR(it, m) if(it->second > 1){
      const string &s = it->first;

      if(s.size() > ans.size()) ans = s;
      else if(s.size() == ans.size() && s < ans) ans = s;
    }

    if(ans.size() > 1) puts(ans.c_str());
    else puts("0");
  }

  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
#define sbp(p, n) rep(i, n) { int a, b; scanf("%d %d", &a, &b); p[i] = make_pair(a, b); }
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
ull gcd(ull a,ull b){return b?gcd(b,a%b):a;}
using namespace std;

int main(void)
{
	int n;
	ull ans = 1, t;
	cin >> n;
	rep(i, n){
		cin >> t;
		ull tmp = gcd(t, ans);
		t /= tmp;
		ans *= t;
	}
	cout << ans << endl;
	return 0;
}

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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    int64_t R, n;
    cin >> R;
    cin >> n;
    vector<int64_t> S(n), T(n);

    for (int i = 0; i < n; i++)
        cin >> S[i] >> T[i];

    vector<int64_t> csum(n + 1);
    for (int i = 0; i < n - 1; i++){
        csum[i + 1] = csum[i] + S[i + 1] - T[i];
    }
    csum[n] = csum[n - 1];

    int64_t ma = 0;
    for (int i = 0; i < n; i++){
        int l = i - 1, r = n;
        while (r - l > 1){
            int mid = (l + r) / 2;
            if (S[i] + R > S[mid]){
                l = mid;
            } else {
                r = mid;
            }
        }

        if (l == i - 1)
            ma = R;
        else {
            ma = max(ma, R - (csum[l] - csum[i] + max(0L, S[i] + R - T[l]))); 
        }
    }
    cout << ma << endl;
}


Measured memory_bytes: 5256
a,b,c=map(int,input().split())
for i in range(500000):
    if a%2==1 or b%2==1 or c%2==1:
        print(i);exit()
    
    else:
      p=(b+c)//2 ;q=(a+c)//2 ; r=(a+b)//2
      a=p ; b=q;c=r
else:
    print(-1)

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 100000;

vector<ll> sushi[MAXN + 1];
vector<ll> best;
vector<ll> rest;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    ll t[n], d[n];
    for(int i=0;i<n;i++) cin >> t[i] >> d[i];
    for(int i=0;i<n;i++){
        sushi[t[i]].push_back(d[i]);
    }
    for(int i=1;i<=MAXN;i++){
        if(sushi[i].empty()) continue;
        sort(sushi[i].rbegin(), sushi[i].rend());
        best.push_back(sushi[i][0]);
        for(int j=1;j<sushi[i].size();j++){
            rest.push_back(sushi[i][j]);
        }
    }
    sort(best.rbegin(), best.rend());
    sort(rest.rbegin(), rest.rend());
    ll bsize = best.size();
    ll rsize = rest.size();
    ll sumbest[bsize], sumrest[rsize];
    sumbest[0] = best[0];
    for(int i=1;i<bsize;i++) sumbest[i] = sumbest[i-1] + best[i];
    if(!rest.empty()){
        sumrest[0] = rest[0];
    }
    for(int i=1;i<rsize;i++) sumrest[i] = sumrest[i-1] + rest[i];
    ll ans = 0;
    for(ll i=0;i<=min(k, bsize);i++){
        // best * i & rest * (k - i)
        ll sum = 0;
        if(i - 1 >= 0){
            sum += sumbest[i-1];
        }
        if(k - i - 1 >= 0 && k - i - 1 < rsize){
            sum += sumrest[k-i-1];
        }
        ans = max(ans, sum + i * i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 8948
#include <iostream>
#include <queue>

using namespace std;

int main()
{
  int k; cin >> k;
  
  queue<long long> q;
  for (long long i = 1; i <= 9; ++i) q.push(i);
  
  while(--k) {
    long long x = q.front(); q.pop();
    if (x % 10 != 0) q.push(x*10+x%10-1);
    q.push(x*10+x%10);
    if (x % 10 != 9) q.push(x*10+x%10+1);
  }
  
  cout << q.front() << endl;
  return 0;
}

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

using namespace std;

int main() {

	ios_base :: sync_with_stdio(0); cin.tie(NULL);
	
	int n;
	cin >> n;

	map<string, int> mp;

	for (int i = 1; i <= n; ++i) {
		string s = to_string(i);
		char x = s[0];
		char y = s.back();
		s.clear();
		s += x; s += y;

		mp[s]++;
	}

	long long ans = 0;

	for(pair<string,int> p : mp) {
		string s = p.first;
		swap(s[0], s[1]);
		ans += p.second * mp[s];
	}
	

	cout << ans << '\n';



	return 0;
}

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

#define FOR(i,n) for(int i=0;i<(n);++i)
#define FORU(i,j,k) for(int i=(j);i<=(k);++i)
#define FORD(i,j,k) for(int i=(j);i>=(k);--i)

#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

using namespace std;

using lli = long long int;
using pll = pair<lli, lli>;

string TYPE(int*)  { return "%d";   }
string TYPE(lli*)  { return "%lld"; }
string TYPE(char*) { return "%c";   }

void RD() {}
template<typename T, typename... Args> 
void RD(T* v, Args... args)
{
    scanf((" " + TYPE(v)).c_str(), v);
    RD(args...);
}

void PR(bool nl = true)
{ if(nl) printf("\n"); }
template<typename T, typename... Args> 
void PR(bool nl, T v, Args... args)
{
    printf((TYPE(&v) + " ").c_str(), v);
    PR(nl, args...);
}
template<typename... Args> 
void PR(Args... args)
{ PR(true, args...); }

vector<string> split(const string& s, char c)
{
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args)
{
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
    err(++it, args...);
}

const long long int oo = 1000*1000*1000;

struct Coord
{
    int x, y;
    Coord(int x = 0, int y = 0) : x(x), y(y) {}
    Coord operator + (const Coord& droite) const
    {
        return Coord(x + droite.x, y + droite.y);
    }
};

struct AB
{
    int k;
    vector<lli> arbre;
    AB(int _k = 20, lli def = 0)
    {
        k = _k;
        FOR(i, 1 << k)
            arbre.push_back(i < (1 << (k-1)) ? 0LL : def);
        FORD(i, ((1 << (k-1)) - 1), 1)
            arbre[i] = arbre[i << 1] + arbre[(i << 1) ^ 1];
    }
    void set(int i, lli x)
    {
        int feuille = i + (1 << (k-1));
        arbre[feuille] = x;
        iset(feuille >> 1);
    }
    void iset(int noeud)
    {
        if(noeud)
        {
            arbre[noeud] = arbre[noeud << 1] + arbre[(noeud << 1)  ^ 1];
            iset(noeud >> 1);
        }
    }
    lli sum(int deb, int fin, int noeud = 1, int p = 0, int q = -1)
    {
        if(q < p)
            q = 1 << (k-1);
        if(deb <= p && q <= fin)
            return arbre[noeud];
        if(deb >= q || fin <= p)
            return 0LL;
        int mil = (p + q) / 2;
        return sum(deb, fin, noeud << 1, p, mil) + sum(deb, fin, (noeud << 1) ^ 1, mil, q);
    }
};

int erath[1042];
lli amount[1042];

int main()
{
	vector<lli> primes;
	FORU(i, 2, 1000)
	{
		if(erath[i] == 0)
		{
			erath[i] = i;
			primes.push_back(i);
			int k = 2;
			while(k * i <= 1000)
				erath[(k++) * i] = i;
		}
	}
	lli n;
	RD(&n);
	lli r = 1;
	FORU(i, 2, n)
	{
		lli j = i;
		while(j != 1)
		{
			++amount[erath[j]];
			j /= erath[j];
		}
	}
	FORU(k, 2, n)
		r = (r * (amount[k] + 1LL)) % 1000000007LL;
	PR(r);
    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 PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    char b;
    cin >> b;
    char a;
    if(b=='A') a='T';
    if(b=='T') a='A';
    if(b=='C') a='G';
    if(b=='G') a='C';
    cout << a << endl;



}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;


int main()
{
	int r, c;
	
	while (cin>>r>>c, r|c)
	{
		if (c % 2 == 0)
		{
			cout << "yes" << endl;
		} else if (r % 2 == 0) {
			cout << "yes" << endl;
		} else if (r % 2 == 1) {
			cout << "no" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1156
<?php
fscanf(STDIN, "%d %d %d", $p, $q, $r);
 
$root1 = $p + $q;
$root2 = $r + $q;
$root3 = $p + $r;
$root4 = $q + $r;
$root5 = $r + $p;
$root6 = $q + $p;

$array = [$root1,$root2,$root3,$root4,$root5,$root6];

echo min($array);

Measured memory_bytes: 4856
n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
t = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    a, b = 10 ** 9, 0
    for j in range(m):
        c = abs(s[i][0] - t[j][0]) + abs(s[i][1] - t[j][1])
        if c < a:
            a = c
            b = j
    print(b + 1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;

 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
  
 

vll dp(100100);

ll sum(ll n) {
ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}




 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
    ci(n);
  vll A(n);
  FOR(i,0,n){
    ci(A[i])
  }
  SORT(A);
  //REV(A);

  ll m=A[n-1];
  vll B(n-1);
  FOR(i,0,n-1){
    B[i]=min(A[i],m-A[i]);
  }
  SORT(B);
  //REV(B);

  bl b=true;

  FOR(i,0,n-1){
    if(A[i]==B[n-2]){
      cout<<m<<" "<<A[i]<<endl;
      b=false;
      break;
    }
  }

  if(b){
    cout<<m<<" "<<m-B[n-2]<<endl;
  }
}

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

S = sum(a)
x = [0]*n
x[0] = S
for i in range(1,n-1,2):
    x[0] -= 2*a[i]

for j in range(1,n):
    x[j] = 2*a[j-1] - x[j-1]

lis = map(str,x)
#print(x)
print(" ".join(lis))    

Measured memory_bytes: 24748
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>

using namespace std;

int main()
{
    int N;
    double v[57];

    scanf("%d\n",&N);
    for(int i=0; i<N; i++)
    {
        scanf("%lf ",&v[i]);
    }

    sort(v, v+N);
    reverse(v, v+N);
    
    double res=0, rate=1;
    for(int i=0; i<N; i++)
    {
        rate*=1.0/2.0;
        res+=v[i]*rate;
    }
    res+=v[N-1]*rate;
    
    printf("%lf\n",res);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    map<int,int> mp;
    rep(i,0,N){
        mp[V[i]] = i;
    }
    set<ll> st;
    st.insert(-1);
    st.insert(N);
    ll ans = 0;
    for(auto p:mp){
        //cout << p.first << "," << p.second << endl;

        auto left = st.upper_bound(p.second);
        left--;
        auto right = st.lower_bound(p.second);
        //cout << *left << " " << *right << endl;
        ans += (*left - p.second) * (p.second - *right) * p.first;
        st.insert(p.second);
    }
    cout << ans << endl;

}

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

int main()
{
  int N;scanf("%d",&N);
  int a[N];bool A[N];fill(A,A+N,false);
  for(int i=0;i<N;i++){scanf("%d",&a[i]);a[i]--;}
  int i=0,ans=0;
  while(i!=1)
  {
    A[i]=true;
    i=a[i];ans++;
    if(A[i]){printf("-1");return 0;}
  }
  printf("%d",ans);
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a.begin(), a.end())
int a[4][3][10];
int main(){
    int n;
    cin >> n;
    rep(i,n){
        int b,f,r,v;
        cin >> b >> f >> r >> v;
        b--;f--;r--;
        a[b][f][r] += v;
    }

    rep(i,4){
        rep(j,3){
            rep(k,10)printf(" %d", a[i][j][k]);
            printf("\n");
        }

        if(i < 3){
            rep(j,20)printf("#");
            printf("\n");
        }
    }

    return 0;
}



Measured memory_bytes: 3216
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String line = lines[0];
        String[] a = line.split(" ");
        int term = Integer.parseInt(a[0]);
        int num = Integer.parseInt(a[1]);

        String line1 = lines[1];
        String[] b = line1.split(" ");
        //int cost = Integer.parseInt(b[i]);

        for (int i = 0; i < num; i++){
            int cost = Integer.parseInt(b[i]);
            term = term - cost;
        }
        if (term < 0){
            System.out.println("-1");
        } else if (term >= 0){
            System.out.println(term);
        }




    }
  
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
  
}


Measured memory_bytes: 39252
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function pos(i,j,w)
	if w == 1
		1
	elseif j <= 2 || j >= w+1
    	if i == j
      		fib(w)
    	else
      		fib(w-1)
    	end
    elseif i <= 2 || i >= w+1
		fib(w-1)
	elseif i == j
		fib(i-1)*fib(w+2-i)
	else
		fib(min(i,j)-1)*fib(w+2-max(i,j))
	end
end

function fib(k)
	if k == 1
		1
	elseif k == 2
		1
	else
		x = Array{Int}(k)
		x[1] = 1
		x[2] = 1
		for i in 3:k
			x[i] = x[i-2]+x[i-1]
		end
		x[k]
	end
end

function main()
	h,w,k = readline() |> split |> parseMap
	dp = Array{Int}(h+1,w+2)
	count = 0
	for i in 1:w+2
		dp[1,i] = 0
	end
	for i in 1:h+1
		dp[i,1] = 0
		dp[i,w+2] = 0
	end
    dp[1,2] = 1
	for i in 2:h+1
		for j in 2:w+1
			dp[i,j] = ((dp[i-1,j-1]*pos(j-1,j,w))%1000000007 + (dp[i-1,j]*pos(j,j,w))%1000000007 + (dp[i-1,j+1]*pos(j+1,j,w))%1000000007)%1000000007
		end
	end
	println(dp[h+1,k+1]%1000000007)
end

main()


Measured memory_bytes: 113832
import numpy as np
n = int(input())
a = np.sort(np.array(list(map(int, input().split()))))
max_num = a[-1]+1
dp = np.array([0]*(max_num))

if np.count_nonzero(a==1)  == 1:
    print(1)
else:
    for i in a:
        for j in np.arange(i, max_num, i):
            dp[j] += 1
    print(np.count_nonzero(dp[a] == 1))

Measured memory_bytes: 51680
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n, m = M()
print(n*(n-1)//2 + m*(m-1)//2)

Measured memory_bytes: 74172
def main():
    import sys
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    N = int(input())
    ans = 0
    for i in range(1, N+1):
        if i % 3 == 0 or i % 5 == 0:
            continue
        ans += i
    print(ans)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 9048
use strict;
use warnings;
use utf8;

use feature qw(say);

my $input = <STDIN>;
chomp $input;
my ($min, $max, $divide) = (split / /, $input);

my $min_value = int($min/$divide);
if ($min == $min_value * $divide) {
    $min_value--;
}

my $max_value = int($max/$divide);

my $answer = $max_value - $min_value;
say $answer;

Measured memory_bytes: 5240
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int a, b;
	cin >> a >> b;
	if(a == 1) a+=13;
	if(b == 1) b+=13;
	if(a > b) puts("Alice");
	else if(a < b) puts("Bob");
	else puts("Draw");
 	return 0;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    H, W = LI()
    S = [SS() for _ in range(H)]

    d = ((1, 0), (0, 1), (-1, 0), (0, -1))

    def dfs(cy, cx, cnt):
        visited[cy][cx] = True
        if S[cy][cx] == '#':
            cnt[0] += 1
        else:
            cnt[1] += 1
        for dy, dx in d:
            ny = cy + dy
            nx = cx + dx
            if 0 <= ny < H and 0 <= nx < W and not visited[ny][nx] and S[ny][nx] != S[cy][cx]:
                dfs(ny, nx, cnt)

    # (黒マス数, 白マス数)
    c = []
    visited = [[False] * W for _ in range(H)]
    for i, j in itertools.product(range(H), range(W)):
        if not visited[i][j]:
            cnt = [0, 0]
            dfs(i, j, cnt)
            c.append(cnt)

    ans = sum([b * w for b, w in c])
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 202308
#include <iostream>
#include <vector>

using namespace std;

struct Node {
	Node() { parent = -1; depth = 0; }

	int parent;
	int depth;
	vector<int> children;
};

vector<Node> node(100000);

void set_depth(int id)
{
	if (node[id].children.empty())
		return;

	for (int i = 0; i < node[id].children.size(); ++i)
	{
		node[node[id].children[i]].depth = node[id].depth + 1;
		set_depth(node[id].children[i]);
	}
}

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

	int n;
	cin >> n;

	for (int i = 0; i < n; ++i)
	{
		int id, k;
		cin >> id >> k;

		while (k--)
		{
			int c;
			cin >> c;
			node[id].children.push_back(c);
			node[c].parent = id;
		}
	}

	for (int i = 0; i < n; ++i)
		if (node[i].parent == -1)
		{
			set_depth(i);
			break;
		}

	for (int i = 0; i < n; ++i)
	{
		cout << "node " << i << ": "
			<< "parent = " << node[i].parent
			<< ", depth = " << node[i].depth
			<< (node[i].parent == -1 ?
				", root" : node[i].children.empty() ? ", leaf" : ", internal node")
			<< ", [";
		
		if (!node[i].children.empty())
		{
			cout << node[i].children[0];
			for (int j = 1; j < node[i].children.size(); ++j)
				cout << ", " << node[i].children[j];
		}
		cout << "]" << endl;
	}

	return 0;
}

Measured memory_bytes: 4900
from collections import deque
n,u,v=map(int, input().split())
edgelist = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    edgelist[a-1].append(b-1)
    edgelist[b-1].append(a-1)
dist = [[0,0] for _ in range(n)]
def distance(start, id):
    que=deque()
    visited = [0]*n

    found = False
    que.append([edgelist[start],start])
    while que:
        ver=que.popleft()
        visited[ver[1]]=1
        for next_v in ver[0]:
            if not visited[next_v]:
                dist[next_v][id]=dist[ver[1]][id]+1
                que.append([edgelist[next_v], next_v])
distance(u-1,0)
distance(v-1,1)
dist.sort(key = lambda x:x[1],reverse = True)
ans=0
for i in range(n):
    if dist[i][1]-dist[i][0]>=1:
        print(dist[i][1]-1)
        exit()


Measured memory_bytes: 39552
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;
 
 
const int ALPHABET_SIZE = 26; 
  
// trie node 


int main() 
{ 
ll int T;T=1;
while(T--)
{ll int N;cin>>N;
  while(N>0)
  {
    ll int k=N%10;
    if(k==7)
    {
      cout<<"Yes"<<endl;
      return 0;
    }
    N/=10;
  }
  cout<<"No"<<endl;
}


       
    return 0; 
} 


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

int main(){
    int n, m;
    cin >> n >> m;
    int left = 1;
    int right = n;
    int l, r;
    for (int i = 0; i<m; i++){
        cin >> l >> r;
        if (left < l) left = l;
        if (right > r) right = r;
    }
    cout << max(0, right - left + 1) << endl;
}





Measured memory_bytes: 384
A, B, C, K = map(int, input().split())
sum = 0

# 最大値を求めたいので、A->B->Cの順に選んでいく
if K - A >= 0 :
  sum = A
  K = K - A
  if K - B >= 0:
    K = K - B
    sum -= K
else :
  sum = K
  
print(sum)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
class book{
public:
	ll t,a,b,flag;
};
bool compare(pair<ll,ll> p1,pair<ll,ll> p2){
  if(p1.second==p2.second) return p1.first>p2.first;
	return p1.second>p2.second;
}
bool comp(char a, char b)
{
    return (a < b);
}
int mex(int *A,int n){
	int C[n];
	for(int i=0;i<n;i++) C[i]=A[i];
	sort(C,C+n);
	for(int i=0;i<=n;i++){
		if(!binary_search(C,C+n,i)) return i;
	}
}
bool check(int *A,int n){
	for(int i=0;i<n-1;i++){
		if(A[i]>A[i+1]) return false;
	}
	return true;
}
bool subsetSum(vector<ll> arr, int n, int s){
	int dp[2][s+1];

	for(int i=0;i<=s;i++){
		dp[0][i] = false;
	}
    dp[0][0] = true;

    int flag = 1;

	for(int i=1;i<=n;i++){
		for(int j =1;j<=s;j++){
			dp[flag][j] = dp[flag^1][j];
			if(j-arr[i-1]>=0){
				dp[flag][j] = dp[flag][j] || dp[flag^1][j-arr[i-1]];
			}
		}
        flag^=1;
	}

 	return dp[flag^1][s];
}
int main() {
	// your code goes here


	int T=1;
	//cin>>T;

	while(T--){
	     ll n;
			 cin>>n;
			 string s;
       cin>>s;
       int i=0;
       for(i;i<n;i++){
         if(s[i]=='W') break;
       }
       ll ans=0;
       if(i==n) ans=0;
       else{
         ll ctr=0;
         for(int j=i;j<n;j++){
           if(s[j]=='W') ctr++;
         }
         ll j=n-1;
         while(ctr--){
           if(s[j]=='R') ans++;
           j--;
         }
       }
       cout<<ans<<endl;
}
	return 0;
}


Measured memory_bytes: 3744
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a*b % 2 == 0){
      System.out.println("Even");
    }else{
      System.out.println("Odd");
    }
  }
}

Measured memory_bytes: 22356
line = input().split(" ")
summer_day = int(line[0])
summer_kadai = int(line[1])

kadai_list = input().split(" ")
hituyou_day = 0
for i in range(summer_kadai):
    hituyou_day = hituyou_day + int(kadai_list[i])

if (hituyou_day <= summer_day):
    print(summer_day - hituyou_day)
else:
    print("-1")


Measured memory_bytes: 65412
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
const int INF=1e9+5;
typedef long long ll;

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

Measured memory_bytes: 3612
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>

#include<atcoder/convolution>
#include<atcoder/dsu>
#include<atcoder/fenwicktree>
#include<atcoder/internal_bit>
#include<atcoder/internal_math>
#include<atcoder/internal_queue>
#include<atcoder/internal_scc>
#include<atcoder/internal_type_traits>
#include<atcoder/lazysegtree>
#include<atcoder/math>
#include<atcoder/maxflow>
#include<atcoder/mincostflow>
#include<atcoder/modint>
#include<atcoder/scc>
#include<atcoder/segtree>
#include<atcoder/string>
#include<atcoder/twosat>

using namespace std;
using namespace atcoder;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=2e5+5,MOD=1e9+7;
const ld EPS = 1e-9;

int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=(xx<<3)+(xx<<1)+ch-'0';ch=getchar();}
    return xx*ff;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
	fastio;

	int n, q; 
	cin>>n>>q;
	int a[n]; 
	forn(i,n) cin>>a[i];
		
	fenwick_tree<ll> f(n);
	forn(i,n) f.add(i, a[i]);

	forn(i,q){
		int c; cin>>c;
		int l, r; cin>>l>>r;
		if(c == 0){
			f.add(l, r);
		}
		else{
			cout<<f.sum(l, r)<<ln;
		}
	}	

	return 0;
}

Measured memory_bytes: 10220
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main() {
    auto s = string{};
    cin >> s;
    cout << s.substr(0, 3);
    return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007LL;

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

    return 0;
}


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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

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

int main()
{
	fast;
	int n, k;
	cin >> n >> k;
	FOR(k)
	{
		int t;
		cin >> t;
		n -= t;
	}
	if (n > 0)
		cout << "No";
	else
		cout << "Yes";
}

Measured memory_bytes: 3648
#include<iostream>
#include<queue>
using namespace std;
struct node{
	int r,c,cen;
};
int h,w;
int p=-1;
int s=-1;
char map[250][250];
//int cen[250][250]={0};
int vis[250][250]={0};
int d[2][4]={1,-1,0,0,0,0,1,-1};
int ok(int r,int c){
	if(r<0||r>=h) return false;
	if(c<0||c>=w) return false;
	if(map[r][c]=='#') return false;
	if(vis[r][c]) return false;
	return true;
}
void bfs(int r,int c){
	vis[r][c] = 1;
	node st;st.r=r;st.c=c;st.cen=0;
	queue<node> q;q.push(st);
	while(!q.empty()){
		node t = q.front();
		q.pop();
		if(map[t.r][t.c]=='$'){
			if(s==-1) s = t.cen;
			else s = min(s,t.cen);
		}
		else if(map[t.r][t.c]=='@'){
			if(p==-1) p = t.cen;
			else p = min(p,t.cen);
		}
		for(int i=0;i<4;++i){
			if(ok(t.r+d[0][i],t.c+d[1][i])){
				vis[t.r+d[0][i]][t.c+d[1][i]] = 1;
				q.push((node){t.r+d[0][i],t.c+d[1][i],t.cen+1});
			}
		}
	}
}
int main(){
	int i,j;
	cin>>h>>w;
	for(i=0;i<h;++i){
		scanf("%s",map[i]);
	}
	for(i=0;i<h;++i){
		for(j=0;j<w;++j){
			if(map[i][j]=='%') {
				 bfs(i,j);
			}
		}
	}
	if(p==-1){
		printf("No\n");
	}
	else if(s==-1){
		printf("Yes\n");
	}
	else if(p>=s) printf("No\n");
	else printf("Yes\n");
} 


Measured memory_bytes: 3440
# ABC155 C

n = int(input())
S = {}
max_S = 0
res = []

for _ in range(n):
    s = input()
    if s in S:
        S[s] += 1
        if S[s] > max_S:
            max_S = S[s]
    else:
        S[s] = 1
        if S[s] > max_S:
            max_S = S[s]

for key in S:
    if S[key] == max_S:
        res.append(key)

for _ in sorted(res):
    print(_)

Measured memory_bytes: 32988
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll inf = 1e18;
vector<int> arr[2 * 100005];
bool vis[2 * 100005];
int val;
void dfs(int i){
    if(vis[i])
        return ;
    vis[i] = 1;
    val++;
    for(int c : arr[i])
        if(!vis[c])
            dfs(c);
}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int m;
    cin >> m;
    for(int i = 0 ; i < m ; i++){
        int a , b;
        cin >> a >> b;
        arr[a].push_back(b);
        arr[b].push_back(a);
    }
    int ans = 0;
    for(int i = 1 ; i <= n ; i++){
        val = 0;
        if(!vis[i])
            dfs(i);
        ans = max(val ,  ans);
    }
    cout<<ans;
}


Measured memory_bytes: 21024
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
int n, m, ct;
vi x, y;

//treeを使う分だけ tree[i] = i で初期化
int tree[100010];
int root(int x){return tree[x] == x ? x : tree[x] = root(tree[x]);}
void unite(int a , int b){tree[root(a)] = root(b);}

int main(){
    cin >> n >> m;
    x = y = vi(m);
    rep(i, m){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }
    rep(i, m){
        rep(j, n) tree[j] = j;
        rep(j, m){
            if(i == j)continue;
            unite(y[j], x[j]);
            
        }
        set <int> va;
        rep(j, n)
            va.insert(root(j));
        if(va.size() > 1)
            ct++;
    }
    cout << ct << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
ll comb[2001][2001];
ll powmod(ll x,ll n){
    if(n == 0)return 1;
    ll ans = powmod(x*x%MOD,n/2);
    if(n % 2)ans = ans * x % MOD;
    return ans;
}
ll divmod(ll a,ll b){
    return ((a%MOD) * (powmod(b,MOD-2)%MOD)) % MOD;
}
ll combi(ll n,ll r){
    ll num = 1;
    for(ll i = 1;i <= r;i++){
        num = divmod((n-i+1)*num,i);
        comb[n][i] = num;
    }
    comb[n][0] = comb[n][n] = 1;
    return num;
}
main(){
    
    //rep(i,0,2001)combi(N-2,2000);
    ll N,K;
    cin >> N >> K;
    if(N == 1){
        if(K == 1)cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    if(N == 2){
        if(K == 1)cout << 2 << endl;
        else if(K == 2) cout << 1 << endl << 0 << endl;
        return 0;
    }
    combi(N - 2, 2000);
    combi(K - 1, 2000);
    combi(N - K + 1, 2000);
    //cout << comb[N][K] << endl;
    rep(i,1,K+1){
        ll ans = comb[N-K+1][i];
        //cout << comb[N-2][i] << " " << comb[K-1][i-1] << " ";
        ans = ans * comb[K-1][i-1] % MOD;
        cout << ans << endl;
    }
}

Measured memory_bytes: 6400
D,N = gets.split(" ").map{|i|i.to_i}

case D
when 0 then
    if N == 100
        puts 101
    else
        puts N
    end
when 1 then
    if N == 100
        puts 10100
    else
        puts N*100
    end
when 2 then
    if N == 100
        puts 1010000
    else
        puts N*10000
    end
end


Measured memory_bytes: 1788
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        double r = in.nextDouble();
        double pi = Math.PI;
        double area = r*r*pi;
        double circleLine = 2*r*pi;
        System.out.printf("%f %f",area,circleLine);
        in.close();
    }
}


Measured memory_bytes: 28224
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) 0;
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  std::vector< std::string > days{
    "SUN","MON","TUE","WED","THU","FRI","SAT"
  };
  std::string s; std::cin >> s;
  int k = std::find(all(days), s) - days.begin();
  assert(0<=k && k < 7);
  int ans = 7 - k;
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
   long long int n;
   cin>>n;
  long long int a[n];

  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  if(a[0]>1)
  {
    a[0]=a[0]-1;
  }
   int f=0;
  for(int i=1;i<n;i++)
  {
     if( a[i]<a[i-1] )
     {
        f=1;
        break;
     }
     else
     if(a[i]==a[i-1])
     {

     }
     else
      a[i]=a[i]-1;
  }
  if(f==1)
  {
    cout<<"No";
  }
  else
    cout<<"Yes";

}


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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

int A[2005], B[2005];
int n;
int Nex[2005];
int Pre[2005];
bool between[2005][2005];
bool between2[2005][2005];


int main(){
	ios::sync_with_stdio(0);
	string a, b;
	cin >> a >> b;
	n = sz(a);
	int sumA=0, sumB=0;
	rep(i,0,n){
		A[i] = (a[i]=='1');
		B[i] = (b[i]=='1');
		sumA += A[i];
		sumB += B[i];
	}
	if(!sumB){
		if(sumA){
			cout << "-1" << endl;
		}
		else{
			cout << "0" << endl;
		}
		return 0;
	}
	rep(i,0,n){
		between[i][0] = B[i];
		between2[i][0] = B[i];
		if(B[i]){
			Nex[i]=0;
			Pre[i]=0;
		}
		else{
			Nex[i]=n*4+1000;
			Pre[i]=n*4+1000;
		}
		rep(j,1,n){
			between[i][j] = (B[(i+j)%n]||between[i][j-1]);
			between2[i][j] = (B[(i+2*n-j)%n]||between2[i][j-1]);
			if(B[(i+j)%n]){
				Nex[i]=min(Nex[i], j);
			}
			if(B[(i+2*n-j)%n]){
				Pre[i]=min(Pre[i], j);
			}
		}
	}
	int ans = 1000000000;
	rep(s,0,2*n){
		vector<pair<int, int> > shifts;
		int cost = s;
		rep(i,0,n){
			int to = (i+s)%n;
			if(B[to]){
				cost += !A[i];
				continue;
			}
			if(!A[i])
				continue;
			++cost;
			if(between[i][s])
				continue;
			shifts.emplace_back(Pre[i], Nex[(i+s)%n]);
		}
		sort(all(shifts));
		if(shifts.empty()){
			ans = min(ans, cost);
			continue;
		}
		ans = min(ans, cost+2*shifts.back().first);
		int worstShift=0;
		for(int i = sz(shifts)-1; i >= 0; --i){
			int worstShift2 = 0;
			if(i)
				worstShift2=shifts[i-1].first;
			worstShift = max(worstShift, shifts[i].second);
			ans = min(ans, cost+worstShift2*2+worstShift*2);
		}
	}
	rep(s,0,2*n){
		vector<pair<int, int> > shifts;
		int cost = s;
		rep(i,0,n){
			int to = (i+2*n-s)%n;
			if(B[to]){
				cost += !A[i];
				continue;
			}
			if(!A[i])
				continue;
			++cost;
			if(between2[i][s])
				continue;
			shifts.emplace_back(Nex[i], Pre[(i+2*n-s)%n]);
		}
		sort(all(shifts));
		if(shifts.empty()){
			ans = min(ans, cost);
			continue;
		}
		ans = min(ans, cost+2*shifts.back().first);
		int worstShift=0;
		for(int i = sz(shifts)-1; i >= 0; --i){
			int worstShift2 = 0;
			if(i)
				worstShift2=shifts[i-1].first;
			worstShift = max(worstShift, shifts[i].second);
			ans = min(ans, cost+worstShift2*2+worstShift*2);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8192