akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

constexpr int MOD = 1000000007;

int mod(const ll &x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(const ll &x,const ll &m){
    return x * m % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

int main(void)
{
    IOS
    int n; cin >> n;
    map<int,int> m;
    REP(i,n) {
        int a; cin >> a;
        m[a]++;
    }

    int ans = 0;
    bool ok = true;
    int cur = n % 2 == 0 ? 1 : 0;

    while(cur < n) {
        int x = cur == 0 ? 1 : 2;
        if (m[cur] != x) {
            ok = false;
            break;
        }
        cur += 2;
    }
    if (ok) ans = modpow(2,n/2); 

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<P>> vvp;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int a,b,c;
  cin >> a >> b >> c;
  int d,e,f;
  d=max({a,b,c});
  f=min({a,b,c});
  e=a+b+c-max({a,b,c})-min({a,b,c});
  
  int ans=0;
  ans+=d-e;
  f+=d-e;
  ans+=(d-f)/2;
  if(d%2!=f%2) ans+=2;
  
  cout << ans << endl;
    
  return 0;     
}


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

int an[5000],bl[5000];

int main(){
    int a,b,ans=0;
    cin>>a>>b;
    for(int i=0;i<a;++i) cin>>an[i];
    for(int i=0;i<b;++i) cin>>bl[i];
    int cnt,cur;
    for(int i=0;i<b;++i){
        cnt=0;cur=i;
        for(int j=0;j<a;++j){
            if(bl[cur]==an[j]) ++cnt,++cur;
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;




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


Measured memory_bytes: 256
#include <stdio.h>
#define N 50

int main( void ) {

  while( 1 ) {
    int i, n;
    int page[ N ], cont[ N ] = { 0 };

    scanf( "%d", &n );
    if( !n ) break;

    scanf( "%d", &page[ 0 ] );

    for( i = 1; i < n; i++ ) {
      scanf( "%d", &page[ i ] );

      if( page[ i-1 ] + 1 == page[ i ] )
        cont[ i-1 ] = 1;
    }

    for( i = 0; i < n; i++ ) {
      printf( "%d", page[ i ] );

      if( cont[ i ] ) {
        printf( "-" );

        for( i++; cont[ i ]; i++ ) ;

        printf( "%d", page[ i ] );
      }

      if( i < n-1 )
        printf( " " );
    }
    printf( "\n" );
  }

  return( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cerr << x << " ";} cerr << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cerr << x << " ";}cerr << endl;}
#define printP(p) cerr << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef vector<vector<int>> Graph;

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

    int N, L;
    cin >> N >> L;
    vi a(N);
    rep(i, N) cin >> a[i];

    rep(i, N) {
        if (a[i] + a[i + 1] >= L) {
            cout << "Possible" << endl;
            vi ans;
            ans.emplace_back(i);
            rep2(j, i + 1, N - 1) ans.emplace_back(j);
            for (int j = i - 1; j >= 0; j--) {
                ans.emplace_back(j);
            }
            reverse(all(ans));
            for (auto && x : ans) cout << x + 1 << endl;
            return 0;
        }
    }

    cout << "Impossible" << endl;
}


Measured memory_bytes: 2548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    private static long[][] dp;
    private static long calculate(int current, int value, int[][] arr){
        if(current < 0 && value == 0) return 0;
        if(current < 0) return Long.MAX_VALUE;
        if(value < 0) return Long.MAX_VALUE;
        if(dp[current][value] != -1) return dp[current][value];
        long x = calculate(current - 1, value, arr);
        long y = calculate(current - 1, value - arr[current][1], arr);
        if(y != Long.MAX_VALUE){
            y += arr[current][0];
        }
        dp[current][value] = Math.min(x, y);
        return Math.min(x, y);
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        // code goes here
        int[] in = nextIntArray(br, 2);
        int n = in[0];
        int w = in[1];
        int[][] arr = new int[n][2];
        int maxValue = 0;
        for(int i = 0; i < n; i++){
            arr[i] = nextIntArray(br, 2);
            maxValue += arr[i][1];
        }
        dp = new long[n][maxValue + 1];

        for(int i = 0; i < n; i++){
            Arrays.fill(dp[i], -1);
        }

        for(int i = 0; i < maxValue + 1; i++)
            calculate(n - 1, i, arr);
        int ans = 0;
        for(int i = 0; i <= maxValue; i++){
            if(dp[n - 1][i] <= w && dp[n - 1][i] > 0) ans = i;
        }
        sb.append(ans);
        System.out.print(sb.toString());
    }

    private static int nextInt(BufferedReader br) throws IOException{
        return Integer.parseInt(br.readLine());
    }

    private static int[] nextIntArray(BufferedReader br, int n) throws IOException{
        StringTokenizer st = new StringTokenizer(br.readLine());
        int[] arr = new int[n];
        for(int i = 0; i < n; i++){
            arr[i] = Integer.parseInt(st.nextToken());
        }
        return arr;
    }

    static class Pair<A, B>{
        A first;
        B second;
        public Pair(A first, B second){
            this.first = first;
            this.second = second;
        }
    }
}


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

int main(){
  ll N;
  cin >> N;
  ll ans = 0;
  for(ll i=1;i<=N;++i) {
    for(ll j=i;j<=N; j+=i) {
      ans += j;
    }
  }
  cout << ans << endl;

}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];

    int res = 1001001001;
    int cnt;
    rep(i, n)
    {
        cnt = 0;
        while (v[i] % 2 == 0)
        {
            cnt++;
            v[i] /= 2;
        }
        res = min(res, cnt);
    }

    cout << res << endl;
    return (0);
}


Measured memory_bytes: 3628
require 'complex'

n,d = gets.split(" ").map{|e| e.to_i}
count =0
dimension = []
n.times do
  dimension << gets.split(" ").map{|e| e.to_i}
end

dimension.combination(2).each do |a,b|
  sum = 0
  a.zip(b).each do|item|
    sum += (item[0]-item[1])**2
  end
  tmp = Math.sqrt(sum)
  count += 1 if (tmp - tmp.to_i) == 0
end

puts count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<ll,ll>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((ll)x.size())
#define MOD (ll)(998244353)
#define INF (9e18)
#define EPS (1e-6)
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif

void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

struct DSU{
	int n;
	int par[100010],size[100010];
	void init(int _n){
		n=_n;
		For(i,0,n-1) par[i]=i;
		For(i,0,n-1) size[i]=1;
	}
	int find(int i){
		if(par[i]==i) return i;
		return par[i]=find(par[i]);
	}
	void uni(int a,int b){
		a=find(a); b=find(b);
		if(a==b) return;
		par[b]=a;
		size[a]+=size[b];
	}
	bool same(int a,int b){
		return find(a)==find(b);
	}
	int ask(int i){
		return size[find(i)];
	}
}dsu;

int ans[100010];

int32_t main() {
	INIT();
	//code...
	int n,m,k; cin>>n>>m>>k;
	memset(ans,0,sizeof(ans));
	dsu.init(n);
	int a,b;
	while(m--){
		cin>>a>>b;
		a--; b--;
		ans[a]++; ans[b]++;
		dsu.uni(a,b);
	}
	while(k--){
		cin>>a>>b;
		a--; b--;
		if(!dsu.same(a,b)) continue;
		ans[a]++; ans[b]++;
	}
	For(i,0,n-1) cout<<(dsu.ask(i)-ans[i]-1)<<" \n"[i==n-1];
	return 0;
}


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

int main() {
  int n;
  cin >>n;
  vector<int> a(n);
  rep(i,n) cin >>a[i]; 
  vector<int> b(n);
  rep(i,n) cin >>b[i];
  int ans = 0;
  int total = 0;
  rep(i,n) total += a[i]+b[i];
  rep(i,n){
    int asum = 0;
    int bsum = 0;
    for(int j = i+1; j<n; j++) asum += a[j];
    for(int j = 0; j<i; j++) bsum += b[j];
    int sum = total - asum - bsum;
    if(sum>ans) ans = sum;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2000010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long C(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main () {
  COMinit();
  long r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  
  long ans = C(r2 + c2 + 2, c2 + 1) - C(r1 + c2 + 1, r1) - C(r2 + c1 + 1, r2 + 1) + C(r1 + c1, r1);
  if(ans < 0)cout << 1000000007 + ans << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 47104
#include <cstdio>
#include <map>
#include <queue>
#include <string>

using namespace std;

const int INF = -1;
const int MAX_H = 1010;
const int MAX_W = 1010;
const int MAX_N = 10;

int H, W, N;
char field[MAX_H][MAX_W];
int d[MAX_H][MAX_W];
int sx, sy, gx, gy;
int power = 1;
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};

typedef pair<int, int> P;

void reset_d() {
  for (int i = 0; i < H; i++)
    for(int j = 0; j < W; j++) d[i][j] = INF;
}

int bfs(int c) {
  queue<P> que;
  reset_d();
  d[sx][sy] = c;
  que.push(P(sx, sy));
  while(que.size()) {
    P p = que.front(); que.pop();
    for (int i = 0; i < 4; i++) {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if ( 0 <= nx && nx <= H && 0 <= ny && ny <= W && field[nx][ny] != 'X' && d[nx][ny] == INF) {
        d[nx][ny] = d[p.first][p.second] + 1;
        que.push(P(nx, ny));
        if (field[nx][ny] - '0' == power) {
          sx = nx;
          sy = ny;
          power++;
          return d[nx][ny];
        }
      }
    }
  }
  return INF;
}

void solve() {
  int c = 0;
  for (int i = 0; i < N; i++) {
    c = bfs(c);
  }
  printf("%d\n", c);
}


int main() {
  scanf("%d %d %d", &H, &W, &N);
  for (int i = 0; i < H; i++) {
    scanf("%s", field[i]);
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (field[i][j] == 'S') {
        sx = i;
        sy = j;
      }
      if (field[i][j] == 'G') {
        gx = i;
        gy = j;
      }
    }
  }
  solve();
  return 0;
}

Measured memory_bytes: 6028
n,m=map(int,input().split())
parent=[]
distances=[]
edges=[]
visited=set()
visited.add(1)
for i in range(n):
  edges.append([])
for i in range(m):
  edges.append([])
  a,b=map(int,input().split())
  edges[a].append(b)
  edges[b].append(a)
for i in range(n+1):
  parent.append(0)
  distances.append(-1)
parent[0]=-1
parent[1]=-1
nextdistancelist=[1]
distancelistcopy=[]
for currentdistance in range(1,n+1):
  distancelistcopy=[]
  for k in nextdistancelist:
    visited.add(k)
    for r in edges[k]:
      if r in visited:
        continue
      if parent[r]!=0:
        continue
      parent[r]=k
      distancelistcopy.append(r)
  nextdistancelist=distancelistcopy.copy()
failflag=0
for i in range(2,n+1):
  if parent[i]==0:
    failflag=1
    break
if failflag==1:
  print('No')
else:
  print('Yes')
  for i in range(2,n+1):
    print(parent[i])

Measured memory_bytes: 54780
#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 rrng(a) a.rbegin(),a.rend()
#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 eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#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 tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,m;
  cin >> n >> m;
  if(m>=n)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
if s=='SUN':
  print(7)
elif s=='MON':
  print(6)
elif s=='TUE':
  print(5)
elif s=='WED':
  print(4)
elif s=='THU':
  print(3)
elif s=='FRI':
  print(2)
elif s=='SAT':
  print(1)

Measured memory_bytes: 2940
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val h = sc.nextInt()
    val w = sc.nextInt()
    val s = (0 until h).map { sc.next() }
    println(problem096c(h, w, s))
}

fun problem096c(h: Int, w: Int, s: List<String>): String {
    for (i in 0 until h) {
        val si = s[i]
        for (j in si.indices) {
            if (si[j] != '#') continue
            if ((j != w - 1 && si[j + 1] != '#') &&
                (j != 0 && si[j - 1] != '#') &&
                (i != h - 1 && s[i + 1][j] != '#') &&
                (i != 0 && s[i - 1][j] != '#')
            ) {
                return "No"
            }
        }
    }
    return "Yes"
}

Measured memory_bytes: 31516
#include<iostream>

using namespace std;

int main(){
    int a, b;
    cin >>a >>b;
    if(a == b){
        cout << "Draw";
    }else if(a == 1){
        cout << "Alice";
    }else if(b == 1){
        cout << "Bob";
    }else if(a > b){
        cout << "Alice";
    }else{
        cout << "Bob";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int n ;
	cin >> n ;
	string s ;
	cin >> s ;
	int b[n] = {0}, w[n] = {0} ;
	for(int i = 0 ; i < n ; i++){
		if(s[i] == '#'){
			b[i]++ ;
		}
		if(i > 0 )
			b[i] += b[i - 1] ;
	}
	for(int i = n - 1 ; i >= 0 ; i--){
		if(s[i] == '.'){
			w[i]++ ;
		}
		if(i < n - 1){
			w[i] += w[i + 1] ;
		}
	}
	int mn = INT_MAX ;
	for(int i = 0 ; i < n ; i++){
		mn = min(b[i] + w[i] , mn) ;
	}
	cout << mn - 1;
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
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(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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

    FOR(n,A,B+1){
        string s = to_string(n);
        string sr = s;
        reverse(ALL(sr));
        if(s == sr) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
int main(){
long long H,W; cin>>H>>W;
if(H==W){
cout<<0<<endl;}
else if(W==0){
if(H>0){
cout<<1+H;}
else
cout<<abs(H);}
else if(H<W){
if(0<=H){
cout<<W-H<<endl;}
else if(W<0)
cout<<abs(abs(W)-abs(H));
else
cout<<1+abs(abs(H)-W);}
else{
if(W>=0){
cout<<2+H-W<<endl;}
else if(H<0){
cout<<2+abs(abs(W)-abs(H));}
else
cout<<1+abs(abs(W)-H);}}


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

long pow(long m,long n,long mod){
    long ans = 1;
    if(n > 0){
        ans = pow(m,n/2,mod);
        if(n%2 == 0) ans = (ans * ans) % mod;
        else ans = (((ans * ans) % mod) * m) % mod;
    }
    return ans;
}

int main(){
    int m,n;
    cin >> m >> n;
    cout << pow(m,n,1000000007) << endl;
    return 0;
}



Measured memory_bytes: 3076
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Deque<Coordinate> deque = new ArrayDeque<Coordinate>();
		int w, h;
		int wall;

		while(true){
			deque.clear();
			w = sc.nextInt();
			h = sc.nextInt();
			if(w==0) break;
			Coordinate[][] room = new Coordinate[h][w];
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					room[i][j] = new Coordinate(i, j);
				}
			}
			for(int i=0; i<2*h-1; i++){
				switch(i%2){
					case 0:
						for(int j=0; j<w-1; j++){
							wall = sc.nextInt();
							room[i/2][j].right += wall;
							room[i/2][j+1].left += wall;
						}
						break;
					case 1:
						for(int j=0; j<w; j++){
							wall = sc.nextInt();
							room[i/2][j].under += wall;
							room[i/2+1][j].up += wall;
						}
						break;
				}
			}
			room[0][0].settled = true;
			deque.offerLast(room[0][0]);
			while(!deque.isEmpty()){
				Coordinate room1 = deque.pollFirst();
				if(room1.left == 0&&room1.x>0){
					if(!room[room1.y][room1.x-1].settled){
						room[room1.y][room1.x-1].settled = true;
						room[room1.y][room1.x-1].count = room1.count + 1;
						deque.offerLast(room[room1.y][room1.x-1]);
					}
				}
				if(room1.up == 0&&room1.y>0){
					if(!room[room1.y-1][room1.x].settled){
						room[room1.y-1][room1.x].settled = true;
						room[room1.y-1][room1.x].count = room1.count + 1;
						deque.offerLast(room[room1.y-1][room1.x]);
					}
				}
				if(room1.right == 0&&room1.x<w-1){
					if(!room[room1.y][room1.x+1].settled){
						room[room1.y][room1.x+1].settled = true;
						room[room1.y][room1.x+1].count = room1.count + 1;
						deque.offerLast(room[room1.y][room1.x+1]);
					}
				}
				if(room1.under == 0&&room1.y<h-1){
					if(!room[room1.y+1][room1.x].settled){
						room[room1.y+1][room1.x].settled = true;
						room[room1.y+1][room1.x].count = room1.count + 1;
						deque.offerLast(room[room1.y+1][room1.x]);
					}
				}
				if(room[h-1][w-1].settled) break;
			}
			if(room[h-1][w-1].settled){
				System.out.println(room[h-1][w-1].count);
			}else{
				System.out.println("0");
			}
		}
	}

	static class Coordinate{
		public int x, y;
		public int left = 0, right = 0, up = 0, under = 0;
		public int count = 1;
		public boolean settled = false;
		public Coordinate(int i, int j){
			x = j;
			y = i;
		}
	}
}

Measured memory_bytes: 67584
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <sstream>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];

    unordered_set<string> t;
    rep(i,n) t.insert(s[i]);
    cout << (t.size()<=3 ? "Three" : "Four") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pii pair<long long,long long>
#define endl '\n'
#define N 300001
int mod=1000000007;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
vector<int> parent(N),sz(N),indegree(N),vis(N); char st[N];
vector<int> adj[N];
int modexp(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        
        return modexp((x*x)%M,n/2,M);
    else                             
        return (x*modexp((x*x)%M,(n-1)/2,M))%M;
}
void make_set(int s)
{
    parent[s]=s;
    sz[s]=1;
}
int find_parent(int p)
{
    if(p==parent[p])
    return p;
    return parent[p]=find_parent(parent[p]);
}
void union_set(int a,int b)
{
    a=find_parent(a);b=find_parent(b);
    if(a!=b)
    {
        if(a<b)
        swap(a,b);
        parent[b]=parent[a];
        sz[a]+=sz[b];
    }
}
void solve()
{
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
        {
            cout<<"No";
            return;
        }
    }
    if(t.size()-s.size()!=1)
    {
        cout<<"No";
        return;
    }
    cout<<"Yes";
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test; test=1; 
    while(test--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 19408
N = int(input())
L = [int(x) for x in input().split()]
max_L = max(L)
idx_max_L = L.index(max_L)
rest_sum_L = 0
for i in range(N):
  if i != idx_max_L:
    rest_sum_L += L[i]

if rest_sum_L > max_L:
  print("Yes")
else:
  print("No")
  

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

#define INF 1LL << 60
#define pb push_back
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)

int main() {
    string S;
    cin >> S;
    int N = S.size();
    int a[2] = {0, 1};
    int m1 = 0, m2 = 0;
    REP(i, N) {
        if (S[i] - '0' == a[i % 2]) {
            m1++;
        } else {
            m2++;
        }
    }

    cout << min(m1, m2) << endl;

    return 0;
}


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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) 0
#endif
#define endl '\n'
#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

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

const integer NN = (int) 5e5 + 2;
int ar[NN];
int n, m, k, x;
string s;

integer main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;
    for (int i = 0; i < n; i++){
        cin >> ar[i];
    }
    sort(ar, ar+n);
    int ans = 0;
    for (int i = 0; i < k; i++){
        ans += ar[i];
    }
    cout << ans << endl;

}


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

typedef long long ll;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> h(N);
    for (ll i = 0; i < N; ++i)
    {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    ll ans = 1000000000;
    for (ll i = 0; i < N - K + 1; ++i)
    {
        ans = min(ans, h[i + K - 1] - h[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3972
#include <iostream>

using namespace std;

int main()
{
    int H,N,i,x;
    cin>>H>>N;
    x=H;
    for (i=0;i<N;i++){
        int a;
        cin>>a;
        x=x-a;
    }
    if (x<=0)
       cout<<"Yes";
    else
       cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string disp(bool x){
    return x ? "Yes" : "No";
}

int calc(int x,int y){
    if(y == 0) return x;
    else return calc(y,x%y);
}

int main(){
    int x,y; cin >> x >> y;
    
    if(x>=y) cout << calc(x,y) << endl;
    else cout << calc(y,x) << endl;
}
    
    







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

int main() {
  int c[3][3];
  int a[3],b[3];
  for(int i=0;i<3;i++) {
    for(int j=0;j<3;j++) {
      cin>>c[i][j];
      if(i==0)b[j]=c[i][j];
    }
  }
  a[0]=0;
  a[1]=c[1][0]-b[0];
  a[2]=c[2][0]-b[0];
  bool valid=true;
  for(int i=0;i<3;i++) {
    for(int j=0;j<3;j++) {
      if(c[i][j]!=a[i]+b[j]) valid =false;
    }
  }
  if(valid) cout<<"Yes\n";
  else cout<<"No\n";
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll a, b, c, x, y; cin >> a >> b >> c >> x >> y;
  ll ans = min(a*x+b*y, max(x, y)*2*c);
  ans = min(ans, min(x*2*c+(max(y-x, 0LL)*b), y*2*c+(max(x-y, 0LL)*a)));
  cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
list1=list(reversed(input().split()))#まだintになってないことに注意 さらに後ろから考えるために逆順になっていることに注意
list2=list(map(int,list1))
#print(list2)#int,逆順の配列完成
if len(list2)==1:
    print("Yes")
else:
    for i in range(len(list2)):
        #print(i)
        d=list2[i]-list2[i+1]
        if d==-1:
            list2[i+1]-=1
        if d<-1:
            print("No")
            break
        if i==len(list2)-2:
            print("Yes")
            break
#print(list2)

Measured memory_bytes: 14868
n, m, l = map(int, input().split())

A = []
B = []
C = [[] for i in range(n)]

for i in range(n):
    tmp_row = list(map(int, input().split()))
    A.append(tmp_row)

for i in range(m):
    tmp_row = list(map(int, input().split()))
    B.append(tmp_row)

for i in range(n):
    for j in range(l):
        ab = sum([A[i][k] * B[k][j] for k in range(m)])
        C[i].append(ab)

for i in C:
    print(" ".join(map(str, i)))

Measured memory_bytes: 8948
/*Lucky_Glass*/
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=700;
int n,mod,Nf,Ng;
vector< pair<int,int> > Epr;
int Ef[N+3][N+3];

int main(){
	scanf("%d%d",&n,&mod);
	Nf=2*n-1;Ng=2*n-1;
	for(int i=0;i<2*n;i++){
		while(i*i+Nf*Nf>4*n*n && Nf>=0) Nf--;
		while(i*i+Ng*Ng>=n*n && Ng>=0) Ng--;
		if(Ng==-1) Epr.push_back(make_pair(Nf+1,0));
		else  Epr.push_back(make_pair(Ng+1,Nf+1));
//		printf("%d %d\n",Epr.back().first,Epr.back().second);
	}
	sort(Epr.begin(),Epr.end());
	int Vans=0;long long typ=1;
	for(int k=0;k<=n;k++){
		memset(Ef,0,sizeof Ef);
		Ef[0][0]=1;
		for(int i=0,Ctf=0,Ctg=0;i<(int)Epr.size();Ctg+=Epr[i].second==0,Ctf+=Epr[i].second!=0,i++){
			for(int j=0;j<=k;j++){
				int tmp=Ef[i][j];
				if(Epr[i].second){
					if(j!=k) Ef[i+1][j+1]=(Ef[i+1][j+1]+1ll*tmp*(Epr[i].first-j-Ctg)%mod)%mod;
					Ef[i+1][j]=(Ef[i+1][j]+1ll*tmp*(Epr[i].second-k-n-(Ctf-j))%mod)%mod;
				}
				else
					Ef[i+1][j]=(Ef[i+1][j]+1ll*tmp*(Epr[i].first-j-Ctg)%mod)%mod;
			}
//			printf("%d %d\n",Ctf,Ctg);
		}
//		printf("%d\n",Ef[Epr.size()][k]);
		Vans=(Vans+typ*Ef[Epr.size()][k]+mod)%mod;
		typ*=-1;
	}
	printf("%d\n",Vans);
	return 0;
}

Measured memory_bytes: 2176
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int cnt2=0;
  int cnt4=0;
  rep(i,n){
    if(a[i]%4==0) cnt4++;
    else if(a[i]%2==0) cnt2++;
  }
  int N=cnt4*2+cnt2;
  if(cnt2==0) N=cnt4*2+1;
  if(N>=n){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll H , W , M; cin >> H >> W >> M;
  vector<P> a(M);
  rep(i, M) cin >> a[i].fi >> a[i].sc;
  rep(i, M) {a[i].fi--; a[i].sc--;}
  SORT(a);

  vector<ll> xcnt(MAX) , ycnt(MAX);
  rep(i, M){xcnt[a[i].fi]++; ycnt[a[i].sc]++;}

  // specify max
  ll xmax = 0, ymax = 0;
  rep(i, MAX){
    xmax = max(xmax, xcnt[i]);
    ymax = max(ymax, ycnt[i]);
  }
  // include max
  vector<ll> nx , ny;
  rep(i, MAX){
    if(xmax == xcnt[i]) nx.pb(i);
    if(ymax == ycnt[i]) ny.pb(i);
  }
  SORT(nx); SORT(ny);
  ll cnt = nx.size() * ny.size();

  // check
  ll ans = xmax + ymax - 1;
  rep(i, M){
    if(binary_search(nx.begin(), nx.end(), a[i].fi)
      and binary_search(ny.begin(), ny.end(), a[i].sc)){
        cnt--;
    }
  }
  if(cnt) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 21976
#include<iostream>
using namespace std;
int main(void) {
  int n;
  int c[500], s[500], f[500];
  cin>>n;
  for(int i=0; i<n-1; i++) {
    cin>>c[i]>>s[i]>>f[i];
  }
  for(int i=0; i<n-1; i++) {
    int t=s[i]+c[i];
    for(int j=i+1; j<n-1; j++) {
      if(t<=s[j]) t+=(s[j]-t)+c[j];
      else {
	int x=t-s[j];
	if(x%f[j]==0) t+=c[j];
	else t+=f[j]-(x%f[j])+c[j];
      }
    }
    cout<<t<<endl;
  }
  cout<<0<<endl;
  return 0;
}


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

int main(){
	int N, input;
	set<int> s;
	cin >> N;
	rep(i, N){
		cin >> input;
		if(s.count(input)){
			cout << "NO" << endl;
			return 0;
		}
		s.insert(input);
	}
	cout << "YES" << endl;
	
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 0; i < N + 1; i++){
        if(i * i <= N)
            ans = i * i;
        else
            break;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"POSSIBLE"<<endl;}
bool coN(){cout <<"IMPOSSIBLE"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
//ここから書き始める

int main()
{
	cout <<setprecision(10);
	int n,m;
	cin >> n >> m;
	vector<pair<int,int>> island;
	map<int,vector<int>> hune; //hune(出る島、着く島,着く島,..)
	rep(i,m){
		int a,b;
		cin >> a >> b;
		hune[a].push_back(b);
	}

	//hune[1]を順にみていくか
	for(auto x:hune[1]){
		for(auto y:hune[x]){
			if(y == n){
				coY();
				return 0 ;
			}
		}
	}
	coN();

}


Measured memory_bytes: 19320
fun main(args:Array<String>) {
    val userInput: String = readLine()!!
    val judgeArray = arrayOf(2,4)
    var tfFlag : Boolean = true

    for (i in judgeArray) {
        if (!(userInput[i] == userInput[i+1])) {
            tfFlag = false
        }
    }

    if (tfFlag) {
        println("Yes")
    } else{
        println("No")
    }
}

Measured memory_bytes: 31824
from collections import Counter
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
T2RSP = {'r':P, 's':R, 'p':S}
ans = 0
for i, t in enumerate(T):
    ans += T2RSP[t]
for k in range(K):
    partT = T[k+K::K]
    pre_t = T[k]
    count = 1
    for t in partT:
        if pre_t == t:
            count += 1
        else:
            ans -= T2RSP[pre_t] * (count // 2)
            pre_t = t
            count = 1
    if count >= 2:
        ans -= T2RSP[pre_t] * (count // 2)


print(ans)


Measured memory_bytes: 41584
#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include <queue>
#include <cstring>

#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define SIZE  ( int)(1e9 + 7)
#define MAXN (ll) ((1e5+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int,int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;




signed main() {
    ll n ;
    bool ctr = 0;
    cin >> n;

    for (int cur , i = 0; i <n ; ++i) {
        cin >> cur;
        if(!(cur&1)){
            if(cur %3 != 0 and cur %5 != 0)ctr=1;
        }

    }
    if(!ctr){
        cout <<"APPROVED";
    }else{
      cout<<"DENIED";
    }

        return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <complex>
using namespace std;
typedef long long LL;
void guan() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls (rt<<1)
#define rs (rt<<1|1)
#define F first
#define S second
#define mst(x,a) memset(x,a,sizeof(x))
#define Pr pair<LL,LL>
#define root 1,cnum,1
#define For(i,b,c) for(int i=b;i<=c;i++)
const int maxn = 400040;
const LL mod = 1e9 + 7;
const double pi = acos(-1.0);
 
int n, m;
int a[maxn];
Pr p[maxn];
 
void solve() {
    for(int i = 1;i <= m;i++) {
        cin >> p[i].F >> p[i].S;
        if(p[i].F > p[i].S) swap(p[i].F, p[i].S);
    }
    sort(p + 1, p + 1 + m);
    int cnt = 1;
    for(int i = 2;i <= m;i++) {
        if(p[i].S >= p[cnt].S && p[i].F <= p[cnt].F) continue;
        while(cnt >= 1 && p[i].S <= p[cnt].S) --cnt;
        p[++cnt] = p[i];
    }
    //cout << cnt << endl;
    //for(int i = 1;i <= cnt;i++) cout << p[i].F << " " << p[i].S << endl;
    int r = 0;
    int ans = 0;
    for(int i = 1;i <= cnt;i++) {
        if(p[i].F < r) continue;
        else r = p[i].S, ans++;
    }
    cout << ans << endl;
}
 
int main() {
    guan();
    int t = 1;
    while(t--) {
        while(cin >> n >> m) solve();
    }
 
    //cin >> t;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=1;i<=n;i++)
signed main(){
    int n,k;
    cin>>n>>k;
    int ak=1;
    double kaka[n];
    double aka=0;
    rep(i,n){
        kaka[i-1]=1.0/n;
        ak=i;
        while(k>ak){
          kaka[i-1]*=0.5;
          ak*=2;
        }
        aka+=kaka[i-1];
    }
    printf("%.45f\n",aka);
}

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

int main(){
    string S;
    int num_0=0, num_1=0;
    cin >> S;

    for(int i=0; i<S.size(); i++){
        if (S[i]=='1') num_1++;
        else num_0++;
    }

    cout << 2 * min(num_0 ,num_1) << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define dom 998244353
#define all(c) begin(c),end(c)
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
template <typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } return false; }
#define long long long
#define List vector
#define var auto
#define Count size()
#define Length size()
#define in :
#define foreach for
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

constexpr int MAX = 100001;
void solve()
{
	int X;
	cin >> X;
	bitset<MAX> B;
	for (int i = 0; i < 6; i++)
	{
		int Y = 100 + i;
		for (int j = 0; j < MAX / Y; j++)
		{
			B[0] = true;
			B |=  B << Y;
		}
	}
	if (B[X])
	{
		cout << 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(11);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[5000005];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1),now=1;
	if(s[1]=='0'||s[n]=='1') return printf("-1\n"),0;
	for(int i=1;i<n;i++) if(s[i]^s[n-i]) return printf("-1\n"),0;
	for(int i=2;i<=n;i++)
	{
		printf("%d %d\n",now,i);
		if(s[i-1]=='1') now=i;
	}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
using namespace std;
const int MAX_N = 10;
const int INF = 100000000;
int N;//N是道路的数量，不是点的数量 
int dp[MAX_N][MAX_N];
bool input(){
	fill(dp[0],dp[0]+MAX_N*MAX_N,INF);
	scanf("%d",&N);
	if(N == 0) return false;
	int a,b,c;
	int max_N = 0;
	for(int i = 0;i < N;++i){
		scanf("%d%d%d",&a,&b,&c);
		dp[a][b] = dp[b][a] = c;
		max_N = (max(a,b) > max_N ? max(a,b) : max_N);
	}
	N = max_N + 1;//N变为点的数量 
	for(int i = 0;i < N;++i) dp[i][i] = 0;
	return true;
}

void shortest_path(){
	for(int k = 0;k < N;++k){
		for(int i = 0;i < N;++i){
			for(int j = 0;j < N;++j){
				if(dp[i][k] != INF && dp[k][j] != INF){
					if(dp[i][j] > dp[i][k]+dp[k][j]) dp[i][j] = dp[i][k]+dp[k][j];
				}
			}
		}
	}
}

int main(){
	while(input()){
		shortest_path();
		int street, res = INF;
		for(int i = 0;i < N;++i){
			int tmp = 0;
			for(int j = 0;j < N;++j) tmp += dp[i][j];
			if(tmp < res){
				res = tmp;
				street = i;
			}
		}
		cout << street << " " << res << endl;
	}
	return 0;
}


Measured memory_bytes: 3136
def resolve():
    w, h, n = map(int, input().split())
    min_x, min_y = 0, 0
    max_x, max_y = w, h
    for _ in range(n):
        x, y, a = map(int, input().split())
        if a == 1:
            min_x = max(min_x, x)
        elif a == 2:
            max_x = min(max_x, x)
        elif a == 3:
            min_y = max(min_y, y)
        elif a == 4:
            max_y = min(max_y, y)
    if min_x >= max_x or min_y >= max_y:
        print(0)
    else:
        print((max_x - min_x) * (max_y - min_y))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3064
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;
mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { println ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }

fn main() {
    let n = get!(usize);
    let ss = get!(String; n);

    let mut mins = vec![100; 26];

    for s in &ss {
        let mut counts = vec![0; 26];
        for x in s.chars() {
            counts[x as usize - 'a' as usize] += 1;
        }

        for i in 0..26 {
            mins[i] = min(mins[i], counts[i]);
        }
    }

    for i in 0..26 {
        for _ in 0..mins[i] {
            print!("{}", ('a' as u8 + i as u8) as char);
        }
    }
    println!();
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<iostream>
int main(void){
    char str[6];
    scanf("%s",str);
    if(str[2]==str[3]){
        if(str[4]==str[5]){
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

struct Pos {
    int x, y;
};

void solve() {
    int H, W;
    ll K;
    cin >> H >> W >> K;
    Pos s, t;
    cin >> s.x >> s.y >> t.x >> t.y;
    --s.x, --s.y, --t.x, --t.y;
    vector<vector<bool>> cell(H, vector<bool>(W));
    for (int i = 0; i < H; i++) {
        string S;
        cin >> S;
        for (int j = 0; j < W; j++) {
            if (S[j] == '@') cell[i][j] = true;
        }
    }

    if (cell[s.x][s.y] == 1) {
        cout << -1 << "\n";
        return;
    }

    constexpr Pos step[] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}};

    using Tup = tuple<ll, int, int, int>;  // cost, x, y, v
    vector<vector<Vl>> dp(H, vector<Vl>(W, Vl(4, L_INF)));
    priority_queue<Tup, vector<Tup>, greater<Tup>> q;
    q.emplace(0, s.x, s.y, 0);
    dp[s.x][s.y][0] = 0;
    while (!q.empty()) {
        auto [c, x, y, v] = q.top();
        q.pop();
        if (c > dp[x][y][v])
            continue;
        int xn, yn;
        ll cn;
        // 前進
        xn = x + step[v].x;
        yn = y + step[v].y;
        if (xn >= 0 && xn < H && yn >= 0 && yn < W) {
            if (!cell[xn][yn]) {
                cn = c + 1;
                if (cn < dp[xn][yn][v]) {
                    dp[xn][yn][v] = cn;
                    q.emplace(cn, xn, yn, v);
                }
            }
        }
        // 回転
        v = (v + 1) % 4;
        xn = x;
        yn = y;
        cn = (c + K - 1) / K * K;
        if (cn < dp[xn][yn][v]) {
            dp[xn][yn][v] = cn;
            q.emplace(cn, xn, yn, v);
        }
    }

    ll ans = L_INF;
    for (ll i = 0; i < 4; i++) {
        if (ll tmp = dp[t.x][t.y][i]; tmp != L_INF) {
            ans = min(ans, (tmp + K - 1) / K);
        }
    }

    if (ans != L_INF)
        cout << ans << "\n";
    else
        cout << -1 << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 143912
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);
    if(abs(x - a) < abs(x - b)) {
        printf("A\n");
    } else {
        printf("B\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int rever(int n)
{

int t=n,r,num=0;

while(t>=1)

{

r=t%10;

t=t/10;

num=num*10+r;

}

return num;

}
int isPalindrome(int num)
{
int n=rever(num);

if(n==num)

return 1;

else

return 0;

}


int main()
{

ll n,m;
cin>>n>>m;

    if(n==1&&m==1) cout<<1;
else if(n==1&&m>1) cout<<m-2;
else if(n>1&&m==1) cout<<n-2;
else {
        ll ans = (m-2)*(n-2);
        cout<<ans;
}

return 0;

}



Measured memory_bytes: 256