akhauriyash/Code-Regression huggingface dataset:
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

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

fn enum_pat(n: usize, pos: usize, cur: &mut Vec<usize>) -> Vec<Vec<usize>>{
    if pos >= n{
        return vec![cur.clone()];
    }

    let mut tmp = enum_pat(n, pos+1, cur);
    cur.push(pos);
    let mut tmp2 = enum_pat(n, pos+1, cur);
    cur.pop();
    tmp.append(&mut tmp2);
    return tmp;
}

fn main(){
    let s = read_as_string();
    let mut tmp: Vec<usize> = Vec::new();
    let pats = enum_pat(s.len(), 1, &mut tmp);

    let mut ans: u64 = 0;
    for pat in &pats{
        if pat.len() == 0{
            ans += ans;
        }
        let mut begin: usize = 0;
        for t in pat{
            ans += u64::from_str(&s[begin..*t]).unwrap();
            begin = *t;
        }
        ans += u64::from_str(&s[begin..s.len()]).unwrap();
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include "iostream"
#include "vector"
#include "cmath"
using namespace std;

int main() {
    int n;
    cin >> n;
    vector <int> a(n);
    for (auto &i: a) {
        cin >> i;
    }
    sort(a.begin(), a.end(), greater<int>());
    if (n == 1) {
        cout << 0 << endl;
    }
    long long ans = a[0];
    int count = 2;
    for (int i=1; i < n && count < n; i++) {
        for (int j=1; j<=2 && count < n; j++) {
            ans += a[i];
            count++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
	string in;
	std::cin >> in;
	int a,b,c,d;
	a = (int)(in[0] - '0');
	b = (int)(in[1] - '0');
	c = (int)(in[2] - '0');
	d = (int)(in[3] - '0');
	char ope[] = {'+','-'};
	int ans;
	for (size_t i = 0; i < 2; i++) {
		for (size_t j = 0; j < 2; j++) {
			for (size_t k = 0; k < 2; k++) {
				ans = a;
				if (i == 0) {
					ans += b;
				}
				else {
					ans -= b;
				}
				if (j == 0) {
					ans += c;
				}
				else {
					ans -= c;
				}
				if (k == 0) {
					ans += d;
				}
				else {
					ans -= d;
				}
				if (ans == 7) {
					std::cout << a<<ope[i]<<b<<ope[j]<<c<<ope[k]<<d<<"=7" << '\n';
					return 0;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define debug(var) std::cout << #var << " : " << var << std::endl;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;


int main(){


	int N; std::cin >> N;
	std::vector<int> h(N);
	rep(i, N)std::cin >> h[i];

	std::vector<int> dp(N, INT_MAX - 2000);
	dp[0] = 0;

	rep(i, N){
		if(i + 1 < N){
			dp[i + 1] = std::min(dp[i + 1], dp[i] + std::abs(h[i + 1] - h[i]));
		}
		if(i + 2 < N){
			dp[i + 2] = std::min(dp[i + 2], dp[i] + std::abs(h[i + 2] - h[i]));
		}
	}

	std::cout << dp[N - 1];

	
	return 0;
}

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

int main() {
    string s ;
    string ans = "";
    cin>>s;
    for(int i = 0 ; i < s.length() ; i++){
        if(s[i]=='0')
        {
            ans += '0';
        }
        else if (s[i]=='1')
        {
            ans += '1';
        }
        else {string ans1 = "";
        if(ans.size()!=0){
        for(int j = 0 ; j<ans.length()-1;j++)
            {
                ans1+=ans[j];
            }
            ans = ans1;
        }}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3580
# coding: utf-8
# Your code here!

try:
   l1 = []
   l2 = []
   for i in range(4):
      l1.append(int(input()))
      l1.sort()
      l1.reverse()
      
   for i in range(2):
      l2.append(int(input()))
      l2.sort()
      l2.reverse()
      
   print(sum(l1[0:3]) + l2[0])

except EOFError:
   pass


Measured memory_bytes: 5600
#include <iostream>

 

using namespace std;

 

int main()
{
  int a,b;
  cin >> a>>b;
  if(a>b) cout << "a > b" << endl;
  else if(a<b) cout << "a < b" << endl;
  else cout << "a == b" << endl;
 return 0;

}


Measured memory_bytes: 3112
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let s = scan.chars();
    let mut is_ok = n % 2 == 0;
    for i in 0..n / 2 {
        if s[i] != s[i+n/2] {
            is_ok = false;
        }
    }
    println!("{}", if is_ok {"Yes"} else {"No"});
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(void) {
	int n;
	int a;
	int z = 1;
	bool no = true;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		if (a == z) {
			++z;
			no = false;
		}
	}
	if (no) {
		cout << -1;
		return 0;
	}
	cout << n - z + 1;
}

Measured memory_bytes: 384
import itertools
n, m, x = map(int, input().split())
ca = [list(int(i) for i in input().split()) for i in range(n)]

cost_list = []
for choice in range(n+1):
  for v in itertools.combinations(ca, choice):
    cost = 0
    us = [0] * m
    for t in v:
      cost += t[0]
      for i in range(m):
        us[i] += t[i+1]
    flag = True
    for check in range(m):
      if us[check] < x:
        flag = False
    if flag == True:
      cost_list.append(cost)

if len(cost_list) == 0:
  print(-1)
else:
  print(min(cost_list))


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

int main(){
    int K,A,B,x,y,ans;
    cin >> K >> A >> B;
    x=B/K;
    y=x*K;
    if(y>=A && y<=B){
        printf("OK");
    }else{
        printf("NG");
    }
    return 0;
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
ll x = 1, y = 1;

int main(){
    cin >> n;
    rep(i,n) {
        ll t, a;
        cin >> t >> a;
        ll tmp = x%t;
        ll tx = x + (tmp?t-tmp:0);
        if (y <= (tx/t)*a) {
            x = tx;
            y = (tx/t)*a;
        } else {
            ll ty = y + (y%a?a-y%a:0);
            x = (ty/a)*t;
            y = ty;
        }
    }
    cout << x+y << endl;
}
































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

int main() {
    int n;cin>>n;
    int v[n],c[n],ans=0;
    for(int i=0;i<n;++i){
        cin>>v[i];
    }
    for(int i=0;i<n;++i){
        cin>>c[i];
    }
    for(int i=0;i<n;++i){
        if(v[i]>c[i])ans+=v[i]-c[i];
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
edges = {i + 1: [] for i in range(N)}
for i in range(M):
    A, B = map(int, input().split())
    edges[A].append(H[B - 1])
    edges[B].append(H[A - 1])


ans = 0
for i in range(N):
    if len(edges[i+1]) <= 0 or H[i] > max(edges[i+1]):
        ans += 1

print(ans)


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

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }
template<typename T> void show(T& a, char del='\n', char last='\n'){ rep(i, a.size() - 1) cout << a[i] << del; cout << a[a.size() - 1] << last; }

void upto(vector<int>& v, int f, int t)
{
  for (int i = f; i <= t; i++) v.push_back(i);
}
void downto(vector<int>& v, int f, int t)
{
  for (int i = f; i >= t; i--) v.push_back(i);
}

int main()
{
  rep(i, in()){
    int f, t;
    f = in();
    t = in();
    vector<int> way;
    if (f < t) upto(way, f, t);
    else if (f <= 5) downto(way, f, t);
    else if (t <= 5) upto(way, f, 9), downto(way, 5, t);
    else upto(way, f, 9), downto(way, 5, 0), upto(way, 1, t);
    show(way, ' ');
  }
  return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>
#define N 10000
#define Q 500

int main()
{
  int S[N],T[Q],C=0;
  int n,q,i,j,key;

  scanf("%d",&n);
  for(i=0; i<n; i++)
    scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++)
    scanf("%d",&T[i]);

  for(i=0; i<q; i++){
    j=0;
    S[n] = T[i];
    while(S[j] != T[i]){
      j++;
    }
    if(j < n) C++;  
  }
  printf("%d\n",C);
  return 0;
}

Measured memory_bytes: 640
def solve():
    X,N = [int(i) for i in input().split()]
    if N == 0:
        print(X)
        return

    P = set([int(i) for i in input().split()])
    for i in range(len(P)+1):
        target = X - i
        if target not in P:
            print(target)
            break
        target = X + i
        if target not in P:
            print(target)
            break

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(){
    ll n, k, q;
    cin >> n >> k >> q;
    ll a[q];
    for(ll i = 0; i < q; i++) cin >> a[i];

    vector<ll> mem(n, 0);
    for(ll i = 0; i < q; i++){
        mem[a[i] - 1]++;
    }

    for(ll i = 0; i < n; i++){
        ll point = mem[i] - q;
        // cout << point << endl;
        if (point + k > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2176
#include<cstdio>
#include <array>

int main()
{
        int N;
        std::array < int , 20 > H{};
        int ans = 0;
        scanf("%d",&N);
        for ( int i = 0; i<N ;i++ ){
                        scanf("%d",&H[i]);
        }
        for ( int i = 0; i < N ; i++ )
        {
                for  (int j = 0; j < i+1; j++ ){
                        if ( i == j ){
                                        ans +=1;
                        }
                        if (    H[j] > H[i]  ){
                                        break;
                        }

                }
        }
        printf("%d\n", ans);
                return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <algorithm>
#include <list>
#include <map>
#include <cmath>
#include <string>
#include <iterator>
#include <vector>
 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 1e5 + 5;
int k[MAXN];

int largest(int a, int b){
	return (a<b)?b:a;
}

int main() {
	int n = 0;
	cin >> n;
	ll ans = 0;
	string s;
	map<string,ll> mymap;
	for(int i = 0; i < n; ++i){
		cin >> s;
		sort(s.begin(), s.end());
		mymap[s]++;
		ans+=mymap[s]-1;
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

#define pi acos(-1)


int g[9];
bool hp() {
  if (g[0]==-1&&g[1]==-1&&g[2]==-1) return true;
  if (g[3]==-1&&g[4]==-1&&g[5]==-1) return true;
  if (g[6]==-1&&g[7]==-1&&g[8]==-1) return true;
  if (g[0]==-1&&g[3]==-1&&g[6]==-1) return true;
  if (g[1]==-1&&g[4]==-1&&g[7]==-1) return true;
  if (g[2]==-1&&g[5]==-1&&g[8]==-1) return true;
  if (g[0]==-1&&g[4]==-1&&g[8]==-1) return true;
  if (g[2]==-1&&g[4]==-1&&g[6]==-1) return true;
  return false;
}
int main() {
  for (int i = 0; i <9; i++) {
      cin >> g[i];
  }

  int n; cin >> n;

  for (int i =0 ; i < n; i++) {
    int m; cin >> m;
    for (int j =0 ; j < 9; j++) {
      if (g[j] == m) {
        g[j] = -1;
        if (hp()) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c;
string s, t;

int main()
{
	a = 1;
	cin >> s ;
	if (s == "SUN")
		a = 7;
	else if (s == "MON")
		a = 6;
	else if (s == "TUE")
		a = 5;
	else if (s == "WED")
		a = 4;
	else if (s == "THU")
		a = 3;
	else if (s == "FRI")
		a = 2;
	else 
		a = 1;
	cout << a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
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;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> A >> B >> C >> D;
    chmax(ans, A * B);
    chmax(ans, C * D);
    cout << ans << endl;
}

Measured memory_bytes: 3644
import java.io.*;
class Main{
public static void main(String[] args)throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str=br.readLine();
int n=Integer.parseInt(str);
String str2=br.readLine();
String[] arr=str2.split(" ");
String[] rev =new String[n];
for(int i=0; i<n; i++){
rev[i]=arr[n-i-1];
System.out.print(rev[i]);
if(i !=n-1)  System.out.print(" ");
}
System.out.println();
br.close();
}
} 

Measured memory_bytes: 24188
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
string s;
cin>>s;
int cnt=0;
int n=size(s);
for(int i=0;i<n/2;i++)
{
	if(s[i]!=s[n-1-i])
		cnt++;
}
cout<<cnt;
}
int main()
{
//code
	
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

#define si(a)           scanf("%d",&a)
#define sii(a,b)        scanf("%d %d",&a,&b)
#define siii(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define sl(a)           scanf("%lld",&a)
#define sll(a,b)        scanf("%lld %lld",&a,&b)
#define slll(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define mp              make_pair
#define all(v)          v.begin(),v.end()
#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a,0,sizeof(a))
#define SET(a)          memset(a,-1,sizeof(a))

#define PI              acos(-1.0)

//inline int setBit(int n,int pos) { return n = n | (1 << pos); }
//inline int resetBit(int n,int pos) { return n = n & ~(1 << pos); }
//inline bool checkBit(int n,int pos) { return (bool)(n & (1 << pos)); }
//inline int countBit(ll n) { return __builtin_popcountll(n); }


//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

/******************************************************************************************/

const ll MAX = 100010;
const ll INF = 0x3f3f3f3f;
//const double inf = 1.0/0.0;
//const int MOD = 1000000007;

ll weight[MAX], val[MAX];
ll n,w;
ll dp[105][MAX];

ll call(ll pos,ll lv) {
    if(lv < 0) return INF;
    if(pos>n) {
        if(lv == 0) return 0;
        else return INF;
    }
    if(dp[pos][lv]!=-1) return dp[pos][lv];
    ll ret = min(weight[pos] + call(pos+1,lv-val[pos]),call(pos+1,lv));
    return dp[pos][lv] = ret;
}

int main() {
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    sll(n,w);

    for(ll i=1;i<=n;i++) {
        sll(weight[i],val[i]);
    }
    SET(dp);

    for(int i=100000;i>=1;i--) {
        if(call(1,i)<=w) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}



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

const int N = 2e5+10;
int n, m, can[N][2], ok[N];
char col[N];

vector<int> g[N];

set< pair<int,int> > A, B;

int main() {
	scanf("%d %d", &n, &m);
	scanf(" %s", col);
	while(m--) {
		int u, v; scanf("%d %d", &u, &v);
		u--, v--;
		g[u].push_back(v);
		g[v].push_back(u);
		can[u][col[v] - 'A']++;
		can[v][col[u] - 'A']++;
	}

	for(int i = 0; i < n; i++) {
		A.insert({can[i][0], i});
		B.insert({can[i][1], i});
	}

	fill(ok,ok+N,1);
	while(!A.empty() && !B.empty()) {
		if(A.begin()->first <= 0) {
			int u = A.begin()->second;

			A.erase(A.begin());
			B.erase({can[u][1], u});

			ok[u] = false;
			for(int v : g[u]) if(ok[v]) {
				if(col[u] == 'A') {
					A.erase({can[v][0], v});
					can[v][0]--;
					A.insert({can[v][0], v});
				} else {
					B.erase({can[v][1], v});
					can[v][1]--;
					B.insert({can[v][1], v});
				}
			}
		} else if(B.begin()->first <= 0) {
			int u = B.begin()->second;

			A.erase({can[u][0], u});
			B.erase(B.begin());

			ok[u] = false;
			for(int v : g[u]) if(ok[v]) {
				if(col[u] == 'A') {
					A.erase({can[v][0], v});
					can[v][0]--;
					A.insert({can[v][0], v});
				} else {
					B.erase({can[v][1], v});
					can[v][1]--;
					B.insert({can[v][1], v});
				}
			}
		} else break;
	}
	int a = 0, b = 0;
	for(int i = 0; i < n; i++) if(ok[i])
		(col[i] == 'A' ? a = 1 : b = 1);
	if(a + b == 2) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 30592
from collections import Counter
import heapq

n=int(input())
word=[]
for i in range(n):
    word.append(input())

word_count=Counter(word)
ma=max(word_count.values())

ans=[k for k, v in word_count.items() if v == ma]
cnt=len(ans)
heapq.heapify(ans)
for i in range(cnt):
    print(heapq.heappop(ans))


Measured memory_bytes: 35572
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
    const lines = input.split('\n')
    const N = lines[0] - 0
    const A = lines[1].split(' ').map(Number)

    let ans = 0
    let head = 0
    let sum = 0
    let xor = 0
    for (let i = 0 ; i < N; i++) {
        for (let j = head; j < N; j++) {
            sum = sum + A[j]
            xor = xor ^ A[j]
            if (sum === xor) {
                head++
            } else {
                xor = xor ^ A[j]
                sum = sum - A[j]
                break
            }
        }
        ans += head - i
        xor = xor ^ A[i]
        sum = sum - A[i]
    }

    console.log(ans)

})(input)


Measured memory_bytes: 43508
#include <stdio.h>

int		main(void)
{
	int h,w;
	scanf("%d%d", &h, &w);
	char s[h + 1][w + 1];
	int i = 0;
	int j;
	while (i < h)
	{
		scanf("%s", s[i]);
		i++;
	}
	i = 0;
	int count;
	int k;
	int n;
	char c;
	while (i < h)
	{
		j = 0;
		while (j < w)
		{
			if (s[i][j] == '.')
			{
				k = i - 1;
				count = 0;
				while (k <= i + 1)
				{
					n = j - 1;
					while (n <= j + 1)
					{
						if (s[k][n] == '#')
							count++;
						n++;
					}
					k++;
				}
				s[i][j] = '0' + count;
			}
			j++;
		}
		i++;
	}
	i = 0;
	while (i < h)
	{
		printf("%s", s[i]);
		if (i != h - 1)
			printf("\n");
		i++;
	}
	return (0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mxn = 1e5+10;
ll mark[mxn];
int main()
{
    ll n;
    ll sum = 0;
    cin>>n;
    ll a[n+2];
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
        sum += a[i];
        mark[a[i]]++;
    }
    int q;
    cin>>q;
    while(q--)
    {
        ll x, y;
        cin>>x>>y;
        if(!mark[x]){cout<<sum<<endl;continue;}
        sum -= (x*mark[x]);
        sum += (y*mark[x]);
        mark[y] += mark[x];
        mark[x] = 0;
        cout<<sum<<endl;
    }
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans;
    ans=b/a;
    
    cout << min(ans,c) << endl;
    

    return 0;
}

Measured memory_bytes: 3636
def main():
    H, W = map(int, input().split(" "))
    grids = []
    for _ in range(H):
        line = input()
        if "#" in line:
            grids.append([l for l in line])
        else:
            continue
    for i in range(W):
        tmp = 0
        for grid in grids:
            if grid[i] == ".":
                tmp += 1
        if tmp == len(grids):
            for grid in grids:
                grid[i] = ""
    for grid in grids:
        print("".join(grid))


if __name__ == '__main__':
    main()

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  int ans = 0;
  REP(i, N) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  long long N;
  cin >> N;

  long long M = 100;


  int cnt = 1;

  while(1){
    M = M * 1.01;
    // cout << M << "\n";
    if(N <= M){
      cout << cnt << "\n";
      return 0;
    }
    cnt++;
  }

}


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

//cmdで g++ test.cpp とするとコンパイルできる
//https://atcoder.jp/contests/abc147/tasks/abc147_c

#define MOD 1000000007
typedef pair<int,int> pii;

int main() {
    int N;
    cin>>N;
    vector<vector<pii>> st(N);
    for(int i=0;i<N;i++){
        int c;
        cin>>c;
        for(int j=0;j<c;j++){
            int x,y;
            cin>>x>>y;
            st.at(i).push_back(make_pair(x-1,y));
        }
    }
    int pw=pow(2,N);
    int ans=0;
    for(int i=0;i<pw;i++){
        int count=0;
        int v=1;
        for(int j=0;j<N;j++){
            if(i&v)count++;
            v<<=1;
        }
        //cout<<"i="<<i<<" count="<<count<<endl;
        //iの1のビットが正直者
        bool ok=true;
        for(int j=0;j<N;j++){
            if(!((1<<j)&i))continue;
            int L=st.at(j).size();
            for(int k=0;k<L;k++){
                int x=st.at(j).at(k).first;
                int y=st.at(j).at(k).second;
                //cout<<"j="<<j<<" x="<<x<<" y="<<y<<endl;
                int xy=((1<<x)&i)?1:0;
                if(xy!=y){ok=false;break;}
            }
            if(!ok)break;
        }
        if(ok)ans=max(ans,count);
        //cout<<"ans="<<ans<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

typedef long long ll;
const int N=2004,P=1e9+7;

int n,k,fac[N*N],inv[N*N],ifac[N*N],f[N][N];

int C(int n,int m)
{
	if(n<m||n<0||m<0)
		return 0;
	return (ll)fac[n]*ifac[m]%P*ifac[n-m]%P;
}

int main()
{
	scanf("%d%d",&n,&k);
	if(k==1)
		return puts("1"),0;
	fac[0]=fac[1]=inv[1]=ifac[0]=ifac[1]=1;
	for(int i=2; i<=n*k; i++)
	{
		fac[i]=(ll)fac[i-1]*i%P;
		inv[i]=(ll)inv[P%i]*(P-P/i)%P;
		ifac[i]=(ll)ifac[i-1]*inv[i]%P;
	}
	// f[i][j] 当前安排了i个白球 有j个颜色安排上了
	// 限制是 i>=j
	// 带标号dp 
	// 钦定当前加入的球最靠前的一个最靠前 
	for(int i=1; i<=n; i++)
	{
		f[i][0]=1;
		for(int j=1; j<=i; j++)
		{
			f[i][j]=f[i-1][j];
			f[i][j]=(f[i][j]+(ll)f[i][j-1]*C(n*k-i-(j-1)*(k-1)-1,k-2)%P*(n-j+1))%P;
		}
	}
	printf("%d",f[n][n]);
	return 0;
}


Measured memory_bytes: 61952
#if 0
accept?????????
30?????????????????£???

??????????????????????????????????§£???????????£?????????
??????????????????????????????????§£???????????£????????§
??????????????????????§£????????????????????¨????????????

Floyd-Warshall????????¨??????
#endif


#include <iostream>
#include <cstdio>
using namespace std;

int N, M, A, B, C, D, x1, x2, y1, y2;
int K[32][32];
const int inf=1001001001;

int main() {
  long long pay,ans;
  for(int i=0;i<32;i++)
    for(int j=0;j<32;j++)
      K[i][j]=inf;

  scanf("%d%d", &N, &M);
  for (int i=0; i<M; ++i) {
    scanf("%d,%d,%d,%d", &A, &B, &C, &D);
    //cerr << "read " << A <<" "<< B <<" " << C <<" " << D<< endl;
    //?????????
    K[A][B]=C; // A ??? B ????????????C
    K[B][A]=D;// B ??? A ????????????D    
  }
  /*
  for(int i=1;i<N+1;i++){//?????§?????????
    for(int j=1;j<N+1;j++){
      if(K[i][j]==inf){
	cout<<"i"<<" ";
      }else{
	cout<<K[i][j]<<" ";
      }
    }
    cout<<endl;
  }
  */
  for(int k=1;k<N+1;k++){
    for(int i=1;i<N+1;i++){
      for(int j=1;j<N+1;j++){
	if(K[i][j]>K[i][k]+K[k][j]){
	  K[i][j]=K[i][k]+K[k][j];
	}
      }
    }/*
    for(int l=1;l<N+1;l++){//?????§??????2???
    for(int m=1;m<N+1;m++){
      if(K[l][m]==inf){
	cout<<"i"<<" ";
      }else{
	cout<<K[l][m]<<" ";
      }
    }
    cout<<endl;
    } 
    cout<<endl;*/
  }
  scanf("%d,%d,%d,%d", &A, &B, &C, &D);
  pay=K[A][B]+K[B][A];
  ans=C-D-pay;
  cout<<ans<<endl; 
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	map<string, ll> mp;
	for( int i = 0; i < n; ++i ){
		string s; cin >> s;
		sort( s.begin(), s.end() );
		++mp[s];
	}
	ll ans = 0;
	for( auto a : mp ){
		ll k = a.second;
		ans += k*(k-1)/2;
	}
	cout << ans << endl;
}

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

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A_list;
    for (int i = 0; i < M; i++) {
        int tmp;
        cin >> tmp;
        A_list.emplace_back(tmp);
    }
    vector<bool> is_cost_taken(N, false);
    for (auto A : A_list) {
        is_cost_taken.at(A) = true;
    }

    int cost_to_zero = 0;
    for (int i = 0; i < X; i++) {
        if (is_cost_taken.at(i)) cost_to_zero += 1;
    }
    int cost_to_N = 0;
    for (int i = X; i < N; i++) {
        if (is_cost_taken.at(i)) cost_to_N += 1;
    }
    int min_cost = min(cost_to_zero, cost_to_N);
    cout << min_cost << "\n";
}


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

int main() {
	int a[3];
  	cin >> a[0] >> a[1] >> a[2];
  	sort(a, a + 3);
  	if (a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES";
  	else cout << "NO";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                                                                        
using namespace std;
int main(){
  string w;
  cin >> w;
  int p_count=0;
  int count=0;
  for(int i=0; i<w.size(); i++){
    for(int j=0; j<w.size(); j++){
      if(w.at(i)==w.at(j))
        p_count++;
    }
    if(p_count%2==0){
      count++;
    }
    p_count=0;
  }
  if(count==w.size())
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

struct UnionFind {
	vector<int> par;
	UnionFind(int x) : par(x, -1) {}
	void init(int x) { par.assign(x, -1); }
	int root(int x) {
		if (par[x] <= -1) return x;
		else return root(par[x]);
	}
	bool issame(int x, int y) {
		return root(x) == root(y);
	}
	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) {
		return -par[root(x)];
	}
};
int p[100010];

int main()
{
	int N, M;
	cin >> N >> M;
	UnionFind G(N + 1);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		G.merge(x, y);
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (G.root(i + 1) == G.root(p[i])) {
			ans++;
		}
	}
	cout << ans << endl;
}


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

using ll = long long;

constexpr int mod = 998244353;

char get_chr(char a, char b) {
    if(a == b) return a;
    if(a > b) swap(a, b);
    if(a == 'a' && b == 'b') return 'c';
    else if(a == 'a' && b == 'c') return 'b';
    else if(a == 'b' && b == 'c') return 'a';
    assert(false);
    return '0';
}

template<typename T>
std::vector<T> table(int n, T v) { return std::vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return std::vector<decltype(val)>(n, std::move(val));
}

int main() {
    string s; cin >> s;
    const int n = s.size();

    if(count(begin(s), end(s), s[0]) == n) { // corner
        cout << 1 << endl;
        return 0;
    }

    if(n <= 3) { // brute force
        set<string> cur = {s};
        while(true) {
            set<string> nxt = cur;
            for(auto s : cur) {
                for(int i = 0; i + 1 < (int)s.size(); ++i) {
                    auto t = s;
                    const char c = get_chr(s[i], s[i + 1]);
                    t[i] = t[i + 1] = c;
                    nxt.insert(t);
                }
            }
            if(nxt.size() == cur.size()) break;
            cur = move(nxt);
        }
        cout << cur.size() << endl;
    } else {
        int m = 0, f = 0;
        for(int i = 0; i < n; ++i) {
            (m += s[i] - 'a') %= 3;
            f |= (i + 1 < n && s[i] == s[i + 1]);
        }
        auto dp = table(n + 1, 3, 3, 2, 0);
        dp[1][0][0][0] = dp[1][1][1][0] = dp[1][2][2][0] = 1;
        for(int i = 1; i < n; ++i) {
            for(int j = 0; j < 3; ++j) {
                for(int pre = 0; pre < 3; ++pre) {
                    for(int k = 0; k < 2; ++k) {
                        (dp[i + 1][j][0][k | (pre == 0)] += dp[i][j][pre][k]) %= mod;
                        (dp[i + 1][(j + 1) % 3][1][k | (pre == 1)] += dp[i][j][pre][k]) %= mod;
                        (dp[i + 1][(j + 2) % 3][2][k | (pre == 2)] += dp[i][j][pre][k]) %= mod;
                    }
                }
            }
        }
        int ans = !f;
        for(int i = 0 ; i < 3; ++i) {
            (ans += dp[n][m][i][1]) %= mod;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 123908
import java.util.Scanner;
public class Main{
	public static void main(String[] args){

        Scanner s = new Scanner(System.in);
		int n,i,j,kai=0;					//kai=回数
        String mark;
        kai = s.nextInt();
        int[][] gya=new int[4][13];		//逆列
        
        for(i=0;i<4;i++)
            for(j=0;j<13;j++)
                gya[i][j]=0;
        
        //S=0,H=1,D=2,C=3
		for(i=0;i<kai;i++){
            mark = s.next();
			n = s.nextInt();
            if(mark.equals("S"))gya[0][n-1]=1;
            else if(mark.equals("H"))gya[1][n-1]=1;
            else if(mark.equals("C"))gya[2][n-1]=1;
            else gya[3][n-1]=1;
        }
        for(i=0;i<4;i++){
            for(j=0;j<13;j++){
                if(gya[i][j]==0&&i==0)System.out.println("S "+(j+1));
                else if(gya[i][j]==0&&i==1)System.out.println("H "+(j+1));
                else if(gya[i][j]==0&&i==2)System.out.println("C "+(j+1));
				else if(gya[i][j]==0&&i==3)System.out.println("D "+(j+1));
            }
        }
		s.close();
	}
}


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

int main() {
	int a , b;
	cin >> a >> b;
	
	if ( a < b) {
		cout << "a < b" << endl;
	} else if ( a > b ) {
		cout << "a > b" << endl;
	} else {
		cout << "a == b" << endl;
	}
	
	return 0;
	
}	


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int x,y,res;
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	cin>>x;
	y=x/500;
	res+=y*1000;
	x-=500*y;
	y=x/5;
	res+=y*5;
	cout<<res<<endl;
	return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int64_t N, M; cin >> N >> M;
  if (N > M) swap(N, M);
  if (N == 1) {
    if (M == 1) cout << "1\n";
    if (M == 2) cout << "0\n";
    if (M > 2) cout << M - 2 << "\n";
    exit(0);
  }

  cout << N * M - 2 * (N + M - 4) - 4 << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int H,W,i,j,k,l,A[55][55]={0};
	scanf("%d %d",&H,&W);
	
	char S[55][55];
	
	for(i=0;i<H;i++){
		scanf("%s",S[i]);
	}
	
	for(i=1;i<=H;i++){
		for(j=1;j<=W;j++){
			if(S[i-1][j-1]=='#'){
				for(k=-1;k<2;k++){
					for(l=-1;l<2;l++){
					A[i+k][j+l]++;
					}
				}
			}
			
		}
	}
	
	for(i=1;i<=H;i++){printf("\n");
		for(j=1;j<=W;j++){
			if(S[i-1][j-1]=='#'){
				printf("#");
				}else{
					printf("%d",A[i][j]);
				}
			}
			
		}
	printf("\n");
	
	return 0;
}

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


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

int main(){
	long n, t1, t2;
	cin >> n;
	vector<pair<long, long> > v;


	for (int i = 0; i< n; i++) {
		cin >> t1 >>  t2;
		v.push_back(make_pair(t2, t1));
	}
	sort(v.begin(), v.end());
	long sum = 0;
	for (int i = 0; i< n; i++) {
		sum += v[i].second;
		if(sum > v[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int A, B;
  cin >> A >>B;
  cout<<(A+B)%24<<"\n";
  return 0;
}


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

void mf(){
	freopen("input.in","r",stdin);
	freopen("output.ou","w",stdout);
}
int n,c,k;
int a[100007];
void solve(){
	cin>>n>>c>>k;
	for(int i = 0; i<n;i++) cin>>a[i];
	sort(a, a+ n);
	int res = 0, cc = 1, tnow = a[0];
	for(int i = 1; i <n; i++){
		if(cc==c || a[i]-tnow > k){
			res++;
			cc = 1;
			tnow = a[i];
		}else{
			cc++;
		}
	}
	if(cc>0) res++;
	cout<<res<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	#ifdef tuanh
	mf();
	#endif
	solve();
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b) cout << c << "\n";
  else{
    if(a == c) cout << b << "\n";
    else cout << a << "\n";
  }
}


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

double x[10], y[10];

long long factorial(int n){
    if(n == 1) return 1;
    
    return n*factorial(n-1);
}

double calculate(int i, int j){
    return pow((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]), 0.5);
}

int main(void){
    int n;
    
    cin >> n;
    
    vector<int> d(n);
    double sum = 0, result;
    
    rep(i, n){
        cin >> x[i] >> y[i];
        d[i] = i + 1;
    }
    
    do{
        rep(i,n-1){
            sum += calculate(d[i]-1, d[i+1]-1);
        }
    }while(next_permutation(d.begin(), d.end()));
    
    result = sum / (double)factorial(n);
    
    printf("%.7lf", result);
    
    return 0;
}

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

inf = float('inf')

def solve(H: int, W: int, A: "List[str]"):
    dist = [[inf] * W for h in range(H)]
    for h in range(1, H):
        for w in range(1, W):
            if A[h][w] == '#':
                dist[h][w] = 0
            else:
                dist[h][w] = min(dist[h-1][w], dist[h][w-1]) + 1
    
    dmax = 0
    for h in range(H-1, -1, -1):
        for w in range(W-1, -1, -1):
            if A[h][w] == '#':
                dist[h][w] = 0
            elif h+1 <= H-1 and w+1 <= W-1:
                dist[h][w] = min(dist[h][w], min(dist[h+1][w], dist[h][w+1]) + 1)
            elif w+1 == W and h+1 <= H-1:
                dist[h][w] = min(dist[h][w], dist[h+1][w] + 1)
            elif h+1 == H and w+1 <= W-1:
                dist[h][w] = min(dist[h][w], dist[h][w+1] + 1)
            dmax = max(dist[h][w], dmax)
    print(dmax) 
    return


# Generated by 1.1.4 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()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 93404
N, M = map(int, input().split())
E = {i: [] for i in range(N)}
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1  # 0-indexed
    E[a].append(b)
    E[b].append(a)
for i in range(N):
    print(len(E[i]))


Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int T,X;
	scan(T);scan(X);
	prin((double)T/X);
	return 0;
}


Measured memory_bytes: 256
from sys import stdin

def main():
    N = int(input())
    A = [int(input()) for _ in [0] * N]

    a = sorted(A, reverse=1)
    for i in A:
        if i < a[0]:
            print(a[0])
        else:
            print(a[1])

input = lambda: stdin.readline()
main()


Measured memory_bytes: 14656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int k = sc.nextInt();
			String s = sc.next();

			if (s.length() <= k) {
				System.out.println(s);
			} else {
				System.out.println(s.substring(0, k) + "...");
			}
		}
	}
}


Measured memory_bytes: 38576
x, y = [int(i) for i in input().split()]
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
if a.count(x) and a.count(y):
    print('Yes')
elif b.count(x) and b.count(y):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int n,m;
  cin >> n >> m;
  
  vector<pair<int , int>> cont(n);
  
  for(int i = 0 ; i < n ; i++){ 
    cin >> cont.at(i).first;
    cin >> cont.at(i).second;
  }
  
  sort(cont.begin() , cont.end());
  
  int64_t sum = 0;
  int64_t count = 0;
  bool jad = false;
  
  for(int i = 0 ; i < n ; i++){
    
    for(int j = 0 ; j < cont.at(i).second ; j++){
      
      if(count == m){
        jad = true;
        break;
      }

      if(cont.at(i).second != 0){
        sum += cont.at(i).first;
        count++;
      }
      else{
        break;
      }
    }
    if(jad){
      break;
    }
  }
 cout << sum << endl;
}
  
  
  
  
  
  

Measured memory_bytes: 1024
from bisect import bisect_left, bisect_right

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

res = 0

cA = [0]
for i in range(N):
    cA.append(cA[-1] + A[i])

cB = [0]
for i in range(M):
    cB.append(cB[-1] + B[i])

for i in range(N + 1):
    rem = K - cA[i]
    if rem < 0:
        continue
    j = bisect_right(cB, rem)
    res = max(res, i + j - 1)

print(res)

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

using namespace std;

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

using ll = long long;

// Problem Specific Parameter:

const int limit = 200000;
vector<int> tree[limit + 10];

int sz[limit + 10];
int len[limit + 10];

int calc_sz(int v, int d) {
	sz[d]++;
	int dmax = d;
	for (auto &v2 : tree[v]) {
		const int tmp =  calc_sz(v2, d + 1);
		chmax(dmax, tmp);
	}
	len[v] = dmax - d + 1;
	return dmax;
}

const ll mod = 1000000007LL;

ll two[limit + 10];

void init() {
	two[0] = 1LL;
	rep(i, limit) two[i + 1] = 2LL * two[i] % mod;
}

void calc_dp(int v, auto &dp) {
	int sub = -1;
	for (auto &v2 : tree[v]) {
		if (sub == -1 or len[sub] < len[v2]) {
			sub = v2;
		}
	}

	if (sub != -1) calc_dp(sub, dp);

	dp[0].push_front(1LL);
	dp[1].push_front(1LL);
	dp[2].push_front(0LL);

	int limit = 0;
	for (auto &v2 : tree[v]) {
		if (v2 == sub) continue;
		array<deque<ll>, 3> dp2;
		calc_dp(v2, dp2);
		chmax(limit, len[v2] + 1);

		rep(i, len[v2]) {
			ll nxt[3] = {0LL, 0LL, 0LL};
			rep(a, 3)rep(b, 2) {
				int ab = min(a + b, 2);
				const ll add = 1LL * dp[a][i + 1] * dp2[b][i];
				nxt[ab] = (nxt[ab] + add) % mod;
			}
			rep(a, 3) dp[a][i + 1] = nxt[a];
		}
	}

	rep(i, limit) {
		dp[0][i] = (dp[0][i] + dp[2][i]) % mod;
		dp[2][i] = 0LL;
	}
}


int main(void) {
	init();

	int n;
	cin >> n;

	vector<int> p(n);
	rep(i, n) cin >> p[i];
	rep(i, n) tree[p[i]].push_back(i + 1);
	calc_sz(0, 0);

	array<deque<ll>, 3> dp;
	calc_dp(0, dp);

	ll ans = 0LL;
	rep(i, len[0] ) {
		ll coef = two[n + 1 - sz[i]];
		ll cur = 1LL * coef * dp[1][i] % mod;
		ans = (ans + cur) % mod;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 104448
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
const int MAX_N = 1e5 + 2;
int arr[MAX_N] = { 0, };
ll sum = 0;

int main()
{
	int N;
	cin >> N;
	while (N--) {
		int tmp;
		cin >> tmp;
		arr[tmp]++;
		sum += tmp;
	}
	int Q;
	cin >> Q;
	while (Q--) {
		int a, b;
		cin >> a >> b;
		sum -= (ll)arr[a] * a;
		arr[b] += arr[a];
		sum += (ll)arr[a] * b;
		arr[a] = 0;
		cout << sum << "\n";
	}

}

Measured memory_bytes: 3980
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int K, X;
    cin >> K >> X;
    
    int min_num = X - K + 1;
    
    for(int i=0; i<2*K-2; i++){
        cout << min_num + i << " ";
    }
    cout << min_num + (2*K - 2) << endl;
}


Measured memory_bytes: 256