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

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc2 = new Scanner(System.in);

	void run(){

		for(;sc2.hasNextLine();){

			String buffer = sc2.nextLine();

			int[] d = new int[11];

			Scanner sc = new Scanner(buffer.replace(',', ' '));

			d[0] = 0;

			for(int i = 1; i < 11;i++){

				d[i] =d[i-1]+ sc.nextInt();

			}

			int v1 = sc.nextInt();

			int v2 = sc.nextInt();

			int ret = 0;

			for(int i = 0;i<11&& v1*(d[10]-d[i])>v2*(d[i]) ; i++){

				ret = i+1;

			}

			System.out.println(ret);

		}		

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

		

	}

}

Measured memory_bytes: 12000
a, b, c, x, y = map(int, input().split())
if x > y:
    cost = min(a*x + b*y, x*c*2, y*c*2 + (x-y)*a)
else:
    cost = min(a*x + b*y, y*c*2, x*c*2 + (y-x)*b)

print(cost)

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

int main()
{
    int n;
    string ans = "Three";
    cin >> n;
    for (size_t i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if (s == "Y")
        {
            ans = "Four";
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        int x = 0;
        int y = 0;
        for (int i = 1; i > 0; i++)
        {
            string[] xy = Console.ReadLine().Split(' ');
            x = int.Parse(xy[0]);
            y = int.Parse(xy[1]);

            if (x == 0 && y == 0)
                break;
            else if (x > y)
            {
                int tmp = x;
                x = y;
                y = tmp;
            }
            Console.WriteLine("{0} {1}", x, y);
        }
        
    }
}

Measured memory_bytes: 9296
#include<bits/stdc++.h>
#define SIZE 55
using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
ll X[SIZE],Y[SIZE];
int main()
{
	int n;
	cin>>n;
	set <P> st;
	for(int i=0;i<n;i++)
	{
		cin>>X[i]>>Y[i];
		st.insert(P(X[i],Y[i]));
	}
	vector <P> vx;
	int ret=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i==j) continue;
			P p=P(X[i]-X[j],Y[i]-Y[j]);
			int cnt=0;
			for(int k=0;k<n;k++)
			{
				P q=P(p.first+X[k],p.second+Y[k]);
				if(st.count(q)) cnt++;
			}
			ret=max(ret,cnt);
		}
	}
	cout<<n-ret<<"\n";
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int x[N], y[N], a[N];
  
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
    a[i] = i;
  }
    
  double dist = 0;
  int count = 0;
  do {
    count++;
    for (int i = 0; i < N-1; i++) {
      dist += sqrt((x[a[i+1]] -x[a[i]]) * (x[a[i+1]] -x[a[i]])
                   + (y[a[i+1]] -y[a[i]]) * (y[a[i+1]] -y[a[i]]));
    }
  } while(next_permutation(a, a+N));
  
  cout << fixed << setprecision(15) << dist / count << endl;
  
 
}



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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

int main() {
  char x, y;
  cin >> x >> y;
  cout << (x == y ? "H" : "D") << endl;
}


Measured memory_bytes: 256
fn main() {
    let n = read::<u32>();
    let mut x = n;

    let mut fx = 0;
    while x > 0 {
        fx += x % 10;
        x /= 10;
    }
    yn(n % fx == 0);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n;
void solve(){
	cin >> n;
	
	i64 cnt = 0;
	i64 d[10][10] = {0};
	for(int i = 1; i <= n; i++){
		int l = i, r = i%10;
		if(r == 0) continue;
		while(l >= 10) l /= 10;
		if(l == 0) continue;
		d[l][r]++;
	}
	for(int i = 1; i < 10; i++){
		for(int j = 1; j < 10; j++){
			cnt += d[i][j]*d[j][i];
		}
	}
	cout << cnt << endl;
	return;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
N, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
total = a.inject(:+)

if total < x then
    puts N-1
elsif total == x then
    puts N
else
    sweets_gave = 0
    puts a.inject(0) {|sum, v|
        sweets_gave += v
        sum = sweets_gave <= x ? sum+1 : sum
    }
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9+21;
const long long LINF = (long long) 1e18;
const long double PI = 2 * acos((long double)0);
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
#define Mahmud main()
#define endl "\n"
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define alla(arr,n) arr,arr+n
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define pb push_back
///Debug
#define dbg1(x) std::cerr<<#x<<"="<<(x)<<endl;
#define dbg2(x,y) std::cerr<<#x<<"="<<(x)<<','<<#y<<"="<<(y)<<endl;
#define dbg3(x,y,z) std::cerr<<#x<<"="<<(x)<<','<<#y<<"="<<(y)<<','<<#z<<"="<<(z)<<endl;
#define dbgArr(arr,n) cerr<<#arr<<"=["; printArray(arr,n,0,93); cerr<<endl;
///traversing
#define rep(n) for(int i=0;i<n;++i)
#define trv(i,t) for(__typeof(t.begin()) i=t.begin();i!=t.end();++i)
///necessary functions
inline ll Int()
{
    ll _x=0,_tmp=1;
    char _tc=getchar();
    while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
    if( _tc == '-' ) _tc=getchar(), _tmp = -1;
    while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
    return _x*_tmp;
}
inline long double Double()
{
    long double d;
    scanf("%Lf",&d);
    return d;
}
ll lcm(ll a,ll b)
{
    return a/__gcd(a,b)*b;
}
int ton(string x)
{
    int y;
    std::istringstream ss(x);
    ss >> y;
    return y;
}
template<typename T>
string tostring(T x)
{
    ostringstream ss;
    ss << x ;
    return ss.str();
}

///Current Code vars
#define N 100010
long long n,k,c,d;
int arr[N+1],brr[N+1];
///Current Code functions

string s;

int sod(int x)
{
    int res = 0;
    while(x)
    {
        res += x%10;
        x /= 10;
    }
    return res;
}

void solve()
{
    n = Int();
    c = Int();
    d = Int();
    int ans = 0;
    for(int i=1;i<=n;++i)
    {
        int sm = sod(i);
        if(sm >= c && sm <= d)
        {
            ans += i;
        }
    }
    cout<<ans<<endl;
}

int Mahmud
{
    // ios_base::sync_with_stdio(0); //cin.tie(0);
  //#ifdef _LOCAL_
    //freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
  //while(1)
    solve();
  //#ifdef _LOCAL_
    //printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
  //#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

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

  priority_queue <ll> que;
  for (int i = 0; i < N; i++){
    ll A; cin >> A;
    que.push(A);
  }
  
  for (int i = 0; i < M; i++){
    ll A = que.top(); que.pop();
    A = A / 2;
    que.push(A);
  }
  
  ll ans = 0;
  while (!que.empty()){
    ll A = que.top(); que.pop();
    ans += A;
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1400
#include<iostream>
using namespace std;
void include3(int i, int x){
    if(x < 3){
    	return;
    }
	if(x%10==3)cout << " " << i;
	else
	include3(i, x/10);
}
int main(){
	int n;
	cin>>n;
	for(int i=2;++i<=n;){
	  if(i%3==0)cout << " " << i;
	  else
	  include3(i, i);
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3100
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

#0:中央 1:南 2:東 3:西 4:北 5:裏側
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]


    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def get_Top(self):
        return self.number[0]


dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

loc_array = str(input())
for tmp_loc in loc_array:
    dice.roll(tmp_loc)

print("%d"%(dice.get_Top()))




Measured memory_bytes: 6396
#include<stdio.h>
#include<string.h>

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
  key = key%M;
  return key;
}
int h2(int key){
  key = 1+key%(M-1);
  return key;
}

int find(char str[]){
  long long sum,key2,i;
  sum = getKey(str);
  for(i=0;i<20;i++){
    key2=(h1(sum)+i*h2(sum))%M;
    if(strcmp(H[key2],str)==0)return 1;
    else if(strlen(H[key2])==0)return 0;
  }
  return 0;
}

int insert(char str[]){
  long long sum,key2,i;
  sum = getKey(str);
  for(i=0;i<20;i++){
    key2=(h1(sum)+i*h2(sum))%M;
    if(strcmp(H[key2],str)==0)return 1;
    if(strlen(H[key2])==0){
      strcpy(H[key2],str);
      return 0;
    }
  }
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
    
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 14280
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif



int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a - b) % c << endl;
	return 0;
}

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

int main(){
  int n,h,l,sum=0;
  cin>>n>>l>>h;
  int q=n/10000,w=(n%10000)/1000,r=(n%1000)/100,t=(n%100)/10;
  for(int a=0;a<=q;a++){
    for(int b=0;b<10;b++){
      if(a==q && b>w) break;
      else if(a+b>h) break;
      for(int c=0;c<10;c++){
        if(a==q && b==w &&c>r) break;
        else if(a+b+c>h)break;
        for(int d=0;d<10;d++){
          if(a==q && b==w && c==r && d>t) break;
          else if(a+b+c+d>h) break;
          for(int e=0;e<10;e++){
            if(a==q && b==w && c==r && d ==t && e>(n%10)) break;
            else if(a+b+c+d+e<=h && l<=a+b+c+d+e) sum+=a*10000+b*1000+c*100+d*10+e;
            else if(a+b+c+d+e>h) break;
          }
        }
      }
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <string>
#include <list>
using namespace std;

void find_ans(string S, list<string> list1, int N, int K){
    for(int i = 0; i < N; i++){
        for(int j = 1; j <= 5; j++) {
            if(i + j <= N) list1.push_front(S.substr(i,j));
        }
    }
    list1.sort();
    list1.unique();
    auto itr = list1.begin();
    for(int i = 1; i < K; ++i) ++itr;
    cout << *itr << endl;
    return;
}

int main(){
    string S;
    cin >> S;
    int K;
    cin >> K;
    int N = S.size();
    list<string> list1;
    find_ans(S, list1, N, K);
    return 0;
}

Measured memory_bytes: 2176
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--) 
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const double pi = 3.14159265358979323846;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int N, M;
    cin >> N >> M;
    graph r(N + 1);
    rep(i, M) {
        int a, b; cin >> a >> b;
        r[a].push_back(b);
        r[b].push_back(a);
    }
    vector<int> next(N + 1);
    vector<int> dist(N + 1, -1);
    queue<int> que;
    dist[1] = 0;
    que.push(1);
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (int nv : r[v]) {
            if (dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            next[nv]=v;
            que.push(nv);
        }
    }
    for (int i = 2; i <= N; i++) {
        if (dist[i] == -1) {
            cout << "No" << endl;
            return 0;
        }
        
    }
    cout << "Yes" << endl;
    for (int i = 2; i <= N; i++) {
        cout << next[i] << endl;
    }

    
}


	








Measured memory_bytes: 10588
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

  int n, k; cin >> n >> k;
  int ans = n-k;
  if(k==1) ans = 0;
  cout << ans << endl;

  return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

vector<vector<int>> G;
vector<bool> visited;

int N;

vector<int> dist0;
vector<int> distN;

void dfs(int v, int dist, vector<int> &memo) {
    if (visited[v]) return;
    visited[v] = true;
    memo[v] = dist;

    for (auto nv: G[v]) {
        dfs(nv, dist + 1, memo);
    }
}

int main() {
    cin >> N;
    G.resize(N);
    visited.resize(N);
    dist0.resize(N);
    distN.resize(N);

    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(i, N) visited[i] = false;
    dfs(0, 0, dist0);
    rep(i, N) visited[i] = false;
    dfs(N - 1, 0, distN);

    int cnt = 0;
    rep(i, N) if (dist0[i] <= distN[i]) cnt++;

    if (cnt > N / 2) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }
}

Measured memory_bytes: 11136
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    BS = list(map(int, input().split()))
    ans = 0
    prev = float('inf')
    for i in range(N-2,-1,-1):
        if BS[i] <= prev:
            ans += BS[i]
        else:
            ans += prev
        prev = BS[i]
    ans += BS[0]
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 12224
S = input()
temp = S[0]
temp1 = '0'
a = 1
b = 0
c = 0
for i in range(1,4):
  if temp == S[i]:
    a = a+1
  elif temp1 == S[i]:
    c = c+1
  else:
    temp1 = S[i]
    b = b+1
if b == 1 and a == 2 and c == 1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9044
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<cstring>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
int m,n;
bool t[22][11000];
int dp[11000];
int main(){
while(cin>>m>>n,n||m){
memset(dp,0,sizeof dp);
rep(i,22)memset(t[i],0,sizeof t[i]);

rep(i,m){
	rep(j,n)cin>>t[i][j];
}

int ans=0,cnt=0;
rep(i,(1<<m)){

	cnt=0;
	rep(j,n){
		rep(k,m){
			if(i&(1<<k)&&t[k][j])dp[j]++;
			if((!(i&(1<<k)))&&!t[k][j])dp[j]++;
			
		}
	}
	rep(j,n)cnt+=max(dp[j],m-dp[j]);
	memset(dp,0,sizeof dp);
	ans=max(cnt,ans);
}

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


Measured memory_bytes: 3344
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, M;
void func()
{
    cin>>N;
    string s[N];
    rep(i, 0, N) {
        cin>>s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(&s[0], &s[N]);
    ll ans=0;
    int i=0;
    while (i<N) {
        int j, k=1;
        for (j=i+1;s[i]==s[j];++j)++k;
        ans+=(ll)k*(ll)(k-1)/2;
        i=j;
    }
    cout<<ans<<endl;

}
int main()
{
    func();
}

Measured memory_bytes: 6644
X, Y = map(int, input().split())

mod = 10**9+7

def com(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(r-i)%mod
    return (p*pow(q, mod-2, mod))%mod

if (X + Y)%3 != 0:
    print(0)

else:
    a = (2*Y-X)//3
    b = (X+Y)//3 - a
    if a < 0 or b < 0:
        print(0)
    else:
        print(com(a+b, a))

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

int main() {
	int n,m,l;
	cin>>n>>m>>l;
	int a[n][m];
	int b[m][l];
	long long c[n][l];
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin>>a[i][j];
		}
	}
	for(int i=0; i<m; i++){
		for(int j=0; j<l; j++){
			cin>>b[i][j];
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<l; j++){
			long long sum=0;
			for(int k=0; k<m; k++){
				sum += a[i][k]*b[k][j];
			}
			c[i][j]=sum;
			cout<<c[i][j];
			if(j!=l-1) cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3248
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;
// 9  3 9
//    2 4 8
bool check(ll x, ll k) {
    while (x%k==0) x /= k;
    return (x%k) == 1;
}

int main(void) {
    ll n;
    cin >> n;
    if (n==2) {
        puts("1");
        return 0;
    }
    for (ll i=1; i*i<=n-1; i++) {
        if ((n-1)%i==0) {
            if (i==1 || i*i==n-1) ans++;
            else ans += 2;
        }
    }

    for (ll i=1; i*i<=n; i++) {
        if (n%i==0) {
            if (i!=1 && check(n, i)) ans++;
            if (i*i!=n && check(n, n/i)) ans++; 
        }
    }

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



Measured memory_bytes: 3616
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B
n,m,c = LI()
b = LI()
a = LIR(n)
ans = 0
for i in range(n):
    d = c
    for k in range(m):
        d += b[k]*a[i][k]
    if d > 0:
        ans += 1
print(ans)
#C

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 39152
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> vec;
  for (int i = 1; i <= a * b; ++i) {
    if (a % i == 0 && b % i == 0) {
      vec.push_back(i);
    }
  }
  sort(vec.rbegin(), vec.rend());
  cout << vec[k - 1] << endl;
}
       

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int h[100005];
int ans,c;
int main(void){
	int n;
	cin>>n;
	cin>>h[0];
	for(int i=1;i<n;i++){
		cin>>h[i];
		if(h[i]>h[i-1]){
			ans=max(ans,c);
			c=0;
		}else{
			c++;
		}
	}
	ans=max(ans,c);
	cout<<ans<<endl;
	
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static Scanner;

class Program
{
    static void Main() => new Program().Solve();

    public void Solve()
    {
        int a = ReadInt();
        Console.WriteLine(a + a * a + a * a * a);
    }
}


static class Scanner
{
    static Queue<string> que = new Queue<string>();

    public static string Read()
    {
        if (!que.Any()) foreach (var s in Console.ReadLine().Split()) que.Enqueue(s);
        return que.Dequeue();
    }
    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());
    public static decimal ReadDecimal() => decimal.Parse(Read());

    public static IEnumerable<string> Read(long n)
    {
        for (long i = 0; i < n; i++) yield return Read();
    }
    public static IEnumerable<int> ReadInt(long n) => Read(n).Select(int.Parse);
    public static IEnumerable<long> ReadLong(long n) => Read(n).Select(long.Parse);
    public static IEnumerable<double> ReadDouble(long n) => Read(n).Select(double.Parse);
    public static IEnumerable<decimal> ReadDecimal(long n) => Read(n).Select(decimal.Parse);
}

Measured memory_bytes: 28320
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 1e5+100;
struct Edge{
    int u,v;
}edges[maxn];
int n,m;
vector<int> g[maxn];
int vis[maxn],d[maxn];

void dfs(int u){
    vis[u]=1; int v;
    for(int i=0;i<g[u].size();++i){
        Edge &e=edges[g[u][i]]; v=e.u^e.v^u;
        if(vis[v]) continue;
        dfs(v); d[u]^=d[v];
        if(d[v]==1) swap(e.u,e.v);
    }
}

int main(){
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;++i){
        scanf("%d %d",&edges[i].u,&edges[i].v); d[edges[i].u]^=1;
        g[edges[i].u].push_back(i); g[edges[i].v].push_back(i);
    }
    dfs(1);
    if(d[1]) printf("-1\n");
    else{
        for(int i=0;i<m;++i) printf("%d %d\n",edges[i].u,edges[i].v);
    }
}

Measured memory_bytes: 16256
// a

#include <iostream>
#include <queue>

using namespace std;

int N, M;

int main() {
    scanf("%d%d", &N, &M);
    long long ai;
    priority_queue<long long> qa;
    for (int i=0; i<N; i++) {
        scanf("%lld", &ai);
        qa.push(ai);
    }

    for (int i=0; i<M; i++) {
        long long max_a = qa.top();
        qa.pop();
        qa.push(max_a/2);
    }

    long long sum = 0;
    while (!qa.empty()) {
        sum += qa.top();
        qa.pop();
    }

    printf("%lld\n", sum);

    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int num[2000000]={};

int main() {
    const long long int mod = 1000000007,INF=50000000000000;
    typedef pair<long long int,long long int>P;
	map<long long int, long long int>mp;
    long long int n,t[200001],a[200001],res[200001]={},fin=1;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>t[i];
    }
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    res[1]=t[1];
    res[n]=a[n];
    if(t[1]>a[1]||t[n]<a[n]){
        cout<<0<<endl;
        return 0;
    }
    for(int i=2;i<=n;i++){
        if(t[i]>t[i-1]){
            if(a[i]<t[i]){
                cout<<"0"<<endl;
                return 0;
            }else{
                res[i]=t[i];
            }
        }
    }
    for(int i=n-1;i>=1;i--){
        if(a[i]>a[i+1]){
            if(a[i]>t[i]){
                cout<<"0"<<endl;
                return 0;
            }else{
                res[i]=a[i];
            }
        }
    }
    for(int i=1;i<=n;i++){
        if(res[i]==0){
            fin*=min(a[i],t[i]);
            fin%=mod;
        }
    }
    cout<<fin%mod<<endl;
} 


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll c = a + b;
  ll d = n / c*a;
  ll e = n % c;
  if(e<=a){
    cout << d + e << endl;
  }
  else{
    cout << d + a << endl;
  }
}

Measured memory_bytes: 256
import sys
from math import sqrt
from collections import Counter

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n = I()
    a_list = LI()

    Alice = 0
    Bob = 0
    a_list.sort()
    while len(a_list) != 0:
        Alice += a_list.pop()
        if len(a_list) != 0:
            Bob += a_list.pop()

    print(Alice - Bob)
    pass


if __name__ == "__main__":
    main()


Measured memory_bytes: 38512
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
a = l()

ans = 1
for i in a:
    ans *= i

ans -= 1
for i in a:
    cnt += ans % i

print(cnt)


Measured memory_bytes: 10248
#include<iostream>
using namespace std;
int main(void){
  
  char c;

  cin >> c;

  if((char)c == 'a' || (char)c == 'i'  || (char)c == 'u' || (char)c == 'e' || (char)c == 'o' ){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, A: "List[int]"):
    n = N
    m = M
    a = A
    t = sum(a)/(4*m)
    res = sum(1 for i in a if i >= t)
    print('Yes' if m <= res else 'No')



# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

int main(){
    long l, r;
    cin >> l >> r;
    long rem = (l*(l+1)) % 2019;

    if(r-l >= 673){
        cout << 0 << endl;
        return 0;
    }
    else{        
        for(long i = l; i < r; i++){
            for(long j = i+1; j <= r; j++){
                if(rem > ((i*j) % 2019)){
                    rem = ((i*j) % 2019);
                }
            }
        }
    }

    cout << rem << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 1;
    int A[100010];
    rep(i, N) {
        cin >> A[i];
        if(A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i, N) {
        int prev = ans;
        ans *= A[i];
        if(ans <= 0 || ans > INF2 || ans / A[i] != prev || ans % A[i] != 0) {
            cout << "-1" << endl;
            return 0;
        }
    }
    if(ans > INF2) {
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4392
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
	char dat[1200];
	int abc[123]={0};
	int i,j;
	
	while (scanf("%s",&dat) != EOF) {
		
		for(i=0 ; i<strlen(dat) ; i++){
			if (isalpha(dat[i])) { //
				if (isupper(dat[i])) {
					abc[tolower(dat[i])]++;
				}
				else {
					abc[dat[i]]++;
				}
			}
		}
	}
	for(i='a' ; i<= 'z' ; i++){
		printf("%c : %d\n",i,abc[i]);
	}
	
	return 0;
}



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

int main(){
  int r;
  cin >> r;
  cout << r*r << endl;
    
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

ll wazu = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (wazu - inv(wazu % x) * (wazu / x)) % wazu;
        if (a >= 0) { return a; }
        else { return wazu + a; }
    }
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    int N, M;
    cin >> N >> M;
    
    vector<int> a(M);
    vector<int> b(M);

    rep(i, M) cin >> a[i];
    rep(i, M) cin >> b[i];

    for (int k = 1; k <= N; ++k) {
        int j = 0;
        rep(i, M) if (a[i] == k) { ++j; }
        rep(i, M) if (b[i] == k) { ++j; }
        cout << j << endl;
    }

}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int H, W; cin >> H >> W;
  string a[H]; rep(i,H) cin >> a[i];
  int dp[H][W] = {}; dp[0][0] = 1;
  rep(h,H) rep(w,W) {
    if (a[h][w]=='.') {
      if (h!=0) dp[h][w] = (dp[h][w]+dp[h-1][w]) % MOD;
      if (w!=0) dp[h][w] = (dp[h][w]+dp[h][w-1]) % MOD;
    }
  }

  int result = dp[H-1][W-1];
  cout << result << endl;
  return 0;
}

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

int main() {
  int n;
  cin>>n;
  for(int i=n;i<1000;i++){
    string s=to_string(i);
    if(s[0]==s[1]&&s[1]==s[2]){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}

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

int main() {

    int a, b, c;
    cin >> a >> b >> c;

    if(a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 3076
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
 
//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];  //Aという配列を作成。N＋1個の配列がある。
 
//	いずれかのAに0が含まれる場合
		for(int i=0 ; i<N ; i++) {
			A[i]=sc.nextLong();  //入力された配列の読み込み
			if(A[i] == 0) {
				System.out.println(0);
				return;
			}
		}
 
//	Aへの入力の時点で結果が「-1」になる場合
		long total = 1;  //計算結果を表す変数
		for(int i=0 ; i<N ; i++) {
			if(A[i] > 1000000000000000000L / total) {
				System.out.println(-1);
				return;
			}
			else {
				total *= A[i];
			}
		}
 
//	計算してみないと「-1」になるかわからない場合
		if(total <= 1000000000000000000L) {
			System.out.print(total);
		}
		else {
			System.out.print(-1);
		}
	}
}

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

int main() {
  int N;
  cin >> N;
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
  for (int i = 0; i < N; i++) {
    int h;
    cin >> h;
    q.push(make_pair(h, i + 1));
  }
  for (int i = 0; i < N - 1; i++) {
    int j;
    tie(ignore, j) = q.top();
    cout << j << " " ;
    q.pop();
  }
  int j;
  tie(ignore, j) = q.top();
  cout << j <<endl;
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define print(v) for (auto i: v) cout << i << " ";

vi rnk, root;

ll find_set(ll a) {
    if (root[a] == a)
        return a;
    return root[a] = find_set(root[a]);
}

void unite(ll a, ll b) {
    ll x = find_set(a);
    ll y = find_set(b);
    if (x != y) {
        if (rnk[x] < rnk[y])
            swap(x, y);
        root[y] = x;
        rnk[x] += rnk[y];
    }
}

int main() {
    fast
    ll n, m, k;
    cin >> n >> m >> k;
    rnk.resize(n+1, 1);
    root.resize(n+1);
    iota(all(root), 0ll);
    ll u, v;
    vi ans(n+1, 0);
    REP(i, 0, m) {
        cin >> u >> v;
        unite(u, v);
        ans[u]--;
        ans[v]--;
    }
    REP(i, 1, n+1)
        ans[i] += rnk[find_set(i)] - 1;
    REP(i, 0, k) {
        cin >> u >> v;
        if (find_set(u) == find_set(v)) {
            ans[u]--;
            ans[v]--;
        }
    }
    REP(i, 1, n+1)
        cout << ans[i] << " ";
    cout << endl;
}


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

int main(){
    int n,ans=0;
    cin>>n;
    vector<int> dat(n);
    rep(i,n) cin>>dat[i];
    sort(dat.begin(),dat.end());
    rep(i,n){
        for(int j=i+1;j<n;j++){
            int r=lower_bound(dat.begin(),dat.end(),dat[i]+dat[j])-dat.begin();
            int l=j+1;
            ans+=r-l;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn sum(mut a: i64) -> i64 {
    let mut s = 0;
    while a > 0 {
        s += a % 10;
        a /= 10;
    }
    s
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(n: i64, a: i64, b: i64);
    let ans: i64 = (1..n + 1).filter(|&i| {
        let s = sum(i);
        a <= s && s <= b
    }).sum();
    puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

char ch;

int main()
{
	while(scanf("%c", &ch) != EOF)
	{
		if(ch == 'A') printf("T\n");
		else if(ch == 'T') printf("A\n");
		else if(ch == 'C') printf("G\n");
		else if(ch == 'G') printf("C\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<int> p(n);
    for (int i = 0; i < n; i++) std::cin >> p[i];
    std::vector<int> id(n);
    std::iota(id.begin(), id.end(), 0);
    std::sort(id.begin(), id.end(), [&](int i, int j) {
        return p[i] > p[j];
    });
    std::multiset<int> s;
    s.insert(-1); s.insert(-1);
    s.insert(n); s.insert(n);
    long long ans = 0;
    for (int i : id) {
        auto iter = s.lower_bound(i);
        int r1 = *iter;
        int r2 = *++iter;
        --iter;
        int l1 = *--iter;
        int l2 = *--iter;
        ans += (long long)(r2 - r1)*(i - l1)*p[i];
        ans += (long long)(l1 - l2)*(r1 - i)*p[i];
        s.insert(i);
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
using namespace std;
int main(){
    int n;
    char d[100000];
    int ans = 0;
    cin >> n;
    cin >> d[0];
    ans+=1;
    for(int i = 1; i < n; i++){
        cin >> d[i];
        if(d[i-1]==d[i]){
            i--;
            n--;
        }else{
            ans+=1;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  bool G = true;
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  if(N == 1){
    cout << "Yes" << endl; 
  }
  

  
  for (int i = 1; i < N; i++) {
    if(vec.at(0) > vec.at(1) + 1){
      cout << "No" << endl;
      G = false;
      break;
    }
    if (vec.at(i-1) <= vec.at(i)-1)  vec.at(i)--;
    if (vec.at(i-1) > vec.at(i)){
     cout << "No" << endl; 
      break;
    }
    if (i == N-1) cout << "Yes" << endl;
  }
  
}


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

typedef long long ll;
#define mp make_pair
#define pb push_back
#define pi pair<ll,ll>
#define ff first
#define ss second
#define MAX 200550
const ll MOD = 1000000007;

vector<int>g[MAX];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);

	int t=1;
//	cin>>t;
	while(t--){
	 int n,m;
	 cin>>n>>m;
	 
	 while(m--)
	 {
	 	int u,v;
	 	cin>>u>>v;
	 	
	 	g[u].pb(v);
	 	g[v].pb(u);
	 }
	 for(auto elm:g[1])
	 {
	 	for(auto f:g[elm])
	 	{
	 		if(f==n)
	 		{
	 			cout<<"POSSIBLE\n";
	 			return 0;
			 }
		 }
	 }
	 cout<<"IMPOSSIBLE\n";
	}		
}

Measured memory_bytes: 15020
#include<cstdio>
using namespace std;
const int N=100100;
int i,j,k,n,m,mi,ma,num,ch,ff;
int a[N];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
int main() {
	R(n);
	ma=0;mi=n;
	for (i=1;i<=n;i++) {
		R(a[i]);
		if (a[i]<mi) mi=a[i];
		if (a[i]>ma) ma=a[i];
	}
	if (ma-mi>1) return puts("No"),0;
	if (ma==mi) {
		if (mi==n-1 || mi<=n/2) puts("Yes");
		else puts("No");
		return 0;
	}
	for (i=1;i<=n;i++) if (a[i]==mi) num++;
	if (num<=mi && mi<num+(n-num)/2) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;

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

    priority_queue<int> pque;
    for(int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        pque.push(A);
    }
    for(int i = 0; i < M; ++i) {
        int tmp = pque.top();
        pque.pop();
        pque.push(tmp /= 2);
    }

    ll ans = 0;
    for(int i = 0; i < N; ++i) {
        ans += pque.top();
        pque.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1020