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

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<String> before = new ArrayList<String>();
		String x;
		int sum = 0;
		while (true) {
			x = sc.next();
			if (x.equals("0")) {
				break;
			}
			before.add(x);
		}
		for (int i = 0; i < before.size(); i++) {
			char[] c = (before.get(i)).toCharArray();
			for (int j = 0; j < c.length; j++) {
				sum += (c[j] - '0');
			}
			System.out.println(sum);
			sum = 0;
		}
		sc.close();
	}
}


Measured memory_bytes: 26136
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 1000;
 
ll table[MAX][MAX];
 
// テーブルを作る前処理
void COMinit() {
    table[0][0] = table[0][1] = 1;
    FOR(i, 1, MAX-1){
      FOR(j, 0, i+1){
        if(j==0) table[i][j] = 1;
        else if(j == i+1) table[i][j] = 1;
        else table[i][j] = table[i-1][j-1]+table[i-1][j];
      }
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return table[n-1][k];
}

void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}

ll SORT(int n, vector<pair<ll, ll>> &v, int start){
  sort(v.begin()+start, v.end());
  return v[n-1].first;
}

bool test(string s){
  if(s.size()==1) return false;
  REP(i, s.size()-1){
    if(s[i]!=s[i+1]){
      return true;
    }
    if(i== s.size()-2 && s[i]==s[i+1]){
      return false;
    }
  }
} 

int main(void){

  string s;
  cin>>s;
  string s_ = s;

  ll ans = 200;

  for(char x='a'; x<='z';x++){  //全てがxになる

    ll count = 0;
    s = s_;

    while(test(s)){

      string t;

      REP(i, s.size()-1){
        if(s[i+1]==x) t += x;
        else t += s[i];
      }
      count++;
      s = t;
     // cout<<t<<":";
    }
   // cout<<count<<endl;
    ans = min(ans, count);
  }

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

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

int main(void) {
	int i[3],k,j;
	scanf("%d",&i[0]);
	scanf("%d",&i[1]);
	scanf("%d",&i[2]);
	for(k=0; k<3; k++){
		for(j=1; j<3-k; j++){
			if(i[k]<i[k+j]){}
			else{
				int temp=i[k];
				i[k]=i[k+j];
				i[k+j]=temp;
			}
		}
	}
	printf("%d %d %d\n",i[0],i[1],i[2]);

	return EXIT_SUCCESS;
}

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

#define ll long long int
#define ull unsigned long long int
#define forr(i,n) for(int i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) int t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vi vector<ll>
const ll md=1e9 +7;const ll M1=998244353;
ll mod(ll n){return ((n%md)+md)%md;}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=res*x;x=x*x;y=y>>1;}return res;}

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

    int a;cin>>a;a^=1;
    cs(a);
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	ll k;
	cin>>k;
	ll poc=-1;
	ll brojac=0;
	vector<ll> v;
	for(int i=0;i<n;i++)
	{
		ll a;
		cin>>a;
		v.push_back(a);
	}
	v.push_back(1e18);
	for(int i=1;i<=n;i++)
	{
		if((v[i]-v[i-1])<=k)
			brojac+=(v[i]-v[i-1]);
		else
			brojac+=k;
	}
	cout<<brojac<<endl;
	return 0;
}

Measured memory_bytes: 3444
gets;
t=$<.map{a,b=_1.split.map &:to_r;a==0?b==0?0:1:b==0?-1:a/b}.tally;
t.default=0;
M=10**9+7;
p (t[0]-1+t.map{|k,v|
k==0?1:(w=t[-1/k];w>0&&k<0?1:2.pow(v,M)+2.pow(w,M)-1)
}.reduce{_1*_2%M})%M
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################


Measured memory_bytes: 38704
#include <bits/stdc++.h>
    using namespace std;
     int main(){
       int A,B; 	
       cin >> A>> B;
       int C;
       C=max(A-B, B-A);
       if(C%2==0) cout<< (A+B)/2 <<endl;
       if(C%2==1) cout<< "IMPOSSIBLE" <<endl;
     }

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] ary = new int[n];
        for (int i = 0; i < n; i++) {
            ary[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(ary);
        int ans = 0;
        for (int i = 0; i < n; i++) {
            j: for (int j = i + 1; j < n; j++) {
                for (int k = j + 1; k < n; k++ ) {
                    if (ary[i] + ary[j] > ary[k]) {
                        ans++;
                    } else {
                        continue j;
                    }
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23884
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var minN = 1000;
        var sumN = 0;
        for (int i = 0; i < n; i++)
        {
            var s = int.Parse(Console.ReadLine().Trim());
            sumN += s;
            if (s % 10 != 0 && s < minN) minN = s;
        }
        if (minN == 1000) { Console.WriteLine(0); goto end; }
        Console.WriteLine(sumN % 10 == 0 ? sumN - minN : sumN);
        end:;
    }
}

Measured memory_bytes: 13140
import sys
from typing import List
import math

n = int(input())
S = [int(i) for i in input().split()]


def merge(A: List[int], left: int, mid: int, right: int) -> None:
    global cnt

    left_list = A[left:mid]
    right_list = A[mid:right]
    n_left = len(left_list)
    left_list.append(sys.maxsize)
    right_list.append(sys.maxsize)

    i = 0  # left_listのインデックス
    j = 0  # right_listのインデックス
    for k in range(left, right):
        if left_list[i] <= right_list[j]:
            A[k] = left_list[i]
            i += 1
        else:
            A[k] = right_list[j]
            j += 1
            cnt += n_left - i  # 反転数を求める。左側のリストの要素数 - i が反転してる数


def merge_sort(A: List[int], left: int, right: int) -> int:
    if left + 1 < right:
        mid = math.floor((left + right) / 2)
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)


hikaku = 0
cnt = 0
merge_sort(S, 0, len(S))
print(cnt)


Measured memory_bytes: 31016
#include <bits/stdc++.h>
#define N 101
#define M 51
using namespace std;
int n,m,l;
double p[N],t[N],d[N],mem[M][M];

double nCr(int n, int r){
  if(mem[n][r]!=0)return mem[n][r];
  double a=1;
  for(int i=0;i<r;i++) a*=(n-i)/(i+1.0);
  return mem[n][r]=a;
}

double DP(){
  double dp[N][M]={};
  for(int i=0;i<=m;i++)dp[0][i]=pow(1-p[0],m-i)*pow(p[0],i)*nCr(m,i);
  
  for(int i=1;i<n;i++)
    for(int j=0;j<=m;j++)
      for(int k=0;k<=m;k++)
	if(d[0]+j*t[0]<d[i]+k*t[i]) 
	  dp[i][j]+=dp[i-1][j]*pow(1-p[i],m-k)*pow(p[i],k)*nCr(m,k);

  double res=0;
  for(int i=0;i<=m;i++)res+=dp[n-1][i];
  return res;
}

int main(){
  cin>>n>>m>>l;
  for(int i=0;i<n;i++){
    cin>>p[i]>>t[i]>>d[i];
    p[i]/=100;
    d[i]=l/d[i];
  }
  
  for(int i=0;i<n;i++){
      printf("%.10f\n",DP());
      swap(p[0],p[i+1]);
      swap(t[0],t[i+1]);
      swap(d[0],d[i+1]);    
  }
  return 0;
}

Measured memory_bytes: 3336
#include<stdio.h>

int main(){

    int x,y;      // define variable,  0<= x, y<=10000

    scanf("%d %d", &x, &y);

   while(x!=0 || y!=0){
      if(x>y) printf("%d %d\n", y, x);
      else printf("%d %d\n", x, y);

      scanf("%d %d", &x, &y);
   }

   return 0;
}

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

int main(){
	int n;
	cin >> n;
	int t = n % 10;
	if(t == 3){
		cout << "bon" << endl;
	} else if (t == 0 || t == 1 || t == 6 || t == 8){
		cout << "pon" << endl;
	}else{
		cout << "hon" << endl;
	}
    return 0;
}



Measured memory_bytes: 3596
#include<iostream>
#include<map>
#include<utility>
#include<algorithm>

using namespace std;

typedef pair<int,int> PII;

bool cmp(PII a,PII b){
  return a.first*b.second>a.second*b.first;
}

int main(){
  int H,W;
  cin>>H>>W;
  map<PII,int,bool(*)(PII,PII)> m(cmp);
  bool g[602][602]={};
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      int ii=i+1;
      int jj=j+1;
      char c;
      cin>>c;
      g[ii][jj]=c=='#';
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      int ii=i+1;
      int jj=j+1;
      bool f=g[ii][jj];
      if((f^g[ii-1][jj-1])&&(f^g[ii-1][jj])&&(f^g[ii][jj-1])){
	m[PII(H-i,j)]++;
      }
      if((f^g[ii][jj+1])&&(f^g[ii+1][jj])&&(f^g[ii+1][jj+1])){
	m[PII(H-i-1,j+1)]--;
      }
    }
  }
  int c=1,ans=1;
  for(auto e:m){
    c+=e.second;
    ans=max(ans,c);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5724
import math

A,B,H,M = map(int, input().split())

A_angle = (H*60+M)*0.5
B_angle = M*6

#中心角度
angle = abs(A_angle - B_angle)

#cos
angle_rad = math.radians(angle)
cos = math.cos(angle_rad)
#余弦定理
ansans = A**2+B**2-2*A*B*cos
ans = math.sqrt(ansans)
print(ans)

Measured memory_bytes: 9512
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Buffer(make([]byte, 0), 1e6) // maxTokenSize
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	/* --- code --- */
	x, n := nextInt(), nextInt()
	matrix := make([]int, 101)
	for i := 0; i < n; i++ {
		p := nextInt()
		matrix[p] = 1
	}

	for i := 0; i < 101; i++ {
		if x-i >= 0 && matrix[x-i] == 0 {
			fmt.Println(x - i)
			return
		} else if x-i < 0 {
			fmt.Println(-1)
			return
		} else if x+i <= 100 && matrix[x+i] == 0 {
			fmt.Println(x + i)
			return
		} else if x+i > 100 {
			fmt.Println(101)
			return
		}
	}

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

func max(a, b int) int {
	return int(max64(int64(a), int64(b)))
}

func max64(a int64, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	return int(min64(int64(a), int64(b)))
}

func min64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


Measured memory_bytes: 1772
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 200000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}

int n, m;
ll ans = 1;

int main() {
    scanf("%d %d", &n, &m);
    prepare();
    for (ll i = 2; i * i <= m; i++) {
        int cnt = 0;
        while (m % i == 0) {
            m /= i;
            cnt++;
        }
        if (cnt > 0) (ans *= C(n + cnt - 1, n - 1)) %= MOD;
    }
    if (m != 1) (ans *= n) %= MOD;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3328
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
/*bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}*/


/*long nCr(int n, int r)
{
       if(n==r) return dp[n][r] = 1;
       if(r==0) return dp[n][r] = 1;
       if(r==1) return dp[n][r] = n;
       if(dp[n][r]) return dp[n][r];
       return dp[n][r] = nCr(n-1,r) + nCr(n-1,r-1);
}*/

int main(){
    int n, m, a, b, k;
    cin >> n >> m >> k;
    bool f = false;
    REP(i, n+1){
        REP(j, m+1){
            int l;
            l=(n-i)*j+(m-j)*i;
            if(l==k){
                f=true;
                break;
            }
        }
        if(f) break;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;



}


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

#define int long long

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

#define endl '\n'
#define all(v) v.begin(), v.end()

#define lcm(a, b)  ((a) * ((b) / __gcd((a), (b)) ))
#define print_(x)  cout << #x << " : " << x << endl;
#define dvec(vct)  for(auto i : vct) cout << i << " "; cout << endl;
#define darr(a, n) for(int i = 0; i < n;) cout << a[i++] <<' '; cout<< '\n';



int32_t main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    if (n == 0) {
        cout << 0 << endl;
    } else {
        n %= k;
        cout << min(n, abs(n - k)) << endl;
    }

}



Measured memory_bytes: 256
if __name__ == "__main__":
    a, b, c = map(int, input().split())

    if a == b == c and a % 2 == 0:
        print(-1)
        exit()

    ans = 0
    while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
        a_tmp = (b+c)//2
        b_tmp = (a+c)//2
        c_tmp = (c+a)//2
        a = a_tmp
        b = b_tmp
        c = c_tmp
        ans += 1

    print(ans)


Measured memory_bytes: 3064
function main(input) {
    const n: number = parseInt(input.split('\n')[0], 10);
    const r: number[] = new Array(n).fill(0);
    const a: number[] = input.split('\n')[1].split(' ').map((v: string) => parseInt(v));
    a.forEach((e: number, i: number) => {
        r[e-1] = i+1;
    });
    console.log(r.join(' '));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 34880
h, w = map(int, input().split())
s = []
for i in range(h):
  l = input()
  s.append(list(l))
ans = ''
for i in range(h):
  if ans == '':
    for j in range(w):
      if ans == '' and s[i][j] == '#':
        f = 0
        if i - 1 >= 0 and s[i - 1][j] == '#':
          f += 1
        if j - 1 >= 0 and s[i][j - 1] == '#':
          f += 1
        if j + 1 <= w - 1 and s[i][j + 1] == '#':
          f += 1
        if i + 1 <= h - 1 and s[i + 1][j] == '#':
          f += 1
        if f == 0:
          ans = 'No'
        else:
          next
      elif ans == '' and s[i][j] == '.':
        next
if ans == '':
  ans = 'Yes'
print(ans)

Measured memory_bytes: 9180
#include <stdio.h>
#define max 10000
#define min -1

typedef struct{
  int p;
  int l;
  int r;
} Node;

Node t[max];

void preParse(int);
void inParse(int);
void postParse(int);

int main(){

  int n,i,v,l,r,root;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    t[i].p = min;
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    t[v].l = l;
    t[v].r = r;
    if(l != min) t[l].p = v;
    if(r != min) t[r].p = v;
  }

  for(i=0;i<n;i++) if(t[i].p == min) root = i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
  
  return 0;
}

void preParse(int u){
  if(u == min) return;
  printf(" %d",u);
  preParse(t[u].l);
  preParse(t[u].r);
}

void inParse(int u){
  if(u == min) return;
  inParse(t[u].l);
  printf(" %d",u);
  inParse(t[u].r);
}

void postParse(int u){
  if(u == min) return;
  postParse(t[u].l);
  postParse(t[u].r);
  printf(" %d",u);
}




Measured memory_bytes: 2052
class UnionFind:
    def __init__(self, size):
        self.table = [-1] * size
    
    def find(self, x):
        while self.table[x] >= 0:
            x = self.table[x]
        return x
    
    def union(self, x, y):
        x_root = self.find(x)
        y_root = self.find(y)
        if x_root != y_root:
            if self.table[x_root] < self.table[y_root]:
                self.table[x_root] += self.table[y_root]
                self.table[y_root] = x_root
            else:
                self.table[y_root] += self.table[x_root]
                self.table[x_root] = y_root
    
    def isDisjoint(self, x, y):
        return self.find(x) != self.find(y)


def solve():
    import sys
    file_input = sys.stdin
    from bisect import bisect_left
    
    while True:
        N, M = map(int, file_input.readline().split())
        if N == 0:
            break
        
        h = [int(file_input.readline()) for i in range(N)]
        
        # h_n's element: (remaining days, island number)
        h_n = list(zip(h, range(N)))
        h_n.sort()
        days, islands = zip(*h_n)
        
        bridges = []
        for i in range(M):
            a, b, c = map(int, file_input.readline().split())
            # change island numbering to 0-based
            a -= 1
            b -= 1
            d = min(h[a], h[b])
            bridges.append((a, b, c, d))
        bridges.sort(key=lambda x: x[3], reverse=True)
        
        i = N
        i_bridges = iter(bridges)
        a, b, c, d = next(i_bridges)
        S = UnionFind(N)
        limit_day = None
        while i > 0:
            i -= 1
            day = days[i]
            i = bisect_left(days, day)
            if day <= d:
                S.union(a, b)
                for a, b, c, d in i_bridges:
                    if day > d:
                        break
                    S.union(a, b)
            if i - N  in S.table:   # if islands are connected
                if limit_day == None:
                    limit_day = day
            else:
                limit_day = None
        
        if limit_day == None:
            print(0)
            continue
        
        bridges.sort(key=lambda x:(min(x[3], limit_day), -x[2]), reverse=True)
        
        S = UnionFind(N)
        cost = 0
        for a, b, c, d in bridges:
            if S.isDisjoint(a, b):
                S.union(a, b)
                cost += c
        
        print(cost)

solve()


Measured memory_bytes: 10240
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = Integer.parseInt(scanner.nextLine());
		
		int[] A = new int[n];
		
		String[] arrayStr = scanner.nextLine().split(" ");
		
		for (int i = 0; i < n; i++) {
			A[i] = Integer.parseInt(arrayStr[i]);
		}
		
		printArray(A);
		
		int v,j;
		for (int i = 1; i < n; i++) {
			v = A[i];
			j = i - 1;
			
			while (j >= 0 && A[j] > v) {
				A[j+1] = A[j];
				j--;
			}
			A[j+1] = v;
			
			printArray(A);	
		}
		
	}
	
	static void printArray(int[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0) {
				System.out.print(" ");
			}
			System.out.print(array[i]);
		}
		System.out.println();
	}
}


Measured memory_bytes: 33936
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int a[200010];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),mx=0,vl=0;
    for(int i=1;i<=n;i++)
	{
		a[i]=read();
		if(a[i]>mx)vl=mx,mx=a[i];
		else vl=max(vl,a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==mx)pr2(vl);
		else pr2(mx);
	}
    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<62);

int main() {
    cin>>Q;
    rep(_, Q){
        cin>>N;
        vec a(N);
        rep(i,N) cin>>a[i];
        cin>>S;
        bool zero = true;
        Rrep(i,N){
            if(S[i] == '1'){
                if(a[i] != 0){
                    zero = false;
                    break;
                }
            }else{
                if(a[i] == 0) continue;
                int min_bit = 0;
                rep(j, 61) {
                    if((a[i]>>j)&1) {
                        min_bit = j;
                        break;
                    }
                }
                Rrep(j,i){
                    if((a[j]>>min_bit)&1){
                        a[j] = a[j] ^ a[i];
                    }
                }
            }
        }
        cout<<(zero ? 0 : 1)<<endl;
    }
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using Card = pair<char, ll>;

void merge(vector<Card>& A, const int left, const int mid, const int right) {
    int n1 = mid - left, n2 = right - mid;

    vector<Card> l(n1 + 1), r(n2 + 1);
    rep(i, 0, n1) { l[i] = A[i + left]; }
    rep(i, 0, n2) { r[i] = A[i + mid]; }

    l[n1].second = 1000000000;
    r[n2].second = 1000000000;

    int i = 0, j = 0;
    rep(k, left, right) {
        if(l[i].second <= r[j].second) {
            A[k] = l[i++];
        } else {
            A[k] = r[j++];
        }
    }
}

void merge_sort(vector<Card>& A, const int left, const int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        merge_sort(A, left, mid);
        merge_sort(A, mid, right);
        merge(A, left, mid, right);  // O(n1 + n2)
    }
}

int partition(vector<Card>& A, const int p, const int r) {
    ll x = A[r].second;
    int i = p - 1;

    rep(j, p, r) {
        if (A[j].second <= x) {
            ++i;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

void quick_sort(vector<Card>& A, const int p, const int r) {
    if (p < r) {
        int q = partition(A, p, r);
        quick_sort(A, p, q - 1);
        quick_sort(A, q + 1, r);
    }
}

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

    vector<Card> A(n), B(n);
    rep(i, 0, n) {
        char c;
        ll d;
        cin >> c >> d;
        A[i] = make_pair(c, d);
        B[i] = make_pair(c, d);
    }

    quick_sort(A, 0, n - 1);
    merge_sort(B, 0, n);

    bool stable = true;
    rep(i, 0, n) {
        if (A[i].first != B[i].first) {
            stable = false;
            break;
        }
    }

    cout << (stable ? "Stable" : "Not stable") << endl;
    rep(i, 0, n) {
        cout << A[i].first << " " << A[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 7404
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N, M;
    scan(N, M);

    priority_queue<int> que;
    vector<vector<int>> v(M + 1, vector<int>());
    REP(i, N) {
        int a, b;
        scan(a, b);
        if (a <= M)
            v[a].emplace_back(b);
    }
    ll ans = 0;
    REP(i, M + 1) {
        for (auto &&j : v[i]) {
            que.push(j);
        }
        if (!que.empty()) {
            ans += que.top();
            que.pop();
        }
    }
    print(ans);

    return 0;
}

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

import math

# 入力
N = int(input())
S = input()

l = int(N/2)

if N % 2 == 1 :
  print ("No")
else :
  if S[0:l] == S[l:N] :
    print ("Yes")
  else :
    print ("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
char s[1000];
int main()
{
	int i,j,k;
	int n,m;
	scanf("%d%d%d",&n,&m,&k);
	int ok=0;
	for(i=0;i<=n;i++)
		for(j=0;j<=m;j++)
			if(k==i*j+(n-i)*(m-j))
				ok=1;
	if(ok) printf("Yes");
	else printf("No");
	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public int[] e;
        public ArrayList<ArrayList<Integer>> m;
        public static int MAX = Integer.MAX_VALUE;

        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int rooms = in.nextInt();
            int loads = in.nextInt();

            e = new int[rooms];
            Arrays.fill(e, MAX);

            m = new ArrayList<>();
            for (int i = 0; i < e.length; i++) {
                m.add(new ArrayList<>());
            }

            for (int i = 0; i < loads; i++) {
                int src = in.nextInt() - 1;
                int dist = in.nextInt() - 1;

                (m.get(src)).add(dist);
                (m.get(dist)).add(src);

            }

            bfs(0);
            for (int i = 1; i < rooms; i++) {
                if (e[i] == MAX) {
                    out.append("No");
                    return;
                }
            }

            out.append("Yes\n");
            for (int i = 1; i < rooms; i++) {
                out.append(e[i] + "\n");
            }
        }

        public void bfs(int s) {

            ArrayDeque<Integer> q = new ArrayDeque<>();
            q.push(s);
            e[s] = 0;
            int u;
            while (!q.isEmpty()) {
                u = q.poll();

                ArrayList<Integer> t = m.get(u);
                for (Integer v : t) {
                    if (e[v] != MAX) {
                        continue;
                    }
                    e[v] = u + 1;
                    q.offer(v);
                }
            }
        }

    }
}



Measured memory_bytes: 76296
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        if (a.equals(b)) System.out.println("=");
        else if (a.compareTo(b) > 0) System.out.println(">");
        else System.out.println("<");
    }
}

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

using namespace std;

typedef long long ull;

const ull P1 = 1000532779;
const ull P2 = 1777777777;
const ull B1 = 1000000009;
const ull B2 = 1000000007;
int main()
{
    char s[300001];
    static pair<ull, ull> hs[300001], pow[300001];
    int n, m;
    
    scanf("%d %d", &n, &m);
    scanf("%s", s);
    
    hs[0] = make_pair(0, 0);
    pow[0] = make_pair(1, 1);
    
    for (int i = 0; s[i]; i++){
        hs[i + 1] = make_pair((hs[i].first * B1 + s[i]) % P1, (hs[i].second * B2 + s[i]) % P2);
        pow[i + 1] = make_pair(pow[i].first * B1 % P1, pow[i].second * B2 % P2);
    }
    
    set<pair<ull, ull> > se;
    
    int left = 0, right = 0;
    for (int i = 0; i < m; i++){
        char t[4];
        scanf("%s", t);
        
        if (t[0] == 'L' && t[1] == '+') left++;
        if (t[0] == 'R' && t[1] == '+') right++;
        if (t[0] == 'L' && t[1] == '-') left--;
        if (t[0] == 'R' && t[1] == '-') right--;
        
        
        pair<ull, ull> L = hs[left], R = hs[right + 1];
        
        se.insert(make_pair((R.first - (L.first * pow[right - left + 1].first) % P1 + P1) % P1, (R.second - (L.second * pow[right - left + 1].second) % P2 + P2) % P2));
    }
    
    printf("%d\n", se.size());
    
    return (0);
}

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

const int MOD = 1000000007;
const int MAX = 2000004;

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

void COMinit() {
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  rep(i, MAX) {
    if (i==0||i==1) continue;
    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 COM(int n, int k) {
  if (n<k) return 0;
  if (n<0||k<0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main() {
  int x,y; cin>>x>>y;
  ll p=2*y-x;
  ll q=2*x-y;
  bool frag=false;
  if (p%3!=0||q%3!=0) frag=true;
  COMinit();
  ll ans=0;
  if (!frag) ans=COM((int)((p+q)/3), int(min(p, q)/3));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 47104
import heapq
import sys
input = sys.stdin.readline

# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
q = []
q = [(-b, i) for i, b in enumerate(B)]
heapq.heapify(q)
ans = 0
N_m1 = N-1
while len(q)>0:
    b, idx = q[0]
    b = -b
    b_p1, b_m1 = B[idx+1 if idx<N_m1 else 0], B[idx-1]
    d = b_p1 + b_m1

    a = A[idx]
    p = min((b-a)//d, (b-b_m1)//d+1, (b-b_p1)//d+1)

    b -= p * d
    B[idx] = b
    ans += p
    if b > a:
        heapq.heapreplace(q, (-b, idx))
        if q[0][1] == idx:
            print(-1)
            exit()
    else:
        heapq.heappop(q)
print(ans)


Measured memory_bytes: 123596
#include <bits/stdc++.h>
#define ref(i,n) for(int i=0;i<n;i++)
using namespace std;
const double pai=3.14159265358979323;
int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double an=2*pai/720*(h*60+m)-2*pai/60*m;
    if (an<0) an=-an;
    if(an>pai) an=2*pai-an;

    cout<<setprecision(20)<<pow(a*a+b*b-2*a*b*cos(an),0.5);
    return 0;

}


Measured memory_bytes: 4332
import numpy as np
n,c,k=map(int,input().split())
t=list(int(input()) for _ in range(n))
t.sort()
t=np.array(t)
s=0
num=0
while True:
    e=np.searchsorted(t,t[s]+k,side="right")
    if e-s>c:
        s=s+c
    else:
        s=e
    num+=1
    if s>n-1:
        break
print(num)

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

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

int main(){
  int n,i;
  cin >> n;
  vector<int> a(n);
  vector<int> ans(n-1);
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  ans[0]=divisor(a[0],a[1]);
  for(i=1;i<n-1;i++){
    ans[i]=divisor(ans[i-1],a[i+1]);
  }
  cout << ans[n-2] << endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, m = mi()
    liked = set(range(1, m+1))
    for _ in range(n):
        L = lmi()
        liked = liked.intersection(L[1:])
        # print(liked)
    print(len(list(liked)))




if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
s = int(input())
if(s==1 or s==2 or s==4):
  print(4)
else:
  c = 1
  while(1):
    if(s == 4):
      break  
    if(s % 2 == 1):
      s = 3*s+1
    else:
      s = s/2
    c=c+1
  print(c+3)

Measured memory_bytes: 3060
using System;
using System.Linq;
using static System.Console;

namespace AtCoder1
{
	class Program
	{
		static void Main(string[] args)
		{
			int N = int.Parse(ReadLine());
			int[] H = ReadLine().Split().Select(s => int.Parse(s)).ToArray();

			int[] dp = Enumerable.Repeat(-1, N).ToArray();

			dp[0] = 0;
			dp[1] = Math.Abs(H[0] - H[1]);

			for(int i=2; i<N; ++i)
			{
				int a = dp[i - 1] + Math.Abs(H[i] - H[i - 1]);
				int b = dp[i - 2] + Math.Abs(H[i] - H[i - 2]);
				dp[i] = Math.Min(a, b);
			}

			WriteLine(dp[N-1]);
		}
    }
}

Measured memory_bytes: 21216
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(n);
// string p=s.substr(0,len);
// string q=s.insert(0,str);
// sort(arr, arr+n, greater<int>());
// cout<<fixed<<setprecision(9)<<pi<<endl
// const  double pi = acos(-1.0);
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	char c;
	cin>>c;
	if(int(c)>=65 && int(c)<=90)
	{
		cout<<'A'<<endl;
	}	
	else
	{
		cout<<'a'<<endl;
	}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll n,m; cin>>n>>m;
    vector<ll> a(n), s(n+1);
    rep(i,n) cin>>a[i];

    rep(i,n) {
        s[i+1] = (s[i]+a[i])%m;
        s[i+1] %= m;
    }

    map<ll,ll> mp;
    ll ans = 0;

    rep(i,n+1) {
        if (!mp.count(s[i])) mp[s[i]]++;
        else {
            ans += mp[s[i]];
            mp[s[i]]++;
        }
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 5760
//56
#include<iostream>
#include<cstdlib>
#include<algorithm>

using namespace std;

int main(){
  int D,N;
  cin>>D>>N;
  int T[200];
  for(int i=0;i<D;i++){
    cin>>T[i];
  }
  int A[200],B[200],C[200];
  for(int i=0;i<N;i++){
    cin>>A[i]>>B[i]>>C[i];
  }
  int dp[200][200];
  fill(dp[0],dp[200],1<<31);
  for(int i=0;i<N;i++){
    if(A[i]<=T[0]&&T[0]<=B[i]){
      dp[0][i]=0;
    }
  }
  for(int i=1;i<D;i++){
    for(int j=0;j<N;j++){
      if(A[j]<=T[i]&&T[i]<=B[j]){
	for(int k=0;k<N;k++){
	  dp[i][j]=max(dp[i][j],dp[i-1][k]+abs(C[j]-C[k]));
	}
      }
    }
  }
  cout<<*max_element(dp[D-1],dp[D])<<endl;
  return 0;
}

Measured memory_bytes: 1316
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  cin >>N;
  vector<int>vec(N);
  rep(i,N) {
cin >>vec.at(i);
  }
  
  sort(all(vec));
  int sum=0;
  rep(i,N-1) {
    sum +=vec.at(i);
  }
  if(sum>vec.at(N-1) ) {
    cout <<"Yes"<< endl;
  }
else {
  cout <<"No"<< endl;
}
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

ll modpow(ll a, ll p) {
    if(p == 0)
        return 1;
    if(p % 2 == 0) {
        ll halfp = p / 2;
        ll half = modpow(a, halfp);
        return half * half % MOD;
    } else {
        return a * modpow(a, p - 1) % MOD;
    }
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while(b) {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if(u < 0)
        u += m;
    return u;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> cnt;
    REP(i, N) {
        cin >> A[i];
        REP(j, 61) {
            if(!(A[i] & (1LL << j))) {
                cnt[j]++;
            }
        }
    };

    ll ans = 0LL;
    REP(j, 61) {
        ll tmp = cnt[j] * (N - cnt[j]) % MOD;
        ans += (tmp * modpow(2LL, j)) % MOD;
        ans %= MOD;
    }

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

Measured memory_bytes: 2560