akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cmath>
#include<ctype.h>
#include<vector>
#include<cstdlib>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<stack>
#include<map>

#define ll long long
#define LL long long
#define ULL unsigned long long 
#define ull unsigned long long 
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)

using namespace std;
int N, K;
int D[10];
bool tmp[10] = {};
int like[10];
int ttmp[6];
int ans[5];
int main()
{
	cin >> N >> K;
	REP(i, K) {
		cin >> D[i];
		tmp[D[i]] = true;
	}
	int j = 0;
	REP(i, 10) {
		if (tmp[i] == false) {
			like[j] = i;
			j++;
		}
	}
	
	int digit=0;
	int number = N;

	int tnum=0;
	for (int i =0;; i++) {
		tnum = N + i;
		int flag = 0;
		number = tnum;
		while (number != 0) {
			number = number / 10;
			++digit;
		}
		int tmp_num = 0;
		for (int y = pow(10, digit - 1); y > 0; y /= 10) {
			ttmp[j] = (tnum - tmp_num) / y;
			tmp_num += ttmp[j] * y;
			for (int k = 0; k < K;k++) {
				if(ttmp[j] == D[k]){
				flag++;
			}
			}
			j++;
		}
		
		if (tnum>=N&&flag == 0)break;
		flag = 0; j = 0; digit = 0;

	}

		cout << tnum;
	
	cout << endl;
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int a, b;

    cin >> a >> b;

    if (a <= 5)
        cout << 0 << endl;
    if (6 <= a && a <= 12)
    {
        cout << b / 2 << endl;
    }
    if (13 <= a)
        cout << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    long long  x;
    cin >> x ;
    long long n;
    n=x/11;
    x%=11;
    if(x>6) cout << 2*n+2 << endl;
    else if(x>0) cout << 2*n+1 << endl;
    else cout << 2*n << endl;
 
}

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

int main()
{
	int N;

	cin >> N;

   vector<int>A(N);
   vector<int>B(N);
   for (int i = 0; i < N-1;i++) {
       cin >> B.at(i);
       //cout << A.at(B.at(i)) << endl;
       A.at(B.at(i)) = A.at(B.at(i)) + 1;
   }

   for (int i = 1; i < N;i++) {
       cout << A.at(i) << endl;

   }
   cout << 0 << endl;


}


Measured memory_bytes: 4840
a,b,c=map(int,input().split())
k=int(input())
for i in range(k):
  if a<b:
    break
  else:
    b*=2
    k-=1
for i in range(k):
  c*=2
if a<b<c:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    string s,t;
    cin>>s>>t;
    if(s.size()==t.size()){
        for(int i=0;i<s.size();i++){
            cout<<s[i]<<t[i];
        }
    }else{
        for(int i=0;i<t.size();i++){
            cout<<s[i]<<t[i];
        }
        cout<<s[s.size()-1];
    }
    cout<<endl;
    
}


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

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)

using namespace std;
using ll = long long;
using pos = pair<ll, ll>;

vector<ll> v;

void solve();

int main() {

   solve();
   return 0;

}

void solve() {

	v.resize(101);
	REP(i, 101) { v[i] = 0; }
	ll buf = 0;
	REP(i, 4) {
		cin >> buf;
		i % 2 ? v[buf]-- : v[buf]++;
	}
	FOR(i,1, 101) { v[i] += v[i - 1]; }
	ll ans = 0;
	REP(i, 101) {
		if (v[i] == 2)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        long N = sc.nextLong();
        for(long i = 1; i <= 3500; i++){
            for(long j = 1; j <= 3500; j++){
                if(4*i*j-i*N-j*N != 0 && (i*j*N)%(4*i*j-i*N-j*N) == 0 && (i*j*N)/(4*i*j-i*N-j*N) > 0){
                    System.out.println(i+" "+j+" "+((i*j*N)/(4*i*j-i*N-j*N)));
                    return;
                }
            }
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 23380
#include<iostream>

using namespace std;

char s[100005] = {}, ans[50005] = {};
int c = 0;

int main() {
	cin >> s;

	while (s[c] != 0) {
		ans[c / 2] = s[c];
		c += 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll f(ll n){
    return n-n%2;
}

ll calc(ll i,ll j, ll l){
    ll res=0;
    res+=f(i);
    res+=f(j);
    res+=f(l);
    if(i&&j&&l){
        ll num=3;
        i--,j--,l--;
        num+=f(i);
        num+=f(j);
        num+=f(l);
        chmax(res,num);
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll I,O,T,J,L,S,Z;
    cin>>I>>O>>T>>J>>L>>S>>Z;
    
    ll ans=O;
    ans+=calc(I,J,L);
    cout1(ans)
}

Measured memory_bytes: 256
xs,ys,xt,yt=list(map(int,input().split()))
N=int(input())
a=[]
for i in range(N):
	a.append(list(map(int,input().split())))

# xs,ys,xt,yt=[-1000000000, -1000000000, 1000000000, 1000000000]
# N=1
# a=[[-1000000000, 1000000000, 1]]

class Dijkstra(object):
	"""
	ダイクストラ法,(N^2)
	ステータス:distance(list),prev(list),size(int)
	distancemap[i][j]->Distance of edge i to j
	"""
	def __init__(self, distancemap, start):
		self.start=start
		self.size=len(distancemap)
		self.distance=[float("inf") for x in range(self.size)]
		self.distance[start]=0
		self.prev=[0 for x in range(self.size)]
		self.prev[start]=-1
		yet=list(range(self.size))
		yet.remove(start)
		now=start
		while(yet!=[]):
			nearest_num=0
			nearest_dis=float("inf")
			for i in yet:
				total_dis=distancemap[now][i]+self.distance[now]
				self.distance[i]=min(total_dis, self.distance[i])
				if self.distance[i]<=nearest_dis:
					nearest_dis=self.distance[i]
					nearest_num=i
			yet.remove(nearest_num)
			self.prev[nearest_num]=now
			now=nearest_num

	def route(self,goal):
		route=[]
		while(True):
			route.append(self.prev[goal])
			goal=self.prev[goal]
			if goal==self.start:
				break
		route.reverse()
		return(route)

import math
def solve(xs,ys,xt,yt,N,a):
	a.insert(0,[xs,ys,0])
	a.append([xt,yt,0])
	def distance(i,j):
		x1=a[i][0]
		y1=a[i][1]
		r1=a[i][2]
		x2=a[j][0]
		y2=a[j][1]
		r2=a[j][2]
		d=math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))-r1-r2
		if d<0:
			d=0
		return(d)
	distancemap=[[0 for x in range(N+2)] for x in range(N+2)]
	for i in range(N+2):
		for j in range(N+2):
			if i>j:
				distancemap[i][j]=distancemap[j][i]
			else:
				distancemap[i][j]=distance(i,j)

	d=Dijkstra(distancemap, 0)
	return(d.distance.pop())

print(solve(xs, ys, xt, yt, N, a))


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    string T;
    cin >> T;
    int N    = T.size();
    lint cnt = 0;

    for (int i = 0; i < N; i++) {
        if (T[i] == '?') {
            if (T[i - 1] == 'P') {
                T[i] = 'D';
            } else {
                T[i] = 'D';
            }
        }
    }
    cout << T << endl;
    return 0;
}

Measured memory_bytes: 3748
#include <stdio.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include <time.h>
#include <bits/stdc++.h>

using namespace std;

int main()
{
	string s;
	cin>>s;

	int b=0,c=0;

	int n=s.size();



	for(int i=0;i<n-1;i++)
	{
		if(s[i]=='A' && s[i+1]=='C')
			b=1;
		
	}

	if(b==1)
		cout<<"Yes";

	else
		cout<<"No";
	return 0;
}

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

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

int main() {
    int n, k, q; cin >> n >> k >> q;
    vector<int> scores(n, 0);
    int a;
    rep(i, q){
        cin >> a;
        scores[a-1]++;
    }
    rep(i, n) cout << (scores[i]+k>q ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <cmath>
#include <set>
#include <map>
#include <algorithm>
#include <limits>
#include <math.h>

using namespace std;
#define iter(b) for(int i = 0;i < (b);i++)
#define VVI vector<vector<int>>
#define VI vector<int>
#define ll long long

int main()
{
    string S;
    cin >> S;
    cout << S.substr(0, 3);
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	n=3*n+k;
	cout<<n/2<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
void chmax(int &x,int y){if(x < y) x = y;}
void chmin(int &x,int y){if(x > y) x = y;}
int n;ll ans;
string s[200005];
int son[1000005][27],tag[1000005];
char typ[1000005];
int ex[1000005][27],suf1[1000005],suf2[1000005][27];
int num;
//root is 0
void ins(string s){
    int cur = 0;
    rap(i,0,s.size()){
        if(!son[cur][s[i] - 'a']) {
            son[cur][s[i] - 'a'] = ++num;
            typ[num] = s[i];
            cur = num;
        }
        else cur = son[cur][s[i] - 'a'];
    }
    tag[cur]++;
}
void dfs(int x){
    ex[x][typ[x] - 'a'] ++;
    suf1[x] += tag[x];
    rep(i,0,25){
        if(son[x][i]) {
            dfs(son[x][i]);
            suf1[x] += suf1[son[x][i]];
            rep(j,0,25) {ex[x][j] += ex[son[x][i]][j]; suf2[x][j] += suf2[son[x][i]][j];}
        }
    }
    rep(ch,0,25) {
        if(typ[x] == ch + 'a') suf2[x][ch] = suf1[x];
    }
    //cout<<x<<' '<<typ[x]<<' '<<suf2[x][2]<<'\n';
}
int main()
{
    fastio;
    cin>>n;
    rep(i,1,n) {cin>>s[i];reverse(s[i].begin(),s[i].end());}
    rep(i,1,n) ins(s[i]);
    dfs(0);
    rep(i,1,n) {
        //walk
        int nwlen = (int)s[i].size() - 1;
        int cur = 0;
        bool flg = 0;
        rap(j,0,nwlen){
            int to = son[cur][s[i][j] - 'a'];
            if(!to) {flg = 1;break;}
            cur = to;
        }
        if(flg) continue;
        //cout<<i<<' '<<cur<<'\n';
        char lst = s[i].back();
        rep(ch,0,25) if(son[cur][ch]) ans += suf2[son[cur][ch]][lst - 'a'];
        //cout<<lst<<' '<<suf2[cur][lst - 'a']<<'\n';
    }
    ans -= n;
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 403728
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int N;
    cin >> N;
    string s;
    cin >> s;
    
    int a = 0;
    int cur = 0;
    rep(i, s.size()){
        if(s[i] == '(') cur++;
        else cur--;
        if(cur < 0) a++, cur = 0;
        
    }
    string pre = "", suf = "";
    rep(i, a){
        pre += '(';
    }
    if(cur > 0){
        rep(i, cur){
            suf += ')';
        }
    }
    output(pre + s + suf);
    
    
    return 0;
}

Measured memory_bytes: 256
import sys

input = lambda :sys.stdin.readline().rstrip()

def main():
    n, m, Q = map(int, input().split())
    Train= [[0 for _ in range(n)] for _ in range(n)]
    
    for i in range(m):
        l, r = map(int, input().split())
        l, r = l - 1, r - 1
        Train[l][r] += 1
    
    P_Train = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
    for i in range(n):
        for j in range(n):
            P_Train[i + 1][j + 1] = P_Train[i][j + 1] + P_Train[i + 1][j] + Train[i][j] - P_Train[i][j]
    
    #print(*P_Train, sep = '\n')

    for i in range(Q):
        p, q = map(int, input().split())
        p, q = p - 1, q - 1
        ans = solve(P_Train, p, q)
        print(ans)

def solve(P_Train, p, q):
    ans = 0
    ans = P_Train[q + 1][q + 1] -P_Train[p][q + 1] - P_Train[q + 1][p] + P_Train[p][p]
    return ans


if __name__ == '__main__':
    main()

Measured memory_bytes: 57948
n = int(input())
mod = 10**9 + 7
a = 1
for i in range(n):
    a *= 10
    a %= mod
b = 1
for i in range(n):
    b *= 9
    b %= mod
b *= 2
b %= mod
c = 1
for i in range(n):
    c *= 8
    c %= mod
print((a - b + c) % mod)

Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 2005;

vector<int> X,Y,X1,Y1,X2,Y2;
bool flag[MAX_N*2][MAX_N*2];
int n;

int main()
{
	int p,q,r,s;
	scanf("%d",&n);
	rep(i,n){
		scanf("%d%d%d%d",&p,&q,&r,&s);
		X.push_back(p),X.push_back(r);
		Y.push_back(q),Y.push_back(s);
		X1.push_back(p),X2.push_back(r);
		Y1.push_back(q),Y2.push_back(s);
	}
	sort(X.begin(),X.end());
	sort(Y.begin(),Y.end());
	X.erase(unique(X.begin(),X.end()),X.end());
	Y.erase(unique(Y.begin(),Y.end()),Y.end());
	rep(i,n){
		X1[i] = lower_bound(X.begin(),X.end(),X1[i]) - X.begin();
		Y1[i] = lower_bound(Y.begin(),Y.end(),Y1[i]) - Y.begin();
		X2[i] = lower_bound(X.begin(),X.end(),X2[i]) - X.begin();
		Y2[i] = lower_bound(Y.begin(),Y.end(),Y2[i]) - Y.begin();
	}
	rep(i,n){
		for(int j=Y1[i];j<Y2[i];j++){
			for(int k=X1[i];k<X2[i];k++){
				flag[j][k] = true;
			}
		}
	}
	ll ans = 0;
	rep(i,Y.size()-1){
		rep(j,X.size()-1){
			if(flag[i][j]){
				ans += (ll)(X[j+1]-X[j])*(Y[i+1]-Y[i]);
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 18988
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn main() {
    let n: usize;
    input!(n);

    p(n * (2 + (n - 1)) / 2);
}

Measured memory_bytes: 4352
from sys import exit
n = int(input())
a = list(map(int, input().split()))
if n==1: print(0); exit()
al = [0 for _ in range(n)]
for index in range(n-1):
	person = a[index]
	person_behind = a[index+1]
	if person_behind < person:
		k = person - person_behind
		a[index+1] += k
		al[index+1] = k
print(sum(al))


Measured memory_bytes: 32308
#include<iostream>
#include<iomanip>
#include<memory>
#include<array>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
  int w, n;
  int a, b;
  char c;
  
  array<int, 30> kuji;
  
  cin >> w;
  cin >> n;

  for ( int i = 0; i < kuji.size(); i++ )
    kuji[i] = i+1;
  
  for ( int i = 0; i < n; i++ )
    {
      cin >> a >> c >> b;
      swap( kuji[a-1], kuji[b-1] );
    }

  for ( int i = 0; i < w; i++ )
    cout << kuji[i] << endl;

  return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
P t[40];
int u[11];
int n,a,b,sum,cnt;
int main(){
  while(cin>>n&&n){
    for(int I=0;I<n;I++){
      cin>>t[I].second;
      for(int i=0;i<=10;i++)u[i]=0;
      sum=0;
      for(int i=1;i<=10;i++){
	cin>>a;

	if(u[i-1]==2)sum+=a;
	if(i-2>=0&&u[i-1]==2&&u[i-2]==2)sum+=a;
	if(u[i-1]==1)sum+=a;

	if(a==10){
	  sum+=a;
	  u[i]=2;
	}else{
	  cin>>b;
	  if(u[i-1]==2)sum+=b;
	  sum+=(a+b);
	  if(a+b==10)u[i]=1;
	}
      }
      
      if(u[10]==2){
	cin>>a>>b;
	sum+=a;
	sum+=b;
	if(u[9]==2)sum+=a;
      }else if(u[10]==1){
	cin>>a;
	sum+=a;
      }
      t[I].first=sum*-1;
    }//for n

    sort(t,t+n);
    for(int i=0;i<n;i++){
      cout<<t[i].second<<' '<<t[i].first*-1<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1164
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define ll long long
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define forn(x) for(int i=1;i<=x;i++) 
#define sforn(x, y) for(int i=1;i<=x;i++)for(int j=1;j<=y;j++)
#define pii pair<int, int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

/*
    LOL KEK CHEBUREK
 
    PIHALITI
 
 */

int main(){ speed;
    ll k;
    cin >> k;
    cout << k*k << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

AB = []
for _ in range(N):
    A, B = map(int,input().split())
    AB.append([B,A])

AB.sort()

t = 0
for i in range(N):
    t += AB[i][1]
    if t > AB[i][0]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 38100
using System;
using System.Linq;
using System.Collections.Generic;
class ans2259
{
    static void Main()
    {
        var scores = new List<int>();
        foreach(String line in ReadLines().Skip(1)) {
            scores.Add(line.Split(' ').Select(x => int.Parse(x)).Sum());
        }
        Console.WriteLine(scores.Max());
    }
    static IEnumerable<string> ReadLines()
    {
        while (true)
        {
            var line = Console.ReadLine();
            if (line == null) break;
            yield return line;
        }
    }
}


Measured memory_bytes: 18484
Nums = list(map(int, input()[:]))
op = ['+', '-']
for i in range(2):
    for j in range(2):
        for k in range(2):
            if Nums[0] + Nums[1] * (-1) ** i\
                    + Nums[2] * (-1) ** j + Nums[3] * (-1) ** k == 7:
                print('%d%s%d%s%d%s%d=7' % (Nums[0], op[i], Nums[1], op[j], Nums[2], op[k], Nums[3]))
                exit()

Measured memory_bytes: 3064
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
vll L;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;

    L.push_back(0);
    rep(ni,N){
        cin >> ltmp;
        L.push_back(ltmp);
    }
    sort(L.begin(),L.end());
    ll ans = 0;
    for( ll ni = 1 ; ni <=N-2 ; ni++ ){
        for( ll ni2 = ni+1 ; ni2 <=N-1 ; ni2++ ){
            for( ll ni3 = ni2+1 ; ni3 <=N ; ni3++ ){
                if(L[ni]!=L[ni2]&&L[ni2]!=L[ni3]&&L[ni]!=L[ni3]){
                    if(L[ni3]<L[ni]+L[ni2]) ans++ ;
                }
            }
        }
    }
    cout << ans << endl;
    

}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <tuple>
using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  vector<tuple<string,int,int>> v;
  for(int i=0;i<n;i++){
    string s;
    int tmp;
    cin>>s>>tmp;
    v.push_back(make_tuple(s,tmp*(-1),i+1));
  }

  sort(v.begin(),v.end());

  for(int i=0;i<n;i++){
    cout<<get<2>(v.at(i))<<endl;
  }

  return 0;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    int temp;
    rep(i,m){
        cin>>temp;
        n-=temp;
        if(n<0){
            n=-1;
            break;
        }
    }
    cout<<n<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n; cin >> n;
    if(n < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

string S;
ll dp[100010][2];

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

  cin>>S;
  ll N=S.size();
  dp[0][0]=1;
  rep(i,N)rep(j,2){
    rep(k,(j==0?S[i]-'0'+1:2)){
      if(k==0) (dp[i+1][!(j==0&&k==S[i]-'0')]+=dp[i][j])%=mod;
      else (dp[i+1][!(j==0&&k==S[i]-'0')]+=dp[i][j]*2%mod)%=mod;
    }
  }

  cout<<(dp[N][0]+dp[N][1])%mod<<endl;

  return 0;
}


Measured memory_bytes: 2000
import java.util.Scanner;

public class Main {

	public static void main(String[] arg) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		int flag = 0;
		for(int i = a; i <= b; i++){
			if(i % n == 0){
				flag = 1;
				break;
			}
		}
		if(flag == 1){
			System.out.println("OK");
		}else {
			System.out.println("NG");

		}
	}
}


Measured memory_bytes: 35776
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    rep(i, h) {
        rep(j, w) {
            if ((j < a && i < b) || (j >= a && i >= b)) cout << 0;
            else cout << 1;
        }
        cout << endl;
    }


    return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<stdlib.h>
#define MAX 100
#define N 100
void bubbleSort(int *,int n);
int main(){
  int A[MAX];
  int n,i,v=0,j=0,l,cnt;
  scanf("%d",&n);
  if(n>N){
    end(1);
  }
  for(j=0;j<n;j++){
    scanf("%d",&A[j]);
  }
  bubbleSort(A,n);
  return 0;
}
void bubbleSort(int *A, int n){
  int i,v,j,l,flag=1,cnt=0;
  while(flag){
    flag=0;
    for(j=n-1;0<j;j--){
      if(A[j]<A[j-1]){
	v=A[j];
	A[j]=A[j-1];
	A[j-1]=v;
	cnt++;
	flag=1;
      }
    }
  }
    for(l=0;l<n;l++){
      printf("%d",A[l]);
      if(l!=n-1){
	printf(" ");
      }
      if(l==n-1){
	printf("\n");
      }
    }
    printf("%d\n",cnt);
}
  



Measured memory_bytes: 2128
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

int64_t
solve(const size_t i,
      const int ci,  // carried from left
      const int cj1,  // carried towards end
      const vector<int> & d,
      unordered_map<uint64_t, int64_t> & cache)
{
  const uint64_t key = i * 4 + cj1 * 2 + ci;
  {
    const auto iter = cache.find(key);
    if(iter != end(cache)) return iter->second;
  }

  const auto j = d.size() - i - 1;
  int64_t out = 0;

  for(int cj = 0; cj < 2; ++ cj) // needed carry at the other end
    for(int ni = 0; ni < 10; ++ni)  // n(i)
    {
      const auto nj = (ni + d[i] + ci) % 10;
      const auto ci1 = (ni + d[i] + ci) / 10;

      if((nj + d[j] + cj) % 10 == ni && (nj + d[j] + cj) / 10 == cj1 && (i || nj))
      {
        if(i + 1 < j)
          out += solve(i + 1, ci1, cj, d, cache);
        else if(i + 1 == j)
          out += (cj == ci1);
        else // i == j
          out += (ni == nj) && (ci == cj) && (ci1 == cj1);
      }
    }

  return cache[key] = out;
}


int64_t arc075_d()
{
  int d;
  cin >> d;

  vector<int> xs;
  for(; d; d /= 10)
    xs.push_back(d % 10);

  DEBUG(xs);
  int64_t out = 0;
  for(size_t i = 0; i < 32; ++i)
  {
    unordered_map<uint64_t, int64_t> cache;
    out += solve(0, 0, 0, xs, cache);
    xs.push_back(0);
  }

  return out;
}

int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << arc075_d();

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            long num;
            var result = 0;
            for (var i = 1; i <= n; i++)
            {
                var count = 0;
                num = i;
                while (num > 0)
                {
                    num = num / 10;
                    count++;
                }
                if (count % 2 == 1) result++;
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

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

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

	string S;
	cin >> S;

	rep (i, S.size ()) {
		if (i % 2 == 0) {
			if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') {
				continue;
			}

			cout << "No" << endl;
			return 0;
		}

		if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D') {
			continue;
		}

		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d = a/b;
	r = a%b;
	f = 1.0*a/b;
	printf("%d %d %.5lf\n",d,r,f);
	return 0;
}

Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

M = 10 ** 9 + 7
H, W = map(int, readline().split())
grid = []
for i in range(H):
    grid.append(readline().decode("utf-8").rstrip())
    assert len(grid[-1]) == W


def solve():
    t = [0] * W
    t[0] = 1
    for c in range(1, W):
        if grid[0][c] == ".":
            t[c] = t[c - 1]
    for r in range(1, H):
        for c in range(W):
            if grid[r][c] == "#":
                t[c] = 0
            elif c > 0:
                t[c] += t[c - 1]
                t[c] %= M
        # print(r, "\t", t)
    return t[-1]


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 4084
def sieve_of_eratosthenes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = True
    for i in range(2, int(n ** 0.5) + 1):
        if is_prime[i] is False:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return is_prime


n = int(input())
ans = []
is_prime = sieve_of_eratosthenes(55555)

for i in range(2, 55556):
    if is_prime[i] is True and i % 10 == 1:
        ans.append(i)
        if len(ans) == n:
            break

print(*ans)


Measured memory_bytes: 64236
#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;
typedef pair<ll, ll> P;

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

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

int wx[20] = {-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2};
int wy[20] = {-2,-2,-2,-2,-2,-1,-1,-1,-1,0,0,1,1,1,1,2,2,2,2,2};

int main()
{
    int h,w;   cin >> h >> w;
    int ch,cw; cin >> ch >> cw; ch--; cw--;
    int dh,dw; cin >> dh >> dw; dh--; dw--;
    char s[h][w];
    int dist[h][w];
    bool visit[h][w];
    rep(i,h) rep(j,w){
        cin >> s[i][j] ;
        dist[i][j] = inf;
        visit[i][j] = false;
    }
    
    deque<P> que;
    que.push_back({ch,cw});
    visit[ch][cw] = true;
    dist[ch][cw] = 0;


    while(!que.empty()){
        P p = que.front(); que.pop_front();
        int y = p.first,x = p.second;
        rep(i,4){
            int ny = y + dy[i], nx = x + dx[i];
            if(0 <= ny && ny < h && 0 <= nx  && nx < w && s[ny][nx] == '.' && !visit[ny][nx]){
                que.emplace_front(ny,nx);
                dist[ny][nx] = dist[y][x];
                visit[ny][nx] = true;
            }
        }
        rep(i,20){
            int ny = y + wy[i], nx = x + wx[i];
            if(0 <= ny && ny < h && 0 <= nx  && nx < w && s[ny][nx] == '.' && !visit[ny][nx]){
                if(dist[ny][nx] > dist[y][x] + 1){
                    que.push_back({ny,nx});
                    dist[ny][nx] = dist[y][x]+1;
                }
            }
        }
    }

    if(dist[dh][dw] == inf){
        cout << -1 << endl;
    }else{
        cout << dist[dh][dw] << endl;
    }
}

Measured memory_bytes: 9636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF INT_MAX
#define LINF 1LL<<60

struct SegTree {
	int N;
	ll init_v = INF;
	vector<ll> node;

	SegTree(int _N) {
		N = 1;
		while (N < _N) N *= 2;
		node.resize(2 * N - 1, INF);
	}

	void update(int k, ll val) {
		k += N - 1;
		node[k] = val;
		while (k) {
			k = (k - 1) / 2;
			node[k] = min(node[2 * k + 1], node[2 * k + 2]);
		}
	}
	ll query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return INF;
		if (a <= l && r <= b) return node[k];
		else {
			ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
			ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
			return min(vl, vr);
		}
	}
	ll rmq(int a, int b) { return query(a, b, 0, 0, N); }
};

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	SegTree ST(n);
	for (int i = 0; i < q; i++) {
		int com, x, y; cin >> com >> x >> y;
		if (com == 0) {
			ST.update(x, y);
		}
		else {
			cout << ST.rmq(x,y+1) << endl;
		}
	}
}

Measured memory_bytes: 4936
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
# import decimal
# from decimal import Decimal
# decimal.getcontext().prec = 10

# from heapq import heappush, heappop, heapify
# import math
# from math import gcd
# import itertools as it
# import collections
# from collections import deque 

def inp():
    return int(input())
def inps():
    return input().rstrip()
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------

X = inp()

for i in range(-120, 120):
    for j in range(-120, 120):
        if i**5 - j**5 == X:
            print(i, j)
            sys.exit()

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

using namespace std;

template < typename T > void Max (T &a, T b) {
  a = max (a, b);
}

inline bool ok (pair < int , int > p) {
  return p.first == 0 || p.second == 0;
}

const int INF = 1e9 + 9;

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  string a, b;
  cin >> a >> b;
  vector < vector < pair < int , pair < int , int > > > > dp (a.length() + 1 , vector < pair < int , pair < int , int > > > (b.length() + 1, {-INF, {0, 0}}));
  dp[0][0] = {0, {0, 0}};
  for (int i = 0; i < (int)a.size(); ++i)
    for (int j = 0; j < (int)b.size(); ++j) {
      if (a[i] == b[j])
        Max (dp[i + 1][j + 1], make_pair (dp[i][j].first + 1, make_pair (i, j)));
      Max (dp[i][j + 1], make_pair (dp[i][j].first, make_pair (i, j)));
      Max (dp[i + 1][j], make_pair (dp[i][j].first, make_pair (i, j)));
    }
  pair < int , pair < int , int > > ans = make_pair (0, make_pair (0, 0));
  for (int i = 0; i <= (int)a.size(); ++i)
    for (int j = 0; j <= (int)b.size(); ++j)
      Max (ans, make_pair (dp[i][j].first, make_pair (i, j)));
  string s;
  while (!ok(ans.second)) {
    int i = ans.second.first,
        j = ans.second.second;
    pair < int , int > prev = dp[i][j].second;
    if (prev == make_pair (i - 1, j - 1))
      s += a[i - 1];
    ans.second = prev;
  }
  reverse (s.begin(), s.end());
  cout << s;
}


Measured memory_bytes: 109016
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <set>

long long pow(long long n) {
    if (n == 1) return 2;
    if (n % 2 == 1) {
        long long num = pow(n / 2);
        return num * num * 2 % 1000000007;
    } else {
        long long num = pow(n / 2);
        return num * num % 1000000007;
    }
}

int main() {
    int n;
    std::cin >> n;

    std::vector<int> v(n);
    std::map<int, int> m;
    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
        m[v[i]]++;
    }

    for (auto it = m.begin(); it != m.end(); it++) {
        if (it->first == 0) {
            if (it->second != 1) {
                std::cout << 0 << std::endl;
                return 0;
            }
        } else {
            if (it->second != 2) {
                std::cout << 0 << std::endl;
                return 0;
            }
        }
    }

    if (n == 1) {
        std::cout << 1 << std::endl;
        return 0;
    }

    long long ans = pow(n / 2);
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
	long long int w,h,x,y;
	cin>>w>>h>>x>>y;
	if(x==w/2&&y==h/2&&w%2==0&&h%2==0){
		printf("%.6lf 1\n",w*(h/2.0));
	}else{
		printf("%.6lf 0\n",w*(h/2.0));
	}
	
	return 0;
}

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

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        long[] N=cin.ArrayLong(2,0);
        long ans=N[0]+N[1];
        if(ans%2==0)Console.WriteLine(ans/2);
        else Console.WriteLine("IMPOSSIBLE");
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }

}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)
#define MAX_N 100000
int d[MAX_N];
int main() {
	rep(i, MAX_N) d[i] = INF;
	int N; cin >> N;
	rep(i, N) cin >> d[i];
	sort(d, d+MAX_N);
	cout << d[N/2] - d[N/2-1] << endl;
}

Measured memory_bytes: 4028