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

public class Main {
  public static void swap(int[] array, int x, int y) {
    int temp = array[x];
    array[x] = array[y];
    array[y] = temp;
  }

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    sc.useDelimiter("[\\s,]");

    int w = sc.nextInt();
    int n = sc.nextInt();

    int[] order = new int[w];
    for(int i = 0; i < w; i++) {
      order[i] = i + 1;
    }

    for(int i = 0; i < n; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      swap(order, a - 1, b - 1);
    }

    for(int i = 0; i < w; i++) {
      System.out.println(order[i]);
    }
  }
}

Measured memory_bytes: 26432
#include "atcoder/all"
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using namespace atcoder;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) fixed << setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  ll ans = (S.size() * (S.size() + 1)) / 2;
  AUTO(a, lcp_array(S, suffix_array(S))) { ans -= a; }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 15636
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;

int n, a[3], ans = 3000;
vector<int> l(8);
void calc(vector<int> v) {
    int b[3] = {0}, fus[3] = {0};
    rep(i, 3) rep(j, n) {
        if (v[j] == i) {
            b[i] += l[j];
            fus[i]++;
        }
    }
    int cnt = 0;
    rep(i, 3) if (fus[i] == 0) return;
    rep(i, 3) if (fus[i]) cnt += (fus[i] - 1) * 10;
    rep(i, 3) cnt += abs(b[i] - a[i]);
    ans = min(ans, cnt);
    //cout << ans << endl;
}
void dfs(int depth, vector<int> v) {
    /*
    rep(i, n) cout << v[i] << " ";
    cout << endl;
    */
    if (depth == n) {
        calc(v);
        return;
    }
    rep(i, 4) {
        v[depth] = i;
        dfs(depth + 1, v);
        
    }
}
int main() {
    cin >> n;
    rep(i, 3) cin >> a[i];
    rep(i, n) cin >> l[i];
    vector<int> v(n);
    rep(i, n) v[i] = -1;
    dfs(0, v);
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, P, ans = 1;
    cin >> N >> P;
    map<int64_t, int64_t> A;

    for (int64_t i = 2; i * i <= P; i++) {
        if (P % i == 0) {
            while (P % i == 0) {
                A[i]++;
                P /= i;
            }
        }
    }
    A[P]++;
    for (auto x: A){
        ans *= pow(x.first, x.second / N);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#define LL long long
#define maxn 100005

using namespace std;

int pre[maxn],n,m,cnt;

struct edge
{
    int u,v,nex;
}e[maxn<<1];

void addedge(int u,int v)
{
    e[cnt].u=u; e[cnt].v=v; e[cnt].nex=pre[u];
    pre[u]=cnt++;
}

queue<int> q;
bool vis[maxn];

void bfs(int u)
{
    while (!q.empty()) q.pop();
    q.push(u);
    vis[u]=1;
    while (!q.empty())
    {
        int u=q.front(); q.pop();
        for (int i=pre[u];~i;i=e[i].nex)
        {
            int v=e[i].v;
            if (vis[v]) continue;
            q.push(v);
            vis[v]=1;
        }
    }
    return ;
}

int main()
{
    memset(pre,-1,sizeof(pre));
    scanf("%d%d",&n,&m);
    for (int i=0;i<m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        addedge(u,v); addedge(v,u);
    }
    int ans=0;
    for (int i=1;i<=n;i++) if (!vis[i])
    {
        bfs(i);
        ans++;
    }
    printf("%d\n",ans-1);
    return 0;
}


Measured memory_bytes: 6136
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n, k = LI()
    a = LI_()
    ab = a[::1]
    a[0] = a[0] % k
    for i in range(n - 1):
        a[i + 1] = (a[i] + a[i + 1]) % k
    ans = 0
    q = deque([0])
    d = defaultdict(int)
    d[0] += 1
    for x, i in enumerate(a):
        q.append(i)
        if len(q) == k+1:
            x = q.popleft()
            d[x] -= 1
        ans += d[i]
        d[i] += 1
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()

Measured memory_bytes: 103160
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

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

    int H = scanner.nextInt();
    int W = scanner.nextInt();
    char[][] map = new char[H][W];
    for (int i = 0; i < H; i++) map[i] = scanner.next().toCharArray();

    int[][] level = new int[H][W];
    Queue<Cell> queue = new LinkedList<>();
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (map[i][j] == '#') {
          queue.add(new Cell(i, j, 0));
        }
      }
    }
    int max = 0;
    while (!queue.isEmpty()) {
      Cell c = queue.remove();
      max = Math.max(max, c.depth);
      for (int[] df : new int[][]{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}) {
        int x = c.x + df[0];
        int y = c.y + df[1];
        if (x >= 0 && x < H && y >= 0 && y < W && map[x][y] == '.') {
          map[x][y] = '#';
          queue.add(new Cell(x, y, c.depth + 1));
        }
      }
    }
    System.out.println(max);
  }

  private static class Cell {
    private final int x;
    private final int y;
    private final int depth;

    private Cell(int x, int y, int depth) {
      this.x = x;
      this.y = y;
      this.depth = depth;
    }
  }
}


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


void solve(long long N, std::vector<std::string> S){
    map<string,int> g;
    int maxs = -1;
    for(auto s:S)
    {
        g[s]++;
        maxs = max(g[s],maxs);
    }
    vector<string> res;
    for(auto p:g)
    {
        if(p.second == maxs)res.push_back(p.first);
    }
    sort(res.begin(),res.end());
    for(auto s:res)cout<<s<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 28404
#include <bits/stdc++.h>
using namespace std;
int main(){
	int i,a[10001],b[10001];
	char op[10001];
	for(i=1;op[i-1]!='?';i++) cin>>a[i]>>op[i]>>b[i];
	i--;
	for(int j=1;j<i;j++){
		if(op[j]=='+') cout<<a[j]+b[j]<<endl;
		if(op[j]=='-') cout<<a[j]-b[j]<<endl;
		if(op[j]=='*') cout<<a[j]*b[j]<<endl;
		if(op[j]=='/') cout<<a[j]/b[j]<<endl;
	}
	return 0;
}



Measured memory_bytes: 3120
#pragma GCC optimize("O3")
#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;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    string s; cin>>s;

    int right = 0;
    ll ans = 1;
    for(auto c : s){
        if(c == 'B'){
            if(right % 2){
                (ans *= right) %= MOD;
                right--;
            }
            else{
                right++;
            }
        }
        else{
            if(right % 2){
                right++;
            }
            else{
                (ans *= right) %= MOD;
                right--;
            }
        }

        if(right < 0) break;
    }

    if(right != 0){
        cout << 0 << endl;
        return 0;
    }

    for(int i=1; i<=n; i++){
        (ans *= i) %= MOD;
    }

    cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    ll N, M;
    cin >> N >> M;
    if(N == 1 && M == 1) cout << 1 << endl;
    else if(N == 1) cout << M - 2 << endl;
    else if(M == 1) cout << N - 2 << endl;
    else cout << (N - 2)*(M-2) << endl;

}

Measured memory_bytes: 256
n,k=map(int,input().split())
ans=[0]*(10**5+1)
for i in range(n):
    a,b=map(int,input().split())
    ans[a]+=b
    
v=0
for i in range(k):
    v+=ans[i]
    if ans[i]==0:
        i-=1
    if v>=k:
        a=i
        break
    
print(a)

Measured memory_bytes: 11732
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element




signed main()
{
	string S;
	cin >> S;

	int half = S.length()/2;

	int ans = 0;
	for (int i = 0; i < half; i++)
	{
		if (S[i] != S[S.length() - i - 1])
		{
			ans++;
		}
	}
	cout << ans << endl;
}




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

int main(){
  int S,h,m,s,x;
  cin >> S;
  h=S/3600;
  x=S%3600;
  m=x/60;
  s=x%60;
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, ans = 0; cin >> n;
  for(long long i = 1; i <= n; ++i) for(long long j = 1; i*j <= n; ++j) ans += i*j;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
char s[maxn];
int f(int x){
//	cout<<"CALL: " << x << endl;
	if(x==0)return 0;
	int k = __builtin_popcount(x);
	return f(x%k)+1;
}
int main()
{
	int n;cin>>n;
	scanf("%s",s+1);
	int cnt = 0;
	for(int i=1;i<=n;i++){
		if(s[i]=='1')cnt++;
	}
	int a = cnt-1,b = cnt+1;
	if(a<=0)a = 1e9;
	int ma = 0,mb = 0;
	for(int i=1;i<=n;i++){
		ma = (ma*2+s[i]-'0')%a;
		mb = (mb*2+s[i]-'0')%b;
//		sum = sum*2 + s[i]-'0';
	}
//	cout << sum << endl;
//	cout << a << " " << ma << endl;
//	cout << b << " " << mb << endl;
	int ca = 1,cb = 1;
	stack<int> ans;
	for(int i=n;i;i--){
		if(s[i]=='1'){
			if(cnt==1){
				ans.push(0);//cout << 0 << endl;
			}
			else{
				ans.push(f((ma-ca+a)%a)+1);//cout << f((ma-ca+a)%a) << endl;
			}
		}
		else{
			ans.push(f((mb+cb)%b)+1);//cout << f((mb+cb)%b) << endl;
		}
		ca = ca*2%a;
		cb = cb*2%b;
//		cout << n-i+1 << " "<< ca << " " << cb << endl;
	}
	while(!ans.empty()){
		cout << ans.top() << endl;
		ans.pop();
	}
	return 0;
}


Measured memory_bytes: 4700
use std::io::*;
use std::cmp;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec_char() -> Vec<char> {
    read::<String>().chars().collect()
}

fn main() {
    let s = read_vec_char();
    let l = s.len();
    let mut m0 = l;
    let mut m1 = l;
    for i in 0..l {
        if s[i] == '1' {
            m1 = cmp::min(m1,cmp::max(i,l-i-1));
        } else {
            m0 = cmp::min(m0,cmp::max(i,l-i-1));
        }
    }
    println!("{}",cmp::max(m0,m1));
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;

int main(){
  string s;cin>>s;
  ll cnt=0;
  for(int i=0;i<s.size();i++)cnt+=(s[i]=='o');
  if(cnt+15-s.size()>=8)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int H,W,i,j; 
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0) break;
    else{
      for(i=0;i<H;i++){
	for(j=0;j<W;j++){
	  printf("#");
	}
	printf("\n");
      } 
    }   printf("\n");
  }
  return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#include <queue>
#define INF LONG_MAX
typedef long long ll;
struct edge{ll to, cost;};
typedef pair<ll,PLL> State;

struct graph{
  ll V;
  VVI G;
  VVLL d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V,VLL(3,INF));
  }

  void add_edge(ll s, ll t){
    G[s].push_back(t);
  }

  void dijkstra(ll s){
    d[s][0] = 0;
    priority_queue<State,vector<State>, greater<State> > que;
    que.push(State(0,{0,s}));
    while(!que.empty()){
      State p = que.top(); que.pop();
      ll cnode = p.second.second;
      ll cdist = p.first;
      ll cc = p.second.first;
      if(d[cnode][cc]< cdist) continue;
      ll cost = 0;
      if(cc == 0) cost = 1;
      for(int to : G[cnode]){
        if(d[to][(cc+1)%3] > cdist + cost){
          d[to][(cc+1)%3] = cdist + cost;
          que.push(State(cdist+cost,{(cc+1)%3,to}));
        }
      }
    }
  }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin >> n >> m;
  graph g(n);
  rep(i,m){
    int to,from;
    cin >> to >> from;
    to--,from--;
    g.add_edge(to,from);
  }
  ll s,t;
  cin >> s >> t;
  s--,t--;
  g.dijkstra(s);
  if(g.d[t][0] == INF) cout << -1 << endl;
  else cout << g.d[t][0] << endl;
  return 0;
}


Measured memory_bytes: 11264
m=10**9+7
i=s=r=f=1
a=open(0).read().split()
for x in a[1:]:r+=int(x)*~-s+int(a[-i])*s;f=f*i%m;i+=1;s+=pow(i,m-2,m)
print(~-r*f%m)

Measured memory_bytes: 70824
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }

    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }

}

fn list_all(v: &mut Vec<bool>, n: usize) -> Vec<Vec<bool>>{

    if v.len() == n{
        let mut res = v.clone();
        return vec![res];
    }

    let mut res = vec![];
    v.push(true);
    let mut tmp: Vec<Vec<bool>> = list_all(v, n);
    v.pop();
    res.append(&mut tmp);


    v.push(false);
    let mut tmp = list_all(v, n);
    v.pop();
    res.append(&mut tmp);

    return res;
}

fn check(graph: &Vec<Vec<(usize, bool)>>, pat: &Vec<bool>) -> bool{

    for i in 0..pat.len(){
        if pat[i] == false{
            continue;
        }
        for j in 0..graph[i].len(){
            let (target, chara) = (graph[i][j].0, graph[i][j].1);
            if chara != pat[target]{
                return false;
            }
        }
    }

    return true;
}

fn main(){
    let n = read_as_vec::<usize>()[0];

    let mut tests: Vec<Vec<(usize, bool)>> = vec![vec![];n];
    for i in 0..n{
        let a = read_as_vec::<usize>()[0];
        for _ in 0..a{
            let line = read_as_vec::<usize>();
            if line[1] == 1{
                let (x, y) = (line[0]-1, line[1]);
                tests[i].push((line[0]-1, true));
            }else{
                let (x, y) = (line[0]-1, line[1]);
                tests[i].push((line[0]-1, false));
            }
        }
    }

    //println!("{:?}", tests);
    let mut v = vec![];
    let possibles = list_all(&mut v, n);
    //println!("{:?}", possibles);


    let mut ans = 0;
    for pat in possibles{
        if check(&tests, &pat){

            ans = cmp::max(pat.iter().filter(|x| **x == true).count(), ans);
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<tuple<int, int, int>> vt(n);
  rep(i, n){
    int x, y, h;
    cin >> x >> y >> h;
    vt.at(i) = make_tuple(x, y, h);
  }
  sort(vt.begin(), vt.end(),
    [](const auto &l, const auto &r){
      return get<2>(l) > get<2>(r);
    }
  );
  rep(i, 101){
    rep(j, 101){
      int d = abs(get<0>(vt.at(0)) - j) + abs(get<1>(vt.at(0)) - i);
      int top = d + get<2>(vt.at(0));
      if(top <= 0) continue;
      bool f = false;
      rep2(k, 1, n){
        int dd = abs(get<0>(vt.at(k)) - j) + abs(get<1>(vt.at(k)) - i);
        int tt = max(top - dd, 0);
        if(tt != get<2>(vt.at(k))){
          f = true;
          break;
        }
      }
      if(f == false){
        cout << j << " " << i << " " << top << endl;
        return 0;
      }
    }
  }
  return 0;
}

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

int main() {
	int A,B,C,D;
  	cin >> A >> B >> C >> D;
  	
  	if ( A+B > C+D ){
      cout << "Left" << endl;
    }
  
    else if( A+B == C+D ){
      cout << "Balanced" << endl;
    }
  	
  	else{
      cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
'''
INPUT SHORTCUTS
N, K = map(int,input().split())
N ,A,B = map(int,input().split())
string = str(input())
arr = list(map(int,input().split()))
N = int(input())
'''


a, b = map(int,input().split())
res = ''
if a<=b:
	for _ in range(b):
		res += str(a)
else:
	for _ in range(a):
		res += str(b)
print(res)

Measured memory_bytes: 38256
n, t = map(int, input().split())
push = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    if push[i + 1] - push[i] >= t:
        ans += t
    else:
        ans += push[i + 1] - push[i]
ans += t
print(ans)


Measured memory_bytes: 25196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int64_t N;
    int64_t A, B;
    cin >> N >> A >> B;
    cout << N / (A + B) * A + min(N % (A + B), A) << endl;
}

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n,m;
    cin >> n >> m;

    vector<pii> lr(m);
    for(auto &x:lr){
        cin >> x.first >> x.second;
    }

    int minval=0,maxval=inf;
    for(int i=0;i<m;i++){
        minval=max(minval, lr[i].first);
        maxval=min(maxval, lr[i].second);
    }

    int ans = maxval-minval;
    if(ans<0)cout << 0 << endl;
    else cout << ans+1 << endl;

    return 0;
}


Measured memory_bytes: 4016
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main( void )
{
	while ( 1 )
	{
		int w, h;
		cin >> h >> w;
		if ( w == 0 && h == 0 )
			break;

		vector <string> data;
		for ( int i = 0; i < h; i++ )
		{
			string line;
			cin >> line;
			data.push_back( line );
		}

		bool loop_flag = false;
		int x = 0;
		int y = 0;
		while ( 1 )
		{
			int oldx = x;
			int oldy = y;
			if ( data[y][x] == '.' )
				break;
			else if ( data[y][x] == '>' )
				x++;
			else if ( data[y][x] == 'v' )
				y++;
			else if ( data[y][x] == '^' )
				y--;
			else if ( data[y][x] == '<' )
				x--;
			else if ( data[y][x] == 'x' )
			{
				loop_flag = true;
				break;
			}
			data[oldy][oldx] = 'x';
		}

		if ( loop_flag )
			cout << "LOOP" << endl;
		else
			cout << x << " " << y << endl;

	}
	return 0;
}

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

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

    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b) {
        cout << "YES";
    } else {
        cout << "NO";
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc019.contest.atcoder.jp/tasks/agc019_b>
問題文============================================================
 英小文字からなる文字列 A=A1A2…An があります。
 
 あなたは 1≤i≤j≤n であるような任意の二つの添字 i,j を選び、
 A のうち部分文字列 AiAi+1…Aj を反転することができます。
 
 この操作は一回まで行うことができます。
 
 これによって得られる文字列は何通りあるでしょうか？
=================================================================

解説=============================================================
 abcda と abcba という文字列があるとする

 [1,5]を反転させると adcba , abcba
 [2,4]を反転させると adcba , abcba
 
 となる。　このことから ある文字(l)を基準とした時,それよりも右側の同一文字(r)を示して反転させることは
 [l-1,r-1] を反転させることに等しい
 よって、ある文字を見た時、それよりも右側にある別の文字と交換して行くことによって重複の文字を防ぐことができる。
 また、両端が別の文字で反転を行っているので回文となる心配がない
 
 よって、右側にいくつ、どのような文字が存在するのかというテーブルを作っておき、順に見ていけば良い
 O(N)
================================================================
*/
ll solve(){
    ll ret = 1;
    string S; cin >> S;
    int alpha[26] = {};
    for(int i = (int)S.length()-1; i >= 0;i--){
        for(int j = 0; j < 26;j++){
            if(j == S[i]-'a')continue;
            ret += alpha[j];
        }
        alpha[S[i]-'a']++;
    }
    return ret;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 720
import sys
import collections
from collections import defaultdict

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [[int(x) for x in input().split()] for _ in range(N)]

    q = [collections.deque() for j in range(N)]

    for i, a in enumerate(A):
        for aa in a:
            q[i].append(aa)

    ans = 0

    current = defaultdict(int)
    for i, v in enumerate(q):
        current[i + 1] = v[0]

    while True:
        v = set()
        for k in current.keys():
            if k == q[current[k] - 1][0]:
                v.add(k)
                v.add(current[k])

        current = defaultdict(int)

        if len(v) == 0:
            break

        for vv in v:
            q[vv - 1].popleft()
            if len(q[vv - 1]):
                current[vv] = q[vv - 1][0]

        ans += 1

    # 全て空なら
    size = 0
    for i in range(N):
        size += len(q[i])

    if size == 0:
        print(ans)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 51020
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define int long long
typedef std::pair<int,int> P;
using namespace std;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
struct edge{
    int to,cost;
};
class dijkstra{
    int V;
    int d[100002];
    priority_queue<P,vector<P>,greater<P>>que;
    void update(int s,vector<edge> G[]){
        fill(d,d+V+1,100000000000ll);
        d[s]=0;
        que.push(make_pair(0,s));
        while(!que.empty()){
            P p=que.top();
            que.pop();
            int v=p.second;
            if(d[v]<p.first)continue;
            rep(i,G[v].size()){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(make_pair(d[e.to],e.to));
                }
            }
        }
    }
public:
    dijkstra(int v,int s,vector<edge> G[]){
        V=v;
        update(s,G);
    }
    int find(int e){
        return d[e];
;    }
};
int dp[111][4][4][4];
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int ans=0;
    int n;
    cin>>n;
    const int A=0,C=1,G=2,T=3,mod=1000000007;
    dp[0][0][0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<4;k++){
                for(int l=0;l<4;l++){
                    for(int m=0;m<4;m++){
                        if(i>2) {
                            if (k == A && l == G && m == C) continue;
                            if (k == A && l == C && m == G) continue;
                            if (k == G && l == A && m == C) continue;
                        }
                        if(i>3) {
                            if (j == A && l == G && m == C) continue;
                            if (j == A && k == G && m == C) continue;
                        }
                        dp[i][k][l][m]+=dp[i-1][j][k][l];
                        dp[i][k][l][m]%=mod;
                    }
                }
            }
        }
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<4;k++){
                ans+=dp[n][i][j][k];
                ans%=mod;
            }
        }
    }
    cout<<ans<<endl;
}



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

using namespace std;

int main(int argc, char const *argv[])
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({1LL * a * c, 1LL * b * d, 1LL * a * d, 1LL * b * c}) << '\n';
    return 0;
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		TreeSet<Integer> prime = new TreeSet<>();
		prime.add(2);
		prime.add(3);
		for(int i = 5; i <= 100003; i+=2) {
			boolean isprime = true;
			for(int j = 2; j*j <= i; j++) {
				if(i % j == 0) {
					isprime = false;
					break;
				}
			}
			if(isprime)
				prime.add(i);
		}
		System.out.println(prime.higher(sc.nextInt()-1));

	}

}

Measured memory_bytes: 23648
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define LL long long
#define INF 1000000001
#define mod 1000000007
using namespace std;
int keta(int n,int k){return (n/int(pow(10,double(k-1)))) % 10;} //nの下からk桁目
ll gcd(ll n,ll m){
	if(n<m){ll a=m;m=n;n=a;}
	ll r=n%m;
	while(r!=0){
		n=m;
		m=r;
		r=n%m;
	}
	return m;
}
ll lcm(ll n,ll m){
	return n*m/gcd(n,m);
}

int main(){
	
	int a;
	cin>>a;
	if(a%10==9 || a/10==9) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;


	
}


Measured memory_bytes: 256
N=int(input())
P=list(map(int,input().split()))
Q=P[::-1]
c=0
for i in range(N-1):
    if P[i]==i+1:
        P[i],P[i+1]=P[i+1],P[i]
        c+=1
if P[N-1]==N:
    c+=1
print(c)

Measured memory_bytes: 13880
import java.util.Scanner;
public class Main {
	public static void main(String []args) {
		Scanner sc=new Scanner(System.in);
		int W=sc.nextInt();
		int H=sc.nextInt();
		int x=sc.nextInt();
		int y=sc.nextInt();
		int r=sc.nextInt();
		
		if((x-r<0||x+r>W)||(y-r<0||y+r>H)) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}
}



Measured memory_bytes: 26424
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>

using namespace std;
typedef long long  ll;

int main()
{
	ll N;
	cin >> N;
	vector<ll> w(N, 0), s(N, 0);
	for (ll i = 0; i < N; i++)
	{
		char temp;
		cin >> temp;
		if (temp == 'E')
		{
			w[i]++;
		}
		else
		{
			s[i]++;
		}
	}
	for (ll i = 1; i < N; i++)
	{
		w[N - 1 - i] += w[N - i];
		s[i] += s[i - 1];
	}
	ll ans = w[1];
	for (ll i = 1; i < N - 1; i++)
	{
		ans = min(ans, w[i + 1] + s[i - 1]);
	}
	ans = min(ans, s[N - 2]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
 
int main(void){
int n,r,k;
scanf("%d",&n);
for(r=1;r<=n;r++){
if(r%3==0||r%10==3){
printf(" %d",r);
}else{
k=r;
while(k!=0){
k/=10;
if(k%10==3){printf(" %d",r);break;}
}
}
}
printf("\n");
return 0;
}
 

 

Measured memory_bytes: 600
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = 3.141592653589;
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
intl n,m,q;
vector<intl> a,b,c,d;
intl dfs(vector<intl> &v){
    if(v.size() == n){
        intl m = 0;
        rep(i,q){
            if(v[b[i] - 1] - v[a[i] - 1] == c[i])m += d[i];
        }
        /*for(auto i : v){
            cout << i << " ";
        }
        debug(m);*/
        return m;
    }
    intl res = 0;
    for(intl i = (v.empty() ? 1 : v.back()); i <= m; i++){
        v.pb(i);
        res = max(res,dfs(v));
        v.pop_back();
    }
    return res;
}
signed main(){
    cout << fixed << setprecision(10);
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    vector<intl> e;
    cout << dfs(e) << endl;
    return 0;
}

Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"os"
)

type Combination struct {
	n int
	f *Factorial
}

func NewCombination(n, m int) *Combination {
	f := NewFactorial(n, m)
	return &Combination{n, f}
}

func (c *Combination) Combination(n, k int) int64 {
	return c.f.F[n] * c.f.Inv[k] % c.f.Mod * c.f.Inv[n-k] % c.f.Mod
}

func (c *Combination) Permutation(n, k int) int64 {
	return c.Combination(n+k-1, n-1)
}

func (c *Combination) Factorial(n int) int64 {
	return c.f.F[n]
}

type Factorial struct {
	n      int
	Mod    int64
	F, Inv []int64
}

func NewFactorial(n, m int) *Factorial {
	f := Factorial{n, int64(m), nil, nil}
	f.F = make([]int64, n+1)
	f.Inv = make([]int64, n+1)
	f.F[0] = 1
	for i := 1; i <= n; i++ {
		f.F[i] = f.F[i-1] * int64(i) % f.Mod
	}
	f.Inv[n] = pow(f.F[n], f.Mod-2, f.Mod)
	for i := n; i > 0; i-- {
		f.Inv[i-1] = f.Inv[i] * int64(i) % f.Mod
	}
	return &f
}

func pow(x, n, m int64) int64 {
	if n == 0 {
		return 1
	}
	if n&1 == 0 {
		r := pow(x, n/2, m)
		return r * r % m
	}
	return x * pow(x, n-1, m) % m
}

func div(x, n, m int64) int64 {
	return x * pow(n, m-2, m) % m
}

const m = 1000000007

var (
	e   [][]int
	dp  []int64
	cnt []int
	res []int64
	c   *Combination
)

func merge(i, j int) {
	dp[i] *= dp[j]
	dp[i] %= m
	dp[i] *= c.Combination(cnt[i]+cnt[j]+1, cnt[i])
	dp[i] %= m
	cnt[i] += cnt[j] + 1
}

func subtract(i, j int) {
	cnt[i] -= cnt[j] + 1
	dp[i] = div(dp[i], c.Combination(cnt[i]+cnt[j]+1, cnt[i]), m)
	dp[i] = div(dp[i], dp[j], m)
}

func dfs(i, p int) {
	dp[i] = int64(1)
	for _, j := range e[i] {
		if j == p {
			continue
		}
		dfs(j, i)
		merge(i, j)
	}
}

func dfs2(i, p int) {
	for _, j := range e[i] {
		if j == p {
			continue
		}
		tempDp, tempCnt := dp[i], cnt[i]
		subtract(i, j)
		merge(j, i)
		dp[i], cnt[i] = tempDp, tempCnt
		dfs2(j, i)
	}
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)
	c = NewCombination(n, m)

	e = make([][]int, n+1)
	for i := 0; i < n-1; i++ {
		var a, b int
		fmt.Fscan(in, &a, &b)
		e[a] = append(e[a], b)
		e[b] = append(e[b], a)
	}

	cnt = make([]int, n+1)
	dp = make([]int64, n+1)
	dfs(1, 0)

	res = make([]int64, n+1)
	dfs2(1, 0)
	for i := 1; i <= n; i++ {
		fmt.Fprintln(out, dp[i])
	}
}


Measured memory_bytes: 25728
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<functional>
#include<map>
#include<math.h>
#include<iterator>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define pp pop_back
#define bs binary_search
#define fr(i,s,e) for(int i=s; i<e; i++)
#define rf(i,s,e) for(int i=e; i>s; i--)
#define rea(a,n)  for(int i=0; i<n; i++) cin>>a[i]
#define pra(a,n)  for(int i=0;i<n;i++) cout<<a[i]<<" "
#define vfr(it, g1)  for (auto it = g1.begin(); it != g1.end(); it++)
#define rep(name) for(auto &e : name)
#define ins insert
#define less bool operator < (const class_name& rhs) const {return object<rhs.object;}
#define grtr bool operator < (const class_name& rhs) const {return object>rhs.object;}
#define ln length
#define vsort(a) sort(a.begin(), a.end())
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int32_t main()
{
    IOS;
	string s;
	cin>>s;
	if(s[1] == 'B')
	cout<<"ARC"<<endl;
	else
	{
		cout<<"ABC"<<endl;
	}
	
	
}

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


int main(){
    int n;
    cin >> n;
    switch(n%10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
        cout << "hon" << endl;
        break;

        case 0:
        case 1:
        case 6:
        case 8:
        cout << "pon" << endl;
        break;

        case 3:
        cout << "bon" << endl;
        break;
        
    }
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
double c[8];
double f(int i){
	return c[i]*(c[(i+3)%6]-c[7])+c[(i+2)%6]*(c[7]-c[i+1])+c[6]*(c[i+1]-c[(i+3)%6]);
}
int main(void){
	int i;
	for(i=0;~scanf("%lf",c+i++);i%8||puts(f(i=0)*f(2)>0&&f(2)*f(4)>0?"YES":"NO"));
	return 0;
}

Measured memory_bytes: 0
#include <string>
#include <iostream>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
	ll N;
	ll K;
	ll Q;
	cin >> N >> K >> Q;

	vector<ll> points(N);

	

	for (ll i = 0; i < N; i++)
	{
		points[i] = 0;
	}
	
	for (ll i = 0; i < Q; i++)
	{
		ll ans;
		cin >> ans;

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



	return 0;

}

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

int main()
{
	string S;
	cin >> S;
	int d = 0, mask = 0, cnt = 0;
	bool flag = true;
	for (char c : S) {
		if (d == 0 && c != 'R') flag = false;
		if (c == 'R') {
			d = (d == 3 ? 0 : d + 1);
		}
		else {
			d = (d == 0 ? 3 : d - 1);
		}
		if (flag) mask |= 1 << d;
		if (d == 0) {
			cnt += (c == 'R' && flag && mask + 1 == (1 << 4));
			flag = true;
			mask = 0;
		}
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 3228
import fractions
from fractions import gcd


def solve():

    N, X = map(int, input().split())
    xlist = list(map(int, input().split()))

    d = abs(X - xlist[0])
    for i in range(1, N):
        d = gcd(d, abs(xlist[i] - xlist[i - 1]))

    print(d)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 88172
def initialize(faces_int: list) -> list:
    list_sn = [faces_int[5], faces_int[4], faces_int[0], faces_int[1]]  # 6,5,1,2
    list_we = [faces_int[5], faces_int[2], faces_int[0], faces_int[3]]  # 6,3,1,4
    return [list_sn, list_we]


def roll_positive(list_a: list, list_b: list) -> list:
    list_a = list_a[1:] + list_a[0:1]  # Roll one unit in the positive direction.
    list_b[0] = list_a[0]  # Change the bottom face.
    list_b[2] = list_a[2]  # Change the top face.
    return [list_a, list_b]


def roll_negative(list_a: list, list_b: list) -> list:
    list_a = list_a[3:] + list_a[0:3]
    list_b[0] = list_a[0]  # Change the bottom face.
    list_b[2] = list_a[2]  # Change the top face.
    return [list_a, list_b]


if __name__ == "__main__":
    faces_int = list(map(lambda x: int(x), input().split()))  # 1,2,3,4,5,6
    question_num = int(input())

    for _ in range(question_num):
        SN_direction, WE_direction = initialize(faces_int)
        q_top, q_front = map(lambda x: int(x), input().split())
        for command in "NNNNWNNNWNNNENNNENNNWNNN":  # Check all patterns.
            if ("N" == command):
                SN_direction, WE_direction = roll_positive(SN_direction, WE_direction)
            elif ("S" == command):
                SN_direction, WE_direction = roll_negative(SN_direction, WE_direction)
            elif ("E" == command):
                WE_direction, SN_direction = roll_positive(WE_direction, SN_direction)
            else:
                WE_direction, SN_direction = roll_negative(WE_direction, SN_direction)
            if SN_direction[2] == q_top and SN_direction[3] == q_front:
                print(f"{WE_direction[1]}")  # Print the right side face.
                break



Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
const ll mod = 1e9 + 7;
namespace IO{
    const int SIZE = (1 << 20) + 1;
    char ibuf[SIZE], *iS, *iT, obuf[SIZE],*oS = obuf, *oT = obuf + SIZE - 1;
    char _st[55];
    int _qr = 0;
    inline char gc(){
        return (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS++) : *iS++);
    }
    inline void qread(){}
    template<class T1, class ...T2>
    inline void qread(T1 &IEE, T2&... ls){
        register T1 __ = 0, ___ = 1;
        register char ch;
        while(!isdigit(ch = gc())) ___ = (ch == '-') ? -___ : ___;
        do{
            __ = (__ << 1) + (__ << 3) + (ch ^ 48);
        }while(isdigit(ch = gc()));
        __ *= ___;
        IEE = __;
        qread(ls...);
        return ;
    }
    inline void flush(){
        fwrite(obuf, 1, oS - obuf, stdout);
        oS = obuf;
        return ;
    }
    inline void putc_(char _x){
        *oS++ = _x;
        if(oS == oT) flush();
    }
    inline void qwrite(){}
    template<class T1, class ...T2>
    inline void qwrite(T1 IEE, T2... ls){
        if(!IEE) putc_('0');
        if(IEE < 0) putc_('-'), IEE = -IEE;
        while(IEE) _st[++_qr] = IEE % 10 + '0', IEE /= 10;
        while(_qr) putc_(_st[_qr--]);
        qwrite(ls...);
        return ;
    }
    struct Flusher_{~Flusher_(){flush();}}io_flusher;
}
using namespace IO;
ll n, x, y, z;
ll dp[45][1 << 18];
int main(){
    cin.tie(0);
    cin >> n >> x >> y >> z;
    ll sum = (1 << z) | (1 << (y + z)) | (1 << (x + y + z));
    dp[0][0] = 1;
    ll qp = 1;
    for(int i = 1;i <= n;i++){
        for(int j = 0;j < (1 << (x + y + z + 1));j++){
            if((j & sum) == sum) continue;
            for(int k = 1;k <= 10;k++){
                ll newnum = (((j << k) | (1 << k)) & ((1 << (x + y + z + 1)) - 1));
                // cout << j << " " << k << " " << ((j << k) | (1 << k)) << endl;
                if((newnum & sum) == sum){
                    continue;
                }
                dp[i][newnum] += dp[i - 1][j];
                dp[i][newnum] %= mod;
            }
        }
        qp = qp * 10 % mod;
    }
    ll ans = 0;
    for(int i = 0;i < (1 << (x + y + z + 1));i++){
        ans += dp[n][i];
    }
    // for(int i = 1;i <= n;i++){
    //     for(int j = 0;j < (1 << 18);j++){
    //         cout << i << " " << j << " " << dp[i][j] << endl;
    //     }
    // }
    ans = ((qp - ans) % mod + mod) % mod;
    cout << ans << endl;
    return 0;
}

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


int main() {
  static const double pi = acos(-1);
  
  int a,b,h,m;
  
  cin >> a >> b >> h >> m;
  
  int min = h*60+m;
  
  //cout << min << endl;
  
  long double rad_jisin,rad_funsin;
  
  rad_jisin = (0.5*min*pi)/180;
  rad_funsin = (6*m*pi)/180;
  
  //cout << rad_jisin << endl << rad_funsin;
  
  long double jisin_x,jisin_y,funsin_x,funsin_y;
  
  jisin_x = a * cos(rad_jisin);
  jisin_y = a * sin(rad_jisin);
  
  funsin_x = b * cos(rad_funsin);
  funsin_y = b * sin(rad_funsin);
  
  long double dx = jisin_x-funsin_x;
  long double dy = jisin_y-funsin_y;
  
  long double dis = sqrt(dx * dx + dy * dy);
  
  cout << fixed << setprecision(20) << dis ;  
}

Measured memory_bytes: 4188
import * as fs from 'fs';

//in
//
//out
//
const main = (inp: string) => {
    let n: number = parseInt(inp);
    let ans: number = 0;
    while (n > 0) {
        if (n.toString().length % 2 === 1) {
            ans++;
        }
        n--;
    }
    console.log(ans);
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 10944
N=int(input())
a=list(map(int,input().split(' ')))
b=list(map(int,input().split(' ')))
i=0
A=0
B=0
n=0
while i < N:
    n+=(b[i]-a[i])
    if (a[i]-b[i])>=0:
        B+=(a[i]-b[i])
        i+=1
    elif (a[i]-b[i])<0 and int(abs(a[i]-b[i])%2)==0:
        A+=int(abs(a[i]-b[i])//2)
        i+=1
    else:
        A+=int(abs(a[i]-b[i])//2 + 1)
        B+=1
        i+=1
if max(n,A,B)==n:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 4596