akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 105
#define __TRUE "YES"
#define __FALSE "NO"
#define cout(x) cout << (x) << endl
#define reps(i,s,n) for(i=s;i<n;i++)
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;

int main() {
  int n,d,x;
  cin >> n >> d >> x;
  int count=0;
  for(int i=0;i<n;i++) {
    int a;
    cin >> a;
    int tmp=1,j=1;
    while(1) {
      if(tmp<=d) {
        tmp = j*a+1;
        j++;
        count++;
      }else break;
    }
  }
  cout(count+x);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define N 500
using namespace std;
struct info {
  int tid[N];
  int pid[N];
  int time[N];
  string message[N];
};
int main(){
  struct info data;
  int t,p,r,i,j,tcorrect[51][11],tp[51],twrong[51][11],tcsum[51],tnum[51];
  while(1){
    cin >> t >> p >> r;
    if(t==0&&p==0&&r==0) break;
    for(i=0;i<r;i++){
      cin >> data.tid[i] >> data.pid[i] >> data.time[i] >> data.message[i];
    }
    for(i=1;i<=t;i++){
      for(j=1;j<=p;j++){
	tcorrect[i][j]=twrong[i][j]=0;
      }
      	tp[i]=0;
    }
    for(i=0;i<r;i++){
      if(data.message[i]=="CORRECT"){
	tcorrect[data.tid[i]][data.pid[i]]++;
	tp[data.tid[i]]=tp[data.tid[i]]+twrong[data.tid[i]][data.pid[i]]*1200+data.time[i];
      }
      else if(data.message[i]=="WRONG"){
	twrong[data.tid[i]][data.pid[i]]++;
      }
    }
    for(i=1;i<=t;i++){
      tcsum[i]=0;
      for(j=1;j<=p;j++){
	tcsum[i]+=tcorrect[i][j];
      }
      tnum[i]=i;
    }
    for(i=1;i<=t;i++){
      for(j=2;j<=t;j++){
	if(tnum[j]<tnum[j-1]){
	  swap(tp[j],tp[j-1]);
	  swap(tcsum[j],tcsum[j-1]);
	  swap(tnum[j],tnum[j-1]);
	}
      }
    }
    for(i=1;i<=t;i++){
      for(j=2;j<=t;j++){
	if(tp[j]<tp[j-1]){
	  swap(tp[j],tp[j-1]);
	  swap(tcsum[j],tcsum[j-1]);
	  swap(tnum[j],tnum[j-1]);
	}
      }
    }
    for(i=1;i<=t;i++){
      for(j=2;j<=t;j++){
	if(tcsum[j]>tcsum[j-1]){
	  swap(tp[j],tp[j-1]);
	  swap(tcsum[j],tcsum[j-1]);
	  swap(tnum[j],tnum[j-1]);
	}
      }
    }
    for(i=1;i<=t;i++){
      cout << tnum[i] << ' ' << tcsum[i] << ' ' << tp[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1248
package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

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
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	k := nextInt()
	n := nextInt()
	a := nextInts(n)
	sort.Ints(a)
	var max int
	for i := 0; i < n; i++ {
		var d int
		if i == n-1 {
			d = (k - a[i]) + a[0]
		} else {
			d = a[i+1] - a[i]
		}
		if d > max {
			max = d
		}
	}
	fmt.Println(k - max)
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define fi first
#define se second
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
int n, a[N], dp[N], b[N], len;
vector <int> G[N];
void dfs(int u, int fa)
{
	bool fg = 0;
	int p = 0, tmp = 0;
	if(!len) b[++len] = a[u], fg = 1;
	else
	{
		if(a[u]>b[len]) b[++len] = a[u], fg = 1;
		else
		{
			int pos = lower_bound(b+1, b+len, a[u]) - b;
			p = pos, tmp = b[pos];
			b[pos] = a[u];
		}
	}
	dp[u] = len;
	for(int v : G[u])
	{
		if(v==fa) continue;
		dfs(v, u);
	}
	if(fg) len--;
	else b[p] = tmp; 
}
int main()
{
	scanf("%d", &n);
	for(int i=1; i<=n; i++) scanf("%d", a+i);
	for(int i=1; i<n; i++)
	{
		int u, v; scanf("%d%d", &u, &v);
		G[u].pb(v); G[v].pb(u);
	}
	dfs(1, 0);
	for(int i=1; i<=n; i++) printf("%d\n", dp[i]);
	return 0;
}

Measured memory_bytes: 30644
n = gets.to_i
a = gets.chomp.split.map(&:to_i)

b = Array.new(n) { 0 }

ans = []

(n - 1).downto(0) do |i|
  sum = 0
  k = 2
  
  while (k * (i + 1) <= n)
    sum += b[k * (i + 1) - 1]
    k += 1
  end
  
  if (sum % 2) == a[i]
    b[i] = 0
  else
    b[i] = 1
  end
end

ans = b.each_with_index.map do |v, i|
  i + 1 if v.nonzero?
end.compact

puts ans.count
puts ans.join(' ') if ans.count.nonzero?

Measured memory_bytes: 24640
using System;
class Program {
  static void Main(string[] args) {
    string[] vals = Console.ReadLine().Split();
    int N = int.Parse(vals[0]);
    int M = int.Parse(vals[1]);

    int[] A = new int[N + 1];
    for (int i = 0; i < M; ++i) {
      vals = Console.ReadLine().Split();
      int a = int.Parse(vals[0]);
      int b = int.Parse(vals[1]);

      ++A[a]; ++A[b];
    }

    for (int i = 1; i <= N; ++i) {
      Console.WriteLine(A[i]);
    }
  }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define bye return 0
using namespace std;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    int a, b;

    cin >> s;
    
    a = ((s[0]-'0') * 10) + (s[1]-'0');
    b = ((s[2]-'0') * 10) + (s[3]-'0');

    if(1<=a && a<=12){
      if(1<=b && b<=12)
      	cout << "AMBIGUOUS" << "\n";
      else
      	cout << "MMYY" << "\n";
   }else{
   	  if(1<=b && b<=12)
   	  	cout << "YYMM" << "\n";
   	  else
   	  	cout << "NA" << "\n";
   }

   

   
     
 
   bye;

}


Measured memory_bytes: 256
#coding: utf-8
# C: String Coloering
from collections import Counter
from itertools import product

def getLeft(in_string, N):
    return in_string[:N]

def getRight(in_string, N):
    return in_string[2*N-1:N-1:-1]

def getDict(left_seq):
    tmp_n = len(left_seq)
    r_dict = Counter()
    for bit in product(range(2), repeat=tmp_n):
        red_left = ""
        blue_left = ""
        for i in range(tmp_n):
            if bit[i]:
                red_left += left_seq[i]
            else:
                blue_left += left_seq[i]
        r_dict[red_left + "-" + blue_left] += 1
    return r_dict

def getMatch(left, right):
    res = 0
    for i in left.keys():
        res += left[i]*right[i]
        
    return res

if __name__ == "__main__":
    N = int(input())
    Seq = input()
    print(getMatch(getDict(getLeft(Seq, N)), getDict(getRight(Seq, N))))
       


Measured memory_bytes: 71396
{
  const main = (
    input: string
  ): void | string | number | string[] | number[] => {
    const r = _reader(input)
    const [A, B, K] = r.nn()

    // if (A >= K) {
    //   return [A - K, 0]
    // }

    // if (A + B <= K) {
    //   return [0, 0]
    // }

    // return [0, B - (K - A)]

    if (K >= A + B) {
      console.log('0 0')
    } else {
      if (K >= A) {
        console.log('0', B - (K - A))
      } else {
        console.log(A - K, B)
      }
    }
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
  if (typeof _res === 'object') console.log(_res.join(' '))
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a + b >= c ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		String n = n();
		int g = 0;
		for (int i = 0; i < n.length(); i++) {
			g += Integer.parseInt(n.substring(i, i + 1));
			g %= 9;
		}

		if (g == 0) {
			out(Y);
		} else {
			out(N);
		}

	}

	/*
	 * 以下メソッド集
	 */

	public static void permutation(String q, String ans) {
		// Base Case
		if (q.length() <= 1) {
			System.out.println(ans + q);
		}
		// General Case
		else {
			for (int i = 0; i < q.length(); i++) {
				permutation(q.substring(0, i) + q.substring(i + 1),
						ans + q.charAt(i));
			}
		}
	}

	static char[][] same(char[][] c, int h, int w) {

		char[][] a = new char[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				a[i][j] = c[i][j];
			}
		}
		return a;

	}

	static int countkuro(char[][] c) {

		int count = 0;
		for (char[] cc : c) {
			for (char ccc : cc) {
				if ('#' == ccc) {
					count++;
				}
			}
		}
		return count;
	}

	static void debug() {

		out("---");
	}

	static void debug(Object a) {

		out("-------");
		out(a);
		out("-------");
	}

	static int ketasuu(int n) {

		String str = "" + n;
		return str.length();
	}

	static int account(String str) {

		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {

		return sc.nextInt();
	}

	static long nl() {

		return sc.nextLong();
	}

	static double nd() {

		return sc.nextDouble();
	}

	static String n() {

		return sc.next();
	}

	static char[] nc() {

		return sc.next().toCharArray();
	}

	static int kaijo(int n) {

		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {

		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(Object obj) {
		System.out.println(obj);
	}

	static void outn(Object obj) {
		System.out.print(obj);
	}

	static double max(double d, double e) {

		return Math.max(d, e);
	}

	static long max(long a, long b) {

		return Math.max(a, b);
	}

	static long min(long d, long e) {

		return Math.min(d, e);
	}

	static int min(int a, int b) {

		return Math.min(a, b);
	}
}

class XY {

	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 49944
n=int(input())
x=list(map(int,input().split()))
sortx=sorted(x)
mida=sortx[n//2-1]
midb=sortx[n//2]
for i in range(n):
    if mida==midb:
        print(mida)
    elif mida>=x[i]:
        print(midb)
    else:
        print(mida)

Measured memory_bytes: 93780
#include <iostream>
#include <vector>
#include <map>
using namespace std;

map<int, vector<int>> A;
int color[101];
int start[101];
int endTime[101];
int elapsed = 0;

void dfs(int u) {
    elapsed++;
    color[u] = 1;
    start[u] = elapsed;
    for (vector<int>::iterator it = A[u].begin(); it != A[u].end(); it++) {
        if (color[*it] == 0) {
            dfs(*it);
        }
    }
    endTime[u] = ++elapsed;
}

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

    int u, k;
    for (int i = 1; i <= n; i++) {
        color[i] = 0;
        cin >> u >> k;
        int ad;
        for (int j = 0; j < k; j++) {
            cin >> ad;
            A[u].push_back(ad);
        }
    }

    for (int i = 1; i <= n; i++) {
        if (color[i] == 0) dfs(i);
    }

    for (int i = 1; i <= n; i++) {
        cout << i << " " << start[i] << " " << endTime[i] << endl;
    }
}



Measured memory_bytes: 3144
class Graph():
	def __init__(self):
		self.adjacency_dict = {}
		self.weight = []

	def add_vartex(self, v):
		self.adjacency_dict[v] = []
		self.weight.append([])

	def add_edge(self, v1, v2, w):
		self.adjacency_dict[v1].append(v2)
		self.adjacency_dict[v2].append(v1)
		self.weight[v1].append(w)
		self.weight[v2].append(w)

	def get_vartexes(self):
		return self.adjacency_dict.keys()

	def get_edges(self, v):
		return self.adjacency_dict[v], self.weight[v]

	def printgraph(self):
		return print(self.adjacency_dict)

n = int(input())

res = []
g = Graph()
for i in range(n):
	res.append(-1)
	g.add_vartex(i)

for i in range(n-1):
	u, v, w = map(int, input().strip().split())
	g.add_edge(u - 1, v - 1, w % 2)


q = []
res[0] = 0
q.append(0)
while(len(q) > 0):
	v = q.pop()
	u_l, w_l = g.get_edges(v)
	for u, w in zip(u_l, w_l):
		if res[u] != -1:
			continue
		res[u] = (res[v] + w) % 2
		q.append(u)

for i in range(n):
	print(res[i])



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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

#define I(a,b) (((a)<<2)|b)

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 800029;

struct eT
{
	void setd ( int _u, int _v, int _l )
	{
		u = _u, v = _v, last = _l;
	}

	int u, v, last;
}edge[MAXN];

int n, m;
int ke, la[MAXN];
AR ( int ) e[MAXN>>2];
char s[MAXN];
bool vis[MAXN];
int q[MAXN], deg[MAXN];

void init ();
void input ();
void work ();

void addedge ( int u, int v )
{
	edge[ke].setd ( u, v, la[u] );
	la[u] = ke++;
	++deg[v];
}



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%d%d", &n, &m );
	scanf ( "%s", s + 1 );
	int u, v;
	lp ( i, 0, m ) {
		scanf ( "%d%d", &u, &v );
		e[u].push_back ( v );
		e[v].push_back ( u );
	}
}

void work ()
{
	// main work

	int fr, to;
	INIT ( la, -1 );
	lpi ( i, 1, n ) {
		lp ( j, 0, 4 ) {
			fr = j >> 1;
			to = ( ( j + 1 ) & 3 ) >> 1;
			if ( s[i] == fr + 'A' ) {
				for ( auto v : e[i] ) {
					if ( s[v] == to + 'A' ) {
						addedge ( I ( i, j ), I ( v, ( j + 1 ) & 3 ) );
					}
				}
			}
		}
	}

	int l = 0, r = 0, now, v;
	lpi ( i, I ( 1, 0 ), I ( n, 3 ) ) if ( !deg[i] ) q[r++] = i;
	while ( l < r ) {
		now = q[l++];
		for ( int i = la[now]; ~i; i = edge[i].last ) {
			--deg[v = edge[i].v];
			if ( !deg[v] ) q[r++] = v;
		}
	}
	printf ( ( r ^ ( n * 4 ) ) ? "Yes\n" : "No\n" );
}

Measured memory_bytes: 25984
a = list(map(int,input().split()))
N = a[0]
K = a[1]
H = list(map(int,input().split()))
H.sort(reverse=True)
ans = 0
MOD = 10**9 + 7
if K >= N:
    print(0)
else:
    for i in range(K,N):
        ans += H[i]

    print(ans)

Measured memory_bytes: 26180
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int[] c = new int[9];
		for (int i = 0; i < 9; i++) {
			c[i] = sc.nextInt();
		}
		sc.close();

		if (c[3] - c[0] == c[4] - c[1] && c[3] - c[0] == c[5] - c[2]
		&& c[6] - c[3] == c[7] - c[4] && c[6] - c[3] == c[8] - c[5]
		&& c[1] - c[0] == c[4] - c[3] && c[1] - c[0] == c[7] - c[6]
		&& c[2] - c[1] == c[5] - c[4] && c[2] - c[1] == c[8] - c[7]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

def readInts():
  return [int(s) for s in input().split(" ")]

def solve(N, K, S):
  chunks = []
  current = '1'
  count = 0
  for i, c in enumerate(S):
    if c != current:
      chunks.append(count)
      current = '0' if current == '1' else '1'
      count = 0
    count += 1
  chunks.append(count)
  if current == '0':
    chunks.append(0)

  if len(chunks) < 2 * K + 1:
    return N

  cSums = [0 for _ in range(len(chunks) + 1)]
  for i, c in enumerate(chunks):
    cSums[i + 1] = cSums[i] + c

  ans = 0
  for i in range(0, len(cSums) - (2 * K + 1), 2):
    ans = max(ans, cSums[i + 2 * K + 1] - cSums[i])

  return ans

def main():
  N, K = readInts()
  S = input()

  print(solve(N, K, S))

if __name__ == "__main__":
  main()


Measured memory_bytes: 7884
#include <iostream>
using namespace std;
int main(){
	int x,y,a,b,s;
	cin>>a>>b;
	if (a>b){
		cout<<"a > b"<<endl;
	}
	else if (a<b){
		cout<<"a < b"<<endl;
	}
	else {
		cout<<"a == b"<<endl;
	}
	return 0;
}

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

long long candies[100002];
int main()
{
    int n;
    long long x;
    cin >> n >> x;
    for(int i = 1; i <= n; ++i)
        cin >> candies[i];
    long long ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        long long eat = max(0ll, candies[i] + candies[i - 1] - x);
        ans += eat;
        if(eat >= candies[i])
        {
            eat -= candies[i];
            candies[i] = 0;
            candies[i - 1] -= eat;
        }
        else
            candies[i] -= eat;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
using namespace std;
typedef long long ll;
int a[100005];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  FOR(i,n){
    cin>>a[i];
  }
  sort(a,a+n);
  int maxi=a[1],mini=a[0],ans=INT_MAX;
  SFOR(i,1,n){
    maxi=a[i];
    mini=a[0];
    maxi=maxi%mini;
    if(mini>maxi) swap(maxi,mini);
    while(mini>0){
      maxi-=mini;
      if(mini>maxi){
        swap(maxi,mini);
      }
    }
    if(maxi!=0) ans=min(maxi,ans);
  }
  cout<<ans<<endl;
  return 0;
}


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

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

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

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

  int n;
  cin >> n;

  vector<vector<P>> vec(n);
  rep(i, n) {
    int a;
    cin >> a;
    rep(j, a) {
      int x, y;
      cin >> x >> y;
      x--;
      vec[i].push_back({x, y});
    }
  }

  int mx = 0;
  rep(i, (1<<n)) {
    int cnt = 0;
    bool canDo = true;
    // cout << i << endl;
    rep(j, n) {
      if (((i>>j)&1) == 0) continue;
      cnt++;
      for(auto k: vec[j]) {
        // cout << k.first << " " << ((i>>k.first)&1) << endl;
        canDo = canDo && (((i>>k.first)&1) == k.second);
      }
    }
    if (canDo) {
      mx = max(mx, cnt);
    }
  }

  cout << mx << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 2019;

int modpow(int a,int b){
	int out = 1;
	while(b > 0){
		if(b & 1) out = (out * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return out;
}

int main(){
	string s;
	cin >> s;
	vector <int> hash(2019);
	int n = s.length();
	long long int count = 0;
	int x = 0;
	for(int i = n - 1;i >= 0;--i){
		int num = s[i] - '0';
		x = (modpow(10,n - 1 - i) * num + x) % mod;
		count = count + hash[x];
		if(x == 0) ++count;
		++hash[x];
	}
	cout << count << "\n";
	return 0;
}

Measured memory_bytes: 3720
a,b,k=map(int,input().split())
lst=[]
for i in range(a,a+k):
    if i>b:
        break
    lst.append(i)
    print(i)
for i in range(b-k+1,b+1):
    if i<a:
        continue
    if not i in lst:
        print(i)

Measured memory_bytes: 9184
#include<stdio.h>
int main()
{
    int B,Z;
    int C,Q,R,A;
    scanf("%d %d %d",&C,&Q,&R);
    A=C+Q;
    B=C+R;
    Z=Q+R;
    if(A<=B&&A<=Z)
    {
    printf("%d",A);
    }
    else if(B<=A&&B<=Z)
    {
        printf("%d",B);
    }
    else
    {
        printf("%d",Z);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

bool Spr(int x, vector<bool>& c)
{
    while (x != 0)
    {
        if (!c[x % 10])
            return false;
        x /= 10;
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<bool> c(10, true);
    for (int i = 0; i < k; ++i)
    {
        int a;
        cin >> a;
        c[a] = false;
    }
    int odp = n;
    while (!Spr(odp, c))
        ++odp;
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

long long X[100000];
int W[100000];
int main(){
    long long N;
    long long T;
    long long L;
    cin >> N >> L >> T;
    for(int i = 0; i < N; i++){
        cin >> X[i] >> W[i];
    }
    
    long long pass_origin_from_right = 0;
    long long pass_origin_from_left = 0;
    for(int i = 0; i < N; i++){
        if(W[i] == 1){
            pass_origin_from_left += (X[i] + T) / L;
            X[i] = (X[i] + T) % L;
        } else {
            if(X[i] - T < 0){
                pass_origin_from_right += (abs(X[i] - T) - 1) / L + 1;
            }
            X[i] = ((X[i] - T) % L + L) % L;
        }
    }
    sort(X, X + N);
    //cout << pass_origin_from_left << " " << pass_origin_from_right << endl;
    int first_ant_pos = ((pass_origin_from_left - pass_origin_from_right) % N + N) % N;
    //cout << first_ant_pos  << endl;
    for(int i = 0; i < N; i++){
        cout << X[(first_ant_pos + i) % N] << endl;
    }
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){
  if (u == NIL || k ==u->key) return u;

  if(k < u->key)return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
  
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;

    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
  //場合分けして格納
}

void inorder(Node u){
  if(u == NIL)return ;

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
  
}
void preorder(Node u){
  if(u == NIL)return ;

  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if (t != NIL) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20496
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		String x = String.valueOf(a.charAt(0)) + String.valueOf(b.charAt(0)) + String.valueOf(c.charAt(0));

		System.out.println(x.toUpperCase());

		sc.close();

	}

}

Measured memory_bytes: 39104
#include <cstdio>

using namespace std;

int main() {
  int i;
  int N;
  scanf("%d", &N);
  long long A[100010], B[100010];
  for (i = 0; i < N; i++) {
    scanf("%lld %lld", &A[i], &B[i]);
  }
  long long ans = 0;
  for (i = N-1; i >= 0; i--) {
    if ((A[i]+ans) % B[i] != 0) {
      int plus = (A[i]+ans) % B[i];
      ans += B[i] - plus;
    }
    //printf("%lld\n", ans);
  }
  printf("%lld", ans);
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <queue>
#define INF 9999999
using namespace std;


int n, m;
int G[100][100];

class A {
public:
  int cost;
  int from;
  int pos;
  A(int cost = 0, int from = 0, int pos = 0) : cost(cost), from(from), pos(pos) {}
  bool operator < (const A &a) const {
    if(cost != a.cost) return cost > a.cost;
    else if(pos != a.pos) pos < a.pos;
    return from < a.from;
  }
};

int calc(int s, int e) {
  int visited[100];
  priority_queue<A> que;
  int maxW, minW;
  int count;
  maxW = minW = G[s][e];
  count = 1;
  fill(visited, visited+n, false);
  visited[s] = true;
  que.push(A(0, s, e));
  while(!que.empty()) {
    A a = que.top();
    que.pop();
    if(visited[a.pos]) continue;
    visited[a.pos] = true;

    if(G[a.from][a.pos] > maxW) maxW = G[a.from][a.pos];
    if(G[a.from][a.pos] < minW) minW = G[a.from][a.pos];

    ++count;
    if(count == n) return maxW - minW;

    for(int i = 0; i < n; ++i) {
      if(G[a.pos][i] == INF) continue;
      if(visited[i]) continue;
      if(G[a.pos][i] > maxW) {
	que.push(A(G[a.pos][i] - minW, a.pos, i));
      } else {
	que.push(A(maxW - G[a.pos][i], a.pos, i));
      }
    }
  }
  return INF;
}

void solve() {
  int ans = INF;
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < n; ++j) {
      if(i == j) continue;
      if(G[i][j] == INF) continue;
      ans = min(ans, calc(i, j));
    }
  }
  if(ans == INF) cout << -1 << endl;
  else           cout << ans << endl;
}

main() {
  while((cin >> n >> m) && (n || m)) {
    fill(G[0], G[100], INF);

    for(int i = 0; i < m; ++i) {
      int a, b, w;
      cin >> a >> b >> w;
      --a; --b;
      G[a][b] = min(G[a][b], w);
      G[b][a] = min(G[b][a], w);
    }
    solve();
  }
}

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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i,N) cin >> a[i];
    
    map<int,int> m;
    REP(i,N){
        m[a[i]] += 1;
    }
    
    int ans = 0;
    for ( auto itr = m.begin(); itr != m.end(); ++itr ){
        int X = itr->first, Xnum = itr->second;
        //cout << X << " " << Xnum << endl;
        if ( X < Xnum ) {
            ans += ( Xnum - X );
        } else if ( X > Xnum ){
            ans += Xnum;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8040
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 998244353;
const int N = 5010;
ll fact[N], invf[N], two[N];

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    return (x * powll(y,mod-2)) % mod;
}

ll nPr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(fact[n], invf[n-r]);
}

ll nCr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(mul(fact[n], invf[r]), invf[n-r]);
}

ll nXr(ll n, ll r){
    return nCr(n + r - 1, n);
}

map<pair<int, P>, ll> mp;

ll calc(int n, int k, int p){
    auto tmp = make_pair(n, P(k, p));
    if (mp.count(tmp)) return mp[tmp];
    ll ret = 0;
    REP(x,p+1){
        ll tmp = (two[x] * nXr(n-x, k-p+x)) % mod;
        tmp = (tmp * nCr(p, x)) % mod;
        ret = (ret + tmp) % mod;
    }
    return mp[tmp] = ret;
}

int main() {
    ll n, k;
    cin >> k >> n;
    fact[0] = invf[0] = two[0] = 1;
    FOR(i,1,N-1){
        fact[i] = (fact[i-1] * i) % mod;
        invf[i] = divll(invf[i-1], i);
        two[i] = (2 * two[i-1]) % mod;
    }

    FOR(s,2,2*k){
        ll ans = 0;
        int c = 0, p = 0;
        set<int> st;
        FOR(j,1,k){
            int y = s - j;
            if (y == j) continue;
            if (st.count(y)) p++;
            else c++;
            st.insert(j);
        }
        ans = calc(n, c, p);
        if (s % 2 == 0){
            ans = (ans + calc(n-1, c, p)) % mod;
        }

        printf("%lld\n", ans);
    }

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <numeric>

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

int gcd(ll x, ll y)
{
  return y == 0 ? x : gcd(y, x % y);
}

int main()
{
  int n;
  ll a, b = 0;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    b = gcd(a, b);
    if (b == 1)
      break;
  }

  cout << b << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,A[1000010],num[1000010];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]),num[i]=A[i];
	sort(A+1,A+1+n);
	for(int i=1;i<=n;i++){
		if(num[i]!=A[n])printf("%d\n",A[n]);
		else printf("%d\n",A[n-1]);
	}
	return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
using namespace std;

int INF=1e9;
const long long mod=1e9+7;


int main(){
  int N,M;
  cin>>N>>M;

  vector<int>oks(N+1,true);
  for(int i=0;i<M;i++){
    int a; cin>>a;
    oks[a]=false;
  }
  vector<long long int>dp(N+1);
  dp[0]=1;
  for(int now=0;now<N;now++){
    for(int next=now+1;next<=min(N,now+2);next++){
      if(oks[next]){
        dp[next]+=dp[now];
        dp[next]%=mod;
      }
    }
  }
  cout<<dp[N]<<endl;
  return 0;
}


Measured memory_bytes: 1408
import bisect
N = int(input())
L = [int(x) for x in input().split()]

L.sort()
ans = 0
for i in range(N) :
    for j in range(i+1,N) :
        le = L[i] + L[j]
        ans += bisect.bisect_left(L[j+1:],le)

print(ans)


Measured memory_bytes: 51676
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	string s;
	cin >> s;

	reverse(s.begin(), s.end());
	int n = s.size();
	vector<vector<int>> dp(n, vector<int>(2, 0));
	dp[0][0] = s[0] - '0';
	dp[0][1] = 11 - (s[0] - '0');
	for (int i = 1; i < n; ++i) {
		int x = s[i] - '0';
		dp[i][0] = min(dp[i-1][0], dp[i-1][1]) + x;
		dp[i][1] = min(dp[i-1][0] + (11 - x), dp[i-1][1] + (9-x));
	}
	cout << min(dp[n-1][0], dp[n-1][1]) << endl;

	return 0;
}


Measured memory_bytes: 58860
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC119
{
    static class B
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] xu = new string[2] { "", "" };
            double sum = 0;
            for (int i = 0; i < n; i++)
            {
                xu = Console.ReadLine().Split().ToArray();
                if (xu[1] == "JPY") { sum += double.Parse(xu[0]); }
                else { sum += double.Parse(xu[0])* 380000.0; }
            }
            Console.WriteLine(sum);
        }
    }
}

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

int n,m;
cin >> n >> m;

cout << (n-1)*(m-1) << endl;

  return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(int argc, char *argv[])
{
    int num, cnt = 0, n = 0;
    char c, dummy;
 
    scanf("%d", &n);
    scanf("%c", &dummy);
 
    char cList[n];
    int numList[n];
    int S[13] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    int H[13] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    int C[13] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    int D[13] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    cnt = 0;
    while (cnt < n)
    {
        // scanf("%c %d\n",&c ,&num);
        scanf("%c",&c);
        scanf("%d",&num);
        scanf("%c", &dummy);
        cList[cnt] = c;
        numList[cnt] = num;
        cnt++;
    }
 
    cnt = 0;
 
    while (cnt < n)
    {
        if (cList[cnt] == 'S')
        {
            S[numList[cnt] - 1] = 1;
        }
        if (cList[cnt] == 'H')
        {
            H[numList[cnt] - 1] = 1;
        }
        if (cList[cnt] == 'C')
        {
            C[numList[cnt] - 1] = 1;
        }
        if (cList[cnt] == 'D')
        {
            D[numList[cnt] - 1] = 1;
        }
        cnt++;
    }
 
    cnt = 0;
    while (cnt < 13)
    {
        if (S[cnt] == 0)
        {
            printf("S %d\n", cnt + 1);
        }
        cnt++;
    }
 
    cnt = 0;
    while (cnt < 13)
    {
        if (H[cnt] == 0)
        {
            printf("H %d\n", cnt + 1);
        }
        cnt++;
    }
    cnt = 0;
    while (cnt < 13)
    {
        if (C[cnt] == 0)
        {
            printf("C %d\n", cnt + 1);
        }
        cnt++;
    }
    cnt = 0;
    while (cnt < 13)
    {
        if (D[cnt] == 0)
        {
            printf("D %d\n", cnt + 1);
        }
        cnt++;
    }
    return 0;
}


Measured memory_bytes: 2688
#include<iostream>

using namespace std;

main()
{
	int n, w = 0, e = 0;
	string str;
	cin >> n >> str;
        int p[n];
	for(int i = 0; i < n; i ++)
	{
		p[i] = 0;
	}
	for(int i = 0; i < n; i ++)
	{
		p[i] += e;
		if(str[i] == 'E')
		{
			e ++;
		}
	}
	for(int i = n-1; i >= 0; i --)
	{
		p[i] += w;
		if(str[i] == 'W')
		{
			w ++;
		}
	}
	int max_ = 0;
	for(int i = 0; i < n; i ++)
	{
		max_ = max(p[i], max_);
	}
	cout << n-1-max_;

}


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

void sss(int &a, int &b){int tmp; tmp = a; a = b; b = tmp;}

int main(){
	int a, b, c;
	cin >> a >> b >> c;
  	sss(a,b);
  	sss(a,c);
  	cout << a << " " << b  << " " << c << endl;
}

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

using namespace std;
typedef long long ll;
const int MAX_N = 2e5;
ll aib[1 + MAX_N], a[1 + MAX_N], h[1 + MAX_N];
int n;
int lsb (int x) {
    return x & -x;
}

void update (int poz, ll x) {
    while (poz <= n) {
        aib[poz] = max (aib[poz], x);
        poz += lsb (poz);
    }
}
ll query (int poz) {
    ll sol = 0;
    while (poz) {
        sol = max (sol, aib[poz]);
        poz -= lsb (poz);
    }
    return sol;
}

int main () {
	cin >> n;
	for (int i = 1; i <= n; i++)
        cin >> h[i];
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        update (h[i], query (h[i]) + a[i]);
    cout << query (n);
    return 0;
}


Measured memory_bytes: 4992
// ctrl+shift+b
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    vector<ll> A(N); rep(i, N){cin >> A.at(i);}
    ll val = 1000;
    rep(i, N - 1){
        if (A.at(i) < A.at(i + 1)){
            // cout << i << " " << val / A.at(i) << " " << A.at(i) << endl;
            val += (val / A.at(i)) * (A.at(i + 1) - A.at(i));
        }
    }
    cout << val << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

int main()
{
	int N, M;
	cin >> N >> M;

	vector<int> A(N);

	int count = 0;
	rep(i, N)
	{
		cin >> A[i];

		count += A[i];
	}

	sort(all(A));
	reverse(all(A));

	bool ans = true;
	rep(i, M)
	{
		if (A[i] * 4 * M < count)
		{
			ans = false;
			break;
		}
	}

	if (ans)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< string, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////


double A, B;
double H, M;



int main(){
    cin>>A>>B>>H>>M;
    double const PI = acos( -1 );
    
    double C = PI/2-2*PI*(H+(M/60))/12;
    double D = PI/2-2*PI*M/60;
    
    double X = A*sin(C)-B*sin(D);
    double Y = A*cos(C)-B*cos(D);
    
    //cout<<X<<" "<<Y<<endl;
    
    double R = sqrt( X*X+Y*Y );
    
    printf("%.10lf\n", R);

}



Measured memory_bytes: 3672
#include<iostream>

using namespace std;
 
int main(){
  int a, b, n;
  while( cin >> a >> b >> n ) {

  for(int i=0;i<n;i++) {
  	
    int x, y;
    cin >> x >> y;
    if(x < b && a < y) {
    	
      cout << "1\n";
      return 0;
      
    }
    
  }
    cout << "0\n";
}
  return 0;
}


Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n0, n, x=0;
  cin >> n0;
  n = n0;
  while(n>0){
    x += n%10;
    n /= 10;
  }
  if(n0 % x == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans=0;
int n,a[100000];
bool f=false;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]<0)
		f^=1;
	}
	if(f)
	{
		int mn=1000000000,mi=0;
		for(int i=0;i<n;i++)
		{
			if(abs(a[i])<mn)
			{
				mn=abs(a[i]);
				mi=i;
			}
		}
		for(int i=0;i<n;i++)
		{
			if(i!=mi)
			ans+=abs(a[i]);
			else
			ans+=abs(a[i])*-1;
		}
		cout<<ans;
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		ans+=abs(a[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
from math import sqrt
def readinput():
    n,d=map(int,input().split())
    xy=[]
    for _ in range(n):
        x,y=map(int,input().split())
        xy.append((x,y))
    return n,d,xy

def main(n,d,xy):
    count=0
    for x,y in xy:
        r=sqrt(x*x+y*y)
        if r<=d:
            count+=1
    return count

if __name__=='__main__':
    n,d,xy=readinput()
    ans=main(n,d,xy)
    print(ans)


Measured memory_bytes: 36152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            if (iB % iA == 0) { iOut = iB + iA; }
            else { iOut = iB - iA; }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    int ac = 0;
    int tle = 0;
    int wa = 0;
    int re = 0;
    int N;
    cin >> N;
    rep(i, N) {
        string s;
        cin >> s;
        if (s == "AC") {
            ac++;
        } else if (s == "TLE") {
            tle++;
        } else if (s == "WA") {
            wa++;
        } else {
            re++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

Measured memory_bytes: 3624
import sys
import itertools
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
def solve():
  n = int(input())
  query = []
  for i in range(n):
    x,y = (int(i) for i in input().split())
    query.append((x,y))
  p = itertools.permutations(query)
  su = 0
  ct = 0
  for i in p:
    ct += 1
    nowx = -1
    nowy = -1
    for nx,ny in i:
      if nowx == -1:
        nowx = nx
        nowy = ny
        continue
      else:
        su += (abs(nx-nowx)**2+abs(ny-nowy)**2)**0.5
      
      
      nowx = nx
      nowy = ny
  print(su/ct)
solve()


Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int main(){
    int X, Y;
    int max, min;
    cin >> X >> Y;

    max = X * 4;
    min = X * 2;

    if(Y < min || Y > max){
        cout << "No" << endl;
    }
    else{
        if(Y % 2 != 0){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3588
#include <iostream>

using namespace std;
int num[6];
int main(void){
  for(int i=1;i<=5;i++){
    cin >> num[i];
  }
  for(int i=1;i<=5;i++){
    if(i != num[i]){
      cout << i << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}

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

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    stringstream ss;
    for(int i = 1;i <= tx-sx;i++)   ss << "R";
    for(int i = 1;i <= ty-sy;i++)   ss << "U";
    for(int i = 1;i <= tx-sx;i++)   ss << "L";
    for(int i = 1;i <= ty-sy;i++)   ss << "D";
    ss << "D";
    for(int i = 1;i <= tx-sx+1;i++)     ss << "R";
    for(int i = 1;i <= ty-sy+1;i++)     ss << "U";
    ss << "LU";
    for(int i = 1;i <= tx-sx+1;i++)     ss << "L";
    for(int i = 1;i <= ty-sy+1;i++)     ss << "D";
    ss << "R";
    cout << ss.str() << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
import math

def gcd(a, b):
    if a < b:
        return gcd(b, a)
    while b > 0:
        a, b = b, a % b
    return a

def sieve_of_eratosthenes(n):
    sieve = list(range(n+1))
    sieve[0] = 1 #素数でない
    sieve[1] = 1 #素数でない
    m = int(math.sqrt(n))
    for i in range(2, m + 1):
        if sieve[i] < i:
            continue
        for j in range(i * i, n + 1, i):
            if sieve[j] == j:
                sieve[j] = i
    return sieve

def factorize_by_sieve(x, sieve):
    factor = defaultdict(int)
    while sieve[x] != x:
        factor[sieve[x]] += 1
        x //= sieve[x]
    factor[x] += 1
    return factor

n = int(input())
a_list = list(map(int, input().split()))
a_list.sort()

sieve = sieve_of_eratosthenes(a_list[-1])
pairwise = True
setwise = True
primes = set()
x = a_list[0]
for a in a_list:
    x = gcd(x, a)
    if pairwise and a != 1:
        factor = set(factorize_by_sieve(a, sieve).keys())
        if not primes.isdisjoint(factor):
            pairwise = False
        else:
            primes |= factor

if pairwise:
    print("pairwise coprime")
elif x == 1:
    print("setwise coprime")
else:
    print("not coprime")

Measured memory_bytes: 187512
s = input()
slt = list(s)

mojiretu = ["A", "C", "G", "T"]

cntlt = list()
cnt = 0
for i in range(0, len(slt)):
    if slt[i] in mojiretu:
        cnt += 1
    else:
        cntlt.append(cnt)
        cnt = 0
else:
    cntlt.append(cnt)

print(max(cntlt))


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

int main()
{
    int K, S;
    cin >> K >> S;

    int counter = 0;

    for (int X = 0; X <= S; X++)
    {
        for (int Y = 0; Y <= S - X; Y++)
        {
            int Z = S - X - Y;
            if (Z >= 0 && X <= K && Y <= K && Z <= K)
                counter++;
        }
    }

    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 256