akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int mod = 1e9 + 7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


const int MAX = 2000;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % mod;
    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}

// 二項係数計算
ll 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 s;
  cin >> s;

  COMinit();

  mint ans = 0;
  for (int i = 1; i <= s/3; i++) {
    ans += COM(s - 2*i - 1, i - 1);
  }

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

Measured memory_bytes: 3680
H, W = gets.split.map(&:to_i)

data = []
H.times do
  data << gets.chomp
end

H.times do |i|
  W.times do |j|
    if data[i][j] == '#'
      found = false

      # up
      found = true if i != 0 && data[i - 1][j] == '#'
      # bottom
      found = true if i != H - 1 && data[i + 1][j] == '#'
      # left
      found = true if j != 0 && data[i][j - 1] == '#'
      # right
      found = true if j != W - 1 && data[i][j + 1] == '#'

      unless found
        puts 'No'
        exit
      end
    end
  end
end

puts 'Yes'

Measured memory_bytes: 1788
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/aoj1176/input.txt"));
			//System.setOut(new PrintStream(new FileOutputStream("src/aoj1172/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}

	int [][] table;
	int R, C, S, K;

	int psum[][];
	int range(int r1, int c1, int r2, int c2) {
		return psum[r2][c2] - psum[r1][c2] - psum[r2][c1] + psum[r1][c1];
	}

	Scanner sc;
	void run() {
		sc = new Scanner(System.in);
		for (;sc.hasNext();) {
			R = sc.nextInt();
			C = sc.nextInt();
			S = sc.nextInt();
			if (R == 0) break;
			table = new int[R][C];

			psum = new int[R+1][C+1];
			for (int r = 0; r < R; r++)
				for (int c = 0; c < C; c++)
					table[r][c] = sc.nextInt();

			for (int r = 0; r < R; r++)
				for (int c = 0; c < C; c++)
					psum[r+1][c+1] = psum[r+1][c] + psum[r][c+1] - psum[r][c] + table[r][c];

			solve();
		}
	}

	final long mask = (1L << 31) - 1;
	long dp[][][][];
	long dp(int r1, int c1, int r2, int c2) {
		if (dp[r1][c1][r2][c2] != 0)
			return dp[r1][c1][r2][c2];
		long best_g = 1;
		long best_k = range(r1, c1, r2, c2);

		long res = (best_g << 31) + best_k;
		for (int r = r1 + 1; r < r2; r++) {
			long p1 = dp(r1, c1, r, c2);
			long p2 = dp(r, c1, r2, c2);

			long cur_g = (p1 + p2) >> 31;
			long cur_k = min(p1 & mask, p2 & mask);
			if (cur_k >= K)
				res = max(res, (cur_g << 31) + cur_k);
		}

		for (int c = c1 + 1; c < c2; c++) {
			long p1 = dp(r1, c1, r2, c);
			long p2 = dp(r1, c, r2, c2);

			long cur_g = (p1 + p2) >> 31;
			long cur_k = min(p1 & mask, p2 & mask);
			if (cur_k >= K)
				res = max(res, (cur_g << 31) + cur_k);
		}

		return dp[r1][c1][r2][c2] = res;
	}
	void solve(){
		int total = range(0,0,R,C);
		K = total - S;
		dp = new long[R][C][R+1][C+1];
		long res = dp(0,0,R,C);

		long best_g = res >> 31;
		long best_k = res & ((1 << 31) - 1);
		System.out.println(best_g + " " + (S - total + best_k));
		return;
	}

	void tr(Object... os) {
		System.err.println(deepToString(os));
	}
}

Measured memory_bytes: 34000
import java.util.Scanner;

class Circle {
	private double x;
	private double y;
	private double r;

	Circle(double x, double y, double r) {
		setX(x);
		setY(y);
		setR(r);
	}

	public void setX(double x) {
		this.x = x;
	}

	public void setY(double y) {
		this.y = y;
	}

	public void setR(double r) {
		this.r = r;
	}

	public double getX() {
		return x;
	}
	public double getY() {
		return y;
	}
	public double getR() {
		return r;
	}

}

public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = (int)sc.nextDouble();

		for (int i = 0; i < n; i++) {
			Circle c0 = new Circle(sc.nextDouble(), sc.nextDouble(), sc.nextDouble());
			Circle c1 = new Circle(sc.nextDouble(), sc.nextDouble(), sc.nextDouble());

			c_Intersection(c0, c1);
		}

	}

	private static void c_Intersection(Circle c0, Circle c1) {
		double d = Math.pow(c0.getX() - c1.getX(), 2) + Math.pow(c0.getY() - c1.getY(), 2);

		if (d < Math.pow(c0.getR() - c1.getR(), 2)) {

			if (c0.getR() >= c1.getR()) {
				System.out.println(2);
			} else {
				System.out.println(-2);
			}

		} else if ( d <= Math.pow(c0.getR() + c1.getR(), 2)) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}

	}

}


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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int k;
  const int max_k = 1e6;
  cin >> k;
  int a[max_k + 1];
  for(int i = 0; i <= k; i++){
    if(i == 0) a[i] = 7 % k;
    else {
      a[i] = (10*a[i-1] + 7) % k;
    }
    if(a[i] == 0){
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;


  return 0;
}

Measured memory_bytes: 7528
s = list(input())

a = ['1', '0']*10**5
b = ['0', '1']*10**5

A = a[:len(s)]
B = b[:len(s)]
cnt = 0
ans = 0
for i in range(len(s)):
    if s[i] != A[i]:
        cnt += 1
    if s[i] != B[i]:
        ans += 1
print(min(cnt, ans))

Measured memory_bytes: 8620
#include<stdio.h>
int main(void){
    int a,b,c,tmp;
    scanf("%d %d %d",&a,&b,&c);
    if(a ==5 && b == 5 && c ==7){
        puts("YES");
    }
    else if (a == 5 && b == 7 && c == 5)
    {
        puts("YES");
    }
    else if (a == 7 && b == 5 && c == 5)
    {
         puts("YES");
    }
    else{
        puts("NO");
    }
    return 0;
    
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    if(a>0)
      cout<<"Positive";               
    else if(b>=0)
      cout<<"Zero";             
    else
      if((a&1)^(b&1))
        cout<<"Positive";  
    else 
      cout<<"Negative";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define mod 998244353
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n,k;
int arr[100000+9];
int dp[100000][100];
int solve(int ind , int last) {
    if (ind == n) {
        if(last == 1)
            return 0;
        return 1e9;
    }
    if(dp[ind][last] != -1)
        return dp[ind][last];
    int a = 1e9;
    if(last+1 <= k){
        a = min(solve(ind+1,last+1),solve(ind+1,1)+abs(arr[ind]-arr[ind-last]));
    }else{
        a = solve(ind+1,1)+abs(arr[ind]-arr[ind-last]);
    }
    return dp[ind][last] = a;
}
int main() {
    cin>>n>>k;
    for(int i = 0;i<n;i++){
        cin>>arr[i];
    }
    memset(dp,-1, sizeof(dp));
    cout<<solve(0,0);
    return 0;
}


Measured memory_bytes: 44416
n, k = map(int, input().split())
s = [int(i) for i in range(0, n+1)]
mod = 10**9+7
ans = 1
mn = 0
mx = 0
i = 0
for _ in range(k+1, n+2):
    mn += s[i]
    mx += s[-i-1]
    ans += mx - mn + 1
    i += 1
print(ans%mod)

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

int main() {
	string s;
	int sum = 700;
	cin >> s;
	if (s.at(0) == 'o')sum += 100;
	if (s.at(1) == 'o')sum += 100;
	if (s.at(2) == 'o')sum += 100;
	cout << sum << endl;
	return 0;

}

Measured memory_bytes: 256
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector           as VB

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

getIntegerVec n =
  VB.unfoldrN n (BS.readInteger . BS.dropWhile isSpace) <$> BS.getLine

main = do
  n <- getInt
  as <- getIntegerVec n
  let m = VB.foldr' lcm 1 as
      as' = VB.map (\i -> m `div` i) as
  print $ (VB.sum as') `mod` 1000000007

Measured memory_bytes: 2684
import math
sin60 = math.sin(60*math.pi/180)
def koch(n,p1,p2):
    if n==0:
        return
    s = [(2*p1[0]+1*p2[0])/3., (2*p1[1]+1*p2[1])/3.]
    t = [(1*p1[0]+2*p2[0])/3., (1*p1[1]+2*p2[1])/3.]
    u = [(t[0]-s[0])*0.5 - (t[1]-s[1])*sin60+ s[0],
        (t[0]-s[0])*sin60 + (t[1]-s[1])*0.5 + s[1]]
    koch(n-1,p1,s)
    print s[0],s[1]
    koch(n-1,s,u)
    print u[0],u[1]
    koch(n-1,u,t)
    print t[0],t[1]
    koch(n-1,t,p2)
       
n = int(raw_input())
p1 = (0,0)
p2 = (100,0)
print p1[0],p1[1]
koch(n,p1,p2)
print p2[0],p1[1]

Measured memory_bytes: 4468
def main():
    n, m, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]

    acum = [0] * (n + 1)
    bcum = [0] * (m + 1)
    for i in range(n):
        acum[i + 1] = acum[i] + a[i]
    for i in range(m):
        bcum[i + 1] = bcum[i] + b[i]
        
    j = m
    maxv = 0
    for i in range(n+1):
        if acum[i] > k:
            break
        while acum[i] + bcum[j] > k:
            j -= 1
        maxv = max(maxv, i + j)
    print(maxv)

if __name__ == '__main__':
    main()

Measured memory_bytes: 47480
#include <iostream>
#include <vector>
#include <string>

int main(int argc, char* argv[])
{
  std::string s;
  std::cin >> s;

  bool judge = true;
  std::string::iterator it;
  it = s.begin();
  if (*it != 'A' || s[1] < 'a' || s[1] > 'z') {
    judge = false;
  }
  it++;

  for (; it != s.end(); it++) {
    if ((*it < 'a' || *it > 'z') && *it != 'C') {
      judge = false;
      break;
    }
  }

  int cnt = 0;
  for (int i = 2; i < s.size() - 1; i++) {
    if (s[i] == 'C') {
      cnt++;
    }
  }

  bool judge2 = cnt == 1 ? true : false;
  std::cout << (judge && judge2 ? "AC" : "WA") << std::endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
axis = []

for i in range(N) :
    x, y, h = map(int, input().split())
    axis.append((x, y, h))

def sol() :
    for cx in range(0, 101) :
        for cy in range(0, 101) :
            axis.sort(key = lambda A : abs(A[0] - cx) + abs(A[1] - cy))
            H = axis[0][2] + abs(axis[0][0] - cx) + abs(axis[0][1] - cy)
            for x, y, h in axis :
                if not h == max(H - abs(x - cx) - abs(y - cy), 0) :
                    break
            else :
                return (cx, cy, H)
    return (-1, -1, -1)

cx, cy, H = sol()
if cx == -1 :
    print('-1')
else :
    print('{} {} {}'.format(cx, cy, H))


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


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

    //sort(A.begin(), A.end());
    //sort(B.begin(), B.end());

    if(A == B) cout << 0 << endl;
    else{
        long long ans = accumulate(A.begin(), A.end(), (long long) 0);
        long long min_B = 1e+9;
        REP(i, N){
            if(A[i] > B[i]) min_B = min(min_B, B[i]);
        }
        cout << ans-min_B << endl;
    }

    return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
    cin.tie();
    
    int n,d;
    cin>>n>>d;
    ll x[n],y[n];
    for(i=0;i<n;i++){
    	cin>>x[i]>>y[i];
	}
	int ans=0;
	for(i=0;i<n;i++){
		long double distanse=sqrt(x[i]*x[i]+y[i]*y[i]);
		if(distanse==0.0){
		    ans++;	
		    goto pass;
		}
		if(distanse+eps<=d)ans++;
		pass:
			j++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6756
n = int(input())

match_num=0

for i in range(n):
  d1,d2 = map(int,input().split())
  if(d1 == d2):
    match_num += 1
  else:
    match_num = 0
  if(match_num == 3):
    print("Yes")
    exit()

print("No")

Measured memory_bytes: 62428
N,A,B,C,D =list(map(int,input().split()))
s=input()

if "##" in s[A-1:max(C,D)]:
  print("No")
  quit()
st,e=0,0

for spl in s.split("##"):
  e += (len(spl)+2)
  if st <A<max(C,D)<=e:
    break
  st+= (len(spl)+2)

if "..." in s[B-2:min(C,D)+1] or B<C<D:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 41584
n = int(input())
a = ''

while n > 0:
    if n%26 == 1:
        a += 'a'
    elif n%26 == 2:
        a += 'b'
    elif n%26 == 3:
        a += 'c'
    elif n%26 == 4:
        a += 'd'
    elif n%26 == 5:
        a += 'e'
    elif n%26 == 6:
        a += 'f'
    elif n%26 == 7:
        a += 'g'
    elif n%26 == 8:
        a += 'h'
    elif n%26 == 9:
        a += 'i'
    elif n%26 == 10:
        a += 'j'
    elif n%26 == 11:
        a += 'k'
    elif n%26 == 12:
        a += 'l'
    elif n%26 == 13:
        a += 'm'
    elif n%26 == 14:
        a += 'n'
    elif n%26 == 15:
        a += 'o'
    elif n%26 == 16:
        a += 'p'
    elif n%26 == 17:
        a += 'q'
    elif n%26 == 18:
        a += 'r'
    elif n%26 == 19:
        a += 's'
    elif n%26 == 20:
        a += 't'
    elif n%26 == 21:
        a += 'u'
    elif n%26 == 22:
        a += 'v'
    elif n%26 == 23:
        a += 'w'
    elif n%26 == 24:
        a += 'x'
    elif n%26 == 25:
        a += 'y'
    elif n%26 == 0:
        a += 'z'
        n -=26
    n = int(n / 26)
a = a[::-1]
print(a)
    

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

int main() {
    int n, m; cin >> n >> m;
    vector<string> a(n);
    
    vector<int> f(26, 0);

    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        for(int j = 0; j < m; ++j) {
            f[a[i][j] - 'a'] += 1;
        }
    }
    
    bool ok = true;

    if(n % 2 == 0 and m % 2 == 0) {
        for(int i = 0; i < 26; ++i) 
            if(f[i] % 4 != 0)
                ok = false;
    } else if(n % 2 + m % 2 == 1) {
        int twos = 0;
        for(int i = 0; i < 26; ++i) {
            if(f[i] % 4 == 1 or f[i] % 4 == 3)
                ok = false;
            if(f[i] % 4 == 2)
                twos += 1;
        }
        
        int who = n;
        if(n % 2)
            who = m;
        if(twos > who / 2) {
            ok = false;
        }
    } else {
        int odds = 0;

        for(int i = 0; i < 26; ++i) {
            if(f[i] % 2) {
                f[i] -= 1;
                odds += 1;

            }
        }

        if(odds != 1) {
            ok = false;
        }

        int twos = 0;

        for(int i = 0; i < 26; ++i) {
            if(f[i] % 4 == 2) {
                twos += 1;
            }
        }

        if(twos > n / 2 + m / 2) {
            ok = false;
        }
    }

    if(ok) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

Measured memory_bytes: 256
N = int(input())
A = []
B = []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a); B.append(b)

A.sort(); B.sort()
if N % 2 == 1:
  n = N // 2
  a, b = A[n], B[n]
  print(b - a + 1)
else:
  n = N // 2
  a0, b0 = A[n-1], B[n-1]
  a1, b1 = A[n], B[n]
  left = a0 + a1; right = b0 + b1
  print(right - left + 1)


Measured memory_bytes: 25548
N=int(input())
list=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list[N-1])

Measured memory_bytes: 3060
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    a,b,c = input().split()
    if a[-1]==b[0] and b[-1]==c[0]:
        print("YES")
    else:
        print("NO")
    return

if __name__=='__main__':
    main()


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

using namespace std;
using ll = long long;


inline ll Calcu(ll a,ll b){
    return min(a, b);
}

class SegTree{
    public:
        ll n;
        ll g;
        std::vector<ll> data;
 
        SegTree(std::vector<ll> a, ll _g){
            g = _g;
            for (n = 1; n < (ll) a.size(); n *= 2);
            data.resize(n * 2, g);
        }
 
        ll rec(ll l, ll r, ll node, ll node_l, ll node_r, ll val) {
            if (node_r <= l || node_l >= r) return g;
            if (node_l >= l && node_r <= r) return data[node] = min(data[node], val);
            ll mid = (node_l + node_r) / 2;
            return Calcu(
                rec(l, r, node * 2, node_l, mid, val),
                rec(l, r, node * 2 + 1, mid, node_r,val));
        }
 
        void query(ll l,ll r, ll val){
            rec(l,r,1,0,n,val);
        }
 
        ll get(ll index){
            ll res = data[index += n];
            for(;index /= 2;)
                res = min(res, data[index]);
            return res;
        }
};
const ll INF = 1e17;


int main()
{
    int n, m; cin >> n >> m;
    vector<tuple<int,int,ll>> q(m);
    for(int i = 0; i < m; i++) {
        int a, b, c; cin >> a >> b >> c;
        a--, b--;
        q[i] = tie(a, b, c);
    }

    sort(q.begin(), q.end());
    SegTree tree(vector<ll>(n, INF), INF);
    tree.query(0, 1, 0);

    for(int i = 0; i < m; i++) {
        ll a, b, c;tie(a, b, c) = q[i];
        tree.query(a + 1, b + 1, tree.get(a) + c);
    }
    cout << (tree.get(n - 1) == INF ? -1 : tree.get(n - 1))<< endl; 
}

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

int N;
map<int, int> mp;

int main()
{
    cin >> N;

    for (int i = 1; i <= N; i++)
    {
        int x;
        cin >> x;
        mp[i] = x;
    }

    int t = 0;
    int i = mp[1];
    bool reach = false;
    int cnt = 1;
    
    while (t < N)
    {
        if (i == 2)
        {
            reach = true;
            break;
        }
        else
        {
            i = mp[i];
            t++;
            cnt++;
        }
    }
    if (reach)
        cout << cnt << endl;
    else
        cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
string s,t;
int main(){
    cin>>s>>t;
    for(int i=0;i<s.size();i++){
        rotate(s.begin(),s.begin()+1,s.end());
        if(s==t){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		int[] at = new int[n];
		int[] bt = new int[m];
		
		for(int i = 0; i < n; i++) {
			at[i] = sc.nextInt();
		}
		
		for(int i = 0; i < m; i++) {
			bt[i] = sc.nextInt();
		}
		
		for(int i = x+1; i <= y; i++) {
			int count = 0;
			for(int a : at) {
				if(a < i) {
					count++;
				}
			}
			
			for(int b : bt) {
				if(b >= i) {
					count++;
				}
			}
			
			if(count == bt.length+at.length) {
				System.out.println("No War");
				return;
			}

		}
		System.out.println("War");
	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

using ll = long long;

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

typedef pair<int, int> P;

const int MOD = (int) 1e9 + 7;

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

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

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

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

int n;
int a[200005], b[200005];

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> n;
	REP(i, n) cin >> a[i];
	REP(i, n) cin >> b[i];
	
	int ans = 0;
	REP(i, 30) {
		vector<int> v;
		REP(j, n) v.push_back(b[j] % (1 << (i + 1)));
		REP(j, n) v.push_back((1 << (i + 1)) + b[j] % (1 << (i + 1)));
		sort(ALL(v));
		
		int cnt = 0;
		REP(j, n) {
			int low1 = lower_bound(ALL(v), (4 << i) - a[j] % (1 << (i + 1))) - v.begin();
			int low2 = lower_bound(ALL(v), (3 << i) - a[j] % (1 << (i + 1))) - v.begin();
			cnt += low1 - low2;
			cnt %= 2;
		}
		ans += cnt << i;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 5676
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    rep(i,s.size()){
        cout << 'x';
    }
    cout << endl;
    return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(s, w);
    if (w >= s) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }

    return 0;
}


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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define count(v,x) count(v.begin(),v.end(),x)
#define find(v,x) find(v.begin(),v.end(),x)


priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

int n;
string s;

void solve(){
    cin >> n;
    cin >> s;
    int ans=0;
    for(char v1='0';v1<='9';v1++){
        for(char v2='0';v2<='9';v2++){
            for(char v3='0';v3<='9';v3++){
                string t;
                t+=v1;
                t+=v2;
                t+=v3;
                int p=0;
                for(int l=0;l<n;l++){
                    if(s[l]==t[p])p++;
                    if(p==3)break;
                }
                if(p==3)ans++;
            }
        }
    }
    cout << ans << endl;
}

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





Measured memory_bytes: 3740
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var a, b int
	fmt.Fscan(read, &a, &b)
	fmt.Fprintln(write, max(a+b, max(a-b, a*b)))
}


Measured memory_bytes: 640
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
s = ""
N = int(input())
if N == 0:
    print(0)
else:
    while N != 0:
        x = N % (-2)
        if x == 0:
            s = "0"+s
            N = N // (-2)
        else:
            N = N//(-2)+1
            s = "1" + s

    print(s)

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

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,A,B;
	cin >> N >> A >> B;
	vector<int> a(N);
	rep(i,N)cin >> a[i];
	int ans;
	if(N==1)ans = abs(a[0]-B);
	else {
		ans = abs(B-a[N-1]);
		ans = max(ans,abs(a[N-2]-a[N-1]));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def main():
  #n = int(input())
  s = input()
  #s = input().split()
  #a,b = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = 0
  count = 0
  lis = []
  
  if s == "A" or s == "T":
    print("AT".replace(s,""))
  else:
    print("CG".replace(s,""))
    

if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

ll func(ll x) {
  if (x % 2 != 0) return 0;
  return 1 + func(x/2);
} 

void solve() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll ans = 0;
  rep(i,n) {
    ans += func(a[i]);
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    string S, T; cin >> S >> T;

    bool ok = true;
    vector<char> p(26, ' ');
    vector<char> q(26, ' ');
    REP(i, 0, S.size()) {
        if (p[T[i] - 'a'] == ' ') p[T[i] - 'a'] = S[i];
        else if (p[T[i] - 'a'] != S[i]) ok = false;

        if (q[S[i] - 'a'] == ' ') q[S[i] - 'a'] = T[i];
        else if (q[S[i] - 'a'] != T[i]) ok = false;
    }

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

Measured memory_bytes: 776
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	ans := make([]int, 3)
	ans[0], _ = strconv.Atoi(stringLineScan())
	ans[1], _ = strconv.Atoi(stringLineScan())
	ans[2], _ = strconv.Atoi(stringLineScan())
	for i := 1; i < n; i++ {
		t := make([]int, 3)
		a, _ := strconv.Atoi(stringLineScan())
		b, _ := strconv.Atoi(stringLineScan())
		c, _ := strconv.Atoi(stringLineScan())
		t[0] = max(ans[1], ans[2]) + a
		t[1] = max(ans[2], ans[0]) + b
		t[2] = max(ans[0], ans[1]) + c
		ans[0], ans[1], ans[2] = t[0], t[1], t[2]
	}
	fmt.Println(maximum(ans))
}
func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}
func maximum(x []int) int {
	y := x[0]
	for _, i := range x {
		if y < i {
			y = i
		}
	}
	return y
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

using tp = tuple<int, int, int>;

int main() {
    int H, W, ch, cw, dh, dw; cin >> H >> W >> ch >> cw >> dh >> dw; ch--, cw--, dh--, dw--;
    vector<vector<char>> g(H, vector<char>(W));
    rep(i, H) rep(j, W) cin >> g[i][j];
    vector<vector<int>> seen(H, vector<int>(W, -1));
    priority_queue<tp, vector<tp>, greater<tp>> q;
    q.push(make_tuple(0, ch, cw));
    while(q.size()) {
        auto now = q.top(); q.pop();
        int nowc = get<0>(now), nowh = get<1>(now), noww = get<2>(now);
        if(seen[nowh][noww] != -1) continue;
        seen[nowh][noww] = nowc;
        Rep(i, -2, 3) {
            Rep(j, -2, 3) {
                int nc = nowc;
                int nh = nowh + i;
                int nw = noww + j;
                if(nh<0||H<=nh||nw<0||W<=nw) continue;
                if(seen[nh][nw] != -1) continue;
                if(g[nh][nw] == '#') continue;
                if(abs(i) + abs(j) > 1) nc++;
                q.push(make_tuple(nc, nh, nw));
            }
        }
    }
    //rep(i, H) {rep(j, W) cout << seen[i][j]; cout << endl;}
    cout << seen[dh][dw] << endl;
}


Measured memory_bytes: 9228
from collections import deque
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
k=0
ans=0
for i in range(N-1):
    ans+=A[k]
    if i%2==0:
        k+=1
print(ans)
'''
9
9 8
9 8 7
9 6 8 7
9 6 8 7 5
9 6 8 4 7 5
9 3 6 8 4 7 5
9 3 6 2 8 4 7 5
9 3 6 2 8 4 7 1 5
9+8+8+7+7+6+6+5
'''




Measured memory_bytes: 93296
program prob4
    implicit none
    integer::n, i
    integer(16)::t, ans, a, b, c
    read(*,*) n
    read(*,*) t
    ans = t
    do i = 2, n
        read(*,*) t
        a = ans
        b = t
        c = mod(a,b)
        do while(c > 0)
            a = b
            b = c
            c = mod(a,b)
        end do
        ans = ans/b*t
    end do
    write(*,*) ans
    stop
end program

Measured memory_bytes: 2732
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().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')

#A
def A():
    s = S()
    s.append("o")
    a = s.count("o")-1
    print(700+a*100)
    return

#B
def B():
    n, x = LI()
    m = IR(n)
    m.sort()
    msum = sum(m)
    print(n + (x - msum) // m[0])
    return

#C
def C():
    a, b, c, x, y = LI()
    if c * 2 > a + b:
        print(x * a + y * b)
        return
    if x > y:
        if c * 2 > a:
            print(c * 2 * y + (x - y) * a)
            return
        print(c * 2 * x)
        return
    if c * 2 > b:
        print(c * 2 * x + (y - x) * b)
        return
    print(c * 2 * y)

    return

#D
def D():
    n, c = LI()
    clock_wise = [0] * n
    clock_wise_max = [0] * n
    clock_wise_rev = [0] * n
    clock_wise_rev_max = [0] * n
    xv = LIR(n)
    clock_wise[0] = xv[0][1] - xv[0][0]
    clock_wise_rev[-1] = - c + xv[-1][1] + xv[-1][0]
    for i in range(1, n):
        clock_wise[i] = clock_wise[i - 1] + xv[i][1] - xv[i][0] + xv[i - 1][0]
        clock_wise_rev[-i - 1] = clock_wise_rev[-i] + xv[-i - 1][1] + xv[-i - 1][0] - xv[-i][0]
    clock_wise_max[0] = clock_wise[0]
    clock_wise_rev_max[-1] = clock_wise_rev[-1]
    for i in range(1,n):
        clock_wise_max[i] = max(clock_wise[i], clock_wise_max[i - 1])
        clock_wise_rev_max[-i - 1] = max(clock_wise_rev[-i - 1], clock_wise_rev_max[-i])
    ans = max(0, max(clock_wise), max(clock_wise_rev))
    for i in range(n - 1):
        ans = max(ans, clock_wise[i] + clock_wise_rev_max[i + 1] - xv[i][0])
        ans = max(ans, clock_wise_rev[-i - 1] + clock_wise_max[-i - 2] - (c - xv[-i - 1][0]))
    print(ans)
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 63708
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		long a = scn.nextLong(), b = scn.nextLong();
		while(a % b != 0) {
			long buf = b;
			b = a%b;
			a = buf;
		}
		System.out.println(b);
	}

}



Measured memory_bytes: 26208
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n = I()
H = LI()

ans = 0
tmp = 0
for i in range(1, n):
    if H[i-1] >= H[i]:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 63888
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll x[200001], y[200001];
    for(int i = 0; i < n; i++){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y, y + n);
    ll mid1 = y[n / 2 - 1];
    ll mid2 = y[n / 2];
    for(int i = 0; i < n; i++){
        if(x[i] <= mid1){
            cout << mid2 << endl;
        }
        else{
            cout << mid1 << endl;
        }
    }
}

Measured memory_bytes: 5376
#!/usr/bin/python3
# abc055_a
"""
Scc Puzzle
"""

def answer():
    """
    Sが余るときとcが余るときに分けて考える。
    """
    S, c = map(int, input().split())

    if S >= c//2:
        return int(c//2)

    return int(S + (c - S*2) // 4)


def main():
    """
    答えを出力
    """
    print(answer())


if __name__ == '__main__':
    main()


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

template <class InputIterator>
auto RLE(InputIterator start, InputIterator end)
{
    using value_type = typename iterator_traits<InputIterator>::value_type;
    vector<pair<value_type, ll>> res;

    auto cmp = start;
    ll cnt = 0;
    while (start != end) {
        start++;
        cnt++;
        if (start == end || *start != *cmp) {
            res.emplace_back(*cmp, cnt);
            cmp = start;
            cnt = 0;
        }
    }

    return res;
}

void main_()
{
    string S;
    cin >> S;
    auto rls = RLE(begin(S), end(S));

    vector<ll> ans(S.size());
    ll index = 0;
    for (auto&& rl : rls) {
        auto ch = rl.first;
        auto num = rl.second;
        if (ch == 'R') {
            ans[index + num - 1] += (num + 1) / 2;
            ans[index + num] += num / 2;
        }
        if (ch == 'L') {
            ans[index] += (num + 1) / 2;
            ans[index - 1] += num / 2;
        }
        index += num;
    }

    copy(begin(ans), end(ans), ostream_iterator<ll>(cout, " "));
    cout << "\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 2880
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    if((a<c&&b>c)||(a>c&&b<c)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
s = input()

length = 0
if len(s) % 2 == 0:
  length = len(s) // 2 - 1
else:
  length = len(s) // 2

top = -1

for i in range(length):
  flag = True
  for j in range(i):
    if s[j] != s[i + j + 1]:
      flag = False
  if flag :
    top = (i+1) * 2

print(top)


Measured memory_bytes: 63584
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<deque>
#include<stack>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
const ll maxn = 1e5 + 5;
const double PI = acos(-1);
void std_quick_io () {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
ll qpow(ll a, ll b) {
    ll ans = 1;
    ll res = a%mod;
    while(b) {
        if(b&1) {
            ans=ans*res%mod;
        }
        res=res*res%mod;
        b>>=1;
    }
    return ans;
}
ll inv(ll a) {  
    return qpow(a, mod-2LL);  
}  
ll C(ll m,ll n)  
{  
    if(m < 0)return 0;  
    if(n < m)return 0;  
    if(m > n-m) m = n-m;  
    ll up = 1, down = 1;  
    for(ll i = 0 ; i < m ; i ++){  
        up = up * (n-i) % mod;  
        down = down * (i+1LL) % mod;  
    }  
    return up * inv(down) % mod;  
}  
int main () {
    //std_quick_io();
    ll n,a,b;
    cin >>n>>a>>b;
    ll ans = (qpow(2LL, n)-1LL+mod)%mod;
    ans = (ans -C(a,n)+mod)%mod;
    ans =(ans - C(b,n)+mod)%mod;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n,k;cin>>n>>k;
    map<int,int> mp;
    rep(i,n)mp[i]=0;
    rep(i,k){
        int d;cin>>d;
        rep(j,d){
            int a;cin>>a;a--;
            mp[a]++;
        }
    }
    int res=0;
    for(auto& p:mp){
        if(p.second==0)res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3600
import bisect, collections

def solution():
    a, b, c = [int(x) for x in input().strip().split(" ")]
    if (c-a-b) >= 0 and (c-a-b)**2 > 4*a*b:
        print("Yes")
    else:
        print("No")
    



def main():    
    # T = int(input().strip())
    for _ in range(1):
        solution()
    

main()

Measured memory_bytes: 38256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

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

int A, B;

int main(){

  cin >> A >> B;
  if(A >= 13) {
    cout << B << endl;
  } else if (A >= 6) {
    cout << B / 2 << endl;
  } else {
    cout << 0 << endl;
  }


  return 0;
}


Measured memory_bytes: 256
import javax.swing.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);
        
        int n = Integer.parseInt(br.readLine());
        HashMap<Integer, Integer> hm = new HashMap<>();
        st = new StringTokenizer(br.readLine());
        long ans = 0;
        int[] a = new int[n];
        for(int i=0 ; i<n ; i++) {
            int x = Integer.parseInt(st.nextToken());
            a[i] = x;
            if(hm.containsKey(x)) {
                hm.compute(x, (y, z) -> z+1);
            }
            else {
                hm.put(x, 1);
            }
        }

        for(Map.Entry<Integer, Integer> ent: hm.entrySet()) {
            long val = ent.getValue();
            val *= (val-1);
            val /= 2;
            ans += val;
        }

        for(int i=0 ; i<n ; i++) {
            long occur = hm.get(a[i]);
            long curr = ans;
            curr -= occur*(occur-1)/2;
            curr += (occur-1)*(occur-2)/2;
            pw.println(curr);
        }
        
        
        
        
        
        pw.flush();
        pw.close();
    }
}


Measured memory_bytes: 58308
#include<bits/stdc++.h>
using namespace std;
int main(){
    double n,tmp;
    scanf("%lf",&n);
    while(true){
        tmp = sqrt(n);
        if(ceil(tmp)!=floor(tmp)) n--;
        else break;
    }
    printf("%d\n",int(n));
    return 0;
}


Measured memory_bytes: 512
import Control.Monad
import Data.List
main = getLine >>= main' . map read . words
    where
        main' [n, m] = replicateM n getLine >>= main'' m . map (map read . words)
        main'' m xs = replicateM m getLine >>= mapM print . solve xs . map (map read . words)

solve :: [[Int]] -> [[Int]] -> [Int]
solve xs ys = [dist x $ zip [1..] ys | x <- xs]

dist :: [Int] -> [(Int, [Int])] -> Int
dist [a, b] = fst . foldl' ff (0, 3 * 100000000)
    where
        ff acc@(_, accd) (n, [c, d])
            | accd > dst = (n, dst)
            | otherwise = acc
            where
                dst = abs (a - c) + abs (b - d)


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

int main(){
    int X, Y;
    int tsuru, kame;

    cin >> X >> Y;

    if((2*X > Y) || (4*X < Y)){
        cout << "No" << endl;
        return 0;
    }
    else if(Y % 2 != 0){
        cout << "No" << endl;
        return 0;
    }

    for(int kame=0; kame<=25; kame++){
        for(int tsuru=0; tsuru<=51; tsuru++){
            if((tsuru * 2 + kame * 4) == Y){
                cout << "Yes" << endl;
                return 0;
    }}}
    cout << "No" << endl;
    return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<typename T>
vector<vector<vector<T>>>
Make3DVector(int d1, int d2, int d3, T default_value) {
  return vector<vector<vector<T>>>(
      d1, vector<vector<T>>(d2, vector<T>(d3, default_value)));
}

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

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

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

  int n;
  int64 cap;
  cin >> n >> cap;
  vector<int64> ws(n);
  vector<int64> vs(n);
  for (int i = 0; i < n; i++) {
    cin >> ws[i];
    cin >> vs[i];
  }

  int64 base = ws[0];
  for (int i = 0; i < n; i++) {
    ws[i] -= base;
  }

  auto solve_m_fn = [&](int m) -> int64 {
    int64 m_cap = cap - base * m;
    if (m_cap < 0) return 0;

    UpdateMin(m_cap, 3LL * m);
    auto dp = Make3DVector<int64>(n + 1, m + 1, m_cap + 1, 0LL);
    for (int i = 0; i < n; i++) {
      for (int k = 0; k <= m; k++) {
        for (int w = 0; w <= m_cap; w++) {
          int new_w = w + ws[i];
          if (k + 1 <= m && new_w <= m_cap) {
            UpdateMax(dp[i + 1][k + 1][new_w], dp[i][k][w] + vs[i]);
          }
          UpdateMax(dp[i + 1][k][w], dp[i][k][w]);
        }
      }
    }
    
    int64 max = 0;
    for (int w = 0; w <= m_cap; w++) {
      UpdateMax(max, dp[n][m][w]);
    }
    return max;
  };

  int64 ans = 0;
  for (int m = 1; m <= n; m++) {
    // cout << m << " " << solve_m_fn(m) << endl;
    UpdateMax(ans, solve_m_fn(m));
  }
  cout << ans << endl;
}

Measured memory_bytes: 23864