akhauriyash/Code-Regression huggingface dataset:
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
//fixed<<setprecision(10)<<ans<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    if (N==1) N=inf;
    if (M==1) M=inf;
    if (N<M) cout << "Bob\n";
    else if (N>M) cout << "Alice\n";
    else cout << "Draw\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 
//なんかむずいんだけどw
// fuck
signed main(){
	int ans;
	for(int i=0; i<5 ;i++){
		int x; cin>>x;
		if(x==0) ans=i+1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3604
import java.util.*;

public class Main {
    private static Scanner scanner;

    public static int[] inputIntArray(int n) {
        int[] res = new int[n];
        for (int i = 0; i < n; ++i) {
            res[i] = scanner.nextInt();
        }

        return res;
    }

    // public static String[] <T> ToStringArray(T[] arr) {
    // String[] res = new String[arr.length];
    // for(int i = 0; i < arr.length; ++i) {
    // res[i] = String.valueOf(arr[i]);
    // }

    // return res;
    // }

    private static List<Integer> asIntergerList(int[] arr) {
        List<Integer> intList = new ArrayList<Integer>();
        for (int i = 0; i < arr.length; i++) {
            intList.add(arr[i]);
        }

        return intList;
    }

    private static int[][] deepCopy(int[][] arr) {
        int[][] res = new int[arr.length][];
        for (int i = 0; i < arr.length; ++i) {
            res[i] = arr[i].clone();
        }

        return res;
    }

    private static String asString(int[][] arr) {
        String str = new String();

        for (int i = 0; i < 2; ++i) {
            str += "" + arr[i][0] + arr[i][1] + arr[i][2] + arr[i][3];
        }

        return str;
    }

    public static void main(String[] args) {
        scanner = new Scanner(System.in);

        while (true) {
            int h, w;
            h = scanner.nextInt();
            w = scanner.nextInt();

            if (h == 0 && w == 0) {
                return;
            }

            for (int i = 0; i < h; ++i) {
                for (int j = 0; j < w; ++j) {
                    System.out.print((i + j) % 2 == 0 ? "#" : ".");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 34724
#include <iostream>
using namespace std;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 2;
  if (a == b && b == c)
    ans = 1;
  else if (a != b && b != c && c != a)
    ans = 3;
  cout << ans << endl;
  return 0;
}

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string a, b, c;
    cin >> a >> b >> c;

    // 処理
    // 出力
    cout << (a.back() == b[0] && b.back() == c[0] ? "YES" : "NO ") << endl;

    return 0;
}


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

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      Graph graph = new Graph(n);
      String[] vInfo;
      int[][] weight = new int[n][n];

      for(int i=0, j=0; i<n; i++, j=0) {
        vInfo = br.readLine().split(" ");
        for (String var : vInfo) {
          if(var.equals("")) continue;
          else weight[i][j++] = Integer.parseInt(var);
        }
        graph.setVertex(i, weight[i]);
      }

      System.out.println(graph.calcMSTWeightSum());
    }
    catch (IOException e) {
      System.err.println(e);
    }
  }


  class Graph {

    Vertex[] vertices;
    int cost;

    public Graph(int size ) {
      vertices  = new Vertex[size];
      cost = 0;
    }

    public void setVertex(int id) {
      vertices[id] = new Vertex(id);
    }
    public void setVertex(int id, int[] distance) {
      setVertex(id);
      setAjacent(id, distance);
    }
    public void setAjacent(int id, int[] distance) {
      vertices[id].distance = distance;
    }

    public int calcMSTWeightSum() {
      prim();

      return cost;
    }

    private void prim() {
      int mincost;
      int u;
      vertices[0].d = 0;
      vertices[0].p = -1;

      while( true ) {
        mincost = Integer.MAX_VALUE;
        u = -1;
        for (Vertex v : vertices) {
          if( (v.state != Vertex.BLACK) && (v.d < mincost) ) {
            u = v.id;
            mincost = v.d;
          }
        }

        if(u == -1) break;

        vertices[u].state = Vertex.BLACK;

        for (Vertex v : vertices) {
          if((v.state != Vertex.BLACK) && (v.distance[u] != -1)) {
            if( v.distance[u] < v.d ) {
              v.d = v.distance[u];
              v.p = u;
              v.state = Vertex.GRAY;
            }
          }
        }
        // System.out.println(u);
      }
      for (Vertex v: vertices) {
        if( v.p != -1 ) {
          cost += v.d;
          // System.out.println(v.id + " " + v.distance[v.p] + " " + v.d + " " + v.p);
        }

      }
    }

    class Vertex {

      static final int WHITE = 0;
      static final int GRAY  = 1;
      static final int BLACK = 2;
      int id;
      int state;
      int d;
      int p;
      int[] distance;

      public Vertex(int id) {
        this.id = id;
        state = WHITE;
        d = Integer.MAX_VALUE;
      }
    }
  }
}


Measured memory_bytes: 27532
/*
Given N probs. and M subs., return the how many ACs and WAs it received.

Array, idx as probs.

2 2

*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long; 

int main() {
    int N, M;
    
    scanf("%d%d", &N, &M);
    
    vector<int> ac(N);
    
    vector<int> wa(N);
    
    int ac_cnt = 0;
    int wa_cnt = 0;
    
    for (int i = 0; i < M; i++) {
        //char type[2];
        string type;
        int idx;
        //scanf("%d%s", &idx, type);
        cin >> idx >> type;
        idx -= 1;
        
        if (type == "WA") {
            if (ac[idx] == 0) {
                //wa_cnt += 1;    
                wa[idx] += 1;
            }
        }
        else if (ac[idx] == 0){
            ac_cnt += 1;
            ac[idx] = 1;
            wa_cnt += wa[idx];
        }
        
    }
    //cout << "tes2" << endl;
    
    printf("%d %d", ac_cnt, wa_cnt);
	
	return 0;
}

Measured memory_bytes: 1024
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_str():
    return input().strip()


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


def get_char_list():
    return list(input().strip())


# inputs
A, B, C = 0, 0, 0


def set_inputs():
    global A, B, C
    A, B, C = get_list_of_int()


def main():
    set_inputs()
    print(min(C, B // A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int n;
	cin>>n;
	while(n > 1000){
		n=n-1000;
	}
	int ans;
	ans= 1000-n;
	cout<<ans<<endl;
}

Measured memory_bytes: 3640
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, W = map(int, readline().split())

tile = [0 for i in range(H)]
cnt = [[0 for _ in range(W)] for _ in range(H)]

for i in range(H):
    tile[i] = readline().decode().strip()

for i in range(H):
    done = [False for _ in range(W)]
    for j in range(W):
        if tile[i][j] == '#':
            continue
        if done[j]:
            continue
        l = 0
        while (j + l < W):
            if tile[i][j + l] == '#':
                break
            l += 1
        for k in range(l):
            cnt[i][j + k] += l
            done[j + k] = True

for j in range(W):
    done = [False for _ in range(H)]
    for i in range(H):
        if tile[i][j] == '#':
            continue
        if done[i]:
            continue
        l = 0
        while (i + l < H):
            if tile[i + l][j] == '#':
                break
            l += 1
        for k in range(l):
            cnt[i + k][j] += l
            done[i + k] = True

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(cnt[i][j] - 1, ans)
print(ans)



Measured memory_bytes: 101336
#include <iostream>
#include <vector>
#include <utility>
#include <complex>
#include <cassert>
using namespace std;
using W = long double;
using P = complex<W>;
using Poly = vector<P>;
using L = pair<P,P>;
#define X real()
#define Y imag()
constexpr W EPS = 1e-10, pi = acos(-1);

void debug(Poly p){
  cerr << "Polygon" << endl;
  for(auto e : p) cerr << e.X << " " << e.Y << endl;
  cerr << "..." << endl;
}

void debug(L l){
  fprintf(stderr,"Segment %Lf %Lf %Lf %Lf\n",l.first.X,l.first.Y,l.second.X,l.second.Y);
}

W dot(const P &a, const P &b){ return a.X*b.X + a.Y*b.Y; }
W cross(const P &a, const P &b){ return a.X*b.Y - a.Y*b.X; }

P intersection(const L &a, const L &b){
  P af = a.first, as = a.second, bf = b.first, bs = b.second;
  return af + cross(bs-bf,af-bf)/(-cross(bs-bf,as-bf)+cross(bs-bf,af-bf))*(as-af);
}

int ccw(P a, P b, P c){
  b -= a, c -= a;
  if(cross(b,c) > +EPS) return +1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < +EPS) return +2;
  if(norm(b) + EPS < norm(c)) return -2;
  return 0;
}

Poly convex_cut(const Poly &p, const L &l){
  Poly ret;
  int n = p.size();
  for(int i = 0; i < n; ++i){
    P cur = p[i], nex = p[(i+1)%n], lf = l.first, ls = l.second;
    if(ccw(lf,ls,cur) != -1)
      ret.push_back(cur);
    if((ccw(lf,ls,cur) != -1) ^ (ccw(lf,ls,nex) != -1))
      ret.push_back(intersection(L(cur,nex),l));
  }
  return ret;
}

W area(const Poly &p){
  int n = p.size();
  W ret = 0;
  for(int i = 0; i < n; ++i){
    ret += cross(p[i],p[(i+1)%n]);
  }
  return ret/2;
}

int main(){
  int N;
  while(cin >> N, N){
    Poly pol;
    for(int i = 0; i < N; ++i){
      W x, y;
      cin >> x >> y;
      pol.emplace_back(x,y);
    }
    W ok = 0, ng = pi, S = area(pol);
    L l(P(0,0),P(10,0));
    W s = area(convex_cut(pol,l));
    if(s-(S-s) < EPS){
      ok = -pi;
      ng = 0;
    }
    for(int tmp = 0; tmp < 100; ++tmp){
      W m = (ok+ng)/2;
      l = L(P(0,0),P(10,0)*P(cos(m),sin(m)));
      s = area(convex_cut(pol,l));
      if(s-(S-s) > EPS){
        ok = m;
      }else{
        ng = m;
      }
    }
    W a = (ok+ng)/2;
    P A = P(10*cos(a),10*sin(a));
    s = area(convex_cut(pol,L(P(0,0),A)));
    assert(abs(s-(S-s)) <= 1e-5);
    //fprintf(stderr,"%.12Lf : %.12Lf\n",s,S-s);
    printf("%.15Lf %.15Lf\n",A.X,A.Y);
  }
}



Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  int ans = 1;
  int d = 0;
  for (int i = 0; i < n; i++) {
    d += l[i];
    if (d > x) {
      break;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
ll A[3], K;
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>A[0]>>A[1]>>A[2]>>K;

    sort(A, A+3);

    REP(i,0,K){
        A[2] *= 2;
    }

    ll ans = A[0] + A[1] + A[2];

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 62;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,K;
    cin >>N>>K;
    vector<ll>X(N);
    vector<ll>Y(N);
    rep(i,N){
        cin>>X[i]>>Y[i];
    }
    ll ans=INF;
    if(K==2){
        rep(i,N){
            rep3(j,i+1,N){
                ll X1=min({X[i],X[j]});
                ll X2=max({X[i],X[j]});
                ll Y1=min({Y[i],Y[j]});
                ll Y2=max({Y[i],Y[j]});
                chmin(ans,(X2-X1)*(Y2-Y1));
                        
            }
        }
    }else if(K==3){
        rep(i,N){
            rep3(j,i+1,N){
                rep3(k,j+1,N){

                    ll X1=min({X[i],X[j],X[k]});
                    ll X2=max({X[i],X[j],X[k]});
                    ll Y1=min({Y[i],Y[j],Y[k]});
                    ll Y2=max({Y[i],Y[j],Y[k]});

                    chmin(ans,(X2-X1)*(Y2-Y1));
                        
                    
                }
            }
        }
    }else{
        rep(i,N){
            rep3(j,i+1,N){
                rep3(k,j+1,N){
                    rep3(m,k+1,N){
                        ll X1=min({X[i],X[j],X[k],X[m]});
                        ll X2=max({X[i],X[j],X[k],X[m]});
                        ll Y1=min({Y[i],Y[j],Y[k],Y[m]});
                        ll Y2=max({Y[i],Y[j],Y[k],Y[m]});
                        ll cnt=0;
                        rep(n,N){
                            if(X[n]>=X1&&X[n]<=X2){
                                if(Y[n]>=Y1&&Y[n]<=Y2){
                                    cnt++;
                                }
                            }
                        }
                        //cout<<cnt<<endl;
                        if(cnt>=K){
                            chmin(ans,(X2-X1)*(Y2-Y1));
                        }
                    }
                }
            }
        }
    }
    
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3600
#!/usr/bin/env python3
from math import sqrt
# ??????
def cross(P0, P1, P2):
    x0, y0 = P0; x1, y1 = P1; x2, y2 = P2
    x1 -= x0; x2 -= x0
    y1 -= y0; y2 -= y0
    return x1*y2 - x2*y1
# ??????
def dot(P0, P1, P2):
    x0, y0 = P0; x1, y1 = P1; x2, y2 = P2
    x1 -= x0; x2 -= x0
    y1 -= y0; y2 -= y0
    return x1*x2 + y1*y2
# 2??????????????¢?????????
def dist2(P0, P1):
    x0, y0 = P0; x1, y1 = P1
    return (x1 - x0)**2 + (y1 - y0)**2
# ????????????????????????
def collision(S0, S1, T0, T1):
    return cross(S0, S1, T0)*cross(S0, S1, T1) < 0 and cross(T0, T1, S0) * cross(T0, T1, S1) < 0
# ????????¨?????????????????¢
def dist_lp(S, E, P):
    dd = dist2(S, E)
    # ???????????????P?????????????????????????¢???? => 0<=sqrt(dist(S, P))*cos??<=sqrt(dist(S, E))
    if 0 <= dot(S, E, P) <= dd:
        # ???????????°???????????????????????????????°? => sqrt(dist(S, P))*sin??
        return abs(cross(S, E, P))/sqrt(dd)
    # ?????????????????°???S??¨E???????????????????????????????????¢???????°?
    return sqrt(min(dist2(S, P), dist2(E, P)))
# ????????¨????????????????????¢
def dist_ll(S0, S1, T0, T1):
    if collision(S0, S1, T0, T1):
        return 0
    return min(
            dist_lp(S0, S1, T0),
            dist_lp(S0, S1, T1),
            dist_lp(T0, T1, S0),
            dist_lp(T0, T1, S1)
            )
# ????§???¢?????¨??????????????????
def contain(PS, A):
    l = len(PS)
    base = cross(PS[-1], PS[0], A)
    for i in range(l-1):
        P0 = PS[i]; P1 = PS[i+1]
        if base * cross(PS[i], PS[i+1], A) < 0:
            return 0
    return 1

c = 0
while 1:
    c += 1
    n = int(input())
    if n == 0:
        break
    sx, sy, ex, ey = map(int, input().split())
    S = sx, sy; E = ex, ey
    cannot = 0
    ans = 10**9
    for i in range(n):
        minx, miny, maxx, maxy, h = map(int, input().split())
        PS = ((minx, miny), (minx, maxy), (maxx, maxy), (maxx, miny))
        cannot |= contain(PS, S) or contain(PS, E)
        for j in range(4):
            cannot |= collision(PS[j-1], PS[j], S, E)
            d = dist_ll(S, E, PS[j-1], PS[j])
            ans = min(ans, (h**2+d**2)/(2*h) if h <= d else d)
    if cannot:
        print(0)
    else:
        print("%.08f" % ans)

Measured memory_bytes: 7852
def prepare(m, mod=10 ** 9 + 7):
	fac = [1] * (m + 1)
	inv = [1] * (m + 1)
	for i in range(1, m + 1):
		fac[i] = fac[i - 1] * i % mod
	inv[-1] = pow(fac[-1], mod - 2, mod)
	for i in range(m - 1, -1, -1):
		inv[i] = inv[i + 1] * (i + 1) % mod
	return fac, inv

def main():
	n, k, *L = map(int, open(0).read().split())
	mod = 10 ** 9 + 7
	fac, inv = prepare(k)
	con = [[] for _ in range(n)]
	cnt = [0] * n
	vis = [False] * n
	for s, t in zip(*[iter(L)] * 2):
		con[s - 1] += [t - 1]
		con[t - 1] += [s - 1]
		cnt[s - 1] += 1
		cnt[t - 1] += 1
	if any(c + 1 > k for c in cnt):
		print(0)
		exit()
	q = [0]
	vis[0] = True
	ans = fac[k] * inv[k - cnt[0] - 1] % mod
	while q:
		cur = q.pop()
		for nxt in con[cur]:
			if vis[nxt]:
				continue
			ans *= fac[k - 2] * inv[k - cnt[nxt] - 1] % mod
			ans %= mod
			vis[nxt] = True
			q.append(nxt)
	print(ans)

if __name__ == "__main__":
	main()

Measured memory_bytes: 40140
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,r,p,c,i,j,a[51],b[51];
	while(1)	{
		scanf("%d %d",&n,&r);
		if(n==0 && r==0)	break;
		for(i=1;i<=n;i++)	{
			a[i]=n-i+1;
		}
		for(j=0;j<r;j++)	{
		
		//	for(i=1;i<=n;i++)	printf(" %d\n",a[i]);
		
			scanf("%d %d",&p,&c);
			for(i=1;i<=c;i++)	{
				b[i]=a[i+p-1];
			}
			for(i=c+1;i<c+p;i++)	{
				b[i]=a[i-c];
			}
			for(i=c+p;i<=n;i++)	{
				b[i]=a[i];
			}
			for(i=1;i<=n;i++)	{
				a[i]=b[i];
			}
		}
		printf("%d\n",a[1]);
	}
	return 0;
}


Measured memory_bytes: 1028
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>

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

using namespace std;

typedef pair<int, int> P;

int main(){
	int n, m;
	while(cin >> n >> m, n|m){
		int least = m;
		int num = 0, d = 10000, cnt = 0;
		rep(i, n){
			int x;
			cin >> x;

			if((least/x+1)*x <= m){ // safe
				continue;
			}else{
				if(least == least/x*x){ // eq
					if(d > x){
						num = i;
						d = x;
						cnt = 1;
					}else if(d == x){
						cnt++;
					}
				}else{ // under
					least = least/x*x;
					num = i;
					d = x;
					cnt = 1;
				}
			}
		}
		if(cnt > 1){
			cout << n << endl;
		}else{
			cout << num+1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll w[100005];
ll s[100005];
ll ans = 0;
ll mxw,n;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>mxw;
    ll sum =  0 ;
    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>s[i];
        sum+=s[i];
    }
    vector<ll>dp(sum+1,1e9);

    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j = sum-s[i]; j>=0;j--)
        {
            dp[j+s[i]] = min(dp[j+s[i]],dp[j]+w[i]);
        }
    }
    for(ll i=0;i<=sum;i++)
    {
        if(dp[i]<=mxw)
            ans = max(ans,i);
    }
    cout<<ans<<endl;

}


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

int main(){
int W,H, x,y,r;
cin>>W>>H>>x>>y>>r;
if(x-r>=0 && y-r>=0 && x+r<=W && y+r<=H){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;
int dy[4] = { 1, 0, -1, 0 }, dx[4] = { 0, 1, 0, -1 };
const ll MOD = 1e9 + 7;
const ll INF = 1e9;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) { cin >> p[i];}
  int cnt = 0;
  for (int i = 1; i < n - 1; i++) {
    if ((p[i-1] <= p[i] && p[i] < p[i+1]) ||  (p[i+1] <= p[i] && p[i] < p[i-1])) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using vs = vector<string>;
using pint = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

    vi p(n);
    rep(i, n) {
        cin >> p[i];
    }

    int cnt = 0;
    rep(i, n) {
        if(i+1 != p[i]) cnt++;
    }

    if(cnt == 2 || cnt == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll saiki(ll H){
  if(H == 1) return 1;
  return 2 * saiki(H / 2) + 1;
}

void solve(){
  ll H;
  cin >> H;
  cout << saiki(H) << endl;
}


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


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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 dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};


int main() {
    cout<<fixed<<setprecision(10);


    ll x,n; cin>>x>>n;
    vint p(n); rep(i,n) cin>>p[i];

    ll ans = 0;
    ll div = LLONG_MAX;

    set<ll> s;
    for(auto e:p) s.insert(e);

    for(ll i=200; i>=-200; i--){
        if(s.count(i)) continue;
        if(abs(i-x) <= div){
            div = abs(i-x);
            ans = i;
        }
    }

    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 3604
import math

a,b,h,m = map(int,input().split())
short_kakudo = 0.5 * (60*h + m)
long_kakudo = 6 * m
s = abs(short_kakudo - long_kakudo)

c = (a**2 + b**2 - 2*a*b*math.cos(math.radians(s)))**0.5

print(abs(c))

Measured memory_bytes: 9508
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <math.h>
#include <string>
#include <stack>
#include <stdlib.h>
#include <iomanip>
#include <queue>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define mset(a, b) memset(a, b, sizeof(a))
#define LL long long
#define P pair<int, int>
#define PLL pair<LL, LL>
const int MAX = 1e5 + 5;
const int inf = 0x3f3f3f3f;
using namespace std;

int main()
{
    stack<int> s;
    int n, cnt = 0;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    rep(i, 0, n){
        if(s.empty())
        {
            s.push(a[i]);
            continue;
        }
        while(a[i] < s.top()){
            int t = s.top();
            s.pop();
            if(s.empty()){
                cnt += t - a[i];
                break;
            }
            cnt += t - max(s.top(), a[i]);
        }
        s.push(a[i]);
    }
    while(1){
        int t = s.top();
        s.pop();
        if(s.empty()) {
            cnt += t;
            break;
        }
        cnt += t - s.top();
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n;
    cin>>n;
    map<int,int> mp;
    int tmp;
    REP(i,n){
        cin>>tmp;
        mp[tmp]++;
        if(mp[tmp]>1){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;

    return 0;
}


Measured memory_bytes: 9600
#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;
	vi h(n);
	vi a(n, 0);
	rep(i, n) cin >> h[i];

	int ans = 0;
	
	while (true) {
		bool b =true;
		int t = 0;
		rep(i, n) {
			if (h[i] != 0) {
				b = false;
				t = i;
				break;
			}
		}
		if (b) {
			break;
		}
		bool f = true;
		repr(i, t, n) {
			if (h[i] > 0) {
				h[i]--;
			}
			else {
				ans++;
				f = false;
				break;
			}
		}
		if (f) {
			ans++;
		}

	}

	cout << ans << endl;

	return 0;
}



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

int main() {
  int t;
  cin >> t;
  while (t--){
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    vector<int> dis(n - 1);
    long long sum = 0;
    for (int i = 0; i < n - 1; i++) {
      dis[i] = x[i + 1] - x[i];
      sum += dis[i];
    }
    sort(dis.begin(), dis.end(), greater<int>());
    
    for (int i = 1; i < min(k, n); i++) {
      sum -= dis[i - 1];
    }
    cout << sum << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> o_tree;



void solve()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll nor=0;
    ll i;
    for(i=0;i<n;i++)
    {
        nor+=(s[i]=='R');
    }
    ll res=0;
    for(i=0;i<nor;i++)
    {
        if(s[i]=='W')
        {
           res++;
        }
    }
    cout<<res<<"\n";
    
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cout << setprecision(20);

    ll t = 1;

    // cin>>t;

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

    return 0;
}

Measured memory_bytes: 3760
#include<stdio.h>
int main()
{
    int a,b;
    for(a=1;a<10;a++)
    {
        for(b=1;b<10;b++)
        {
            printf("%d",a);
            printf("x");
            printf("%d",b);
            printf("=");
            printf("%d\n",a*b);
        }
    }
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
#include <cassert>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef long double D;
typedef complex<D> P;
typedef pair<P,P> L;
typedef vector<P> Pol;
D eps=1e-11,Eps=1e-9;
D cro(P a,P b){return imag(conj(a)*b);}
int ccw(P a,P b,P c){
	if(cro(b-a,c-a)>eps) return 1;
	if(cro(b-a,c-a)<-eps) return -1;
	if(abs(abs(a-c)+abs(c-b)-abs(a-b))<eps) return 0;
	if(abs(abs(a-b)+abs(c-b)-abs(a-c))<eps) return -2;
	return 2;
}
bool iLS(L l,L s){
	if(abs(cro(l.fs-l.sc,s.fs-s.sc))<eps) return 0;
	return cro(l.sc-l.fs,s.fs-l.fs)*cro(l.sc-l.fs,s.sc-l.fs)<eps;
}
P intLL(L a,L b){
	D t=cro(a.sc-a.fs,a.sc-b.fs)/cro(a.sc-a.fs,b.sc-b.fs);
	return b.fs+t*(b.sc-b.fs);
}
int M,N;
Pol a,b;
D rec(D x){
	L l=L(P(x,0),P(x,1));
	Pol inters;
	rep(j,M){
		L e=L(a[j],a[(j+1)%M]);
		if(iLS(l,e)) inters.pb(intLL(l,e));
	}
	if(inters.size()<=1) return -1;
	D leny=0;
	for(P p:inters) for(P q:inters) leny=max(leny,abs(p-q));
	inters.clear();
	rep(j,N){
		L e=L(b[j],b[(j+1)%N]);
		if(iLS(l,e)) inters.pb(intLL(l,e));
	}
	if(inters.size()<=1) return -1;
	D lenz=0;
	for(P p:inters) for(P q:inters) lenz=max(lenz,abs(p-q));
	return leny*lenz;
}
int main(){
	while(true){
		cin>>M>>N;
		if(M==0) break;
		a.clear(),b.clear();
		vector<D> xs;
		D ans=0;
		rep(i,M){
			D x,y;
			cin>>x>>y;
			a.pb(P(x,y));
			xs.pb(x-Eps);
			xs.pb(x+Eps);
		}
		rep(i,N){
			D x,y;
			cin>>x>>y;
			b.pb(P(x,y));
			xs.pb(x-Eps);
			xs.pb(x+Eps);
		}
		sort(all(xs));
		rep(i,xs.size()-1){
			if(rec(xs[i])<-eps||rec(xs[i])<-eps) continue;
			ans+=(xs[i+1]-xs[i])/6.0*(rec(xs[i])+4.0*rec((xs[i+1]+xs[i])/2)+rec(xs[i+1]));
		}
		printf("%.4f\n",(double)ans);
	}
}

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

using namespace std;

int c[10][10];

int main()
{
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			cin >> c[i][j];
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			for (int k = 0; k < 10; k++)
				c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
	int r = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int a;
			cin >> a;
			r += a < 0 ? 0 : c[a][1];
		}
	}
	cout << r << endl;
	return 0;
}


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

int main()
{
	ll n, k; cin >> n >> k;

	vector<ll> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	sort(h.begin(), h.end(),greater<ll>());

	ll ans = 0;
	if (n <= k) {
		cout << 0 << endl;
	}
	else {
		for (int i = k; i < n; i++) {
			ans += h[i];
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1792
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my ($h, $w) = split / /, <STDIN>);
my (@s, @que);
for my $i (1..$h) {
  chomp (my $in = <STDIN>);
  my @b = split //, $in;
  for my $j (1..$w) {
    if ($b[$j-1] eq '#') {
      $s[$i][$j] = -1;
    }
  }
}
push @que, 1;
push @que, 1;
$s[1][1] = 0;
while (@que) {
  my ($i, $j);
  $i = shift @que;
  $j = shift @que;
  my $cnt = $s[$i][$j];
  if ($s[$i+1][$j] == -1) {
    if ($s[$i][$j+1] == -1 || $s[$i+1][$j-1] == -1) {
      say 'Impossible';
      exit;
    }
    $s[$i+1][$j] = $cnt + 1;
    push @que, $i+1;
    push @que, $j;
  }
  if ($s[$i][$j+1] == -1) {
    if ($s[$i+1][$j] == -1 || $s[$i-1][$j+1] == -1) {
      say 'Impossible';
      exit;
    }
    $s[$i][$j+1] = $cnt + 1;
    push @que, $i;
    push @que, $j+1;
  }
}
say 'Possible' if $s[$h][$w]>=0;
say 'Impossible' unless $s[$h][$w]>=0;

Measured memory_bytes: 896
import math
N=int(input())
n=int(math.sqrt(N))
a=0
b=0
if n<10:
  for i in range(1,n+1):
    if N%i==0:
      a=i
      b=N//i
      if b<10:
        print('Yes')
        exit()
else:
  for i in range(1,10):
    if N%i==0:
      a=i
      b=N//i
      if b<10:
        print('Yes')
        exit()
print('No')

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

int main (){
  string a;
  cin >> a;
  int N=a.size();
  string M1,M2;
  for (int i=0;i<(N-1)/2;i++){
    M1.push_back(a.at(i));
    M2.push_back(a.at(i+1+(N-1)/2));
  }
  int abc = 1;
  for ( int i=0;i<(N-1)/2;i++){
    if ((M1.at(i)==M1.at((N-1)/2-1-i)) && (M2.at(i)==M2.at((N-1)/2-1-i)) &&(M1.at(i)==M2.at((N-1)/2-1-i)) && M1.at((N-1)/2-1-i) == M2.at(i)){
    }
    else{
      abc = 0;
    }
  }
  if (abc ==1 ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No " << endl;
  }
}

Measured memory_bytes: 256
def relu(num):
    if num < 0: num = 0
    return num

S = str(input())
S_len = len(S)
ans = 0
for i in range(S_len):
    for j in range(i, S_len):
        part_num = int(S[i:j+1])
        ans += part_num * 2 ** relu(i-1) * 2 ** relu(S_len - j - 2)
print(ans)

Measured memory_bytes: 3060
import sys

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    bulbs = []
    for _ in range(M):
        b = tuple(map(int, input().split()))
        bulbs.append(b[1:])

    P = list(map(int, input().split()))

    ans = 0
    for switch in range(2**N):
        check = [0] * M
        for i, bulb in enumerate(bulbs):
            cnt = 0
            for b in bulb:
                if switch >> (b - 1) & 1:
                    cnt += 1

            if cnt % 2 == P[i]:
                check[i] = True
            else:
                check[i] = False

        if all(check):
            ans += 1

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e17;

struct edge{ll from; ll to; ll cost;};

bool comp(const edge& e1, const edge& e2){
    return e1.cost<e2.cost;
}

//Union-Find Tree

int par[100001];
int rnk[100001];
int size[100001];
int N;
edge es[1000001];

void shoki(){
    for(int i=0;i<=N;i++) {par[i]=i; rnk[i]=0; size[i]=1;}
}

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

void con(int A,int B){
    A=sch(A);
    B=sch(B);
    if(A==B) return;
    if(rnk[A]>rnk[B]) swap(A,B);
    par[A]=B;
    size[B]+=size[A];
    size[A]=size[B];
    if(rnk[A]==rnk[B]) rnk[B]++;

    return;
}

int is_size(int k){
    return size[sch(k)];
}

bool same(int A,int B){
    return sch(A)==sch(B);
}


int main(){
    cin>>N;
    shoki();
    vector<pair<int,int>> X,Y;
    for(int i=0;i<N;i++){
        ll x,y;
        cin>>x>>y;
        X.push_back(make_pair(x,i));
        Y.push_back(make_pair(y,i));
    }

    sort(X.begin(),X.end());
    sort(Y.begin(),Y.end());

    for(int i=0;i<N-1;i++){
        es[i].from=X.at(i).second;
        es[i].to=X.at(i+1).second;
        es[i].cost=X.at(i+1).first-X.at(i).first;
    }

    for(int i=0;i<N-1;i++){
        es[i+N-1].from=Y.at(i).second;
        es[i+N-1].to=Y.at(i+1).second;
        es[i+N-1].cost=Y.at(i+1).first-Y.at(i).first;
    }
    int E=2*N-2;
    sort(es,es+E,comp);
    ll ans=0;
    for(int i=0;i<E;i++){
        edge e=es[i];
        
        if(!same(e.from,e.to)){
            con(e.from,e.to);
            ans+=e.cost;
        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 10348
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

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

    int high = 0;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        if (x == y) {
            cnt++;
            high = max(high, cnt);
        } else {
            cnt = 0;
        }
    }

    cout << (high >= 3 ? "Yes" : "No") << endl;
    return 0;
}


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

template <class T, class seq_t = std::vector<T>>
class Z_algorithm
{
    seq_t key;
    const size_t len;
    std::vector<size_t> z;
  public:
    Z_algorithm(const seq_t &_key) : key(_key), len(_key.size()), z(len)
    {
        assert(len);
        for(size_t i{1}, j{0}; i != len; ++i)
        {
            if(z[i - j] + i < z[j] + j)
            {
                z[i] = z[i - j];
            }
            else
            {
                size_t k{z[j] + j > i ? z[j] + j - i : 0};
                while(k + i < len && key[k] == key[k + i]) ++k;
                z[i] = k;
                j = i;
            }
        }
        z.front() = len;
    }

    size_t size() const { return z.size(); }
    size_t operator[](size_t i) const { return z[i]; }

    std::vector<size_t> pattern_search(const seq_t &str) const
    {
        seq_t tmp(key);
        tmp.insert(end(tmp), begin(str), end(str));
        Z_algorithm other(tmp);
        std::vector<size_t> res(other.z.begin() + len, other.z.end());
        for(size_t &x : res) if(x > len) x = len;
        return res;
    }
};

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

    int n; cin>>n;
    vector<int> a(n),b(n);
    for(int i=0; i<n; ++i)
    {
        cin>>a[i];
    }
    for(int i=0; i<n; ++i)
    {
        cin>>b[i];
    }
    vector<int> aa(n*2),bb(n);
    for(int i=0; i<n; ++i)
    {
        bb[i]=b[i]^b[(i+1)%n];
    }
    for(int i=0; i<n*2; ++i)
    {
        int ii=i%n;
        aa[i]=a[ii]^a[(ii+1)%n];
    }

    Z_algorithm<int> z(bb);
    
    auto pref(z.pattern_search(aa));

    for(int k=0; k<n; ++k)
    {
        if(pref[k]==bb.size())
        {
            cout << k << " " << (b[0]^a[k]) << "\n";
        }
    }
}

Measured memory_bytes: 19056
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll ant[5]; REP(i, 5)ant[i] = in();
    ll k = in();
    ll cnt = 0;
    REP(i, 5) {
        for (ll j = i + 1; j < 5; ++j) {
            if (ant[j] - ant[i] > k)++cnt;
        }
    }
    cout << (cnt == 0 ? "Yay!" : ":(") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W;
  cin>>H>>W;
  vector<string> S(H);
  for(int i=0;i<H;++i) cin>>S[i];
  int num;
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      if(S[i][j]=='#') continue;
      num = 0;
      if(i>0 && S[i-1][j]=='#') num++;
      if(j>0 && S[i][j-1]=='#') num++;
      if(i>0 && j>0 && S[i-1][j-1]=='#') num++;
      if(i>0 && j<W-1 && S[i-1][j+1]=='#') num++;
      if(i<H-1 && S[i+1][j]=='#') num++;
      if(i<H-1 && j>0 && S[i+1][j-1]=='#') num++;
      if(i<H-1 && j<W-1 && S[i+1][j+1]=='#') num++;
      if(j<W-1 && S[i][j+1]=='#') num++;
      S[i][j] = num+'0';
    }
  }
  for(int i=0;i<H;++i) cout<<S[i]<<endl;
}


Measured memory_bytes: 3608