akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(deque<T> &vec) {
    for (auto& a : vec) {
        cout << a+1;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

int main(){
    ll n,m; cin >> n >> m;
    vector<vector<ll>> graph(n);
    rep(i,m) {
        ll a,b;cin >> a >> b;
        a--;b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }
    bitset<n_max> bs(0);
    deque<ll> ans;
    ans.emplace_back(0);
    ans.emplace_back(graph[0][0]);
    bs[0] = 1;
    bs[ans[1]] = 1;
    auto check = [&](){
        ll start = ans.front();
        ll end = ans.back();
        for(auto to : graph[start])if(bs[to] == 0){
            ans.emplace_front(to);
            bs[to] = 1;
            return false;
        }
        for(auto to : graph[end])if(bs[to] == 0){
            ans.emplace_back(to);
            bs[to] = 1;
            return false;
        }
        return true;
    };
    while(!check()){}
    print(ans.size());
    print(ans);
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	char c; cin >> c;
	if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
		printf("vowel\n");
	}else{
		printf("consonant\n");
	}
	return 0;
}

Measured memory_bytes: 256
s = input()
n = int(input())

for _ in range(n):
    quary = list(map(str,input().split()))
    if quary[0] == "print":
        print(s[int(quary[1]):int(quary[2])+1])
    if quary[0] == "replace":
        s = s[0:int(quary[1])] + quary[3] + s[int(quary[2])+1:]
    if quary[0] == "reverse":
        s = s[0:int(quary[1])] + ''.join(list(reversed(s[int(quary[1]):int(quary[2])+1]))) + s[int(quary[2])+1:]


Measured memory_bytes: 5612
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if((a < b) && (b < c)){
			System.out.println("Yes");
		} else{
			System.out.println("No");
		}
	}
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int n;
vi arr;
vec<pi> tmp;
void in(){
    cin >> n;
    rep(i,0,n){
        int t;
        cin >> t;
        tmp.push_back(pi(t, i));
    }
    sort(all(tmp));

}

void solve(){
    
    int ans = 0;
    set<int> s;
    rep(i,0,n){
        int val = tmp[i].first;
        int ind = tmp[i].second;

        auto right = s.lower_bound(ind);
        int r = (right == s.end() ? n - ind : *right - ind);

        int l = (right == s.begin() ? ind + 1 : ind - *--right);

        ans += val * r * l;
        s.insert(ind);
    }
    print(ans);


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 13164
#include <iostream>
using namespace std;
int main(){
  long long h,w,ans=19896894689,a,b,c,d;
  cin >> h >> w;
  if(h%3==0 or w%3==0){
    cout << 0 << endl;
    return 0;
  }
  a=min(h,w)/2;
  b=min(h,w)/2+min(h,w)%2;
  c=max(h,w)/2;
  d=max(h,w)/2+max(h,w)%2;
  for(int i=1;i<max(h,w);i++){
    ans=min(ans,max(min(h,w)*i,b*(max(h,w)-i))-min(min(h,w)*i,a*(max(h,w)-i)));
  }
  for(int i=1;i<min(h,w);i++){
    ans=min(ans,max(max(h,w)*i,d*(min(h,w)-i))-min(max(h,w)*i,c*(min(h,w)-i)));
  }
  ans=min(ans,min(h,w));
  cout << ans << endl;
  return 0;
}

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

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

    int ans;

    if (N == 1){
        ans = 2;
    }
    if (N % 2 == 0){
        ans = N;
    }
    else{
        ans = 2 * N;
    }

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

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt()-1;
		int[] arr = new int[n];
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		int res = arr[0];
		for(int i = 1; i < n; i++) {
			if(arr[i] > arr[i-1]) res += arr[i-1];
			else res += arr[i];
		}
		System.out.println(res+arr[n-1]);
	}

}


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

#define int long long

struct Combination {
  int mod; // e.g. 1000000007
  vector<int> fact; // factorial
  vector<int> invf; // inverse factorial
  vector<vector<int> > part; // partition number

  /*
    constructor : O(sz+log(mod))   
    make factorial table (fact) and inverse factorial table (invf)
  */
  Combination(int sz, int mod) : fact(sz+1), invf(sz+1), mod(mod) {
    fact[0] = 1;
    for ( int i = 1; i < (int)fact.size(); i++ ) {
      fact[i] = fact[i-1]*i%mod;
    }
    invf[sz] = inv(fact[sz]);
    for ( int i = sz-1; i >= 0; i-- ) {
      invf[i] = invf[i+1]*(i+1)%mod;
    }
  }

  int pow(int x, int n) const {
    int ret = 1;
    while ( n > 0 ) {
      if ( n & 1 ) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return ret;
  }

  int inv(int x) const {
    return pow(x, mod - 2);
  }

  /*
    permutation
  */
  int P(int n, int r) const {
    if ( r < 0 || n < r ) return (0);
    return fact[n]*invf[n-r]%mod;    
  }

  /*
    combination
  */
  int C(int n, int r) const {
    if ( r < 0 || n < r ) return (0);    
    return fact[n]*invf[r]%mod*invf[n-r]%mod;    
  }  

  /*
    combination with repetition
  */
  int H(int n, int r) const {
    if ( n < 0 || r < 0 ) return 0;
    if ( n == 0 && r == 0 ) return 1;
    return C(n+r-1, n);    
  }

  /*
    stirling number
  */
  int S(int n, int r) const {
    int ret = 0;
    for ( int i = 1; i <= r; i++ ) {
      int add = C(r, i)*pow(i, n)%mod;      
      if ( (r-i)&1 ) ret += mod-add;
      else ret += add;
      ret %= mod;      
    }
    (ret *= invf[r]) %= mod;
    return ret;
  }

  /*
    bell number
  */
  int B(int n, int r) const {
    int ret = 0;
    for ( int i = 1; i <= r; i++ ) {
      (ret += S(n, i)) %= mod;      
    }
    return ret;
  }

  /*
    calc partition number
    return and make partition number table (part)
  */
  vector<vector<int> > built_part(int n, int r) {
    part = vector<vector<int> >(n+1, vector<int>(r+1, 0));
    part[0][0] = 1;
    for ( int i = 0; i <= n; i++ ) {
      for ( int j = 1; j <= r; j++ ) {
	if ( i-j >= 0 ) {
	  (part[i][j] = part[i][j-1]+part[i-j][j]) %= mod;	  
	} else {
	  part[i][j] = part[i][j-1];
	}
      }
    }
    return part;    
  }

};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  
  int N;
  cin >> N;

  int MOD = 1e9+7;  
  Combination comb(N+100, MOD);

  vector<int> used(N+1, 0);
  int l, r;  
  for ( int i = 0; i < N+1; i++ ) {
    int a;
    cin >> a;
    if ( used[a] ) {     
      l = used[a]-1;
      r = i;       
    } else {
      used[a] = i+1;      
    }
  }

  int all = l+(N-r);
  for ( int i = 1; i <= N+1; i++ ) {
    int ans = comb.C(N+1, i) - comb.C(all, i-1); 
    cout << (ans+MOD) % MOD << endl;    
  }
  
  return 0;
}


Measured memory_bytes: 3584
//https://atcoder.jp/contests/abc122/tasks/abc122_b
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
  string S; cin>>S;
  vector<char> ch={'A','C','G','T'};
  auto check=[&](char ic){
    for(const auto&c:ch){
      if(ic==c)return true;
    }return false;
  };
  ll ans=0;
  ll cnt=0;
  for(auto&c :S){
    if(check(c)){
      ++cnt;
      chmax(ans,cnt);
    }else{
      cnt=0;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


void Main(){
    int A, B;
    cin >> A >> B;
    if(A<10 && B<10){
        cout << A*B << el;
    }else{
        cout << -1 << el;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;

vector<int> ra(MX,0);
vector<int> par(MX,0);
using P = pair<int, int>;
using ll = long long;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int find(int x) {
    if(par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x==y) return;
    if(ra[x]<ra[y]) {
        par[x] = y;
    }else {
        par[y] = x;
        if(ra[x]==ra[y]) {
            ra[x]++;
            
        }
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int a[MX];
int c[10][1000];
signed main(){
    double a,b;
    cin >> a >> b;
    
    double x = a/0.08;
    double y = b/0.1;

    double ma = max(ceil(x),ceil(y));

    //cout << ma << endl;
    if(floor(ma*0.08)==a && floor(ma*0.1)==b) cout << ma << endl;
    else cout << -1 << endl;


    return 0;

}



Measured memory_bytes: 15872
#include <cstdio>
#include <string>
using namespace std;

int main(){
	string str;
	char tmp[1001];
	scanf("%s", tmp);
	str = tmp;
	
	for (int i = 0; i < str.size(); i++){
		if (str[i] == 'A' || str[i] == 'B' || str[i] == 'C'){
			str[i] += 23;
		}else{
			str[i] -= 3;
		}
	}

	printf("%s\n", str.c_str());

	return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,k;
    cin >>n>>k;
    vector<int> a(n);

    for (int i = 0; i < n; i++)
    {
        cin >>a[i];
    }
    sort(all(a),greater<int>());
    
    for (int i = 0; i <k; i++){
        ans += a[i];
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] l = new int[n];
    for (int i = 0; i < n; i++) {
      l[i] = sc.nextInt();
    }

    Arrays.sort(l);
    int sum = 0;
    for (int i = (n - k); i < n; i++) {
      sum += l[i];
    }

    System.out.println(sum);

  }
}

Measured memory_bytes: 35748
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		int result = 0;
		if (A >= K) {
			result = K;
		} else if ((A + B) >= K) {
			result = A;
		} else {
			result = A - (K - A - B);
		}
		System.out.println(result);

	}

}


Measured memory_bytes: 27072
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from fractions import Fraction

K, X = map(int, input().split())
ans = [i for i in range(X-K+1, X+K)]
print(*ans)

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

int main() {
    int h, w;
    char mp[105][105];
    int Xsum[105] = {};
    int Ysum[105] = {};

    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> mp[i][j];
            if (mp[i][j] == '#') {
                Xsum[i]++;
                Ysum[j]++;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        int f = 0;
        for (int j = 0; j < w; j++) {
            if (Xsum[i] != 0 && Ysum[j] != 0) {
                cout << mp[i][j];
                f = 1;
            }
        }
        if (f) cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
x,y,z = map(int,input().split())
li=[int(input()) for i in range(z)]
ans = y - z 
ans_li = [ans] * x
for i in li:
  ans_li[i - 1] += 1
for j in ans_li:
  if j <= 0:
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 10452
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

MOD = 10**9 + 7

ans = 0
for i in range(N):
    for j in range(N):
        l, r = 0, 0
        if A[i] > A[j] and i < j:
            l += 1
        if A[i] > A[j] and i > j:
            r += 1
        ans += (1+K)*K//2*l
        ans += K*(K-1)//2*r
        ans %= MOD

print(ans)


Measured memory_bytes: 43372
#include <bits/stdc++.h>
#define     mod             1000000007
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n" 
#define     ll              long long int 
#define     vi              vector<int> 
#define     vvi             vector<vector<int>>
using namespace std;

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


void solve(){
	int x;
	cin>>x;
	int lcm = 360*x / gcd(360,x);
	cout<<lcm / x;

}
 

int32_t main()
{
    IOS;

    solve();

}

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

int main(){
	int N,M;
	cin >> N >> M;
	vector<ll> A(N);
	rep(i, N){
		cin >> A[i];
	}
	sort(A.begin(),A.end());
	vector<pair<ll, int>> card;
	int b;
	ll c;
	rep(i, M){
		cin >> b >> c;
		card.push_back(make_pair(-c,b));
	}
	sort(card.begin(),card.end());
	int now(0);
	ll S(0);
	rep(i,N){
		if(now < card.size()){
			if(A[i] < -card[now].first){
				S -= card[now].first;
				card[now].second--;
				if(card[now].second<=0) now++;
			}else{
				S += A[i];
			}
		}else{
			S += A[i];
		}
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

string a[55];
ll dx[4]={-1, 0, 1, 0};
ll dy[4]={0, -1, 0, 1};
ll H, W;
ll d[55][55];

void bfs() {
    queue<P> q;
    P u;
    q.push(mkp(0, 0));
    d[0][0]=0;
    
    while(q.size()) {
        u=q.front(); q.pop();
        
        for(ll i=0; i<4; i++) {
            ll tx=u.first+dx[i];
            ll ty=u.second+dy[i];
            
            if(tx<0 || ty<0 || tx>=H || ty>=W) continue;
            if(a[tx][ty]=='#') continue;
            if(d[tx][ty]!=INF) continue;
            
            d[tx][ty]=d[u.first][u.second]+1;
            q.push(mkp(tx, ty));
        }
        
    }
}

int main(void) {
    ll i, j;
    cin >> H >> W;
    ll cnt=0;
    for(i=0; i<H; i++) {
        cin >> a[i];
    }
    
    for(i=0; i<H; i++) {
        for(j=0; j<W; j++) {
            d[i][j]=INF;
            
            if(a[i][j]=='#') cnt++;
            
        }
    }
    
    bfs();
    if(d[H-1][W-1]==INF) pr(-1);
    else pr(H*W-d[H-1][W-1]-1-cnt);
    
}






















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define tp          tuple<int,int,int>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 6;

int main()  {
    fastio;
    string s, t;
    cin>>s>>t;
    
    int ans = INF;

    for(int i =0; i + t.size()- 1 < s.size() ; i++ ) {
        int cnt = 0;
        for(int j = i , k = 0 ; k < t.size() ; k++ , j++) {
            if(s[j]!= t[k]) cnt++;
        }
        ans = min(ans , cnt);
    }
    cout<<ans<<'\n';
    return 0;
    
    
}

Measured memory_bytes: 3640
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve() {
	while (true) {
		int w, d;
		cin >> w >> d;
		if (w == 0) return;
		vector<int> a, b;
		REP(i, w) {
			int c;
			cin >> c;
			a.push_back(c);
		}
		REP(i, d) {
			int c;
			cin >> c;
			b.push_back(c);
		}
		int ans = 0;
		REP(i, a.size()) {
			REP(q, b.size()) {
				if (a[i] == b[q]) {
					ans += a[i];
					a.erase(a.begin() + i);
					b.erase(b.begin() + q);
					i--;
					break;
				}
			}
		}
		REP(i, a.size()) {
			ans += a[i];
		}
		REP(i, b.size()) {
			ans += b[i];
		}
		cout << ans << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3020
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int main()
{
    int N, D;
    cin >> N >> D;
    vector<vector<int>>vec(N, vector<int>(D, 0));
    for (int i=0; i<N; i++) {
        for (int j=0; j<D; j++) {
            int p;
            cin >> p;
            vec[i][j] = p;
        }
    }

    int sum_ = 0;
    for (int i=0; i<N-1; i++) {
        for (int j=i+1; j<N; j++) {
            double num = 0;
            for (int k=0; k<D; k++) {
                num += pow(vec[i][k] - vec[j][k], 2);
            }

            if (floor(sqrt(num)) == sqrt(num)) {
                sum_ += 1;
            }

        }
    }

    cout << sum_ << endl;
    return 0;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 200005
#define MOD 998244353
#define INF 2000000000
#define EPS 0.00000000001
char s[MAX];
int main()
{
    long long int a,b,v,w,t;
    scanf("%lld %lld %lld %lld %lld",&a,&v,&b,&w,&t);
    long long int d=b-a,e=v-w;
    if(d<0)d=-d;
    if(e<0) e=-e;
    if(v<=w||e*t<d)
    {
        printf("NO");
    }
    else
    {
        printf("YES");
    }
    return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B, C, D, a, b;
  cin >> N;
  A = N/1000;//千の位の数字
  a = N%1000;//下三桁
  B = a/100;//百の位の数字
  b = a%100;//下二桁
  C = b/10;//十の位の数字
  D = b%10;//一の位の数字
  
  if (A == B && B == C && C == D){
    cout << "Yes" << endl;
  }
  else if ( B == C && C == D){
    cout << "Yes" << endl;
  }
  else if ( A == B && B == C){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/perl
use strict;
use warnings;
use feature qw(:5.10);
use utf8;

my %bingo;
for my $n (1..3){
    my $line = <STDIN>;
    my @line = split(/\s+/, $line);
    $bingo{"$n$_"} = {
        number => $line[$_-1],
        mark => 0
    } for 1..3;
}

<STDIN>;

while (my $n = <STDIN>){
    for my $k (keys %bingo){
        $bingo{$k}->{mark} = 1 if $bingo{$k}->{number} == $n;
    }
}

# 縦
for my $n1 (1..3){
    my $b = "";
    $b .= $bingo{"$_$n1"}->{mark} for 1..3;
    if ($b eq "111"){
        say "Yes";
        exit;
    }
}

# 横
for my $n1 (1..3){
    my $b = "";
    $b .= $bingo{"$n1$_"}->{mark} for 1..3;
    if ($b eq "111"){
        say "Yes";
        exit;
    }
}

# 斜め
{
    my $start1 = 4;
    my $b = "";
    for(1..3){
        $start1 += 9;
        $b .= $bingo{$start1}->{mark};
    }
    if ($b eq "111"){
        say "Yes";
        exit;
    }
}
{
    my $start1 = 0;
    my $b = "";
    for(1..3){
        $start1 += 11;
        $b .= $bingo{$start1}->{mark};
    }
    if ($b eq "111"){
        say "Yes";
        exit;
    }
}
say "No";

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,m;
    cin >> n >> m;

    rep(i,m/2){
        int l = i+1;
        int r = m-i;
        cout << l << " " << r  << endl;
    }
    rep(i,(m+1)/2){
        int r = m+m-i+1;
        int l = m+i+1;
        cout << l << " " << r << endl;
    }

    return 0;
}


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

int main(void){
    int p, q, r, minsum;         //minsum refers to minimum sum
    cin >> p >> q >> r;    
          
    if(p+q > p+r){               //There are 3 patterns. p+q, p+r, r+q. (Info)p+q = q+p
        minsum = p+r;
    }            
    else{
        minsum = p+q;
    }
    minsum = min(minsum, r+q);

    cout << minsum << endl;          
    return 0;
}


// AtCoder Beginner Contest 129

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=1e5+5,MAXM=1e6+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,N,ans,p[MAXN],q[MAXN],P[MAXN],Q[MAXN];
struct Edge{int to,next,w;}edges[MAXM];
int head[MAXN],cur[MAXN],d[MAXN],cnt=1,S,T;
inline void add(int x,int y,int w){
	edges[++cnt]=(Edge){y,head[x],w},head[x]=cnt;
	edges[++cnt]=(Edge){x,head[y],0},head[y]=cnt;
}
inline bool bfs(){
	queue<int>q;memset(d,0,sizeof(d)),d[S]=1,q.push(S),memcpy(cur,head,sizeof(head));
	for(int x;!q.empty();q.pop()){
		x=q.front();
		for(int i=head[x],y;i;i=edges[i].next)	
			if(edges[i].w&&!d[y=edges[i].to])d[y]=d[x]+1,q.push(y);
	}return d[T];
}
int dfs(int x,int dist){
	if(x==T||!dist)return dist;int z=0;
	for(int&i=cur[x],y,k;i;i=edges[i].next)if(edges[i].w&&(d[y=edges[i].to]==d[x]+1)){
		k=dfs(y,min(dist,edges[i].w)),edges[i].w-=k,edges[i^1].w+=k,z+=k,dist-=k;
		if(!dist)break;
	}return z;
}
inline int Dinic(){int ans=0;for(;bfs();)ans+=dfs(S,1e9);return ans;}
inline void Get1(int x){for(N++;!p[x];x=P[x])p[x]=N;}
inline void Get2(int x){for(N++;!q[x];x=Q[x])q[x]=N;}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();
	Rep(i,1,n)P[i]=read()+1;Rep(i,1,n)Q[i]=read()+1;
	Rep(i,1,n)if(!p[i])Get1(i);Rep(i,1,n)if(!q[i])Get2(i);
	S=0,T=N+1,ans=n;
	Rep(i,1,n){
		if(P[i]==i&&Q[i]==i)ans--;
		else if(P[i]==i&&Q[i]!=i)add(q[i],T,1);
		else if(P[i]!=i&&Q[i]==i)add(S,p[i],1);
		else if(P[i]!=i&&Q[i]!=i&&P[i]!=Q[i])add(q[i],p[i],1);
		else if(P[i]!=i&&Q[i]!=i&&P[i]==Q[i])add(p[i],q[i],1),add(q[i],p[i],1);
	}cout<<ans-Dinic();
	return 0;
}




Measured memory_bytes: 13508
#include <iostream>
#include <string>
#include<math.h>
using namespace std;

int main() {
	int N;
	int T, A;
	cin >> N >> T >> A;
	int H[1010];
	
	for (int i = 1; i <= N; ++i) cin >> H[i];
	int ans = 1;

	for (int i = 1; i <= N; i++) {
		double T1, T2;
		T1 = fabs((double)A - (double)T + (double)H[ans] * 0.006);
		T2 = fabs((double)A - (double)T + (double)H[i] * 0.006);
		if (T1 > T2)  ans = i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
# https://atcoder.jp/contests/abc161/tasks/abc161_b
N, M = map(int, input().split())
A = list(map(int, input().split()))
total = sum(A)
limit = total / (4 * M)

count = 0
for a in A:
    count += (a >= limit)

if count >= M:
    print("Yes")
else:
    print("No")


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

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    int Y = C - B;
    if (Y <= 0) {
        cout << "delicious" << endl;
    }
    else if (Y > A) {
        cout << "dangerous" << endl;
    }
    else {
        cout << "safe" << endl;
    }
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main()
{
   ll n,c,k;
   cin>>n>>c>>k;
   ll a[n];
   for(ll i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  ll ans=0;
  ll cr=0;
  ll lm;
  ll i=0;
  while(i<n)
  {
    if(cr==0)
    {
      ans++;
      cr++;
      lm=a[i]+k;
      i++;
      continue;
    }
    if(a[i]>lm||cr==c)
    {
      cr=0;
      continue;
    }
    cr++;
    i++;
  }
  cout<<ans<<endl;
}













Measured memory_bytes: 1024
N = int(input())
P = list(map(int, input().split()))

ans = 0
for i in range(len(P) - 2):
    if (P[i] < P[i+1] < P[i+2]) or (P[i+2] < P[i+1] < P[i]):
        ans += 1
    else:
        ans = ans

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

bool ok(const vecint& a, const int th) {
  ll n = a.size();
  vecint v(n*4);
  int offset = n*2;
  ll cnt = 0;
  ll sum = 0;
  REP(i,n) {
    v[offset] += 1;
    if (a[i] >= th) {
      offset -= 1;
      sum -= v[offset];
    } else {
      sum += v[offset];
      offset += 1;
    }
    cnt += sum;
  }
  ll m = n * (n+1) / 2;
  ll mid = m/2 + 1;
  return cnt >= mid;
}

int main()
{
  int n;
  cin>>n;
  vecint a(n);
  REP(i,n) cin>>a[i];
  vecint b = a;
  b.push_back(0);
  b.push_back(1000000007);
  sort(ALL(b));
  b.erase(unique(ALL(b)), end(b));
  int hi = b.size()-1;
  int lo = 0;
  while ((hi - lo) > 1) {
    int mid = (hi + lo) / 2;
    if (ok(a, b[mid])) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  cout << b[lo] << endl;
  return 0;
}


Measured memory_bytes: 2652
#include<iostream>

using namespace std;

int main()
{
  int N,i;
  cin>>N;
  double A[N],sum=0;
  for(i=0;i<N;i++)
  {
    cin>>A[i];
    A[i]=1/A[i];
    sum+=A[i];
  }
  cout<<1/sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		int n;
		cin>>n;
		int arr[n];
		for(int i=0;i<n;i++)
			cin>>arr[i];
		sort(arr,arr+n);
		int count=0;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(i!=j && arr[i]!=arr[j]){
					int sum=arr[i]+arr[j];
					for(int k=j+1;k<n;k++){
						if((k!=i && k!=j && arr[k]!=arr[i] && arr[k]!=arr[j]) && sum>arr[k])
							count++;
					}
				}
			}
		}
		cout<<count;
		return 0;
	}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
 
 
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
struct state{
  int d[5][5];
  void cpy(const state& s){
    for(int i=0;i<4;i++)
      for(int j=0;j<4;j++)
    d[i][j] = s.d[i][j];
  }
   
 
  void sim(){
     
    bool f = false;
 
    bool fl[5][5][4] = {};
     
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
    if( d[i][j] > 4 ){
      d[i][j] = 0;
      f = true;
      for(int k=0;k<4;k++)
        fl[i][j][k] = 1;
    }
      }
    }
 
 
    do{
      f = false;
      bool nf[5][5][4] = {};
     
      for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      for(int k=0;k<4;k++){
     
        if( fl[i][j][k] == 1 ){
          f = true;
          if( d[i][j] > 0 ){
        d[i][j]++;
        fl[i][j][k] = 0;
          } else {
        fl[i][j][k] = 0;  
        if( i + dx[k] >= 4 || j + dy[k] >= 4 ||
            i + dx[k] < 0 || j + dy[k] < 0 ) continue;
        nf[i+dx[k]][j+dy[k]][k] = 1;        
          }
        }
      }
    }
      }
 
      for(int i=0;i<4;i++)
    for(int j=0;j<4;j++)
      for(int k=0;k<4;k++)
        fl[i][j][k] = nf[i][j][k];
 
 
      for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      if( d[i][j] > 4 ){
        d[i][j] = 0;
        f = true;
        for(int k=0;k<4;k++)
          fl[i][j][k] = 1;
      }
    }
      }
 
    }while(f);
 
 
  }
 
  bool check(){
    for(int i=0;i<4;i++)
      for(int j=0;j<4;j++)
    if( d[i][j] > 0 ) return false;
    return true;
  }
 
  void view(){
    cout << "view" << endl;
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
    cout << d[j][i];
      }
      cout << endl;
    }
  }
 
};
 
int res = 10;
int solve(state &s,int c){
  // s.view();
  if( s.check() ) return c;
  if( c == 5 || c > res ) {
    return -1;
  }
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      state nex; nex.cpy( s );
      nex.d[i][j]++;
      nex.sim();
      int ret = solve( nex, c + 1 );
      if( ret > -1 ) res = min( res, ret );
    }
  }
  return res;
}
 
 
int main(){
  state s;
  for(int i=0;i<4;i++)
    for(int j=0;j<4;j++)
      cin >> s.d[j][i];
  int res = solve(s,0);
  if( res > 5 ) cout << -1 << endl;
  else cout << res << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main() {
    int c[3][3];
    rep(i,3){
        rep(j,3){
            cin>>c[i][j];
        }
    }
    bool res=false;
    for(int i=0;i<=100;i++){
        int p=c[0][0]-i,q=c[0][1]-i,r=c[0][2]-i;
        for(int j=0;j<=100;j++){
            for(int k=0;k<=100;k++){
                if(j+p==c[1][0]&&j+q==c[1][1]&&j+r==c[1][2]){
                    if(k+p==c[2][0]&&k+q==c[2][1]&&k+r==c[2][2]){
                        res=true;
                    }
                }

            }
        }
    }
    if(res) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main(){
  int W, H; 

  while(true){
    cin >> W >> H;
    if (W == 0 && H == 0){
      break;
    }
    for (int i = 0; i < W; i++){
      for (int j = 0; j < H; j++){
        cout << '#';
      }
       cout << endl;
    }
    cout << endl;
  }
 
}


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

const int mx=100009;
ll w[mx], v[mx], dp[mx][200], n, W;

ll find_max(ll val, ll index)
{
    if(index==n) return val==0 ? 0 : INT_MAX;

    if(~dp[val][index]) return dp[val][index];

    ll ans = find_max(val, index+1);

    if(v[index]<=val)
    {
        ans = min(ans, find_max(val-v[index], index+1) + w[index]);
    }
    return dp[val][index] = ans;
}
ll calc(ll mxx)
{
    for(ll i=mxx;i>=1;i--)
    {
        if(find_max(i, 0)<=W)
        {
            return i;
        }
    }
    return 0;
}

void solve()
{
    ll mxx=0;
    cin>>n>>W;

    memset(dp, -1, sizeof dp);

    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
        mxx+=v[i];
    }
    cout<<calc(mxx)<<endl;
}

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

    int t=1;
   // cin>>t;

    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 159912
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <queue>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
#define ll long long
int n,m;
vector<vector<int> > G;
vector<bool> visited;
int dfs(int cur){
    bool all_v = true;
    for(bool x:visited){
        if(x==false){
            all_v = false;
            break;
        }
    }

    if(all_v)return 1;

    int ret = 0;
    for(int x:G[cur]){
        if(visited[x])continue;
        visited[x]=true;
        ret += dfs(x);
        visited[x]=false;
    }
    return ret;
}

int main(){
    cin >> n >> m;
    G.resize(n);
    visited.resize(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int i=0;i<n;i++){
        visited[i]=false;
    }
    visited[0]= true;
    cout << dfs(0) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{
  public static void main(String[] args){
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try {
      String str = br.readLine();
      String str2[] = str.split(" ");
      int a = Integer.parseInt(str2[0]);
      int b = Integer.parseInt(str2[1]);
      System.out.println(a*b + " " + (a+b)*2);
      br.close();
    } catch (IOException e){
      System.err.println(e.toString());
    }
  }
}


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

int main() {
  int X, Y;
  cin >> X >> Y;
  
  if (Y % 2 == 1){
    cout << "No" << endl;
    return 0;
  }
  
  if (X > 50){
    cout << "No" << endl;
    return 0;
  }
  
  for(int i=0; i<=X; i++){
    int A = i;
    int B = X - A;
    
    if(A*4 + B*2 == Y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
}


Measured memory_bytes: 3620
# -*- coding: utf-8 -*-

grid = [list(map(int, input().split())) for i in range(3)]

# 組み合わせてイコールになる箇所を考えてみる
if grid[0][0] + grid[2][2] == grid[0][2] + grid[2][0]\
        and grid[0][1] + grid[1][0] - grid[1][1] == grid[0][0]\
        and grid[0][1] + grid[1][2] - grid[1][1] == grid[0][2]\
        and grid[1][0] + grid[2][1] - grid[1][1] == grid[2][0]\
        and grid[1][2] + grid[2][1] - grid[1][1] == grid[2][2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
"""

手の付け方がわからない
ある条件を決める中での余事象？
A != Bでおいていく
毎回横で被る場合を引く

←にk個置かれてて
* MC2　したとする
上側に置いたのがかぶってる確率は (k / M)
下側もそう
両側は (k/M)**2

dp[k+1] = dp[k] * MC2 * (1 - 2*(k/M) + (k/M)**2)

Aを置いた
Bを置く　→　ほう助原理

"""

def inverse(a,mod): #aのmodを法にした逆元を返す
    return pow(a,mod-2,mod)

def modfac(n, MOD):
 
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return factorials, invs


def modnCr(n,r): #上で求めたfacとinvsを引数に入れるべし(上の関数で与えたnが計算できる最大のnになる)

    return fac[n] * inv[n-r] * inv[r] % mod


N,M = map(int,input().split())
mod = 10**9+7

fac,inv = modfac(5*10**5+10,mod)

las = fac[N] * modnCr(M,N)

now = 0
for i in range(N+1):

    np = modnCr(N,i) * fac[N-i] * modnCr(M-i,N-i)
    if i % 2 == 0:
        now += np
    else:
        now -= np
    #print (np)
    now %= mod

#print (las,now)
print (las * now % mod)


Measured memory_bytes: 108176
package main

import "fmt"

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var a, v, b, w, t int
	fmt.Scan(&a, &v, &b, &w, &t)

	d := abs(a - b)
	if w >= v {
		fmt.Println("NO")
	} else if (v-w)*t >= d {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1816
n=int(input())
l=[]
t=int(n**0.5)
while len(l)==0:
    if n%t==0:
        l.append((t,n//t))
    t-=1
x,y=l[0][0],l[0][1]
ans=max(len(list(str(x))),len(list(str(y))))
print(ans)

Measured memory_bytes: 9456
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
//#define MOD 1000000007 //10^9+7
#define MOD 2019

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

int main(void){

  string s;
  cin>>s;

  ll length = s.size();

  vector<ll> v(2019); //余りを格納
  REP(i, 2019) v[i] = 0;

  ll ten = 1;
  ll mod = 0;;

  REPD(i, length){
    ll x = s[i]-'0';
    //cout<<x<<" :";
    if(i!= length-1){
      ten *= 10;
      ten = ten%MOD;
    }
    mod = (mod+ x*ten)%MOD;
    //cout<<mod<<endl;
    v[mod]++;
  }

  ll ans = 0;
  REP(i, 2019){
    ans += (v[i]*(v[i]-1))/2;
  }
  ans += v[0];

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

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

int main() {
    int a = 0, b = 0, c = 0;
    string x, y, z;
    char temp = 'a';
    cin >> x >> y >> z;
    while(true) {
        if(temp == 'a') {
            if(a == x.length()) {
                cout << "A" << endl;
                break;
            }
            temp = x.at(a);
            a++;
        } else if(temp == 'b') {
            if(b == y.length()) {
                cout << "B" << endl;
                break;
            }
            temp = y.at(b);
            b++;
        } else if(temp == 'c') {
            if(c == z.length()) {
                cout << "C" << endl;
                break;
            }
            temp = z.at(c);
            c++;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
vector<bool> sieve_of_eratosthenes(int num) {
  vector<bool> res(num + 1, true);
  res[0] = res[1] = false;
  for (int i = 2; i * i <= num; ++i) if (res[i]) {
    for (int j = i * i; j <= num; j += i) res[j] = false;
  }
  return res;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  vector<bool> table = sieve_of_eratosthenes(100000);
  vector<int> ruiseki(100001, 0);
  for (int i = 3; i < 100000; i += 2) {
    if (table[i] && table[(i + 1) / 2]) ++ruiseki[i];
  }
  REP(i, 100000) ruiseki[i + 1] += ruiseki[i];
  int q; cin >> q;
  REP(i, q) {
    int l, r; cin >> l >> r;
    cout << ruiseki[r] - ruiseki[l - 1] << '\n';
  }
  return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define FILE "parade"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const ull ULLINF = numeric_limits<ull>::max();
const double PI = acos(-1.0);

int main()
{
//    freopen(FILE".in", "r", stdin);
//    freopen(FILE".out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n - 1; i++)
    {
        if(s[i] == s[i + 1])
        {
            cout << i + 1 << " " << i + 2;
            return 0;
        }
    }
    for(int i = 0; i < n - 2; i++)
    {
        if(s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2])
        {
            cout << i + 1 << " " << i + 3;
            return 0;
        }
    }
    cout << "-1 -1";
    return 0;
}


Measured memory_bytes: 512
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

bool exhaustive_search_search(int32_t data[], size_t size, int32_t find)
{
  uint32_t i;

  if (find == 0) return true;

  if ((data == NULL) || (size == 0)) return false;

  if (exhaustive_search_search(&data[1], size - 1, find)) {
    return true;
  }

  if (((find - data[0]) >= 0) && exhaustive_search_search(&data[1], size - 1, find - data[0])) {
    return true;
  }

  return false;
}

#if !defined(TEST)
#include <stdio.h>
int32_t main(void)
{
  int32_t buf1[20];
  int32_t num1;
  scanf("%d", &num1);

  int32_t i;
  for (i = 0; i < num1; i++) {
    scanf("%d", &buf1[i]);
  }

  int32_t num2;
  scanf("%d", &num2);
  int32_t buf2[200];

  for (i = 0; i < num2; i++) {
    scanf("%d", &buf2[i]);
  }

  for (i = 0; i < num2; i++) {
    if (exhaustive_search_search(buf1, num1, buf2[i])) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return 0;
}
#endif

Measured memory_bytes: 580
#include <iostream>

int main(int argc, char const* argv[])
{
    int x, A;
    std::cin >> x >> A;
    if (x >= A) {
        std::cout << 10 << std::endl;
    }
    else {
        std::cout << 0 << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
s = input()
x, y = [ int(v) for v in input().split() ]

f_length_list = list(map(len,s.split("T")))

x_point_set = set([0])
y_point_set = set([0])

for i, v in enumerate(f_length_list):
    new_point_set = set([])
    if i % 2 == 0:
        if i == 0:
            new_point_set.add(v)
        else:
            for j in x_point_set:
                new_point_set.add(j+v)
                new_point_set.add(j-v)
        x_point_set = new_point_set

    elif i % 2 != 0:
        for j in y_point_set:
            new_point_set.add(j+v)
            new_point_set.add(j-v)
        y_point_set = new_point_set

if x in x_point_set and y in y_point_set:
    ans = "Yes"
else:
    ans = "No"
print(ans)

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

int main(void){

    long long N, K, Q;
    cin >> N >> K >> Q;
    vector<long long> arr(Q);
    for (long long i = 0; i < Q; i++) cin >> arr[i];

    vector<long long> point(N, 0);

    for (long long i = 0; i < Q; i++) point[arr[i]-1]++;

    for (long long i = 0; i < N; i++) {
        if(Q - point[i] >= K) cout << "No" << endl;
        else cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 2176