akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define LL long long
#define maxn 100010
LL sum,a[maxn],cnt[maxn];
int main(){
	int i,n,q,b,c;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%lld",&a[i]),sum+=a[i],cnt[a[i]]++;
	//printf("sum=%lld\n",sum);
	scanf("%d",&q);
	while(q--){
		scanf("%d%d",&b,&c);
		//printf("cnt[%d]=%lld cnt[%d]=%lld\n",b,cnt[b],c,cnt[c]);
		sum-=cnt[b]*b;
		//printf("sum=%lld\n",sum);
		sum+=cnt[b]*c;
		//printf("sum=%lld\n",sum);
		cnt[c]+=cnt[b],cnt[b]=0;
		printf("%lld\n",sum);
	}
	return 0;
}

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

typedef long long ll;

ll a, b, c, d;
ll res;

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

int main()
{
    cin >> a >> b >> c >> d;
    ll lcm = c / gcd(c, d) * d;
    res += b - b / c - b / d + b / lcm;
    a--;
    res -= (a - a / c - a / d + a / lcm);
    cout << res << endl;
    return 0;
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,K=MAP()
S=list(input())

S[K-1]=S[K-1].lower()
print(''.join(S))


Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))

ans = 0

while True:
    flag = False
    ans_tmp = ans
    for i in range(n):
        if a[i] > 0:
            a[i] -= 1
            if not flag:
                flag = True
                ans += 1
        else:
            flag = False
    if ans_tmp == ans:
        break

print(ans)


Measured memory_bytes: 38896
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

	ll x = 0, y = 0, z = 0;

	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; i + j <= n; j++)
		{
			int k = n - (i + j);
			if (s == 1000 * i + 5000 * j + 10000 * k)
			{
				cout << k << " " << j << " " << i << endl;
				return 0;
			}
		}
	}

	cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int max = Math.max(Math.max(a, b), c);
		boolean bool = false;
		int count = 0;
		if (a != max) {
			count += (max - a) / 2;
			if ((max - a) % 2 == 1) {
				bool = true;
			}
		}
		if (b != max) {
			count += (max - b) / 2;
			if ((max - b) % 2 == 1) {
				if (bool == false) {
					bool = true;
				} else {
					count++;
					bool = false;
				}
			}
		}
		if (c != max) {
			count += (max - c) / 2;
			if ((max - c) % 2 == 1) {
				if (bool == false) {
					bool = true;
				} else {
					count++;
					bool = false;
				}
			}
		}
		if (bool == true) {
			count += 2;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

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

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let mut h: usize;
    input!(h);

    let mut x = 1_usize;
    let mut ans = 0;

    while h > 0 {
        ans += x;
        h /= 2;
        x *= 2;
        
    }
    println!("{}", ans);
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,ans=0,AB=0,isA=0,isB=0;cin>>n;
  string s;
  rep(i,n) {
    cin>>s;
    if(s[0]=='B') isB++;if(s[s.length()-1]=='A') isA++;
    if(s[0]=='B'&&s[s.length()-1]=='A') AB++;
    for(ll i=0;i<s.length()-1;++i) if(s.substr(i,2)=="AB") ++ans;
  }
  ll Aval=isA-AB,Bval=isB-AB;
  if (AB==0) ans+=min(isA,isB);
  if (AB!=0&&max(Aval,Bval)!=0) ans+=AB+min(Aval,Bval);
  if (AB!=0&&max(Aval,Bval)==0) ans+=AB-1;
  print(ans);
  return 0;  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int d = sc.nextInt();
	int t = sc.nextInt();
	int s = sc.nextInt();
	if (d <= t * s) System.out.print("Yes");
	else { System.out.print("No"); }
    }
}


Measured memory_bytes: 35624
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <string>

#define TABLE_SIZE 16777216
#define ORDER_LENGTH 7
#define STR_LENGTH 13

using namespace std;

int translateChar(char ch){
	int ret;
	switch(ch){
	case 'A':
		ret = 1;
		break;
	case 'C':
		ret = 2;
		break;
	case 'G':
		ret = 3;
		break;
	case 'T':
		ret = 4;
		break;
	}
	return ret;
}

int calc(int num){
	if(num == 0){
		return 1;
	}else{
		return 4*calc(num-1);
	}
}

int translateStr(char buf[]){
	int sum = 0;
	for(int i = 0; buf[i] != '\0'; i++){
		sum += translateChar(buf[i])*calc(i);
	}
	return sum - 1;
}

int main(){

	queue<string> Messages;
	int n;
	scanf("%d",&n);
	char order[ORDER_LENGTH],str[STR_LENGTH];

	char* check_table = (char*)malloc(TABLE_SIZE);

	for(int i = 0; i < n; i++){
		scanf("%s %s",order,str);
		if(strcmp(order,"insert") == 0){
			check_table[translateStr(str)] = 'Y';
		}else{
			if(check_table[translateStr(str)] == 'Y'){
				Messages.push("yes");
			}else{
				Messages.push("no");
			}
		}
	}

	while(!Messages.empty()){
			cout << Messages.front() << endl;
			Messages.pop();
	}

	free(check_table);

}

Measured memory_bytes: 27540
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;
int n,m,x,y,t,flag,sum;
char a[12][12],s[66];
char h[5]="UDLR";
void get(int x,int y,int t,int num)
{
    //printf("%d:%d->%d:%d\n",x,y,t,num);
    s[num]=h[t];
    a[x][y]='.';
    if(flag)return;
    if(num==sum-1)
    {
        printf("%s\n",s+1);
        flag=1;
        return;
    }
///U
    if(t!=1)
    {
        for(int i=x-1; i>=0; i--)
        {
            if(a[i][y]=='o')
            {
                get(i,y,0,num+1);
                if(!flag)a[i][y]='o';
                else return;
                break;
            }
        }
    }

///D
    if(t!=0)
    {
        for(int i=x+1; i<n; i++)
        {
            if(a[i][y]=='o')
            {
                get(i,y,1,num+1);
                if(!flag) a[i][y]='o';
                else return;
                break;
            }
        }
    }

///L
    if(t!=3)
    {
        for(int i=y-1; i>=0; i--)
        {
            if(a[x][i]=='o')
            {
                get(x,i,2,num+1);
                if(!flag) a[x][i]='o';
                else return;
                break;
            }
        }
    }

///R
    if(t!=2)
    {
        for(int i=y+1; i<m; i++)
        {
            if(a[x][i]=='o')
            {
                get(x,i,3,num+1);
                if(!flag) a[x][i]='o';
                else return;
                break;
            }
        }
    }
}
int main()
{
    while(~scanf("%d%d",&n,&m))
    {
        sum=0;
        for(int i=0; i<n; i++)
        {
            scanf("%s",a[i]);
            for(int j=0; j<m; j++)
            {
                if(a[i][j]=='U')
                {
                    x=i,y=j,t=0;
                }
                if(a[i][j]=='D')
                {
                    x=i,y=j,t=1;
                }
                if(a[i][j]=='L')
                {
                    x=i,y=j,t=2;
                }
                if(a[i][j]=='R')
                {
                    x=i,y=j,t=3;
                }
                if(a[i][j]!='.')sum++;
            }
        }
        flag=0;
        memset(s,0,sizeof(s));
        get(x,y,t,0);
        //printf("*****\n");
    }
    return 0;
}

Measured memory_bytes: 1176
import math
     
A,B,H,M = map(int, input().split())
     
hourdegrees = ( H * 60 + M ) * (0.5)
mindegrees = M*(6)
      
if mindegrees < hourdegrees:
  degree = hourdegrees - mindegrees
else:
  degree = mindegrees - hourdegrees
      
distance = math.sqrt(A ** 2 + B ** 2 -2 * A * B * math.cos(math.radians(degree) ) )
print(distance)

Measured memory_bytes: 62648
l = map(int, raw_input().split())
points = map(int, raw_input().split())
cor = 0
for i in range(1,len(points)):
    if ((points[i]-points[i-1])*l[1]) > l[2]:
        cor+=l[2]
    elif ( (points[i]-points[i-1])*l[1])< l[2]:
        cor+=(points[i]-points[i-1])*l[1]

print cor


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

string a;

int main(){
    int left,right;
    cin>>a;
    for(int i=0;i<a.length();i++)
        if(a[i]=='A'){
            left=i;
            break;
        }
    for(int i=a.length()-1;i>=0;i--)
        if(a[i]=='Z'){
            right=i;
            break;
        }
    cout<<right-left+1<<endl;
    return 0; 
} 

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

int main(){
  int k,n;
  cin>>k>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int b=0,c,d=0;
  for(int i=0;i<n-1;i++){
    if(a.at(i+1)-a.at(i)>b){
      b=a.at(i+1)-a.at(i);
      c=i;
    }
  }
  if(k-a.at(n-1)+a.at(0)>b){
    b=k-a.at(n-1)+a.at(0);
    d++;
  }
  cout <<k-b;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define LL long long
#define PB push_back
#define X first
#define Y second
#define INF 1000 * 1000 * 1000
using namespace std;
const LL mod = 1000 * 1000 * 1000 + 7;
const LL ob = (mod + 1) >> 1;
int n , m;
string s[505];
string a[505];
string b[505];
int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 0; i < n; i++)
	{
		cin >> s[i];
		a[i] = b[i] = s[i];
	}
	for(int i = 0; i < n; i++)
	{
		a[i][0] = '#';
		b[i][m - 1] = '#';
	}
	for(int i = 1; i < n - 1; i += 2)
	{
		for(int j = 1; j < m - 1; j++)
			a[i][j] = '#';
	}
	for(int i = 2; i < n - 1; i += 2)
	{
		for(int j = 1; j < m - 1; j++)
			b[i][j] = '#';
	}
	
	for(int i = 0; i < n; i++)
		cout << a[i] << endl;
	cout << endl;
	for(int i = 0; i < n; i++)
		cout << b[i] << endl;

}




Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        String S;


        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            S = sc.next();
        }

        if(N >= 3200){
            System.out.println(S);
        }else{
            System.out.println("red");
        }
    }

}


Measured memory_bytes: 21972
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
	priority_queue<long long int>q; 
	long int m,n,t,i;
	cin >>n>>m;
	for(i=0;i<n;i++){
		cin>>t;
		q.push(t); 
	}
	long long int s=0;
	while(m){
		t=q.top()/2;
		q.pop();
		q.push(t);
		m--;
	}
	while(!q.empty()){
		s+=q.top();
		q.pop();
	}
	cout<<s; 
	return 0;
}

Measured memory_bytes: 1400
#include<stdio.h>
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a<=b && b<=c){
    printf("%d %d %d\n",a,b,c);
    //return 0;
  }
  else if(a<=c && c<=b){
    printf("%d %d %d\n",a,c,b);
    //return 0;
  }
  else if(b<=c && c<=a){
    printf("%d %d %d\n",b,c,a);
    //return 0;
  }
  else if(b<=a && a<=c){
    printf("%d %d %d\n",b,a,c);
    //return 0;
  }
  else if(c<=a && a<=b){
    printf("%d %d %d\n",c,a,b);
    //return 0;
  }
  else if(c<=b && b<=a){
    printf("%d %d %d\n",c,b,a);
    //return 0;
  }
  else{
    //return 0;
  }
  return 0;
  }

Measured memory_bytes: 1856
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

            main.solveA(sc);
            // main.solveB(sc);
            // main.solveC(sc);
            // main.solveD(sc);
            // main.solveE(sc);

        }

    }

    private void solveD(Scanner sc) {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out)) {
        } catch (IOException e) {

        }
    }

    private void solveE(Scanner sc) {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out)) {

        } catch (IOException e) {

        }
    }

    private void solveC(Scanner sc) {

    }

    void solveB(Scanner sc) {

    }

    class SolveB {
        int N;
        int M;

        void solve() {
            try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out)) {
                String[] line = br.readLine().split(" ");

            } catch (IOException e) {

            }

        }

    }

    void solveA(Scanner sc) {
        int N = sc.nextInt();
        int size = N * 3;
        List<Integer> list = new ArrayList<>(N * 3);
        for (int i = 0; i < N * 3; i++) {
            list.add(sc.nextInt());
        }
        java.util.Collections.sort(list);

        long sum = 0;
        for (int i = 1; i <= N; i++) {
            sum += list.get(size - i * 2);
        }

        System.out.println(sum);

    }
}


Measured memory_bytes: 99136
#include<iostream>

using namespace std;

int main(){

  int n,k;
  while(cin >> n >> k,n+k){
    int s[k];
    for(int i = 0;i < k;i++){
      cin >> s[i];
      
    }
    int b[n][k];
    for(int i = 0;i < n;i++){
      for(int j = 0;j < k;j++){
     
	cin >> b[i][j];
      }
    }
    int c[k] = {0};
    for(int i = 0;i < k;i++){
      for(int j = 0;j < n;j++){
	c[i] += b[j][i];
      }
    }
    int f = 1;
    /*for(int i = 0;i < k;i++){
      cout << s[i] << c[i] << endl;
      }*/
    for(int i = 0;i < k;i++){
      if(c[i] > s[i])
	f = 0;
    }
    if(f == 0)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }

}

Measured memory_bytes: 3032
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(void)
{
    LL Q,H,S,D,N;
    while(scanf("%lld %lld %lld %lld",&Q,&H,&S,&D)!=EOF)
    {
        scanf("%lld",&N);
        if(2LL*Q <= H)
            H = 2LL*Q;
        if(2LL*H <= S)
            S = 2LL*H;
        if(2LL*S <= D)
            D = 2LL*S;
        if(N%2LL == 0)
        {
            printf("%lld\n",N/2LL*D);
        }
        else
        {
            printf("%lld\n",N/2LL*D+S);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 10000000000

int main() {
	int n, m, i, j;
	long long k, ans = 0;
	cin >> n >> m >> k;
	vector<long long> a(n+1), b(m+1);
	a.at(0) = 0;
	for (int i = 1; i < n+1; i++) {
		cin >> a.at(i);
		a.at(i) += a[i-1];
	}
	b.at(0) = 0;
	for (int i = 1; i < m+1; i++) {
		cin >> b.at(i);
		b.at(i) += b[i-1];
	}

	i = 0;
	j = m;
	while (i < a.size()) {
		if (a[i] > k) break;
		while (j > 0) {
			if (b[j] <= k - a[i]) break;
			j--;
		}
		if (i + j > ans) ans = i + j;
		i++;
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 6348
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int length = S.length();
        int cnt = 0;
        int left = 0;
        int right = length - 1;
        while (left < right) {
            if (S.charAt(left) != S.charAt(right)) {
                cnt++;
            }
            left++;
            right--;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 23252
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto H = readln.split.map!(to!int).array;
    auto A = readln.split.map!(to!long).array;

    const int MAX = 2*10^^5 + 10;
    auto st = new SegmentTree!(long, max, 0L)(MAX);
    foreach (i; 1..MAX) st.assign(i, -(1L << 59));

    foreach (i; 0..N) {
        auto v1 = st.query(0, H[i]-1);
        auto v2 = st.query(H[i], H[i]);
        st.assign(H[i], max(v1+A[i], v2));
    }

    st.query(0, MAX).writeln;
}


class SegmentTree(T, alias op, T e) {
    T[] table;
    int size;
    int offset;

    this(int n) {
        size = 1;
        while (size <= n) size <<= 1;
        size <<= 1;
        table = new T[](size);
        fill(table, e);
        offset = size / 2;
    }

    void assign(int pos, T val) {
        pos += offset;
        table[pos] = val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    void add(int pos, T val) {
        pos += offset;
        table[pos] += val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    T query(int l, int r) {
        return query(l, r, 1, 0, offset-1);
    }

    T query(int l, int r, int i, int a, int b) {
        if (b < l || r < a) {
            return e;
        } else if (l <= a && b <= r) {
            return table[i];
        } else {
            return op(query(l, r, i*2, a, (a+b)/2), query(l, r, i*2+1, (a+b)/2+1, b));
        }
    }
}


Measured memory_bytes: 23428
import java.util.*;

public class Main {
	final static int TRUE = 1;
	final static int FALSE = -1;
	final static int UNDICIDE = 0;

	public static int solve(int s[][], int n) {
		int max = (int)Math.pow(2, n);
		int ans = 0, a = 0;
		for(int i = 0; i < max; ++i){
			int current = 1;
			a = 0;
			boolean judg[] = new boolean[n];
			for(int j = 0; j < n; ++j){
				int tmp = current & i;
				if(tmp > 0){
					judg[j] = true;
					++a;
				}
				current *= 2;
			}

			for(int j = 0; j < n; ++j){
				if(judg[j]){
					for(int k = 0; k < n; ++k){
						if(judg[k] && s[j][k] == FALSE){
							a = 0;
							break;
						}
						if(!judg[k] && s[j][k] == TRUE){
							a = 0;
							break;
						}
					}
				}
			}
			ans = Math.max(ans, a);
		}
		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int s[][] = new int[n][n];
		for (int i = 0; i < n; ++i) {
			int a = sc.nextInt();
			for (int j = 0; j < a; ++j) {
				int x = sc.nextInt(), y = sc.nextInt();
				if(y == 0) y = -1;
				s[i][x - 1] = y;
			}
		}
		sc.close();
		int ans = solve(s, n);
		System.out.println(ans);
	}
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
	friend ostream& operator<<(ostream& os, P p) {
		return os << "(" << p.x << "," << p.y << ")"; }
};

typedef Point<double> P;
double ccRadius(const P& A, const P& B, const P& C) {
	return (B-A).dist()*(C-B).dist()*(A-C).dist()/
			abs((B-A).cross(C-A))/2;
}
P ccCenter(const P& A, const P& B, const P& C) {
	P b = C-A, c = B-A;
	return A + (b*c.dist2()-c*b.dist2()).perp()/b.cross(c)/2;
}
pair<P, double> mec(vector<P> ps) {
	shuffle(all(ps), mt19937(time(0)));
	P o = ps[0];
	double r = 0, EPS = 1 + 1e-8;
	rep(i,0,sz(ps)) if ((o - ps[i]).dist() > r * EPS) {
		o = ps[i], r = 0;
		rep(j,0,i) if ((o - ps[j]).dist() > r * EPS) {
			o = (ps[i] + ps[j]) / 2;
			r = (o - ps[i]).dist();
			rep(k,0,j) if ((o - ps[k]).dist() > r * EPS) {
				o = ccCenter(ps[i], ps[j], ps[k]);
				r = (o - ps[i]).dist();
			}
		}
	}
	return {o, r};
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int n,a,b;
	cin >> n;
	vector<P> x;
	x.resize(n);
	for(int i =0; i <n ; i++) {
		cin >> a >> b;
		x[i] = P(a, b);
	}
	cout << fixed << setprecision(15);
	cout << mec(x).second;
}


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

void solve(){
    int n ,m; cin >> n >> m;
    int sum = 0;
    deque<int> A(n);
    REP(i, n){
        int a;
        cin >> a;
        sum += a;
        A[i] = a;
    }
    bool flag = true;
    sort(A.rbegin(), A.rend());
    //cout << sum*(1/(4.0*m)) << endl;
    REP(i, m){
        if(A[0] < sum*(1/(4.0*m))) flag = false;
        A.pop_front();
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,v[23],c[23],z[23],h=0;
	cin>>n;
	for(int i=0;i<n;i++)cin>>v[i];
	for(int i=0;i<n;i++)cin>>c[i];
	for(int i=0;i<n;i++){
		z[i]=(v[i]-c[i]);
		if(z[i]>0)h+=z[i];
	}
	cout<<h;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;


int main() {
	int N, K; cin >> N >> K;
	vector<int> V(N);
	long long ans = 0;
	
	for (int i = 0; i < N; i++)cin >> V[i];
	for (int l = 1; l <= K; l++) {
		if (l > N)break;
		for (int i = 0; i <= l; i++) {
			long long x = 0;
			vector<int> a;
			for (int j = 0; j < i; j++) a.push_back(V[j]);
			for (int k = 0; k < l - i; k++) a.push_back(V[N - 1 - k]);
			sort(a.begin(), a.end());
			for (int j = 0; j < a.size(); j++) x += a[j];
			for (int j = 0; j <= K - l; j++) {
				ans = max(ans, x);
				if (j == l)break;
				x -= a[j];
				
			}
		}
	}
	
	cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int a,b,c,d;
    cin>>s;
    a=s[0]-'0';
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';
    if(a+b+c+d==7)
        cout<<a<<'+'<<b<<'+'<<c<<'+'<<d;
    else if(a+b+c-d==7)
        cout<<a<<'+'<<b<<'+'<<c<<'-'<<d;
    else if(a+b-c-d==7)
        cout<<a<<'+'<<b<<'-'<<c<<'-'<<d;
    else if(a-b-c-d==7)
        cout<<a<<'-'<<b<<'-'<<c<<'-'<<d;
    else if(a+b-c+d==7)
        cout<<a<<'+'<<b<<'-'<<c<<'+'<<d;
    else if(a-b+c+d==7)
        cout<<a<<'-'<<b<<'+'<<c<<'+'<<d;
    else if(a-b-c+d==7)
        cout<<a<<'-'<<b<<'-'<<c<<'+'<<d;
    else if(a-b+c-d==7)
        cout<<a<<'-'<<b<<'+'<<c<<'-'<<d;
    cout<<"=7";
}


Measured memory_bytes: 3632
{-# OPTIONS_GHC -O #-}
import Data.List

mp = 1000000007
invmod a p = invmod' a p p 0 1
    where invmod' a p q x y
            | amq==0 = mod (x+p) p
            | otherwise = invmod' q p amq (y-div a q*x) x
            where amq = mod a q
divmod a b p = mod (a * invmod b p) p
cmbmod n k p = foldl' (\a i->divmod (mod (a*(n-i+1)) p) i p) 1 [1..k]

main = do
    (h:w:a:b:_)<-map read.words<$>getLine::IO[Int]
    print $ sol h w a b

sol h w a b = foldl' (\s x-> mod (s+x) mp) (aa*bb) $ unfoldr psi (aa,na,ka, bb,nb,kb)
    where
        na = h-a-1+b
        ka = b
        aa = cmbmod na ka mp
        nb = a-1+w-b-1
        kb = w-b-1
        bb = cmbmod nb kb mp
psi (_,_,_,_,_,0) = Nothing
psi dt@(aa,na,ka,bb,nb,kb) = Just ((aa'*bb')`mod` mp, (aa',na+1,ka+1, bb', nb-1,kb-1))
    where
        aa' = divmod ((aa*(na+1))`mod` mp) (ka+1) mp
        bb' = divmod ((bb*kb)`mod` mp) nb mp

Measured memory_bytes: 1020
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int,int>>> ADJ;
int N;
vector<int> C;
void dfs(int p,int t,int v)
{
	if(v%2==0)
	{
		C[t]=0;
	}
	else
	{
		C[t]=1;
	}
	for (int i = 0; i < ADJ[t].size(); ++i)
	{
		if(p!=ADJ[t][i].first)
		{
			dfs(t,ADJ[t][i].first,v+ADJ[t][i].second);
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
 //        freopen ("INPUT.txt" , "r" , stdin);
 //        // freopen ("OUTPUT.txt" , "w" , stdout);
 //    #endif

	cin>>N;
	ADJ.resize(N);
	C.resize(N);
	for (int i = 0; i < N-1; ++i)
	{
		int u,v,w;
		cin>>u>>v>>w;
		u--;v--;
		ADJ[u].push_back({v,w});
		ADJ[v].push_back({u,w});
	}
	dfs(-1,0,0);
	for (int i = 0; i < N; ++i)
	{
		cout<<C[i]<<endl;
	}	

	return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e2+5;
const int inf=1e9;
struct node
{
    int x,y;
}a[maxn],b[maxn];
int vis[maxn];
bool cmp(node a,node b)
{
    if(a.x==b.x)
        return a.y<b.y;
    else
        return a.x<b.x;
}
int main()
{
    memset(vis,0,sizeof(vis));
    int n,sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d%d",&a[i].x,&a[i].y);
    for(int i=0;i<n;i++)
        scanf("%d%d",&b[i].x,&b[i].y);
    sort(b,b+n,cmp);
    for(int i=0;i<n;i++)
    {
        int max1=-1,min_log=-1;
        for(int j=0;j<n;j++)
        {
            if(!vis[j])
            {
                if(a[j].x<b[i].x&&a[j].y<b[i].y)
                {
                    if(a[j].y>max1)
                    {
                        max1=a[j].y;
                        min_log=j;
                    }

                }
            }
        }
        if(min_log!=-1)
        {
            vis[min_log]=1;
            sum++;
        }
    }
    printf("%d\n",sum);
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (check(n)) System.out.println("Yes");
        else System.out.println("No");
    }
    
    public static boolean check(int n){
        String[] narray = String.valueOf(n).split("");
        int len = narray.length;
        int count = 0;
        int bool = 0;
        for (int i=0;i<2;i++){
            for (int j=i;j<i+3;j++){
                if (narray[i].equals(narray[j])) count++;
            }
            if(count==3) {
                bool = 1;
                break;
            }
count=0;
        }
        if(bool==0){
            return false;
        }else{
            return true;
        }
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    i32 N;
    cin >> N;
    Vec<i64> A(N + 2);
    Vec<i64> B(N + 1);
    for (i32 i = 1; i <= N + 1; i++) cin >> A[i];
    for (i32 i = 1; i <= N; i++) cin >> B[i];
    i64 sum = 0;
    for (i32 i = 1; i <= N + 1; i++) {
        if (i == 1) {
            if (A[1] <= B[1]) {
                sum += A[1];
                B[1] -= A[1];
                A[1] = 0;
            } else {
                sum += B[1];
                A[1] -= B[1];
                B[1] = 0;
            }
        }
        if (A[i] > 0) {
            if (B[i - 1] > 0) {
                if (A[i] <= B[i - 1]) {
                    sum += A[i];
                    B[i - 1] -= A[i];
                    A[i] = 0;
                } else {
                    sum += B[i - 1];
                    A[i] -= B[i - 1];
                    B[i - 1] = 0;
                }
            }
            if (i != N + 1  && A[i] > 0 && B[i] > 0) {
                if (A[i] <= B[i]) {
                    sum += A[i];
                    B[i] -= A[i];
                    A[i] = 0;
                } else {
                    sum += B[i];
                    A[i] -= B[i];
                    B[i] = 0;
                }
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 4616
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int a,b;
	int sum;
	int wsum;
	int x;
	int i;
	cin>>n>>a>>b;
	wsum=0;
	for(i=1;i<=n;i++){
		x=i;
		sum=0;
		while(x>0){
			sum+=x%10;
			x/=10;
		}
		if(a<=sum&&sum<=b)	wsum+=i;
	}
	cout<<wsum<<endl;
	return 0;
}

Measured memory_bytes: 256
x=input()
a=x[0]
b=x[1]
c=x[2]
d=x[3]

for i in range(8):
  bi=bin(i)[2:].zfill(3)
  temp=[]
  for j in range(3):
    if bi[j]=="0":
      temp.append("-")
    else:
      temp.append("+")
  ans=""
  for j,k in zip(x,temp):
    ans+=j+k
  ans+=d
  if eval(ans)==7:
    print(ans+"=7")
    exit()

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

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0 ; i < n ; i ++) cin >> a[i];
    
    sort(a.begin(),a.end());
    
    int count = 1;
    for(int i = 0 ; i < n - 1 ; i ++){
        if(a[i + 1] != a[i]) count ++;
    }
    
    cout << count << endl;
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;

    long[] B = new long[](N);
    long cnt = 0;
    while (A.reduce!max >= N) {
        long T = 0;
        fill(B, 0);
        foreach (i; 0..N) {
            if (A[i] >= N) {
                B[i] = - A[i] / N;
                T += A[i] / N;
                A[i] %= N;
            }
        }

        foreach (i; 0..N) {
            A[i] += T + B[i];
        }

        cnt += T;

    }

    cnt.writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
    
    #define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
    #define ll long long int
    #define ull unsigned long long int
    #define ld long double
    #define sb __builtin_popcount
    #define vi vector<int>
    #define vl vector<ll>
    #define vc vector<char>
    #define ii pair<int, int>
    #define pq priority_queue<ii, vector<ii>, greater<ii>>
    #define vii vector<ii>
    #define viii vector<tuple<ll, ll, ll>>
    #define sz(a) int((a).size())
    #define f(a, b) for (int i = a; i < b; i++)
    #define fr(a, b) for (int i = a - 1; i >= b; i--)
    #define tr(x, m) for (auto x : m)
    #define in(a, b) (b.find(a) != string::npos)
    #define minin(a) *min_element(all(a))
    #define maxin(a) *max_element(all(a))
    #define bs(l, h, k) equal_range(l, h, k);
    #define X first
    #define Y second
    #define fill(a, x) memset(a, x, sizeof(a))
    #define pb push_back
    #define pf push_front
    #define mp make_pair
    #define all(v) v.begin(), v.end()
    #define rall(v) reverse(v.begin(), v.end())
    #define unq(v) v.erase(unique(all(v)), v.end())
    #define el "\n"
    #define mx3(a, b, c) max(max(a, b), c)
    #define S(v) accumulate(all(v), (ll)0)
    #define IP(v1, v2) inner_product(all(v1), v2.begin(), (ll)0)
    const long double PI = atan(1.0) * 4.0;
    const ll MOD = 1e9 + 7;
    const ll INF = 1e18;
    const ld EPS = 0.0000001;
      
        int main() {
            fio;
            ll n;
            cin>>n;
            ll ans=0;
            for(ll i=1;i<=n;i++){
                for(ll j=1;j<=n;j++){
                    for(ll k=1;k<=n;k++){
                        ans+=__gcd(__gcd(i,j),k);
                    }
                }
            }
            cout<<ans<<el;
            return 0;
        }


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;
int main(){
  string s;cin>>s;
  int goo=0;
  for(int i=0;i<(int)s.size();i++){
  	if(s[i]=='g')goo++;
  }
  cout<<((goo-((int)s.size()-goo))/2)<<endl;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL A, V;
    cin >> A >> V;
    LL B, W;
    cin >> B >> W;
    LL T;
    cin >> T;
    if(V <= W) {
        cout << "NO" << endl;
    } else {
        LL t = llabs(A - B);
        V -= W;
        LL tt = t / V;
        if(t % V) ++tt;
        if(tt <= T) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 3644
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    A,B=map(int,input().split())
    print(max(A+B,A-B,A*B))

if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    vector<string> days{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string S;
    cin >> S;
    for (int i=0 ; i<days.size() ; i++)
    {
        if (days[i]==S)
        {
            if (i==0)
                cout << 7;
            else
                cout << 7-i;
            break;
        }
    }
}

// https://atcoder.jp/contests/abc146/tasks/abc146_a

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

void Main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        int a;
        cin >> a;
        if(i % 2 == 1 && a % 2 == 1) {
            ans++;
        }
    }
    
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  map<int,int> a;
  for(int i = 0; i < n; i++){
    int x; cin >> x;
    a[x]++;
  }
  bool bad = false;
  if(n&1){
    if(a[0] != 1) bad = true;
    for(int i = 2; i < n; i += 2) if(a[i] != 2) bad = true;
  } else {
    for(int i = 1; i < n; i += 2) if(a[i] != 2) bad = true;
  }
  if(bad) cout << 0 << endl;
  else {
  	int ans = 1;
    for(int i = 0; i < n/2; i++) ans = (ans + ans) % 1000000007;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4096
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int v[20];
  int c[20];
  for(int i=0;i<n;i++){
    scanf("%d",&v[i]);
  }
  for(int i=0;i<n;i++){
    scanf("%d",c+i);
  }
  int sum = 0;
  for(int i=0;i<n;i++){
    if(v[i] > c[i]) sum += v[i] - c[i];
  }
  printf("%d\n",sum);
  return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(string s;cin>>s;){
		cout<<(s.substr(0,4)=="YAKI"?"Yes":"No")<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a = n/2;
    double res = (double)(n-a)/n;
    cout << res << endl;
    return 0;
}

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

int main() 
{
    
    int N, M;
    cin >> N >> M;
    vector<int>S(M);
    vector<int>C(M);
    for (int i = 0; i < M; i++) {
        cin >> S[i] >> C[i];
    }
    
    for (int i = 0; i < 1000; i++) {
        int keta = 1;
        int nx = i/10;
        vector<int>d(1, i%10);
        while (nx) {
            keta++;
            d.push_back(nx % 10);
            nx /= 10;
        }
        if (keta != N) {
            continue;
        }
        
        bool flag = true;
        reverse(d.begin(), d.end());
        for (int i = 0; i < M; i++) {
            if (d[S[i]-1] != C[i]) {
                flag = false;
            }
        }
        if (flag) {
            cout << i << endl;
            return 0;
        }
    }
    
    cout << -1 << endl;
}


Measured memory_bytes: 256
def myAnswer(N:int,A:int,B:int) -> int:
   if(B - A > N or B - A < 0): return 0
   ans = (B*(N-1) + A) - (A * (N - 1) + B) + 1
   return ans

def modelAnswer():
   return
def main():
   N,A,B = map(int,input().split())
   print(myAnswer(N,A,B))
if __name__ == '__main__':
   main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	string S;
	cin >> S;
	if(S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi"){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3632
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int l=0,r=n-1;
	int cnt=0;
	while(l<r){
		while(l<n && s[l]=='R')
			l++;
		while(r>=0 && s[r]=='W')
			r--;
		if(l<r && s[l]=='W' && s[r]=='R')
			swap(s[l],s[r]),cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}







Measured memory_bytes: 3768
n = int(input())
a = list(map(int, input().split()))
d = {i:0 for i in range(9)}
for ele in a:
  if ele>=3200:
    d[8] += 1
  else:
    d[ele//400] = 1
ans1, ans2 = 0, 0
for k, v in d.items():
  if k!=8:
    ans1 += v
  ans2 += v
ans1 = max(1, ans1)
ans2 = ans2
print(ans1, ans2)

Measured memory_bytes: 3188