akhauriyash/Code-Regression huggingface dataset:
from bisect import bisect as bisect

def main():
    score = [1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
    M = len(score)
    N = int(input())
    A = [int(x) for x in input().split()]

    colors = set()
    m = 0
    for a in A:
        i = bisect(score, a)
        if i != M:
            colors.add(i)
        elif i == M:
            m += 1
    print(len(colors) if len(colors) > 0 else 1, len(colors)+m)

main()





Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
const int MAXN = 1000001;
vector<int> adj[MAXN];
int power(int x, int y, int p = mod){ 
    int res = 1; 
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0) {  
        if (y & 1) res = (res*x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
} 
int modFact(int n, int p = mod) 
{ 
    if (n >= p) 
        return 0; 
  
    int result = 1; 
    for (int i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result; 
} 
int32_t main(){
    SPEED;
    int n, d;
    cin >> n >> d;
    int mat[n][d];
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < d; ++j){
            cin >> mat[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            int res = 0;
            for(int k = 0; k < d; ++k){
                int cal = abs(mat[i][k] - mat[j][k]);
                res += cal * cal;
            }
            int temp = sqrt(res);
            if(temp * temp == res ) ans++;
            //cout << res << " ";
        }
    }
    cout << ans << endl;
}
// check indices of loop
// check for overflow


Measured memory_bytes: 27108
#include <iostream>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int H, W;
while (cin >> H >> W && (H > 0 || W > 0)) {
for (int i = 0; i < H; i++) {
 for (int j = 0; j < W; j++) cout << "#";
 cout << "\n";
}
cout << "\n";
}
}

Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
#define MaxN 1003

const int Mod = 1e9 + 7;
int N, M;
int f[MaxN][MaxN];
char a[MaxN][MaxN];

int main() {
	cin >> N >> M;
	for(int i = 1; i <= N; ++i)
		cin >> a[i] + 1;
	f[0][1] = 1;
	for(int i = 1; i <= N; ++i)
		for(int j = 1; j <= M; ++j)
			if(a[i][j] != '#')
				f[i][j] = (f[i - 1][j] + f[i][j - 1]) % Mod;
	cout << f[N][M] << endl;
	return 0;
}

Measured memory_bytes: 5120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try{
			int verLineNum = Integer.parseInt(br.readLine()); //tate
			int horLineNum = Integer.parseInt(br.readLine()); //yoko
			ArrayList<Integer[]> horLineList = new ArrayList<Integer[]>();
			for(int i=0;i<horLineNum;i++){
				String[] lineStr = br.readLine().split(",");
				Integer[] lineInfo = new Integer[2];
				for(int j=0;j<lineInfo.length;j++){
					lineInfo[j] = Integer.parseInt(lineStr[j]);
				}
				horLineList.add(lineInfo);
			}
			
			for(int i : SortGoalLine(verLineNum, horLineList)){
				System.out.println(i);
			}
		}
		catch(Exception e){
			return;
		}
		finally{
			try {
				br.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				return;
			}
		}
	}
	
	private static Integer[] SortGoalLine(int verLineNum,List<Integer[]> horizonLineList){
		Integer[] goalNum = new Integer[verLineNum];
		for(int i=0;i<goalNum.length;i++){
			goalNum[i] = i+1;
		}
		
		for(Integer[] i : horizonLineList){
			int temp = goalNum[i[0]-1];
			goalNum[i[0]-1] = goalNum[i[1]-1];
			goalNum[i[1]-1] = temp;
		}
		
		return goalNum;
	}

}

Measured memory_bytes: 9344
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
 
public class Main {

	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final int size = 3;
			
			int[][] board = new int[size][size];
			for(int i = 0; i < size; i++){
				for(int j = 0; j < size; j++){
					board[i][j] = sc.nextInt();
				}
			}
			
			for(int a1 = -200; a1 <= 200; a1++){
				for(int a2 = -200; a2 <= 200; a2++){
					for(int a3 = -200; a3 <= 200; a3++){
						final int b1 = board[0][0] - a1;
						final int b2 = board[0][1] - a1;
						final int b3 = board[0][2] - a1;
						
						if(board[1][0] - a2 != b1){ continue; }
						if(board[1][1] - a2 != b2){ continue; }
						if(board[1][2] - a2 != b3){ continue; }
						if(board[2][0] - a3 != b1){ continue; }
						if(board[2][1] - a3 != b2){ continue; }
						if(board[2][2] - a3 != b3){ continue; }
						
						System.out.println("Yes");
						return;
					}
				}
			}
			
			System.out.println("No");
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22484
from typing import List, Optional


class Node:
	def __init__(self, key) -> None:
		self.key: int = key
		self.left: Optional[Node] = None
		self.right: Optional[Node] = None
		self.parent: Optional[Node] = None


class Tree:
	def __init__(self) -> None:
		self.root: Optional[Node] = None


def insert(T: Tree, z: Node) -> None:
	y: Optional[Node] = None
	x: Optional[Node] = T.root
	while x is not None:
		y = x # 親を設定
		if z.key < x.key:
			x = x.left
		else:
			x = x.right
	z.parent = y

	if y is None:
		T.root = z
	elif z.key < y.key:
		y.left = z
	else:
		y.right = z


def inorder(z: Optional[Node]):
	if z is not None:
		inorder(z.left)
		print(f" {z.key}", end="")
		inorder(z.right)


def preorder(z: Optional[Node]):
	if z is not None:
		print(f" {z.key}", end="")
		preorder(z.left)
		preorder(z.right)


if __name__ == "__main__":
	m = int(input())
	T = Tree()
	for _ in range(m):
		command = list(input().split())
		if command[0] == "insert":
			z = Node(int(command[1]))
			insert(T, z)
		else:
			inorder(T.root)
			print("")
			preorder(T.root)
			print("")


Measured memory_bytes: 106768
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define ll long long
#define INF 1000000001

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  char X,Y;cin>>X>>Y;
  if(X<Y)P('<');
  if(X>Y)P('>');
  if(X==Y)P('=');
  return 0;
}


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

int main() {
  vector<int>v(3); cin >> v.at(0) >> v.at(1) >> v.at(2);
  sort(v.begin(),v.end());
  if(v.at(2) == v.at(0)+v.at(1)) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int yaku(int n){
  int ans = 1;
  for(int i=2;i<=n;i++){
    if(n%i == 0) ans ++;
  }
  return ans;
}

int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i=1;i<=n;i+=2){
    if(yaku(i) == 8) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())

ans = 0
for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        d = i-1
        if d!=0 and N//d==N%d:
            ans += d
        if i*i!=N:
            d = N//i-1
            if d!=0 and N//d==N%d:
                ans += d

print(ans)

Measured memory_bytes: 41068
#include <bits/stdc++.h>
#define pb push_back
#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long LL;

const int maxn= 200000 + 10; 

int col[maxn] , N,M;
vector<int> G[maxn];
bool DFS(int u, int &wh, int &bl,int &en){
	#ifdef che
	debug("DFS(%d)\n", u);
	#endif
	if ( col[u] ) wh++;	
		else bl++;
	bool bip = true;
	en += G[u].size();
	for (int i=0, v; i<G[u].size()?v=G[u][i] ,1:0; i++)
		if( col[v] == -1){ col[v] = col[u]^1; bip&=DFS(v, wh, bl,en);}
			else bip &= col[u] ^col[v];
	return bip;
}

int main(){

	scanf("%d%d", &N , &M);
	for (int i=0, u ,v; i<M; i++){
		scanf("%d%d", &u, &v);
		G[u].pb(v); G[v].pb(u);
	}
	LL ans=0 ;
	memset(col, -1, sizeof(col));
	for (int u=1,wh, bl,en; u<=N; u++)
		if( col[u] ==-1 ){
			wh = bl = en= col[u]=0 ;
			if ( DFS(u , wh, bl, en)) ans+= (LL)bl*wh-(LL)en/2;
				else ans +=(LL)(bl+wh)*(LL(bl+wh-1))/2  -(LL)en/2;
			#ifdef che
			debug("DFS(%d) : white= %d, black = %d, edgn = %d)\n", u, wh, bl, en);
			#endif
		}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
long long a=2019;
int main(){
  long long L,R; cin>>L>>R;
  if(L+2019<R){cout<<0<<endl; return 0;}
  L%=a; R%=a;
  if(L>=R){cout<<0<<endl; return 0;}
  long long ans=2000000;
  for(long long i=L;i<=R;i++){
    for(long long j=L;j<=R;j++){
      if(j==i)continue;
      ans=min(ans,(i*j)%a);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
import sys

inf = float('inf')

n, k, *xy = map(int, sys.stdin.read().split())
xy = list(zip(*[iter(xy)] * 2))

def main():
    xy.sort(key=lambda x: x[0])
    x = []
    y = []
    for i in range(n):
        x.append(xy[i][0])
        y.append(xy[i][1])
    
    area = inf
    for l in range(n-k+1):
        for r in range(l+k-1, n):
            dx = x[r] - x[l]
            seq_y = sorted(y[l:r+1])
            m = r - l + 1
            for d in range(m-k+1):
                for u in range(d+k-1, m):
                    dy = seq_y[u] - seq_y[d]
                    area = min(area, dx * dy)

    return area

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
def main():
    n,a,b = map(int,input().split())
    x = list(map(int,input().split()))
    ans=0
    for i in range(n-1):
        ans+=min( (x[i+1]-x[i])*a , b )
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 62704
n, m = map(int, input().split())
arr = list(list(input()) for _ in range(n))
rmv_row = [1] * n
rmv_col = [1] * m
for i in range(n):
    for j in range(m):
        if arr[i][j] == '#':
            rmv_row[i] = 0
            rmv_col[j] = 0
for i in range(n):
    if rmv_row[i] == 1:
        continue
    for j in range(m):
        if rmv_col[j] == 1:
            continue
        print(arr[i][j], end='')
    print()

Measured memory_bytes: 42984
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a;
    int b;
    int c;
    scanf("%d %d %d",&a,&b,&c);
    if (a<b&&b<c) {
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 580
use std::io::{stdin, stdout, BufReader, BufRead, StdinLock, Write, BufWriter};

fn main() {
    let (std_in, std_out) = (stdin(), stdout());
    let mut br = BufReader::new(std_in.lock());
    let mut bw = BufWriter::new(std_out.lock());
    
    let n = rn::<usize>(&mut br);
    let p = rvn::<usize>(&mut br);

    let mut sorted = p.clone();
    sorted.sort();

    let mut cnt = 0;
    for i in 0..n {
        if (p[i] != sorted[i]) {
            cnt += 1;
        }
    }
    if (cnt <= 2) {
        writeln!(&mut bw, "YES");
    } else {
        writeln!(&mut bw, "NO");
    }
} 


//////////////////////////////////////////////////////////////////////////////////
#[allow(dead_code)]
fn rs(br: &mut BufReader<StdinLock>) -> Vec<char> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().chars().collect()
}

#[allow(dead_code)]
fn rn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> T {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn rvs(br: &mut BufReader<StdinLock>) -> Vec<Vec<char>> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.chars().collect()).collect()
}

#[allow(dead_code)]
fn rvn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> Vec<T> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
def main():
    import sys
    input = sys.stdin.readline
    MAX = 10**9+7

    n = int(input())
    a = tuple(map(int, input().split()))

    li = [0]*61
    for i in a:
        for j in range(61):
            li[j] += i&1
            i >>= 1
    ans = 0
    bit = 1
    for i in li:
        ans += bit * i * (n-i)
        bit <<= 1
    print(ans%MAX)

if __name__ == '__main__':
    main()


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, M;
  cin >> N >> M;

  VVI G(N, VI(N, 1));
  REP(i,M){
	int u, v;
	cin >> u >> v;
	--u;
	--v;
	G[u][v] = G[v][u] = 0;
  }
  REP(i,N) G[i][i] = 0;

  int ans = 0;
  VI col(N);
  vector<PII> comp;
  REP(i,N){
	if(col[i]) continue;
	queue<int> q;
	PII cnt(1,0);
	VI as, bs;
	col[i] = 1;
	as.PB(i);
	
	REP(j,N){
	  if(G[i][j]){
		col[j] = -1;
		cnt.SS++;
		bs.PB(j);
		q.push(j);
	  }
	}
	if(q.empty()){
	  comp.EB(1, 0);
	  continue;
	}

	bool ok = true;
	while(!q.empty()){
	  int u = q.front();
	  q.pop();
	  REP(to,N){
		if(G[u][to]){
		  if(col[to]){
			if(col[u] == col[to]){
			  ok = false;
			  break;
			}
		  }
		  else{
			col[to] = col[u] * -1;
			++(col[to] > 0 ? cnt.FF : cnt.SS);
			(col[to] > 0 ? as : bs).PB(to);
			q.push(to);
		  }
		}
	  }
	}

	if(!ok){
	  cout << -1 << endl;
	  return 0;
	}
	comp.PB(cnt);
	for(int a: as){
	  for(int b: bs){
		if(!G[a][b])
		  ++ans;
	  }
	}
  }

  VVI dp(2, VI(710, -1e9));
  int S = 0, crt = 0, nxt = 1;
  dp[crt][0] = 0;
  for(auto& p: comp){
	fill(ALL(dp[nxt]), -1e9);
	for(int k=0;k<=S;++k){
	  maxi(dp[nxt][k + p.FF], dp[crt][k] + k * p.SS + (S-k) * p.FF);
	  maxi(dp[nxt][k + p.SS], dp[crt][k] + k * p.FF + (S-k) * p.SS);
	}
	S += p.FF + p.SS;
	swap(crt, nxt);
  }

  int mx = 0;
  REP(i,S+1) maxi(mx, dp[crt][i]);

  cout << M - ans - mx << endl;

  return 0;
}


Measured memory_bytes: 2176
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	cout << (max(0, n - k)*y + min(k, n) * x) << endl;
		return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
 
using namespace std;
  
int main(){
  int K, N;
  cin >> K >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  
  bool place[K];
  for(int i=0;i<K;i++){
    place[i] = false;
  }
  for(int i=0;i<N;i++){
    place[A[i]] = true;
  }
  int distance = 0;
  int max_distance = 0;
  bool second = false;
  int i = 0;
  while(1){
    if(place[i]){
      max_distance = max(max_distance, distance+1);
      distance = 0;
      if(second) break;
    }else{
      distance++;
    }
    i++;
    if(i>=K){
      i = 0;
      second = true;
    }
  }
  int ans = K-max_distance;
    
    
  
  
  cout << ans << endl;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,ans=0;
    cin>>n;
    if(n%2==0)
    {
        cout<<n<<endl;
    }
    else
    {
        ans=n*2;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        double a = in.nextDouble();
        double b = in.nextDouble();
        out.println(a/b);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



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

int main(){
  long long int h,w;
  cin >> h >> w;
  long long int ans=0;
  if(h==1||w==1){
    ans = 1;
  }else if(h%2==0){
    ans = h/2*w;
  }else if(w%2==0){
    ans = h*w/2;
  }else{
    ans = h*(w/2)+h/2+h%2;
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
   int n,m;
   long long res=0;
   cin>>n>>m;
   vector<int>arm[m+1];
   for(int i=0;i<m;i++)
   {
       int c;
       cin>>c;
       for(int j=0;j<c;j++)
       {
           int cc;
           cin>>cc;
           arm[i].push_back(cc);
       }
   }
   int p[m+1];
   for(int i=0;i<m;i++)
    cin>>p[i];

   long long lim=pow(2,n);

//cout<<lim<<endl;
   for(int i=0;i<lim;i++)
   {
       vector<int>temp;
       int cnt=0;
       for(int j=0;j<n;j++)
       {
           if(i&1<<j)
            temp.push_back(1);
           else temp.push_back(0);
       }

       reverse(temp.begin(),temp.end());

       for(int j=0;j<m;j++)
       {
           int cntt=0;
           for(int k=0;k<arm[j].size();k++)
           {
               int cc=arm[j][k];
               if(temp[cc-1])
                cntt++;
           }
           if(cntt%2==p[j])
            {cnt++;}
       }
       if(cnt==m)
       {
          res++;
       }
       cnt=0;
       temp.clear();
   }
   cout<<res<<endl;
   return 0;
}


Measured memory_bytes: 256
def main():
    n, x = map(int, input().split())
    L = list(map(int, input().split()))
    cnt = 1
    tmp = 0
    for i in range(len(L)):
        tmp += L[i]
        if tmp <= x:
            cnt += 1
        else:
            break
    print(cnt)


if __name__ == '__main__':
    main()

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll h; cin >> h;
    ll ans=1;
    ll cnt=2;
    while(h>1){
        ans += cnt;
        cnt *= 2;
        h/=(ll)2;
    }
    cout << ans << endl;
}

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

int ha[100005] = { 0 };
int hb[100005] = { 0 };

int main()
{
	int A, B,M;
	cin >> A >> B>>M;
	ha[0] = 100000000;
	hb[0] = 100000000;
	for (int i = 1; i <= A; i++) {
		cin >> ha[i];
		if (ha[i] < ha[0])ha[0] = ha[i];
	}
	for (int i = 1; i <= B; i++) {
		cin >> hb[i];
		if (hb[i] < hb[0])hb[0] = hb[i];
	}

	int ans = ha[0] + hb[0];
	for (int i = 1; i <= M; i++) {
		
		int x, y, c;
		cin >> x >> y >>c;
		if (ha[x] + hb[y] - c < ans)ans = ha[x] + hb[y] - c;
		
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
(let* ((N (read))
       (M (read))
       (C (read))
       (B (loop for i below M
             collect (read)))
       (A (loop for i below N
             collect (loop for j below M
                        collect (read)))))
  (format t "~A~%"
          (loop for i below N
             count (< 0 (+ (reduce #'+
                                   (mapcar #'* (nth i A) B))
                           C)))))


Measured memory_bytes: 15968
// std::set を用いた解
#include <iostream>
#include <set>
#include <map>
#include <string>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    long A[N];
    for (int i = 0; i < N; ++i) cin >> A[i];
 
    map<int, int> mp; // 連想配列 map<key:数値, value:出現回数の偶奇> 
    for (int i = 0; i < N; ++i) {
        auto itr = mp.find(A[i]);        // s[i] が設定されているか？
        if(itr != mp.end() ) {
             mp[A[i]] = (mp[A[i]] + 1) % 2; // ある場合
        }
        else {
             mp[A[i]] = 1 ;
        }
    }
    int sum = 0;
    
    //for(auto itr = mp.begin(); itr != mp.end(); ++itr){
    //    cout << itr->first << " " << itr->second << endl;
    //}
    
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) sum += itr->second;
	
    cout << sum << endl;
}
 

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define DEBUG true
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}

inline LL calcM(LL x, LL y) {   // returns argmin{m} x >= m * y;
    LL ret = x / y;
    if (x % y != 0) ret++;
    return ret;
}

int main() {
    LL N;
    cin >> N;
    LL tmin = 1, amin = 1;
    REP(i, N) {
        LL t, a;
        cin >> t >> a;
        LL tm = calcM(tmin, t);
        LL am = calcM(amin, a);
        LL m = max(tm, am);
        tmin = t * m;
        amin = a * m;
    }
    cout << tmin + amin << endl;
	
    return 0;
}


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

long long n, m, w, v, dp[100001], ans;

int main() {
	cin>>n>>m;
	for (int i=1; i<=n; i++) {
		cin>>w>>v;
		for (int j=m; j>=w; j--) {
			dp[j]=max(dp[j],dp[j-w]+v);
		}
	}
	for (int j=1; j<=m; j++) ans=max(ans,dp[j]);
	cout<<ans<<endl;;
	return 0;
}

Measured memory_bytes: 1024
import Control.Applicative
import Data.List

findMatches :: [(Int, Int)] -> Int
findMatches [] = 0
findMatches ((x,y):xs) = a + findMatches xs
    where a = (x+y) `mod` 2

getMapping :: [(Int, Int)] -> Int -> [(Int, Int)]
getMapping [] _ = []
getMapping ((x, y):xs) p = (p,y):ys
    where ys = getMapping xs (p+1)

main :: IO ()
main = do
    n <- read <$> getLine
    raw <- mapM (\x -> (\s -> ((read :: String -> Int) s, x)) <$> getLine) [1..n]
    let xs = sort raw
        mp = getMapping xs 1
        res = (findMatches mp) `div` 2
    putStrLn . show $ res


Measured memory_bytes: 71036
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE OverloadedStrings #-} 
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as TIO
import Data.Monoid
import Data.List
import qualified Data.Vector.Unboxed as V

main = do
  input <- TIO.getContents
  let ls = T.lines input 
      n = ls !! 0
      l :: V.Vector Int
      l =   V.fromList $ fmap ( read .T.unpack) $ T.words $ ls !! 1      
      (!s0,!s2,!s4) = V.foldl f (0,0,0) l
        where f  (s0,s2,s4) a  | (a `mod` 4) == 0 = (s0, s2, s4 + 1)
                               | (a `mod` 2 ) == 0 =  (s0, s2 + 1, s4)
                               | otherwise =  (s0 + 1, s2 , s4)
      getR (s0,s2,s4) | (s0<=s4) || ( s0 == s4+1 && s2 == 0 ) = "Yes"  
                      | otherwise = "No"
  Prelude.putStr $  getR (s0,s2,s4)


Measured memory_bytes: 7848
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int findsumofDigits(int n){
        int sum = 0;
        while(n >0){
            sum += n%10;
            n /= 10;
        }
        return sum;
    }

int main()
{
    int a,b,ans,x[50],y;
    cin >> a >> b ;
    ans = 0;
    
    while(a<=b)
    {
        y = a;
        for(int i = 0; i < 5; i++)
        {
            x[i] = y%10;
            y /= 10;
        }

        if (x[0] == x[4] && x[1] == x[3]) {
            ans++;
        }
        
        a++;
    }
    
    cout << ans <<endl;
    
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
namespace Atcoder_0404
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB=GetInput_int();

            Console.WriteLine(AB[0] * AB[1]);
        }
        
        #region input
        

        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        /// <summary>
        /// 最大公約数
        /// </summary>
        public static int GCD(int a, int b)
        {

            /* 自然数 a > b を確認・入替 */
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            /* ユークリッドの互除法 */
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        public static int LCM(int a, int b)
        {
            int x = a * b;
            b = GCD(a, b);
            return x / b;

        }
        #endregion

        static long mod = 1000000000 + 7;
        
    }
}

Measured memory_bytes: 27536
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ASC(v) sort(v.begin(), v.end());
#define DESC(v) sort(v.begin(), v.end(), greater<int>());
#define REVERSE(v) reverse(v.begin(), v.end());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main() {
	string S, T, U;
	cin >> S >> T;
	ll A, B;
	cin >> A >> B;
	cin >> U;

	if (U == S) A--;
	if (U == T) B--;

	cout << A << " " << B << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#define ll long long

using namespace std;
ll MOD = 1e9 + 7;
int main(){
  int n;
  cin >> n;
  vector<ll> a( n+1 , 0 );
  for( int i = 0 ; i < n ; i++ ){
    cin >> a[i];
  }
  ll ret = 0;
  for( int i = 60 ; i >= 0 ; i-- ){
    ll num1 = 0;
    ret = ret << 1;
    for( int j = 0 ; j < n ; j++ ){
      if( a[j] >> i & 1 ) num1++;
    }
    ret = ret + num1 * ( n - num1 );
    ret %= MOD;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n);
  
  int a[200001] = {0} , b;
  for(int i = 0;i < n-1;i ++){
    scanf("%d",&b);
    a[b] ++;
  }
  for(int i = 1;i <= n;i ++){
    printf("%d\n",a[i]);
  }

  return 0;
}

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

int main() {
    using namespace std;

    int N;
    cin >> N;

    int max_count = 0;
    int max_number = N;
    while (0 < N) {
        int count = 0;
        int m = N;
        while (true) {
            if (m % 2 != 0)
                break;

            count++;
            m = m / 2;
        }

        if (max_count < count) {
            max_number = N;
            max_count = count;
        }

        N--;
    }

    cout << max_number << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>


#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

ll g(ll n) { return n * (n + 1) / 2; }

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;

    ll ans = 0;
    for (unsigned int i = 1; i <= n; i++) {
        ans += i * g(n / i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    ll x, k, d;
    cin >> x >> k >> d;
    if (abs(x)/d > k) {
        cout << abs(x) - k * d << "\n"; return 0;
    }
    ll r = abs(x) % d;
    ll num = abs(x) / d;
    ll ans;
    if (x > 0) {
        ans = x - num * d;
    } else {
        ans = x + num * d;
    }
    ll y = (k - num) % 2;
    if (y == 1) {
        if (x > 0) ans -= d;
        else ans += d;
    }
    cout << abs(ans) << "\n";
    return 0;
}


Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

const int MOD=1e9+7;
    // a x + b y = gcd(a, b)
// O(log (a+b) )
LL extgcd(LL a, LL b, LL &x, LL &y) {
    LL g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

// mを法とするaの逆元
// O(log a)
LL invMod(LL a) {
    LL x, y;
    if (extgcd(a, MOD, x, y) == 1)return (x + MOD) % MOD;
    else return 0; // unsolvable
}

#define SZ 2000010
LL fact[SZ];
struct fact_{
    fact_(){
        fact[0]=1;
        for(int i=1;i<SZ;i++)
            fact[i]=fact[i-1]*i%MOD;
    }
}fact_init;


// 組み合わせnCk (mod MOD)
// O(log n)
LL Comb(LL n,LL k){
    LL u=fact[n];
    LL d=(fact[k]*fact[n-k])%MOD;
    return (u*invMod(d))%MOD;
}
typedef vector<LL> V;
typedef vector<V> VV;
int main(){
    int N;
    LL X,Y;
    cin>>N>>X>>Y;
    VV g(N);
    V sz(N,0);
    V e(N,0);
    REP(i,N){
        int c;LL w;
        cin>>c>>w;
        g[c-1].pb(w);
    }
    REP(i,N){
        sort(ALL(g[i]));
        if(g[i].size()>1&&g[i][0]+g[i][1]<=X)sz[i]=2;
        FOR(j,2,g[i].size()){
            if(g[i][0]+g[i][j]<=X)sz[i]++;
        }
    }
    
    int a=-1,b=-1;
    REP(i,N){
        if(g[i].size()==0)continue;
        if(a==-1)a=i;
        if(g[i].front()<g[a].front())a=i;
    }
    REP(i,N){
        if(g[i].size()==0||a==i)continue;
        if(b==-1)b=i;
        if(g[i].front()<g[b].front())b=i;
    }

    if(b==-1){
        cout<<1<<endl;
    }
    else{
        REP(i,N){
            LL cost=g[a][0];
            if(i==a){
                cost=g[b][0];
            }
            FOR(j,0,g[i].size()){
                if(cost+g[i][j]<=Y){
                    chmax(sz[i],j+1ll);
                    e[i]=1;
                }
            }
        }
        LL sum=0;
        REP(i,N)if(e[i]){
            
            sum+=sz[i];
            // cout<<sz[i]<<endl;
        }
        LL res=fact[sum];
        REP(i,N){
            if(e[i]&&sz[i]>0){
                (res*=invMod(fact[sz[i]]))%=MOD;
            }
        }
        cout<<res<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 28288
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  long n,sum = 0;
  cin >> n;

  for(long i = 1; i <= n; i++) {
    if(i % 3 == 0 || i % 5 == 0) continue;
    sum += i;
  }

  cout << sum << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#include <map>


#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

string ws,sws;
int cnt =0;
	while(cin >> ws){
		sws = ws;
		reverse(sws.begin(),sws.end());
		if(ws == sws) cnt++;
	}
	cout << cnt << endl;
	return 0;
	
}

Measured memory_bytes: 1192
def func(n):
    if(n%2==0):
        return int(n/2)
    else:
        return int(3*n+1)

S = input()
a = []
i = 0
a.append(int(S))
while(True):
    next = func(a[i])
    if(next in a):
        break
    else:
        a.append(next)
        i+=1

print(i+2)


Measured memory_bytes: 3060
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = list(input())
score = 0
for i in range(N):
    if(T[i]=="r"):
        score +=P
    elif(T[i]=="s"):
        score +=R
    elif(T[i]=="p"):
        score +=S
    if(i <= N-K-1):
        if(T[i]==T[i+K]):
            T[i+K] = "0"
print(score)

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

using namespace std;

struct UnionFind {
  vector<int> parent;

  UnionFind(int n) : parent(n, -1) {}

  int find(int x) {
    if (parent[x] < 0) {
      return x;
    }
    return parent[x] = find(parent[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) {
      return;
    }

    if (parent[x] > parent[y]) {
      swap(x, y);
    }
    parent[x] += parent[y];
    parent[y] = x;
  }

  int size(int x) {
    return -parent[find(x)];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
};
const int MAXN = 1e5+10;

int n, m, k;
int a[MAXN], b[MAXN], c[MAXN], d[MAXN];

void solve() {
  UnionFind uf(n);
  for (int i=0;i<m;i++) {
    uf.unite(--a[i], --b[i]);
  }
  vector<int> v(n, 0);
  for (int i=0;i<n;i++) {
    v[i] = uf.size(i) - 1;
  }
  for (int i=0;i<m;i++) {
    v[a[i]]--;
    v[b[i]]--;
  }
  for (int i=0;i<k;i++) {
    if (uf.same(--c[i], --d[i])) {
      v[c[i]]--;
      v[d[i]]--;
    }
  }
  for (int i=0;i<n;i++) {
    cout << (i == 0 ? "" : " ") << v[i];
  }
  cout << endl;
}

int main() {
  cin >> n >> m >> k;
  for (int i=0;i<m;i++) {
    cin >> a[i] >> b[i];
  }
  for (int i=0;i<k;i++) {
    cin >> c[i] >> d[i];
  }
  solve();
}


Measured memory_bytes: 3200
package main

import (
	"io"
	"os"

	"fmt"
)

func Solve(in io.Reader, out io.Writer) {
	var s string
	fmt.Fscan(in, &s)

	n := 0
	for _, c := range s {
		if c == '+' {
			n++
		}
		if c == '-' {
			n--
		}
	}

	fmt.Fprintln(out, n)
}

func main() {
	Solve(os.Stdin, os.Stdout)
}


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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n;
    cin >> n;

    int bonus = n / 15;

    // 処理
    // 出力
    cout << n * 800 - bonus * 200 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;

int main() {
	while (cin >> n&&n) {
		bool f = 1;
		int ans = 0;
		bool rn[2] = { 0,-1 }, ln[2] = { 0,-1 };
		REP(i, n) {
			string s;
			cin >> s;
			if (s == "lu") {
				ln[0] = 1;
			}
			else if (s == "ru") {
				rn[0] = 1;
			}
			else if (s == "ld") {
				ln[0] = 0;
			}
			else {
				rn[0] = 0;
			}
			if (ln[1] != ln[0] || rn[1] != rn[0]) {
				if (ln[0] == rn[0]) {
					if (f == ln[0]) {
						ans++;
						f = !f;
					}
				}
			}
			ln[1] = ln[0];
			rn[1] = rn[0];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3144
package main

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

func main() {
	b := nextString()
	if b == "A" {
		fmt.Printf("T")
	} else if b == "C" {
		fmt.Printf("G")

	} else if b == "G" {
		fmt.Printf("C")

	} else {
		fmt.Printf("A")
	}
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

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

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

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

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
A,B = list(map(int,input().split()))
C = input()
for i in range(A):
    if C[i] !="-":
        pass
    else:
        print("No")
        exit()
if C[A] == "-":
    pass
else:
    print("No")
    exit()
for i in range(A+1,A+B+1):
    if C[i] !="-":
        pass
    else:
        print("No")
        exit()
print("Yes")

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

int main() {
  int N,M;
  cin >> N ;
  vector<string> s(N);
  vector<int> point(N);
  int p=0;
  for(int i = 0; i < N; i++){
    cin >> s[i];
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(s[i] == s[j])
        point[i]++;
    }
  }
  cin >> M;
  vector<string> t(M);
  for(int i = 0; i < M; i++){
    cin >> t[i];
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
      if(s[i] == t[j])
        point[i]--;
    }
    if(point[i]>p){
      p = point[i];
    }
  }
  cout << p << endl;
} 


Measured memory_bytes: 256
import math

n, m = map(int, input().split())

sup = math.ceil(m**0.5)

ans = 1

for i in range(1,sup+1):
    if m%i==0:
        j = m//i
        if j>=n and i>ans:
            ans = i
        if i>=n and j>ans:
            ans = j

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};


const int MAX=3000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,k;
  cin >> n >> k;
  vector<int>vec(n);
  rep(i,n) cin >> vec[i];
  ll ans = 0;
  for(int i=1;i<=min(n,k);i++){
    for(int a=0;a<=i;a++){
      int b=i-a;
      priority_queue<int,vector<int>,greater<int>>q;
      ll sum=0;
      rep(j,a){
        q.push(vec[j]);
        sum += vec[j];
      }
      rep(j,b){
        q.push(vec[n-1-j]);
        sum += vec[n-1-j];
      }
      int res = k-i;
      while(res>0 && !q.empty()){
        int t=q.top();
        if(t<0){
          sum -= t;
          q.pop();
          res--;
        }
        else break;
      }
      ans=max(ans,sum);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3548