akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();

		if ((a % 2) * (b % 2) == 0) {
			pr.println("Even");
		} else {
			pr.println("Odd");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23508
from collections import defaultdict

def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))

n = getN()
seq = getList()
bucket = defaultdict(int)

for num in seq:
    bucket[num] += 1

ans = 0
for i in (bucket.keys()):
    num = bucket[i]
    if num != 0:
        if num < i:
            ans += num
        elif num > i:
            ans += num -i

print(ans)

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

typedef long long ll;

int main(){
  static int n,k;
  static ll h[200010];
  cin >> n >> k;
  for(int i = 0 ; i < n ; i ++){
    cin >> h[i];
  }
  sort(h,h+n);
  ll ret = 0;
  for(int i = 0 ; i < n-k ; i ++){
    ret += h[i];
  }
  cout << ret << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    ll r = 0, g = 0, b = 0;
    rep(i, n) {
        if (s[i] == 'R') r++;
        else if (s[i] == 'G') g++;
        else if (s[i] == 'B') b++;
    }
    ll ans = r * g * b;
    rep(i, n) {
        rep(d, n) {
            int j = i + d;
            int k = j + d;
            if (k >= n) continue;
            if (s[i] != s[j] && s[j] != s[k] && s[i] != s[k])
                ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<cstdio>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<stack>
#include<iterator>
#include<functional>
#include<string.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//namespace mp = boost::multiprecision;

int main(){
   int n; cin>>n;
   if(n==7||n==5||n==3){
   	cout<<"YES"<<endl;
   	}else{cout<<"NO"<<endl;}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    string s;
    cin >>s;
    ll q;cin >> q;
    vl count(q);
    ll c=0;
    vector<pair<ll,char>> pl(q,mp(0,'0'));
    rep(i,q){
        ll x;
        cin >> x;
        if(x==1)c++;
        if(x==2){
            ll a;char b;
            cin >> a >>b;
            pl[i]=mp(a,b);
        }
        count[i]=c;
    }
    if(c%2==1){
        reverse(all(s));
        string pre="";
        rep(i,q){
            if(pl[i].fi!=0){
                ll y=pl[i].fi+c-count[i];
                if(y%2==0){
                    s+=pl[i].se;
                }
                else{
                    pre+=pl[i].se;
                }
            }
        }
        reverse(all(pre));
        cout << pre+s <<endl;
        return 0;
    }
    if(c%2==0){
        string pre="";
        rep(i,q){
            if(pl[i].fi!=0){
                ll y=pl[i].fi+c-count[i];
                if(y%2==0){
                    s+=pl[i].se;
                }
                else{
                    pre+=pl[i].se;
                }
            }
        }
        reverse(all(pre));
        cout << pre+s <<endl;
        return 0;
    }
}

Measured memory_bytes: 5984
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    REP(i, 10) {
        char c = i + '0';
        vector<bool> b(10, false);
        vvi v(10, vi(10));
        REP(j, n) {
            if (c == s[j]) {
                FOR(k, j + 1, n) {
                    char q = s[k];
                    int d = (int)(q - '0');
                    REP(l, 10) {
                        if (b[l]) {
                            v[l][d] = 1;
                        }
                    }
                    b[d] = true;
                }
                break;
            }
        }
        // printvv(v);
        REP(x, 10) REP(y, 10) ans += v[x][y];
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const ll INF = (1LL << 31) - 1;
const double pi=acos(-1);

int main(){
  int h,w;
  cin >> h >> w;
  vector<string>f(h+2);
  string t="";
  rep(i,w+2)t+='.';
  f[0]=t;
  f[h+1]=t;
  rep(i,h){
    string u;
    cin >> u;
    u.insert(0,".");
    u.insert(u.size(),".");
    f[i+1]=u;
  }
  rep(i,h+2){
    rep(j,w+2){
      if(f[i][j]=='#'){
        if(f[i-1][j]=='.' &&f[i+1][j]=='.' &&f[i][j+1]=='.' &&f[i][j-1]=='.'){
          cout <<"No"<<endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes"<<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int counter(int x){
  if (x==0) return 0;
  return counter(x>>1)+(x&1);
}
int main(){
  cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    int x[20][20];
    int y[20][20];
    int A[20];
    cin >> n;
  for(int i=1;i<=n;i++){
    cin >> A[i];
    for(int j=1;j<=A[i];j++){
      cin >> x[i][j] >> y[i][j];
    }
  }
  int ans = 0;
  for(int bits = 1; bits < (1 << n); bits++) {
        bool ok = true;
        for(int i = 1; i <= n; i++) {
            if(!(bits & (1 << (i-1)))) continue;
            for(int j = 1; j <= A[i]; j++) {
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if(ok) ans = max(ans, counter(bits));
    }
  cout << ans << endl;

  

        
}

Measured memory_bytes: 256
n,t = map(int,input().split())
orders = []
for i in range(n):
    a,b = map(int,input().split())
    orders.append([a,b])

orders.sort(key=lambda x:(x[0],-x[1]))
# print(orders)

dp = [[-1e10 for i in range(t+1)] for j in range(n+1)]
dp[0][0] = 0

for i,od in enumerate(orders):
    for j in range(t+1):
        dp[i+1][j] = dp[i][j]
    for j in range(t):
        nt = j+od[0]
        if nt > t-1:
            nt = t
        if dp[i+1][nt] < dp[i][j]+od[1]:
            dp[i+1][nt] = dp[i][j]+od[1]

# for l in dp:
#     print(l[:11])
# print(dp[-1])
print(max(dp[-1]))

Measured memory_bytes: 217092
use std::io;


fn main() {
    let n = read_one::<usize>();
    for i in 1..3501 { for j in 1..3501 {
        if i * j % n != 0 { continue; }
        let denom = i * j;
        let numer = 4 * i * j / n;
        if numer < i + j { continue; }
        let numer = 4 * i * j / n - i - j;
        if numer == 0 { continue; }
        if denom % numer == 0 { println!("{} {} {}", i, j, denom / numer); return; }
    }}
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;



int main()
{
    int a,b;
    cin>>a>>b;
    char s,t;
    s='0'+a;
    t='0'+b;
    string ss,tt;
    rep(i,b){
        ss+=s;
    }
    rep(i,a){
        tt+=t;
    }
    if(ss<tt){
        cout<<ss<<endl;
    }else{
        cout<<tt<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;


int main() {

	int N, W;

	cin >> N >> W;

	vector<vector<long long>> dp(N+1, vector<long long>(W+1));

	vector<int> v(N), w(N);

	REP(i, N) {
		cin >> w[i] >> v[i];
	}

	REP(i, N+1) {
		dp[i][0] = 0;
	}

	REP(i, W + 1) {
		dp[0][i] = 0;
	}

	REP(i, N) {
		REP(j, W+1) {
			if (w[i] <= j) {
				dp[i + 1][j] = max(dp[i][j], v[i] + dp[i][j - w[i]]);
			}
			else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}

	cout << dp[N][W] << endl;

	return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007



// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;


int h, w;
int foo[410][410];
string mp[410];

int dfs(int x,int y){
    int dy[]={0, 0, 1, -1};
    int dx[]={1, -1, 0, 0};
    rep(i,4){
        if(x+dx[i]<0 || w<=x+dx[i]|| y+dy[i]<0 || h<=y+dy[i])continue;
        if(foo[y+dy[i]][x+dx[i]]==0 &&mp[y+dy[i]][x+dx[i]]!=mp[y][x]){
            foo[y+dy[i]][x+dx[i]]=foo[y][x];
            dfs(x+dx[i],y+dy[i]);
        }
    }
    return 0;
}

int main()
{
    cin>>h>>w;
    rep(i,h){
        rep(j,w){
            foo[i][j]=0;
        }
    }
    rep(i,h){
        cin>>mp[i];
    }
    int count=1;
    rep(i,h){
        rep(j,w){
            if(foo[i][j]==0) {
                foo[i][j]=count++;
                dfs(j,i);
            }
        }
    }
    map<int,int> piyo;
    map<int,int> bw;
    rep(i,h){
        rep(j,w){
            piyo[foo[i][j]]++;
            if(mp[i][j]=='#'){
                bw[foo[i][j]]++;
            }
        }
    }
    long long int ans=0;
    for(auto itr=piyo.begin() ; itr!=piyo.end();itr++){
        ans+=(long long int)bw[itr->first]*(long long int)(itr->second-bw[itr->first]);
    }
    cout<<ans<<endl;
    if(DEBUG){
        rep(i,h){
            rep(j,w){
                cout<<foo[i][j]<<" ";
            }
        cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 23552
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(){
	int n,i,r=0,b;
	scanf("%d",&n);
	vector<int>A(n),B(n);
	for(i=0;i<n;i++)scanf("%d",&A[i]);
	for(i=0;i<n;i++)scanf("%d",&B[i]);
	for(b=0;b<29;b++){
		int r0=0,t=1<<b;
		vector<int>a;
		transform(A.begin(),A.end(),back_inserter(a),
			[&](int e){return -(e%(2*t));}
		);
		sort(a.begin(),a.end());
		for(auto &e_:B){
			int e=e_%(2*t),sgn=-1,q;
			for(q=1;q<=4;sgn=-sgn,q++){
				r0+=sgn*distance(a.begin(),upper_bound(a.begin(),a.end(),-q*t+e));
			}
		}
		r^=(r0&1)*t;
	}
	printf("%d\n",r);
}

Measured memory_bytes: 3672
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<random>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
short gh[2][4] = { {0,0,-1,1},{-1,1,0,0} };
struct P {
ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
ll to, cost;
};
struct S {//辺の情報を入れる変数
int from, to, cost;
};
struct H {
int x, y;
};
bool operator<(H a, H b) {
if (a.x != b.x) return a.x < b.x;
return a.y < b.y;
}
ll gcm(ll i, ll j) {//最大公約数
if (i > j) swap(i, j);
if (i == 0) return j;
return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
if (b <= c || d <= a) return 0;
return 1;
}//[a,b),[c,d)
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int n,y;
signed main() {
	cin>>n>>y;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n-i;j++){
			int sum=i*10000+j*5000;
			int z=(y-sum)/1000;
			if((y-sum)>=0&&i+j+(y-sum)/1000==n){
				cout<<i<<" "<<j<<" "<<(y-sum)/1000<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
	getchar(); getchar();
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int x,y,r,tmp;
	scanf("%d %d", &x, &y);
	
	if(y > x){
		tmp = x;
		x = y;
		y = tmp;
	}

	while (y > 0){
		r = x % y;
		x = y;
		y = r;
	}
	
	printf("%d\n", x);
	
	return 0;
}


Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb push_back
#define eb emplace_back
#define fs first
#define sc second
using lint = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vii = vector<pii>;
const int INF = 1e9;
const int dx[] = {-1,1,0,0};
const int dy[] = {0,0,-1,1};

int h, w, ch, cw, dh, dw;
char s[1002][1002];

int dst[1002][1002];

int solve(){
  for(int i=1;i<=h;++i)
    for(int j=1;j<=w;++j)
      dst[i][j] = INF;
  dst[ch][cw] = 0;
  priority_queue<pair<int,pii>> pq;
  pq.emplace(0, pii(ch,cw));
  while(!pq.empty()){
    int x = pq.top().sc.fs;
    int y = pq.top().sc.sc;
    int d = -pq.top().fs; pq.pop();
    if(dst[x][y] < d) continue;

    for(int i=0;i<4;++i){
      int nx = x + dx[i], ny = y + dy[i];
      if(nx<1 || nx>h || ny<1 || ny>w || s[nx][ny]=='#') continue;
      if(dst[nx][ny] > d) dst[nx][ny] = d, pq.emplace(-d, pii(nx,ny));
    }
    for(int dx=-2;dx<=2;++dx)
      for(int dy=-2;dy<=2;++dy){
        int nx = x + dx, ny = y + dy;
        if(nx<1 || nx>h || ny<1 || ny>w || s[nx][ny]=='#') continue;
        if(dst[nx][ny] > d + 1) dst[nx][ny] = d + 1, pq.emplace(-(d+1), pii(nx,ny));
      }
  }
  return dst[dh][dw]==INF ? -1 : dst[dh][dw];
}

int main(){
  scanf("%d%d%d%d%d%d",&h,&w,&ch,&cw,&dh,&dw);
  for(int i=1;i<=h;++i)
    scanf("%s",s[i]+1);

  int ans = solve();
  printf("%d",ans);
}


Measured memory_bytes: 8652
#include<stdio.h>
#include<math.h>
int main()
{
    int n,a[100002],de[100002],sum=0,i,ans;
    scanf("%d",&n);
    a[0]=0;a[n+1]=0;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        de[i-1]=abs(a[i-1]-a[i]);
        sum+=de[i-1];
    }
    de[i-1]=abs(a[i-1]-a[i]);
        sum+=de[i-1];
    for(i=1;i<=n;i++)
    {
        ans=sum-de[i-1]-de[i]+abs(a[i-1]-a[i+1]);
        printf("%d\n",ans);
    }
    return 0;
}


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

int main() {
  
  int K, X;
  cin >> K >> X;

  vector<int> ans(K * 2 - 1);
  ans.at(0) = X - K + 1;
  for (int i = 1; i < ans.size(); i++) {
     ans.at(i) = ans.at(i - 1) + 1;
   }
     cout << ans.at(0);
  for (int i = 1; i < ans.size(); i++) {
     cout << " ";
     cout << ans.at(i);
   }

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,tmp;
	;
	while(1){
		scanf("%d %d\n ", &a,&b);
		if((a==0) && (b==0)) break;
		if(a>b)		printf("%d %d\n", b,a);
		
		else		printf("%d %d\n", a,b);
		
	
	}
	
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

vi cfs(100050, 1e15);
vi cft(100050, 1e15);
V(V(P)) yedge(100050);
V(V(P)) sedge(100050);


void dijkstra(int s, vi &cost, V(V(P)) &edge) {
    priority_queue<P, V(P), greater<P>> q;
    cost[s] = 0;
    q.push(P(0, s));
    while(!q.empty()) {
        P p = q.top();
        q.pop();
        int v = p.se;
        if(cost[v] < p.fi) continue;
        rep(i, edge[v].size()) {
            if(cost[edge[v][i].fi] > cost[v]+edge[v][i].se) {
                cost[edge[v][i].fi] = cost[v] + edge[v][i].se;
                q.push(P(cost[edge[v][i].fi], edge[v][i].fi));
            }
        }
    }
}

signed main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    rep(i, m) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        yedge[u].pb(P(v, a));
        yedge[v].pb(P(u, a));
        sedge[u].pb(P(v, b));
        sedge[v].pb(P(u, b));
    }

    dijkstra(s, cfs, yedge);
    dijkstra(t, cft, sedge);

    vi res(n, 1e15);
    rep(i, n) res[i] = cfs[i] + cft[i];
    //rep(i, n) cout << res[i] << endl;
    //cout << endl;
    for(int i=n-2; i>=0; i--) res[i] = min(res[i], res[i+1]);

    rep(i, n) {
        cout << 1000000000000000-res[i] << endl;
    }



    return 0;
}


Measured memory_bytes: 19140
let input_int_array n =
	Array.init n (fun _ -> Scanf.scanf "%d " (fun v -> v))
let get_int () = Scanf.scanf "%d " (fun v -> v)

let () =
  let n = get_int ()
  in let a = input_int_array n
  in Array.sort Pervasives.compare a;
  a.(Array.length a - 1) - a.(0)
  |> string_of_int |> print_endline


Measured memory_bytes: 4480
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

signed main() { 
        int n;
        cin >> n;
        vector<int> s(n);
        int sum = 0;
        rep(i, n) {
                cin >> s[i];
                sum += s[i];
        }
        sort(all(s));
        int no = -1;
        rep(i, s.size()) {
                if (s[i] % 10 != 0) {
                        no = s[i];
                        break;
                }
        }
        if (sum % 10 != 0) cout << sum << endl;
        else if (no != -1) {
                cout << sum - no << endl;
        } else {
                cout << 0 << endl;
        }
        return 0;
}               


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long f[10000005];
int main()
{
	long long n;
	cin>>n;
	for(int i=1;i<=n;++i)
		for(int j=i;j<=n;j+=i)
			f[j]+=1;
   	long long ans=0;
	for(long long i=1;i<=n;++i)
	   ans+=i*f[i];
	cout<<ans<<endl;
	return 0;
 } 

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

int main() {
    int A, B;
    int ans = 0;
    int tap = 1;
    cin >> A >> B;

    while (tap < B){
        tap -= 1;
        tap += A;
        ans++;
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int maxn=2e5+5,mod=1e4+7;
const double pi=acos(-1);

ll cmb(ll k)
{
    return k*(k-1)/2;
}

int a[maxn],vis[maxn],p[maxn];
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        memset(vis,0,sizeof(vis));
        memset(p,0,sizeof(p));
        for(int i=0; i<n; i++)
        {
            scanf("%d",&a[i]);
            vis[a[i]]++;
        }
        ll kk=0;
        for(int i=0; i<n; i++)
            if(!p[a[i]])
            {
                kk+=cmb(vis[a[i]]);
                p[a[i]]=1;
            }
        for(int i=0; i<n; i++)
            printf("%lld\n",kk-vis[a[i]]+1);
    }
    return 0;
}


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

int main() {

	ll h; cin >> h;
	ll cnt = 0;
	while (0 < h) {
		cnt++;
		h /= 2;
	}
	ll ans = 1;
	while (cnt--) {
		ans *= 2;
	}
	cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int dp[100005] = {};
    fill(dp, dp + 100005, INF);
    dp[0] = 0;

    int N;
    cin >> N;
    for (int i = 0; i <= N; i++) {
        dp[i + 1] = min(dp[i] + 1,dp[i+1]);
        for (int j = 1; (int)round(pow(6, j)) + i <= N; j++) {
            dp[(int)round(pow(6, j)) + i] = min(dp[(int)round(pow(6, j)) + i],dp[i] + 1);
        }
        for (int j = 1; round(pow(9, j)) + i <= N; j++) {
            dp[(int)round(pow(9, j)) + i] = min(dp[(int)round(pow(9, j)) + i],dp[i] + 1);
        }
    }

    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 640
from collections import deque

def read():
    return [int(i) for i in input().split()]

visited = []

def bfs(e, G):
    """ 連結じゃなければtrue. """
    n = len(G)
    visited = [False for i in range(n)]
    q = deque([0])
    visited[0] = True

    while len(q) > 0:
        cur = q.popleft()
        for dst in G[cur]:
            if sorted([cur,dst]) == sorted(e):
                continue
            if visited[dst]:
                continue
            q.append(dst)
            visited[dst] = True
    
    return sum(visited) != n


def main():
    n, m = read()
    G = [[] for j in range(n)]
    edge = []
    for i in range(m):
        a, b = read()
        a -= 1; b -= 1
        edge.append([a,b])
        G[a].append(b)
        G[b].append(a)

    cnt = 0
    for e in edge:
        cnt += bfs(e,G)
    print(cnt)

main()

Measured memory_bytes: 3316
from sys import stdin, setrecursionlimit


def main():
    a = [list(map(int, stdin.readline().split())) for _ in range(3)]
    n = int(stdin.readline())
    b = [int(stdin.readline()) for _ in range(n)]

    bg = []
    for i in range(3):
        bg.append(a[i])
        bg.append([a[0][i], a[1][i], a[2][i]])
    bg.append([a[i][i] for i in range(3)])
    bg.append([a[i][2 - i] for i in range(3)])

    for bgi in bg:
        if len(list(set(bgi) - set(b))) == 0:
            print('Yes')
            exit()

    print('No')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(){
	map <int, pair <int, int> > check;
	for(int i = -1000; i <= 1000; i++){
		for(int j = -1000; j <= 1000; j++){
			check[pow(i, 5) - pow(j, 5)] = make_pair(i, j);
		}
	}
	int x;
	cin >> x;
	cout << check[x].first << ' ' << check[x].second;
}

Measured memory_bytes: 4776
#include<bits/stdc++.h>
#define debug(x) cerr << #x << " = " << x << "\n";
#define debug_v(x) cerr << #x << " ="; for(auto in : x) {cerr << " [" << in << "]";} cerr << '\n';
using namespace std;
using ll = long long;
using ld = long double;
const double PI = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e5;
const ll inf64 = 1e18 + 100;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(20);
	ll n;
	cin >> n;
	vector<ll> a(n + 1), b(n);
	
	for (int i = 0; i < n + 1; i++){
		cin >> a[i];
	}
	for (int i = 0; i < n; i++){
		cin >> b[i];
	}
	ll answer = 0;
	if(b[n - 1] >= a[n]){
		answer += a[n];
		b[n - 1] -= a[n];
		a[n] = 0;
	}
	else{
		a[n] -= b[n - 1];
		answer += b[n - 1];
		b[n - 1] = 0;
	}
	if(b[n  - 1] >= a[n - 1]){
		answer += a[n - 1];
		b[n - 1] -= a[n - 1];
		a[n - 1] = 0;
	}
	else{
		answer += b[n - 1];
		a[n - 1] -= b[n - 1];
		b[n - 1] = 0;
	}
	for (int i = 0; i < n - 1; i++){
		if(b[i] >= a[i]){
			answer += a[i];
			b[i] -= a[i];
			a[i] = 0;
		}
		else{
			answer += b[i];
			a[i] -= b[i];
			b[i] = 0;
		}
		if(b[i] >= a[i + 1]){
			answer += a[i + 1];
			b[i] -= a[i + 1];
			a[i + 1] = 0;
		}
		else{
			a[i + 1] -= b[i];
			answer += b[i];
			b[i] = 0;
		}
	}
	
	cout << answer << '\n';
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int main(void) {
	int n; cin >> n;
	int ans = 0;
	double ww = 1000000;
	double t, a; cin >> t >> a;
	rep(i, n) {
		double x;
		cin >> x;
		double ato = t - x * 0.006;
		if (abs(a - ato) < ww) {
			ww = abs(a - ato);
			ans = i+1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    ll X, Y;
    cin >> X >> Y;
    ll cnt = 0;
    while (X <= Y) {
        X *= 2;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import static java.lang.System.out;
public class Main{
   public static void main(String []args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int result = 0;
      for(int i= 0; i<N; i++){
         int li = sc.nextInt();
         int ri = sc.nextInt();
         result += (ri - li)+1;


      }
      out.println(result);
   }
}

Measured memory_bytes: 27492
#include<stdio.h>
int main(){
  int N,i,j,temp,mini,count=0;
  int argv[100];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&argv[i]);
  }
  for(i=0;i<=N-1;i++){
    mini=i;
    for(j=i;j<=N-1;j++){
      if(argv[j]<argv[mini]){
        mini=j;
      }
    }
      if(i != mini){
        count++;
        temp=argv[i];
        argv[i]=argv[mini];
        argv[mini]=temp;
      }}
    for(i=0;i<N-1;i++){
      printf("%d ",argv[i]);

        }
    printf("%d\n",argv[N-1]);
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2076
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

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

  cout << S / 3600 << ":" << S % 3600 / 60 << ":" << S % 60 << endl;
  return 0;
}



Measured memory_bytes: 3108
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		int i,j,k,v;
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		int array[] = new int[n];

		for(i=0;i<n;i++)array[i] = Integer.parseInt(in.next());

	for(i=0;i<n;i++){
		v = array[i];
		j = i-1;
		while(j>=0 && array[j]>v){
			array[j+1] = array[j];
			j--;
		array[j+1] = v;
		}
	    for(k = 0;k<n-1;k++)System.out.print(array[k]+" ");
	    if(i<(n-1))System.out.println(array[k]);
	    else System.out.println(array[k]);
	}
	}

}

Measured memory_bytes: 31688
pos, times, ranges = map(int, input().split())
first_try = abs(pos) // ranges

if first_try >= times: 
    print(abs(pos) - times * ranges)
else: #正の範囲で０に近づくだけ移動する
    remain_times = times - first_try
    second_pos = abs(pos) - first_try * ranges
    if remain_times % 2 == 0: #のこりが偶数回しかないなら終了
        print(abs(second_pos))
    else:
        if abs(second_pos + ranges) <= abs(second_pos - ranges):
            print(abs(second_pos + ranges))
        else:
            print(abs(second_pos - ranges))

Measured memory_bytes: 9200
#include <stdio.h>
int main(void){
    // Your code here!
    int i, j, n, m;
    int dp[100002];
    int flag;
    int a[100002];
    int js = 0;

    scanf("%d %d", &n, &m);

    for (i = 0; i < m; i++) {
        scanf("%d", &a[i]);
    }
    dp[0] = 1;

    flag = 0;
    for (j = 0; j < m; j++) {
        if (1 == a[j]) {
            flag = 1;
            break;
        }
    }
    if (flag) {
        dp[1] = 0;
    } else {
        dp[1] = 1;
    }


    for (i = 2; i <= n; i++) {
        flag = 0;
        for (j = js; j < m; j++) {
            if (i == a[j]) {
                flag = 1;
                js = j + 1;
                break;
            }
        }
        if (flag) {
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
    }
    printf("%d\n", dp[n]);

    return 0;
}


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

using namespace std;

#define Rep(i,a,b)  for (int i=(a);i<(b);i++)
#define rep(i,n)    for (int i=0;i<(n);i++)
#define all(x)      (x).begin(), (x).end()

#define ll long long

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



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

int n,a[100001],minn,maxx,minc,maxc;

int main() {
    cin>>n>>a[0];
    minn=maxx=a[0];
    minc=maxc=1;
    for (int i=1;i<n;++i) {
    	cin>>a[i];
    	if (minn==maxx) {
    		if (abs(a[i]-minn)>1) {
    			cout<<"No";
    			return 0;
    		}
    		if (a[i]==minn-1) {
    			minn=a[i];
    			minc=1;
    		} else if (a[i]==minn+1) {
    			maxx=a[i];
    			maxc=1;
    		} else {
    			++minc;
    			++maxc;
    		}
    	} else {
	    	if (a[i]<minn||a[i]>maxx) {
			cout<<"No";
			return 0;
	    	} else {
	    		++(a[i]==minn?minc:maxc);
	    	}
    	}
    }
    if (minn==maxx) {
    	if (minn==n-1||minn*2<=n) cout<<"Yes";
    	else cout<<"No";
    	return 0;
    }
    if (minc>=maxx||(maxx-minc)*2>maxc) cout<<"No";
    else cout<<"Yes";
    return 0;
}

Measured memory_bytes: 640
N = int(input())
str = input()

r_sum = 0
for i in range(N):
    if str[i] == "R":
        r_sum += 1
r_sum2 = 0
for i in range(r_sum):
    if str[i] == "R":
        r_sum2 += 1

print(r_sum - r_sum2)


Measured memory_bytes: 9472
#include<bits/stdc++.h>
#define ri register int
#define forn(i, n) for(int i = 1; i <= (n); i++)
typedef long long ll;
using namespace std;
/* Template_In_Programming_Contest */

void rd(int& u) {scanf("%d", &u);}
void rd2(int& u, int& v) {scanf("%d%d", &u, &v);}
void rd3(int& u, int& v, int& w) {scanf("%d%d%d", &u, &v, &w);}
void ptn(int u) {printf("%d\n", u);}
void pte(int u) {printf("%d ", u);}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int , int> pii;
typedef pair <ll , ll> pll;
typedef vector <int> vi;

int n, m;
int main(){
	cin >> n;
	vector <int> v(n);
	for(int i = 0; i < n; i++) cin >> v[i];
	
	int sum = 0;
	for(int i = 0; i < n; i++) {
		int ans = 0;
		for(int j = i + 1; j < n; j++) ans += v[j];
		sum += v[i] * ans;
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main() {
  char alf[26] = { 0 };
  char S[111111];
  int i;
  
  scanf("%s", S);
  for(i = 0; S[i] != '\0'; i++) {
    alf[S[i]-'a']++;
  }
  
  for(i = 0; i < 26; i++) {
    if(alf[i] == 0) {
      printf("%c\n", 'a' + i);
      return 0;
    }
  }
  printf("None\n");
  
  return 0;
}

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

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

// テーブルを作る前処理
/*
void COMinit() {
    fac[0] = fac[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }
}
*/

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}




int main()
{
    string S;

    cin >> S;

    if(S[2]==S[3] && S[4]==S[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

 
    return 0;

}

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


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    bool exist = false;
    for (int i = 1; i <= b; i++) {
        if ((a * i) % b == c) {
            exist = true;
        }
    }
    if (exist) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
template<class T>void sort(vec<T> &v){sort(v.begin(),v.end());}
template<class T>void rsort(vec<T> &v){sort(v.rbegin(),v.rend());}
const ll mod = 1e9+7;
const ll inf = 99999999999;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,x; cin >> n >> m >> x;
    ll c[15];
    ll a[15][15];
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }
    ll ans = inf;
    rep(tmp,(1 << n)){
        bitset<13> s(tmp);
        ll p = 0;
        vec<ll> un(m,0);
        rep(i,n){
            if(s.test(i)){
                p += c[i];
                rep(j,m){
                    un[j]+=a[i][j];
                }
            }
        }
        bool ok = true;
        rep(j,m){
            if(un[j] < x)ok = false;
        }
        if(ok)ans = min(ans,p);
    }
    if(ans == inf)ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n){ 
    cin >> a[i];
  }
  int ans = 1e9;
  FOR(k,-100,101){
    int tmp = 0;
    REP(i,n) tmp += (k-a[i])*(k-a[i]);
    ans = min(ans, tmp);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>

using namespace std;

void solve(int N, int T, vector<pair<int, int>> X) {
  int cc = 1000;
  bool TLE = true;
  for (auto x : X) {
    if (x.first <= cc && x.second <= T) {
      cc = x.first;
      TLE = false;
    }
  }
  if (TLE) {
    printf("TLE\n");
  } else {
    printf("%d\n", cc);
  }
}

int main() {
  int N, T;
  cin >> N >> T;
  vector<pair<int, int>> X(N);
  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    X[i] = make_pair(c, t);
  }
  solve(N, T, X);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    if (a & 1) return cout << "first" << '\n', 0;
  }
  cout << "second" << '\n';
}

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

 int main()
 {
      string s;
      int Max=0;
      cin>>s;
      int a=s.size();
      int sum=0;
      if(s[0]=='R')sum++;Max=sum;
      for(int i=1;i<a;i++)
      {
        if(s[i]==s[i-1]&&s[i]=='R')sum++;
        else if(s[i]=='R'&&s[i-1]=='S')sum=1;
        else if(s[i]=='S')sum=0;
        Max=max(Max,sum);
      }cout<<Max<<endl;
 }


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
const int maxn = 100000 + 5;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int n, m;
int a[maxn];
vector<int> odd, b;

int main() {
    //freopen("b.in", "r", stdin);
   // freopen("b.out", "w", stdout);

    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; ++i) {
        a[i] = read<int>();
        if(a[i] & 1) odd.pb(i);
    }

    if(odd.size() > 2) { return puts("Impossible"), 0; }

    if(odd.size() >= 1) swap(a[1], a[odd[0]]);
    if(odd.size() >= 2) swap(a[m], a[odd[1]]);

    for(int i = 1; i <= m; ++i) printf("%d ", a[i]);
    for(int i = 1; i <= m; ++i) {
        if(i == 1) {
            if(a[i] > 1) 
                b.pb(a[i] - 1);
        }else {
            if(i == m) 
                b.pb(a[i] + 1);
            else 
                b.pb(a[i]);
        }
    }
    if(m == 1) b.pb(1);

    printf("\n%d\n", int(b.size()));
    for(int i = 0; i < int(b.size()); ++i) printf("%d ", b[i]);

    return 0;
}


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

using namespace std;
 
typedef long long ll;
 

int main(){
    int n, m;

    cin >> n >> m;


    vector<int> x;
    for(int i = 0; i < m; i++)
    {
        int tmp;
        cin >> tmp;
        x.push_back(tmp);
    }
    
    if (n >= m){
        cout << "0" << endl;
        return 0;
    }


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

    vector<pair<int, int>> dx;

    for(int i = 0; i < m - 1; i++)
    {
        dx.push_back(make_pair(x[i+1]-x[i], i));
    }
    
    sort(dx.begin(),dx.end(),greater<pair<int, int>>());

    /*
    for(auto f: dx)
    {
        cout << f.first << " " << f.second << endl;
    }
    */
    int ans = 0;

    ll minos = 0;
    for(int i = 0; i < n - 1; i++)
    {
        minos += dx[i].first;        
    }
    ans = x[x.size()-1] - x[0] - minos;

    cout << ans << endl;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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

ll n,k;
int main() {
  cin >> n >>k;
  n=n%k;
  cout << min(n,(ll)abs(n-k));
}


Measured memory_bytes: 256