akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000005
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int w[101],val[101],dp[100005];
int32_t main(){
    boost;
    //freopen(".in","r",stdin);
    int n,W,a,b;
    cin>>n>>W;
    for (int j = 0; j <= 100000; ++j)
        dp[j]=INF;
    dp[0]=0;
    for (int i = 0; i < n; ++i)
    {
        cin>>a>>b;
        for (int j = 100000; j >= b; j--)
            dp[j]=min(dp[j],dp[j-b]+a);
    }
    for (int i = 100000; i >= 0; i--)
        if(dp[i]<=W){cout<<i<<"\n";return 0;}
    return 0;
}

//do smth instead of nothing and stay organized
//long long
//array bounds
//special cases
//binary search

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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll=long long;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9+7;

    int x;
    cin>>x;
    x=lcm(360,x)/x;
    cout<<x<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <vector>
#include <queue>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    int K, N;
    cin >> N >> K;
    vector<int> A(N);
    REP(i,N)cin>>A[i];

    sort(A.begin(), A.end());
    priority_queue<int, vector<int>, greater<int>> que;
    int pre_val = A[0];
    int count = 0;
    REP(i,N){
        int val = A[i];
        if(pre_val != val){
            que.push(count);
            count = 0;
        }
        count++;
        pre_val = val;
    }
    que.push(count);

    int ans = 0;
    while(que.size() > K){
        int c_val = que.top();
        que.pop();
        ans += c_val;
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 4860
MOD = 998244353
a, b, c, d = map(int, input().split())
dp = [[0] * (d + 1) for _ in range(c + 1)]
dp[a][b] = 1
for i in range(a, c + 1):
    for j in range(b, d + 1):
        if i > a:
            dp[i][j] += dp[i - 1][j] * j
        if j > b:
            dp[i][j] += dp[i][j - 1] * i
        if i > a and j > b:
            dp[i][j] -= dp[i - 1][j - 1] * \
                (i - 1) * (j - 1)
        dp[i][j] %= MOD
print(dp[c][d])


Measured memory_bytes: 133944
main = do
  [a, b, c, d] <- map read . words <$> getLine
  let x = c - a
      y = d - b
      x1 = c - y
      y1 = d + x
      x2 = x1 - x
      y2 = y1 - y
  putStrLn . unwords . map show $ [x1, y1, x2, y2]


Measured memory_bytes: 508
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s=sc.next();
		char[] cs=s.toCharArray();
		System.out.println(Slime(cs));
	}

	private static int Slime(char[] cs) {
		int r=1;
		for(int i=1;i<cs.length;i++) {
			if(cs[i-1]!=cs[i]) {
				r++;
			}
		}

		return r;
	}

}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    int n ;
    cin >> n ;

    vll v ( n ) ;
    for ( int i=0 ; i < n ; i ++ )
        cin >> v[i] ;

    vll a ( n ) , b ( n ) ;

    for ( int i=0 ; i < n ; i ++ )
        a[i] = v[i] + i ;

    for ( int i=0 ; i < n ; i ++ )
        b[i] = i - v[i] ;

    map < ll , int > h ;

    h[b[n - 1]] = 1 ;

    ll ans = 0 ;

    for ( int i = n - 2 ; i > -1 ; i -- )
    {
        ans += h[a[i]] ;

        h[b[i]] ++ ;
    }

    cout << ans ; line ;
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


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

int main() {
	ll n,temp,count=1,ans=0;cin>>n;
  	vector<ll> a(n+1);
  	a[0]=0;
  	for(int i=0;i<n;i++){
      cin>>temp;
      a[i+1]+=temp+a[i];
     
    }
  	sort(a.begin(),a.end());
  	for(int i=0;i<n;i++){
    	if(a[i]==a[i+1]){
        	count++;
        }else{
			ans+=count*(count-1)/2;
          	count=1;
        }
    }
  			ans+=count*(count-1)/2;
  			cout<<ans<<endl;
}

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

int main()
{
  int a[3][3];
  bool app[3][3];
  int c[10];
  int in;

  for(int i=0;i<3;i++)
  {
    for(int j=0;j<3;j++)cin>>a[i][j];
  }

  cin>>in;
  for(int i=0;i<in;i++)cin>>c[i];
  for(int i=0;i<in;i++)
  {
    for(int j=0;j<in;j++)
    {
        app[i][j] = false;
        for(int k=0;k<in;k++)
        {
          if(a[i][j]==c[k])app[i][j]=true;
        }
    }
  }
  
  string ans="No";
  if(app[0][0]==true &&app[0][1]==true&&app[0][2]==true)ans = "Yes";
  if(app[1][0]==true &&app[1][1]==true&&app[1][2]==true)ans = "Yes";
  if(app[2][0]==true &&app[2][1]==true&&app[2][2]==true)ans = "Yes";

  if(app[0][0]==true &&app[1][0]==true&&app[2][0]==true)ans = "Yes";
  if(app[0][1]==true &&app[1][1]==true&&app[2][1]==true)ans = "Yes";
  if(app[0][2]==true &&app[1][2]==true&&app[2][2]==true)ans = "Yes";

  if(app[0][0]==true &&app[1][1]==true&&app[2][2]==true)ans = "Yes";
  if(app[0][2]==true &&app[1][1]==true&&app[2][0]==true)ans = "Yes";

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
using namespace std;

template<typename type>
class UnionFindTree
{
  private:
    vector<type> parent;
    vector<type> rank;

  public:
    UnionFindTree(size_t size) {
        parent.resize(size);
        rank.resize(size, 0);
        for (int i = 0; i < size; ++i) {
            parent[i] = i;
        }
    }

    type findRoot(type x) {
        if (parent[x] == x) return x;
        else return parent[x] = findRoot(parent[x]);
    }

    void uniteTwoGroup(type x, type y) {
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) return;

        if (rank[x] < rank[y]) parent[x] = y;
        else {
            parent[y] = x;
            if (rank[x] == rank[y]) ++rank[x];
        }
    }

    bool isSameGroup(type x, type y) {
        return findRoot(x) == findRoot(y);
    }
};

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

    int N, M;
    cin >> N >> M;

    UnionFindTree<int> utree(N);

    vector<int> X(M);
    vector<int> Y(M);
    vector<int> Z(M);

    for (int i = 0; i < M; ++i) {
        cin >> X[i] >> Y[i] >> Z[i];
        utree.uniteTwoGroup(X[i] - 1, Y[i] - 1);
    }

    set<int> s;
    for (int i = 0; i < N; ++i) {
        s.insert(utree.findRoot(i));
    }

    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<vector<int>> M(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>M.at(i).at(j);
    }
  }
  map<int,bool> m;
  int N;
  cin>>N;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      m[M.at(i).at(j)]=false;
    }
  }
  
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    m[a]=true;
  }
  if((m.at(M.at(0).at(0))&&m.at(M.at(0).at(1))&&m.at(M.at(0).at(2)))||
     (m.at(M.at(1).at(0))&&m.at(M.at(1).at(1))&&m.at(M.at(1).at(2)))||
     (m.at(M.at(2).at(0))&&m.at(M.at(2).at(1))&&m.at(M.at(2).at(2)))||
     (m.at(M.at(0).at(0))&&m.at(M.at(1).at(0))&&m.at(M.at(2).at(0)))||
     (m.at(M.at(0).at(1))&&m.at(M.at(1).at(1))&&m.at(M.at(2).at(1)))||
     (m.at(M.at(0).at(2))&&m.at(M.at(1).at(2))&&m.at(M.at(2).at(2)))||
     (m.at(M.at(0).at(0))&&m.at(M.at(1).at(1))&&m.at(M.at(2).at(2)))||
     (m.at(M.at(0).at(2))&&m.at(M.at(1).at(1))&&m.at(M.at(2).at(0)))){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;
void swap(ll &a,ll &b){
    ll temp=a;
    a=b;
    b=temp;
}
ll gcd(ll a,ll b){
    while(b){
        a%=b;
        swap(a,b);
    }
    return a;
}

ll lcm(ll a,ll b){
    ll ans=(a*b)/gcd(a,b);
    return ans;
}

void solve(){
    ll N;
    cin>>N;
    vpl AB(N);
    F0R(i,N){
        cin>>AB[i].second>>AB[i].first;
    }
    sort(all(AB));
    ll curr=0;
    F0R(i,N){
        if(curr+AB[i].second<=AB[i].first){
            curr+=AB[i].second;
        }else{
            out("No");
            return ;
        }
    }
    out("Yes");

}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }



int main(int argc, char const *argv[]) {
  int n, k;
  cin >> n >> k;
  vector<int> c(n);
  rep(i,n) cin >> c[i];
  sort(all(c));
  ll sum = 0;
  rep(i, k) sum += c[i];
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3580
macro_rules! get_one {
    ($t:ty) => {{
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse::<$t>().unwrap()
    }};

    ($t:ty; $n:expr) => {
        (0..$n).map(|_| get_one!($t)).collect::<Vec<_>>()
    };
}

fn main() {
    let _ = get_one!(usize);
    let v_s: Vec<char> = get_one!(String).chars().collect();
    let r_pos = pos('R', &v_s);
    let g_pos = pos('G', &v_s);
    let b_pos = pos('B', &v_s);

    let mut except = 0;
    for &r in r_pos.iter() {
        for &g in g_pos.iter() {
            if let Some('B') = v_s.get((2 * r - g) as usize) {
                except += 1;
            }
            if let Some('B') = v_s.get((2 * g - r) as usize) {
                except += 1;
            }
            if (r + g) % 2 == 0 && v_s[((r + g) / 2) as usize] == 'B' {
                except += 1;
            }
        }
    }

    let r_num = r_pos.len();
    let g_num = g_pos.len();
    let b_num = b_pos.len();

    println!("{}", r_num * g_num * b_num - except);
}

fn pos(chr: char, v: &Vec<char>) -> Vec<i32> {
    v.iter().enumerate().filter_map(|(i, &c)| if c == chr {Some(i as i32)} else {None}).collect()
}


Measured memory_bytes: 2156
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void codeforces()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
string convert(int a) {
    string s;
    map<int, char> m;
    for(char c = 'a'; c<'z'; c++) m[c - 'a' + 1] = c;
    m[0] = 'z';
    while( a> 0){
        s+= m[a%26];
        if( a%26 == 0) a = a/26 - 1;
        else a = a/26;
    }
    reverse(s.begin(), s.end());
    return s;
}
int32_t main()
{
    
    // w(t)
    {
        int n; cin>>n;
        // int a[n];
        map<int, int> m;
        int sum = 0;
        for(int i=0; i<n; i++){
            // cin>>a[i];
            int a; cin>>a;
            sum += a;
            m[a]++;
        }
        int q; cin>>q;
        for(int i=0; i<q; i++){
            int b, c;
            cin>>b>>c;
            cout<<sum - m[b]*b + m[b]*c<<endl;
            m[c] += m[b];
            sum = sum - m[b]*b + m[b]*c;
            m.erase(b);
        }
    }
    return 0;
}

Measured memory_bytes: 7576
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ld> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ld INF=1.0e30L;
const ld EPS=1.0e-15L;
const double PI=M_PI;

vec min_x(3),max_x(3),min_y(3),max_y(3);
ld f(ld T){
    ld Mx=max(max_x[0],max(max_x[1]+T,max_x[2]-T));
    ld mx=min(min_x[0],min(min_x[1]+T,min_x[2]-T));
    ld My=max(max_y[0],max(max_y[1]+T,max_y[2]-T));
    ld my=min(min_y[0],min(min_y[1]+T,min_y[2]-T));
    return (Mx-mx)*(My-my);
}

int main(){
    int N; cin>>N;
    mat X(3),Y(3);
    rep(i,N){
        ld x,y; cin>>x>>y;
        char d; cin>>d;
        if(d=='U'){
            X[0].pb(x); Y[1].pb(y);
        }
        if(d=='D'){
            X[0].pb(x); Y[2].pb(y);
        }
        if(d=='R'){
            X[1].pb(x); Y[0].pb(y);
        }
        if(d=='L'){
            X[2].pb(x); Y[0].pb(y);
        }
    }
    rep(i,3){
        if(X[i].empty()){
            min_x[i]=INF; max_x[i]=-INF;
        }
        else{
            sort(all(X[i])); 
            min_x[i]=X[i][0]; max_x[i]=X[i][SZ(X[i])-1];
        }
        if(Y[i].empty()){
            min_y[i]=INF; max_y[i]=-INF;
        }
        else{
            sort(all(Y[i]));
            min_y[i]=Y[i][0]; max_y[i]=Y[i][SZ(Y[i])-1];
        }
    }
    ld T,ans=f(0.0L);
    rep(i,2){
        T=fabs(max_x[i+1]-max_x[0]);
        ans=min(ans,f(T));
        T=fabs(max_y[i+1]-max_y[0]);
        ans=min(ans,f(T));
        T=fabs(min_x[i+1]-min_x[0]);
        ans=min(ans,f(T));
        T=fabs(min_y[i+1]-min_y[0]);
        ans=min(ans,f(T));        
    }
    T=fabs(max_x[2]-max_x[1])/2.0L;
    ans=min(ans,f(T));
    T=fabs(max_y[2]-max_y[1])/2.0L;
    ans=min(ans,f(T));
    T=fabs(min_x[2]-min_x[1])/2.0L;
    ans=min(ans,f(T));
    T=fabs(min_y[2]-min_y[1])/2.0L;
    ans=min(ans,f(T)); 
    printf("%.15Lf\n",ans);
    return 0;
}

Measured memory_bytes: 4196
#include <stdio.h>

int main()
{
    
	int K, X;
	int m = scanf("%d %d",&K, &X);
	if (m == EOF) {
		printf("scan error!\n");
		return 0;
	}

	for (int i = X - K + 1; i <= X + K - 1; i++) {
		printf("%d ", i);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int time, hour, minute, second;
	
	scanf("%d", &time);
	
	hour = time / (60 * 60);
	minute = (time - hour * 3600) / 60;
	second = time - (hour * 3600 + minute * 60);
	
	printf("%d:%d:%d\n", hour, minute, second);
	
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int num =0;
  
  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    
    for (int j = A; j <= B; j++) {
      num++;
    }
  }
  cout << num << endl;
}
      

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Numeric

main :: IO ()
main = loop

loop :: IO ()
loop  = do
  { [h, w] <- getInts
  ; if h == 0 && w == 0 then done
    else do
      { putStrLn $ unlines $ checkerboard h w
      ; loop 
      }
  }



firstLine :: Int -> String
firstLine n = take n (cycle "#.")

secondLine :: Int -> String
secondLine n = take n (cycle ".#")

checkerboard :: Int -> Int -> [String]
checkerboard h w = take h (cycle [firstLine w, secondLine w])
  
--

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn .unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""

done :: IO ()
done = return ()


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

int main(){

  long long n;
  long long a[1000000];
  long long ans1=0,ans2=0,sum=0;

  cin>>n;

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

  
  //一つ目がプラス
  for(int i=0;i<n;i++){
    sum+=a[i];
    if( (i+1)%2==1 && sum<=0 ){
      ans1+=abs(sum)+1;
      sum=1;
    }
    if( (i+1)%2==0 && sum>=0 ){
      ans1+=abs(sum)+1;
      sum=-1;
    }
  }

  sum=0;

  //一つ目はマイナス
  for(int i=0;i<n;i++){
    sum+=a[i];
    if( (i+1)%2==0 && sum<=0 ){
      ans2+=abs(sum)+1;
      //cout<<i+1<<" "<<abs(sum)+1<<endl;
      sum=1;
    }
    if( (i+1)%2==1 && sum>=0 ){
      ans2+=abs(sum)+1;
      //cout<<i+1<<" 奇数 "<<abs(sum)+1<<endl;
      sum=-1;
    }
  }


  //cout<<"ans1:"<<ans1<<"  "<<"ans2:"<<ans2<<endl;

  if(ans1>ans2)
    cout<<ans2<<endl;
  else 
    cout<<ans1<<endl;


  return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <algorithm>
#define INF (1 << 25)
using namespace std;

int n,m,cost[32][32],x1,x2,y1,y2;

void init(){
    for(int i=0;i<32;i++){
        for(int j=0;j<32;j++) cost[i][j] = INF;
    }
}

void add_info(){
    int a,b,c,d;
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    cost[a][b] = c; cost[b][a] = d;
}

int main(){
    cin >> n >> m;
    init();
    for(int i=0;i<m;i++) add_info();
    scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=n;k++){
                cost[j][k] = min(cost[j][k],cost[j][i] + cost[i][k]);
            }
        }
    }
    cout << y1-(cost[x1][x2]+cost[x2][x1]+y2) << endl;
}

Measured memory_bytes: 1244
#include <stdio.h>
 
int main()
{
    int r, c;
    scanf("%d %d", &r, &c);
 
    int i, j;
    int a[100][100] = {0};
    int h[100] = {0};
    for(i=0; i<r; i++)
    {
        for(j=0; j<c; j++)
        {
            scanf("%d", &a[i][j]);
            h[j] += a[i][j];
        }
    }
 
     
    for(i=0; i<r+1; i++)
    {
        int w=0;
        for(j=0; j<c+1; j++)
        {
            if(j == c)
            {
                printf("%d\n", w);
            }
            else
            {
                int s = i==r?h[j]:a[i][j];
                printf("%d ", s);
                w += s;
            }
 
        }
         
    }
 
 
    return 0;
}

Measured memory_bytes: 648
N = int(input())
L = [tuple(map(int, input().split())) for _ in range(N)]
L.sort(key=lambda x: x[1])
work = 0
for n in range(N):
  work += L[n][0]
  if work > L[n][1]:
    print('No')
    exit()
print('Yes')

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

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

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int N; cin >> N;
	vector<char> c(N);
	rep(i, N)cin >> c[i];
	int count = 0;
	rep(i, N) {
		if (c[i] == 'R')++count;
	}
	if (count == 0 || count == N) {
		cout << 0;
		return 0;
	}

	int cw = 0;
	int cr = 0;
	
	int r = N - 1;
	int l = 0;
	rep(i, N) {
		if (c[r - i] == 'R') {
			rep(j, N - l) {
				if (c[l + j] == 'W') {
					if (r - i < l + j) {
						cout << cr;
						return 0;
					}
					++cr;
					c[l + j] = 'R';
					c[r - i] = 'W';
					l = l + j;
					break;
				}
			}
		}
	}
	
	cout << cr;
}

Measured memory_bytes: 3600
using System;

namespace TenkaPBC2019
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int C = int.Parse(input[2]);
            //ＣがＡとＢの間にあったら”Ｙｅｓ”，そうでないとき”Ｎｏ”
            if ((A < C) && (C < B))
            {
                Console.WriteLine("Yes");
            }
            else if ((A>C)&&(B<C))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;
import java.util.*;
public class Main {
	public static String S;
	public static String T;
	public static int sub = Integer.MAX_VALUE;

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		S = scan.next();
		T = scan.next();
		System.out.println(search());
	}

	private static int search() {
		for (int i = 0;i <= S.length() - T.length() ;i++ ) {
			int count = 0;
			for (int j = 0;j < T.length() ;j++ ) {
				String s_i = S.substring(i + j,i + j + 1);
				String t_i = T.substring(j,j + 1);
				if (!s_i.equals(t_i)) count++;
			}
			sub = Math.min(sub,count);
		}
		return sub;
	}

}


Measured memory_bytes: 52924
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>

//#include<boost/circular_buffer.hpp>
using namespace std;

//cout << fixed << setprecision(10);
typedef long long ll;
#define PI 3.141592653589793
#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

int gcd(int a, int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int lcm(int a, int b) {
	long long int L;
	L = (a * b) / gcd(a, b);
	return L;
}

vector<long long  int> Prime;
void Eratosthenes(long long int n) {
	vector<bool> is_prime(n, true);
	for (int i = 2; i * i <= n; i++) {
		;
		if (is_prime.at(i)) {
			for (int j = i * i; j <= n; j += i) {
				is_prime.at(j) = false;
			}
		}
		Prime.emplace_back(i);
	}
}

/*
map<int, int> prime;
void Prime_number(long long int n) {
	for (int i = 2; i <= n; i++) {
		int count = 0;
		while (n % i == 0) {
			count++;
			n /= i;
		}
		if (count != 0) {
			prime.insert(make_pair(i, count));
		}
	}
}
*/
//std::cout.fill('0');

int keta(long long int N) {
	int k = 0;
	while (N > 0) {
		N /= 10;
		k++;
	}
	return k;
}

int main() {
	int x, n, m;
	int ans = 0;
	cin >> x;
	n = x / 100;
	m = x % 100;

	if (5 * n >= m)
		ans = 1;
	cout << ans;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

while True:
    N = input()
    if N == "0000":
        break

    nums = [int(N[i]) for i in range(4)]
    ans = 1
    while True:
        nums.sort()
        S = nums[3]*1000 + nums[2]*100 + nums[1]*10 + nums[0]
        T = nums[0]*1000 + nums[1]*100 + nums[2]*10 + nums[3]
        if S - T == 6174:
            break
        elif S - T == 0:
            ans = -1
            break
        else:
            K = S - T
            nums[0] = K // 1000
            K -= nums[0]*1000
            nums[1] = K // 100
            K -= nums[1]*100
            nums[2] = K // 10
            K -= nums[2]*10
            nums[3] = K
            ans = ans + 1

    if ans == -1:
        print("NA")
    elif N == "6174":
        print(0)
    else:
        print(ans)
    


Measured memory_bytes: 5632
import sys
sys.setrecursionlimit(1000000)

def calc(p1, p2, v):
    dists_v = dists[v]
    if v == n - 1:
        return dists_v[p1] + dists_v[p2]
    if visited[p1][p2]:
        return dp[p1][p2]
    dp[p1][p2] = min(dists_v[p1] + calc(p2, v, v + 1), dists_v[p2] + calc(p1, v, v + 1))
    visited[p1][p2] = True
    return dp[p1][p2]


n = int(input())
points = [complex(*map(int, input().split())) for _ in range(n)]
dists = [[abs(p1 - p2) for p2 in points] for p1 in points]
visited = [[False] * n for _ in range(n)]
dp = [[0] * n for _ in range(n)]

print(calc(0, 0, 0))

Measured memory_bytes: 68648
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;

int main() {

	int N, K;
	cin >> N >> K;
	vector<int> denominator(N);
	for (int i = 1; i <= N; i++) {
		int score = i;
		int j = 0;
		int flag = true;
		while (flag) {
			if (score >= K) {
				denominator[i - 1] = N * pow(2, j);
				flag = false;
				break;
			}
			score *= 2;
			j++;
		}
	}
	double probability = 0.0;
	for (int i = 1; i <= N; i++) {
		//cout << denominator[i - 1] << endl;
		probability += static_cast<double>(1.0 / denominator[i - 1]);
	}
	cout << fixed << setprecision(12) << probability << endl;
	return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc047/tasks/abc047_b
# a=1のなかで一番大きい値をXとするとき、x<Xはすべて黒く塗られる
# a=2のなかで一番小さい値Xとするとき、X<xはすべて黒く塗られる
# a=3→一番大きいY、y<Y
# a=4→一番小さいY、Y<y は塗る
W, H, N = read_ints()
A = [0, W, 0, H]
for _ in range(N):
    x, y, a = read_ints()
    a -= 1
    if a == 0:
        A[a] = max(x, A[a])
    if a == 1:
        A[a] = min(x, A[a])
    if a == 2:
        A[a] = max(y, A[a])
    if a == 3:
        A[a] = min(y, A[a])

if A[1] - A[0] > 0 and A[3] - A[2] > 0:
    print((A[1] - A[0]) * (A[3] - A[2]))
else:
    print(0)


Measured memory_bytes: 38256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#include <array>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__)
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int n, m, q;
int a[50],b[50],c[50],d[50];
int main(){
    cin >> n >> m >> q;
    rep(i,q)cin >> a[i] >> b[i] >> c[i] >> d[i];
    //(n+m-1)C(m-1)
    vector<int>p(n + m - 1);
    rep(i,m-1)p[p.size()-1-i]=1;
    int ans = 0;
    do{
        vector<int>A;
        int t = 1;
        rep(i,n+m-1){
            if(!p[i])A.push_back(t);
            else t++;
        }
        int s = 0;
        rep(i,q){
            if(A[b[i]-1]-A[a[i]-1]==c[i])s+=d[i];
        }
        ans = max(ans, s);
    }while(next_permutation(p.begin(), p.end()));
    cout << ans << endl;
}


Measured memory_bytes: 3628
r, c = map(int, input().split())

rows = []
for i in range(r):
    row = list(map(int, input().split()))
    row.append(sum(row))
    rows.append(row)

erow = [0 for i in range(c + 1)]
for row1 in rows:
    print(" ".join(str(s) for s in row1))
    for i in range(c + 1):
        erow[i] += row1[i]

print(" ".join(str(s) for s in erow))

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

int main() {
  string s;
  cin >> s;
  string result = "Yes";
  if (s.size() % 2 != 0) {
    result = "No";
  } else {
    for (int i = 0; i < s.size(); ++i) {
      if (i % 2 == 0) {
        if (s[i] != 'h') {
          result = "No";
          break;
        }
      } else {
        if (s[i] != 'i') {
          result = "No";
          break;
        }
      }
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	repr(i, 1, n) {
		int t = 0;
		string a = s.substr(0, i);
		string b = s.substr(i, s.size());
		sort(all(a));
		sort(all(b));
		a.erase(unique(all(a)), a.end());
		b.erase(unique(all(b)), b.end());
		rep(j, a.size()) {
			if (b.find(a[j]) != -1) {
				t++;
			}
		}
		ans = max(t, ans);
	}

	cout << ans << endl;
	

	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> piipi;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back
char s[100005];
int main(){
    scanf("%s", s+1);
    int n = strlen(s+1), ans = 0;
    for(int i=1;i<=n;i++){
        if(i%2 == 1){
            if(s[i] == 'p') ans--;
        }
        else{
            if(s[i] == 'g') ans++;
        }
    }
    printf("%d\n", ans);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

pair<ll, ll> P[100100];
int main(){
    ll N, M;
    cin >> N >> M;
    REP(i,N){
        ll a, b;
        cin >> a >> b;
        P[i] = make_pair(a,b);
    }

    sort(P, P+N);

    ll ans = 0;
    ll m = M;
    for(int i = 0; i < N; i++){
        auto p = P[i];
        ll a = p.first;
        ll b = p.second;
        if(m > b){
            m -= b;
            ans += a*b;
        }
        else{
            ans += a*m;
            break;
        }
    }

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


Measured memory_bytes: 1792
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N, L; scanf("%d%d", &N, &L);

    vector<int> A(N+2, -1);
    for(int i=1; i<=N; i++) scanf("%d", &A[i]);

    vector<bool> visited(N+2);
    visited[0] = visited[N+1] = true;

    priority_queue< pair<ll, ll>, vector< pair<ll, ll> >, greater< pair<ll, ll> > > que;
    for(int i=1; i<=N; i++) {
        bool ok = true;
        for(int j=-1; j<=1; j+=2) ok &= A[i] > A[i+j];
        if(ok) que.emplace(0LL, (ll)i);
    }

    ll ans = 0;
    while(que.size()) {
        ll l, k; tie(l, k) = que.top(); que.pop();
        l += L - A[k];
        chmax(ans, l);
        A[k] = 0;
        for(int j=-1; j<=1; j++) {
            if(visited[k+j]) continue;
            if(A[k+j-1] < A[k+j] and A[k+j+1] < A[k+j]) {
                visited[k+j] = true;
                que.emplace(l, k+j);
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 4240
N, K, Q = map(int, input().split())
A = [int(input()) for x in range(Q)]
Ans = [K-Q]*N

for i in range(Q):
    Ans[A[i]-1] += 1

for i in range(N):
    if Ans[i] >0:
        print("Yes")
    if Ans[i] <=0:
        print("No")

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
#define MAX 2000000000
using ll = long long;
using Graph = vector<vector<int>>;
//二項係数を求める。

ll modpow(ll a, ll n, ll mod){
  ll res = 1;
  while(n>0){
    if(n&1)res = res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll comb(ll a, ll b, ll mod){//aCb(mod)
  ll ans = 1;
  for(ll i = a; i > a-b; i--){
    ans=ans*i%mod;
  }
  for(ll i = 1; i <= b; i++){
    ans=(ans*modpow(i,mod-2,mod))%mod;
  }
  return ans;
}


int main(){
  ll n,a,b; cin>>n>>a>>b;
  cout<<(modpow(2,n,MOD)-comb(n,a,MOD)-comb(n,b,MOD)-1+MOD*2)%MOD<<endl;  
  return 0;
}

Measured memory_bytes: 256
dice1 = list(map(int, input().split()))
dice2 = list(map(int, input().split()))

flag = False

# ②W方向
for _ in range(4):
    temp = dice2[0]
    dice2[0] = dice2[2]
    dice2[2] = dice2[5]
    dice2[5] = dice2[3]
    dice2[3] = temp
    # ①水平右回り
    for _ in range(4):
        temp = dice2[1]
        dice2[1] = dice2[2]
        dice2[2] = dice2[4]
        dice2[4] = dice2[3]
        dice2[3] = temp
        
        if dice2 == dice1:
            flag = True
            
# ④N方向
for _ in range(4):
    temp = dice2[0]
    dice2[0] = dice2[1]
    dice2[1] = dice2[5]
    dice2[5] = dice2[4]
    dice2[4] = temp
    # ③水平右回り
    for _ in range(4):
        temp = dice2[1]
        dice2[1] = dice2[2]
        dice2[2] = dice2[4]
        dice2[4] = dice2[3]
        dice2[3] = temp
        
        if dice2 == dice1:
            flag = True
            
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5608
def main():
  N = int(input())
  H = list(map(int, input().split()))
  ans = 0
  count = 0

  for i in range(N-1):
      if H[i] >= H[i+1]:
          count += 1
      else:
          ans = max(ans, count)
          count = 0
  ans = max(ans, count)
  print(ans)
if __name__ == '__main__':
  main()

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(c - a) <= d){
        cout << "Yes" << endl;
    }else if(abs(a - b) <= d && abs(c - b) <= d){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


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

int main() {
	int a, b;
    cin >> a >> b;
  
  if (a % 2 == 1 && b % 2 == 1) {
   cout << "Odd" << endl;
  }
  else {
   cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s);
    Cout(s[0], s[1], s[2]);
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, n) for (ll i = n-1; i >= 0; i--)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd2(i, s, n) for (ll i = n-1; i >= (s); i--)

int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll ans;
    if (x/k >= d) {
        ans = x - d*k;
    }
    else {
        ll a;
        a = x/d;
        k -= a;
        x -= a*d;
        if (k%2 == 1) x = abs(x-d);
        ans = x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
import std.stdio;
import std.ascii;
import std.string;
import std.conv;

class T {
    int value;
    T left, right;
    this(int value, T left, T right) {
        this.value = value;
        this.left = left;
        this.right = right;
    }
    override string toString() const {
        string l = (left ? left.toString : "");
        string r = (right ? right.toString : "");
        return "(" ~ l ~ ")" ~ "[" ~ value.to!string ~ "]" ~ "(" ~ r ~ ")";
    }
}

int size(string s) {
    return cast(int)(s.length);
}

int parse_int(string s, ref int n) {
    assert(isDigit(s[n]));
    int r = 0;
    while (n < s.size && isDigit(s[n])) {
        r = r * 10 + cast(int)(s[n] - '0');
        n++;
    }
    return r;
}

T parse(string s, ref int n) {
    assert(s[n] == '(');
    n++;
    if (s[n] == ')') {
        return null;
    }
    T l = parse(s, n);
    //stderr.writeln(s, " ", n, " ", s[n]);
    assert(s[n] == ')');
    n++;
    assert(s[n] == '[');
    n++;
    int value = parse_int(s, n);
    assert(s[n] == ']');
    n++;
    T r = parse(s, n);
    assert(s[n] == ')');
    n++;
    return new T(value, l, r);
}

void main() {
    auto A = "(" ~ stdin.readln.chomp ~ ")";
    auto B = "(" ~ stdin.readln.chomp ~ ")";

    T dfs(T a, T b) {
        if (a is null || b is null) return null;
        return new T(a.value + b.value, dfs(a.left, b.left), dfs(a.right, b.right));
    }

    int n = 0, m = 0;
    writeln(dfs(parse(A, n), parse(B, m)));
}

Measured memory_bytes: 2460
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
#include <set>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll a, b, c, x, y;

int main(){
  cin >> a >> b >> c >> x >> y;
  if((a + b) > c * 2) {
    if(x > y) {
      if(a > 2 * c) {
        cout << 2 * c * x << endl;
      } else {
        cout << 2 * c * y  + a * (x - y) << endl;
      }
    } else {
      if(b > 2 * c) {
        cout << 2 * c * y << endl;
      } else {
        cout << 2 * c * x + b * (y - x) << endl;
      }
    }
  } else {
    cout << x * a + y * b << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import copy
H, W, K = map(int, input().split())
C = []
for i in range(H):
    C.append(list(input()))
ans = 0
for i in range(2**H):
    for j in range(2**W):
        tmp = copy.deepcopy(C)
        for k in range(H):
            if i >> k & 1:
                for m in range(W):
                    tmp[k][m] = "r"
        for l in range(W):
            if j >> l & 1:
                for n in range(H):
                    tmp[n][l] = "r"
        cnt = 0
        for h in range(H):
            for w in range(W):
                if tmp[h][w] == "#":
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)
                


Measured memory_bytes: 76624
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    string S,T;
    cin>>S>>T;
    int ans=0;
    for(int i=0;i<S.size();i++){
        if(S[i]!=T[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3916
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
 
n = int(input())
A = [int(input()) for _ in range(n)]
cnt = 0
G = [int(pow(4, i) + 3*pow(2, i-1) + 1) for i in range(10)[::-1]] + [1]
G = [v for v in G if v <= n]
m = len(G)
for i in range(m):
    insertionSort(A, n, G[i])
print(m)
print(*G)
print(cnt)
print(*A, sep='\n')


Measured memory_bytes: 53292