akhauriyash/Code-Regression huggingface dataset:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.special import perm
# from scipy.special import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W
 
# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

########

def C(n,r):
    f = math.factorial
    return int(f(n) // f(r) // f(n-r))

N, A, B = l_inpl()
v = l_inpl()

sort_v = sorted(v, reverse=True)
ans_1 = sum(sort_v[:A])/A
print(ans_1)

max_v = sort_v[A-1]
max_v_count = sort_v.count(max_v)
max_v_count_in_ans = sort_v[:A].count(max_v)

if max_v != sort_v[0]: # 1つでも増やすと平均が減少する場合
    ans = C(max_v_count, max_v_count_in_ans)
else:
    ans = 0
    for i in range(A, min(B, max_v_count) + 1):
        ans += C(max_v_count, i)

print(int(ans))


Measured memory_bytes: 3912
#include "bits/stdc++.h"

using namespace std;

using i64 = long long;

const i64 MOD = i64(1e9) + 7;
const i64 INF = i64(1e18) + 7;


bool solve(){
    int h, w;
    cin >> w >> h;
    if(!h)
        return false;
    vector<string> s(h);
    for(int i = 0; i < h; ++i)
        cin >> s[i];
    vector<pair<int, int>> poses;
    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j)
            if(s[i][j] == 'o')
                poses.emplace_back(i, j);
    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j)
            if(s[i][j] == '*')
                poses.emplace_back(i, j);

    vector<int> dx{1, 0, -1, 0};
    vector<int> dy{0, 1, 0, -1};
    int m = poses.size();
    auto f = [&](int sxx, int syy){
        vector<vector<int>> range(h, vector<int>(w, MOD));
        range[sxx][syy] = 0;
        queue<pair<int, int>> que;
        que.emplace(sxx, syy);
        while(!que.empty()){
            int x, y;
            tie(x, y) = que.front();
            que.pop();
            for(int d = 0; d < 4; ++d){
                int nx = x + dx[d];
                int ny = y + dy[d];
                if(nx < 0 || ny < 0 || nx >= h || ny >= w || s[nx][ny] == 'x')
                    continue;
                if(range[nx][ny] > range[x][y] + 1){
                    range[nx][ny] = range[x][y] + 1;
                    que.emplace(nx, ny);
                }
            }
        }
        vector<int> dist(m);
        for(int i = 0; i < m; ++i)
            dist[i] = range[poses[i].first][poses[i].second];
        return dist;
    };
    vector<vector<int>> dist(m + 1);
    for(int i = 0; i < m; ++i)
        dist[i] = f(poses[i].first, poses[i].second);
    vector<vector<int>> dp(1 << m, vector<int>(m, MOD));
    dp[1][0] = 0;
    for(int i = 0; i < (1 << m); ++i)
        for(int j = 0; j < m; ++j){
            for(int k = 0; k < m; ++k){
                if(!(i & (1 << k)))
                    dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], dp[i][j] + dist[j][k]);
            }
        }
    int ans = *min_element(dp.back().begin(), dp.back().end());
    cout << (ans == MOD ? -1 : ans) << endl;
    return true;
}
    signed main(){
        while(solve());
}




Measured memory_bytes: 3248
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DMultipleOf2019 solver = new DMultipleOf2019();
        solver.solve(1, in, out);
        out.close();
    }

    static class DMultipleOf2019 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long[] mod = new long[2019];
            String s = in.next();
            long n = 0;
            mod[0]++;
            int pow = 1;
            for (int i = 0; i < s.length(); i++) {
                n = (n + (s.charAt(s.length() - 1 - i) - '0') * pow) % 2019;
                mod[(int) n]++;
                pow = pow * 10 % 2019;
            }
            long sum = 0;
            for (long l : mod) {
                sum += l * (l - 1) / 2;
            }
            out.println(sum);
        }

    }
}



Measured memory_bytes: 40608
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

string Long2Bin(ll n){
    if(n == 1)return "1";
    else if(n == 0)return "0";

    return Long2Bin(n/2)  + Long2Bin(n%2);
}


int main(){
    ll d, g;
    cin >> d >> g;

    vector<ll> p(d), c(d);
    rep(i, d)cin >> p[i] >> c[i];

    ll ans = INF;
    //bitが立っているものを全部使う
    rep(bit, (1<<d)){
        ll cnt = 0;
        ll point = g;
        rep(i, d)if((1<<i) & bit){
            cnt += p[i];
            point -= (i+1)*100*p[i] + c[i];
        }

        if(point <= 0){
            ans = min(ans, cnt);
            continue;
        }

        //使っていないものを大きい物を使う
        for(ll i = d-1; i >= 0; --i){
            if(!((1<<i) & bit)){
                ll c_i = point / ((i+1)*100);
                if(point % ((i+1)*100) > 0)c_i++;

                c_i = min(c_i, p[i]);
                point -= (i+1)*100*c_i;
                cnt += c_i;
                break;
            }
        }

        if(point <= 0)ans = min(ans, cnt);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,r,c,p;
    vector<int> s,s2;
    while(1){
        cin >> n >> r;
        if(n==0&&r==0)  break;
        for(int i=1;i<=n;i++){
            s.push_back(i);
        }
        while(r--){
            cin >> p >> c;
            for(int i=0;i<n-c-p+1;i++){
                s2.push_back(s[i]);
            }
            for(int i=n-p+1;i<n;i++){
                s2.push_back(s[i]);
            }
            for(int i=n-c-p+1;i<n-p+1;i++){
                s2.push_back(s[i]);
            }
            s.clear();
            for(int i=0;i<n;i++){
                s.push_back(s2[i]);
            }
            s2.clear();
        }
        cout << s[n-1] << "\n";
        s.clear();
    }
}

Measured memory_bytes: 3144
#include <iostream>
using namespace std;
int main(void){
	long long n,v[100010],i,ans=0,temp,q,b,c;
	cin >> n;
	for (i=0 ; i<=100000; i++) {
		v[i] = 0;
	}
	for (i=0 ; i<n ; i++) {
		cin >> temp;
		ans += temp;
		v[temp]++;
	}
	cin >> q;
	for (i=0 ; i<q ; i++) {
		cin >> b >> c;
		ans += v[b] * (c-b);
		v[c] += v[b];
		v[b] = 0;
		cout << ans << '\n';
	}
}


Measured memory_bytes: 4396
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll aw=0,ae=0;
    REP(i,n){
      if(s[i]=='E')ae++;
      else aw++;
    }
    int w[300005] = {0};
    int e[300005] = {0};
    w[0] = 0;
    e[0] = ae;
    int ans=aw;
    FOR(i,1,n){
      if(s[i-1]=='E')e[i-1]--;
      else w[i]++;
      ans = min(ans,w[i-1]+e[i-1]);
      //cout << w[i-1] << " " << e[i-1] << endl;
      e[i] = e[i-1];
      w[i] += w[i-1];
    }
    if(s[n-1]=='E')e[n-1]--;
    ans = min(ans,w[n-1]+e[n-1]);
    cout << ans << endl;
}

Measured memory_bytes: 2964
S = input()

a = int(S[0]+S[1])
b = int(S[2]+S[3])

if 1<=a<=12 and 1<=b<=12:
    print('AMBIGUOUS')
elif 1<=b<=12:
    print('YYMM')
elif 1<=a<=12 :
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

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

   int i;
   int result;

   result = 0;
   for (i=0;i<3;i++) {
      if ((N % 10) == 7)
        result = 1;
      N = N/10;
   }

   if (result)
    cout << "Yes " << endl;
  else
    cout << "No " << endl;
  return 0;
}


Measured memory_bytes: 3632
while True:
    table = input().split()
    
    a = int(table[0])
    op = table[1]
    b = int(table[2])
    
    if op == '?':
        break
        
    if op == '+':
        print("%d"%(a+b))
    elif op == '-':
        print("%d"%(a-b))
    elif op == '/':
        print("%d"%(a/b))
    elif op == '*':
        print("%d"%(a*b))


Measured memory_bytes: 5596
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
int main()
{
fast;
    ll x,n;
    cin>>x>>n;
    ll a[n];
    map<ll,ll>m;
    f(i,n)
    {
        cin>>a[i];
        m[a[i]]++;
    }
    sort(a,a+n);
    ll c1,c2;
    if(m[x]==0)
        cout<<x;
    else
    {
        ll y=x;
        while(m[y]!=0)
        {
            y--;
        }
        c1=y;
        y=x;
        while(m[y]!=0)
        {
            y++;
        }
        c2=y;
        if(abs(c1-x)<=abs(c2-x))
        {
            cout<<c1;
        }
        else
        {
            cout<<c2;
        }
    }
    return 0;
}

Measured memory_bytes: 3648
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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 mut $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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: usize,
        s: usize
    }

    //test
    //
    /*
    let k: usize = 2;
    let s: usize = 2;
    */

    let mut ans: usize = 0;

    for x in 0..k + 1 {
        for y in 0..k + 1 {
            if (x + y) > s {
                break;
            }
            if (x + y + k) >= s {
                ans += 1;
            }
        }
    }

    //assert_eq!(ans, 6);
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[w];
		String[] st = new String[2];
		for(int i = 0; i < a.length; i++)
			a[i] = i + 1;
		
		for(int i = 0; i < n; i++){
			String str = sc.next();
			st = str.split(",",0);
			int x = Integer.parseInt(st[0])-1;
			int y = Integer.parseInt(st[1])-1;
			int t = a[x];
			a[x] = a[y];
			a[y] = t;
		}
		for(int i = 0; i < a.length; i++){
			System.out.println(a[i]);
		}
	}
}

Measured memory_bytes: 17216
n = int(input())
x=[int(i) for i in input().split()]
sorted_x = sorted(x)
min = sorted_x[int((n/2)-1)]
max = sorted_x[int(n/2)] 

for i in range(n):
    if x[i]<=min:
        print(max)
    else:
        print(min)


Measured memory_bytes: 25624
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
#include<map>
#include <cassert>
#include<sstream>
using namespace std;
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
long long mod = 1e9 + 7;
signed main()
{
	int h, w;
	cin >> h >> w;
	int t = max(h, w);
	int n;
	cin >> n;
	cout << n / t + min(1, n%t);
}


Measured memory_bytes: 256
N = int(input())
d, X = map(int, input().split())
a = [int(input()) for _ in range(N)]
ans = 0
for i in range(N):
    cnt = 1
    for j in range(1,101):
        if a[i]*j + 1 <= d:
            cnt += 1
        else:
            ans += cnt 
            break

print(X+ans)

Measured memory_bytes: 8972
n = int(input())
xy = [[] for i in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        xy[i].append((x-1,y))
ans = 0
for i in range(2**n):
    tf = [0]*n #正直者1
    flag = True
    for j in range(n):
        if (i>>j)&1:
            tf[j] = 1
    for j in range(n):
        if tf[j]==1:
            for x,y in xy[j]:
                if tf[x] !=y:#正直者の言うことが矛盾してたら
                    flag = False
                    break
    if flag:ans = max(ans,sum(tf))
print(ans)


Measured memory_bytes: 3064
import math
N,K = map(int,input().split())
S = 0
for i in range(1,N+1):
  if i < K:
    p = math.log2(K/i)
    if p == int(p):
      S += (1/N)*((1/2)**p)
    else:
      S += (1/N)*((1/2)**(int(p)+1))
  else:
    S += 1/N
print(S)

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main()
{
    string num;
    cin>>num;
    if(num[0]=='7'||num[1]=='7'||num[2]=='7')
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3572
#include<stdio.h>
int main(){
  int n,i,x,y,z;
  scanf("%d",&n);
  int f[n+1];
  for(i=1;i<=n;i++)
    f[i]=0;
  for(x=1;x<100;x++)
    for(y=1;y<100;y++)
      for(z=1;z<100;z++)
        if(x*x+y*y+z*z+x*y+y*z+z*x<=n)
          f[x*x+y*y+z*z+x*y+y*z+z*x]++;
  for(i=1;i<=n;i++)
    printf("%d\n",f[i]);
  return 0;
}

Measured memory_bytes: 1704
//
// Created on 2020/02/16.
//

//#include <bits/stdc++.h>
#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 <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;
using gragh = vector<vector<int>>;

int main() {
    int ans = 0;
    map<string,int>mp;
    int n;
    cin>>n;
    for (int i = 0; i < n; ++i) {
        string temp;
        cin>>temp;
        mp[temp] ++;
        ans = max(ans,mp[temp]);
    }
    for (auto itr = mp.begin();itr != mp.end();++itr){
        if(itr->second==ans){
            cout<<itr->first<<endl;
        }
    }

}


Measured memory_bytes: 25216
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int X,A;

int main(){
    cin>>X>>A;
    if(X<A){
        cout<<0<<endl;
    }else{
        cout<<10<<endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func rot(s1 string) (s2 string) {
	s2 = ""
	var last string
	for i, x := range s1 {
		if i == 0 {
			last = string(x)
		}
		if i != 0 {
			s2 += string(x)
		}
	}
	s2 += last
	return
}

func main() {
	var s1, s2 string
	var res bool = false
	fmt.Scan(&s1, &s2)
	for i := 0; i < len(s1); i++ {
		s1 = rot(s1)
		if s1 == s2 {
			res = true
		}
	}
	if res {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using namespace std;

#define lli long long int

int main()
{
    lli n,totweight;
    cin>>n>>totweight;
    lli w[n+5],v[n+5],sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
        sum+=v[i];
    }
    lli dp[sum+5];
    for(int i=0;i<=sum;i++)
    {
        dp[i]=1000000000000000000;
    }
    ///cout<<dp[0]<<endl;
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(lli j=sum;j>=0;j--)
        {
            if(j+v[i]<=sum)
            {
                dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i]);
            }
        }
    }
    lli ans=0;
    for(int i=0;i<=sum;i++)
    {
        if(dp[i]<=totweight)
            ans=i;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  REP (i, sx, tx) {
    cout << 'R';
  }

  REP (i, sy, ty) {
    cout << 'U';
  }
  
  REP (i, sx, tx ) {
    cout << 'L';
  }

  REP (i, sy, ty ) {
    cout << 'D';
  }

  cout << 'D';
  
  REP (i, sx, tx + 1) {
    cout << 'R';
  }

  REP (i, sy, ty + 1) {
    cout << 'U';
  }

  cout << 'L';
  
  cout << 'U';
  
  REP (i, sx, tx + 1) {
    cout << 'L';
  }

  REP (i, sy, ty + 1) {
    cout << 'D';
  }

  cout << 'R' << endl;
  
  return 0;
}


Measured memory_bytes: 256
# https://www.planeta.tokyo/entry/6193/
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]  # 親
        self.rank = [1] * n  # 木の高さ
        self.size = [1] * n  # size[i] は i を根とするグループのサイズ

    def find(self, x):  # x の根を返す
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])  # 経路圧縮
            return self.parent[x]

    def unite(self, x, y):  # x, y の属する集合を併合する
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def is_same(self, x, y):  # x, y が同じ集合に属するか判定する
        return self.find(x) == self.find(y)

    def group_size(self, x):  # x が属する集合の大きさを返す
        return self.size[self.find(x)]

    def group_members(self, x):  # x が属する集合の要素を返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):  # すべての根をリストで返す
        return [i for i, x in enumerate(self.parent) if i == x]

    def group_count(self):  # 木の数を返す
        return len(self.roots())

    def all_group_members(self):  # すべての木の要素を辞書で返す
        return {r: self.group_members(r) for r in self.roots()}

    def __str__(self):  # print 表示用
        return '\n'.join('{}: {}'.format(r, self.group_members(r)) for r in self.roots())

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

uf = UnionFind(n)

for i in range(m):
  x,y,z = map(int, input().split())
  x -= 1
  y -= 1
  uf.unite(x,y)

print(uf.group_count())


Measured memory_bytes: 12592
import Control.Applicative
import Control.Monad
import Data.List

trans :: [String] -> [[Integer]] 
trans []=[]
trans (x:xs)=(map read.words$x) : trans xs

dist [a,b] [c,d]=abs (a-c)+abs (b-d)

comp a b
    |(snd a)==(snd b) =compare (fst a) (fst b)
    |otherwise =compare (snd a) (snd b)

nearFt :: [[Integer]] -> [Integer] -> Integer
nearFt checkPts student=(fst.head) $ sortBy comp $zip [1,2..] (map (dist student) checkPts)

nearPts :: [[Integer]] -> [[Integer]] -> [Integer]
nearPts students checkPts=map (nearFt checkPts) students

output n students checkPts size_n=do
  if(n==1) then 
             (putStrLn.show) $ last (nearPts students checkPts)
           else do
             (putStrLn.show) $ (nearPts students checkPts)!!(size_n-n)
             output (n-1) students checkPts size_n

main=do
  [n,m]<-map read.words<$>getLine
  data_students<- replicateM n getLine
  data_checkPts<- replicateM m getLine
  output n (trans data_students) (trans data_checkPts) n

Measured memory_bytes: 1020
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);
ll dp[1000000];

ll solve(ll a[],ll n,ll k){
    if(n==0)
    {
        return 0;
    }
    if(n==1)
    {
        return abs(a[0]-a[1]);
    }
    else
    {
        if(dp[n]!=-1)
        {
            return dp[n];
        }
        else
        {
            ll mini=inf;
            for(ll i=1;i<=k&&i<=n;i++)
            {
                mini=min(mini,solve(a,n-i,k)+abs(a[n-i]-a[n]));
            }
            dp[n]=mini;
            return dp[n];
        }
    }
    

}

int main(){
   ll n,k;
   cin>>n>>k;
   ll a[n];
   for(ll i=0;i<n;i++)
   {
       cin>>a[i];
   }
   for(ll i=0;i<100000;i++)
{
    dp[i]=-1;
}
   cout<<solve(a,n-1,k)<<"\n";
   return 0;
}

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

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

    vector<pair<int,int>> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.begin(),a.end());

    int ans = 0;
    for(int i=0; i<n; i++){
        if(a[i].second % 2 != i % 2) ans += 1;
    }
    ans /= 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4048
#include<iostream>
#include<algorithm>
using namespace std;
long dp[3],a;
char op;
int n;
main()
{
	cin>>n>>dp[0];
	dp[1]=dp[2]=-1e18;
	for(int i=1;i<n;i++)
	{
		cin>>op>>a;
		if(op=='+')
		{
			dp[0]+=a;
			dp[1]=max(dp[1]-a,dp[2]+=a);
		}
		else
		{
			dp[0]=dp[1]=max(dp[2]=dp[1]+a,dp[0]-a);
		}
	}
	cout<<dp[0]<<endl;
}


Measured memory_bytes: 256
array = gets.chomp.chars  ## array をこう置くこともある
# 文字列を配列に分解
n = array.length  ## length , size で文字列の数を取得

n.times do |i|
  if array[i] == "1"
    array[i] = "9"  
  elsif array[i] == "9"
    array[i] = "1"
  end
end

puts array.join.to_i ## join でつなげないと上から下に表示されるだけになる


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

#define MOD 998244353


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll n;
    cin>>n;
    vector<string> w(n);
    for(ll i = 0; i<n; i++){
        cin>>w[i];
    }
    bool ans = true;
    for(ll i = 0; i<n-1; i++){
        if(w[i][w[i].length()-1] != w[i+1][0])ans = false;
    }
    for(ll i = 0; i<n; i++){
        for(ll j = 0; j<i; j++){
            if(w[i]==w[j])ans = false;
        }
    }
    if(ans)puts("Yes");
    else puts("No");
    return 0;
}


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

using namespace std;

// input
int n,k;

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

  cin >> n >> k;
  
  int exp_num = 0;
  while(true) {
    if(pow(k,exp_num) > n) {
      break;
    }
    exp_num += 1;
  }
  cout << exp_num;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(){
    long long int t;
    scanf("%lld",&t);
    long long int num[t]={0}; 
    long long int hasil=1;
    for (long long int i=0;i<t;i++){
        scanf("%lld",&num[i]); 
    }
    for(long long int i=0;i<t;i++){
    
        if (num[i]==0){
            printf("0\n");
            return 0;
        }
        }
    for (int i=0;i<t;i++){
        if(num[i]<=1000000000000000000/hasil){
            hasil*=num[i];
        }
        else{
            printf("-1\n");
            return 0;
        }
    }    
        printf("%lld",hasil);
        return 0;
    }

Measured memory_bytes: 2476
N = int(input())
S = str(input())
E = [0]*N
W = [0]*N
min = 10**9
for i in range(N):
    if S[i]=="E":
        E[i] += 1+E[i-1]
        W[i] = W[i-1]
    elif S[i]=="W":
        W[i] += 1+W[i-1]
        E[i] = E[i-1]
if S[0]=="W":
    W.insert(0,0)
    W.pop(-1)
for j in range(N):
    tmp = E[-1]-E[j]+W[j]
    if min>tmp:
        min = tmp
print(min)


Measured memory_bytes: 17692
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

ll A[105][105], B[105][105], C[105][105];

int main () {
  int n = in(), m = in(), l = in();
  rep(i,n)rep(j,m) cin >> A[i][j];
  rep(i,m)rep(j,l) cin >> B[i][j];
  rep(i,n)rep(j,l) {
    rep(k,m) C[i][j] += A[i][k]*B[k][j];
  }
  rep(i,n)rep(j,l) printf("%lld%c", C[i][j], j==l-1?'\n':' ');
  return 0;
}


Measured memory_bytes: 3448
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
char a[1100];
int main()
{
	long long int t;
	while(cin>>t)
	{
		int head=0,tail=0,mid=0,con=0,ans=0;
		for(int i=0;i<t;++i)
		{
			scanf("%s",&a);
			int len = strlen(a);
			if(a[0]=='B'&&a[len-1]=='A')
				con++;
			if(a[0]=='B'&&a[len-1]!='A')
				head++;
			if(a[len-1]=='A'&&a[0]!='B')
				tail++;
			for(int j =1;j<len-1;++j)
			{
				if(a[j]=='B'&&a[j-1]=='A')
					ans++;
			}
		}
		int h=0,t=0;
		if(con)
		{
			ans = ans+con-1;
			if(head)
				t = 1;
			if(tail)
				h = 1;
		}
		head = head+h;
		tail = tail+t;
			
		ans = ans+min(head,tail);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
// #define vb          vector<bool>
// #define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
// #define ub(x)       upper_bound(x)
// #define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("b1.in","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N            1e5+5
// #define M           1e9+7
#define MAX         50000
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define pi          3.14159265358979323

struct cmp { 
    bool operator() (pii a,pii b){
        return ((a.F-a.F/2)*a.S)<((b.F-b.F/2)*b.S);
    }
};

const int N=1e6+1;
// int n,m,k;
// int cnt[N],all;
const int MOD=1e9+7;
int func(int n){
    return n*(n+1)/2;
}
const bool cmp(int a,int b){
    return a>b;
}

void Anon_mouS(){
    int x;
    cin>>x;
    cout<<!x<<endl;
}
int32_t main(){
    fastio;
    int q=1;
    // sieve();
    // cin>>q;
    for(int it=1;it<=q;it++){
        // cout<<"Case #"<<it<<": ";
        Anon_mouS();
    }
    return 0;   
}

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

using namespace std;

int main() {
  int a, b, c;
  int k;
  cin >> a >> b >> c >> k;
  if (a > b)
    swap(a, b);
  if (a > c)
    swap(a, c);
  if (b > c)
    swap(b, c);
  c <<= k;
  cout << a + b + c << '\n';
  return 0;
}


Measured memory_bytes: 256
#coding:utf-8
from scipy.spatial.distance import pdist
N, D = map(int,input().split())
P = []
for i in range(N):
    P.append(list(map(int,input().split())))
DI = pdist(P)
sm = 0
for d in DI:
    sm += d.is_integer()
print (sm)


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

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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;
}
const long long INF = 1LL << 60;

int main() {
    ll N, H;
    cin >> N >> H;
    vector<pair<ll, ll>> ab(N);
    vector<pair<ll, ll>> ba(N);
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        ab[i].first = a;
        ab[i].second = b;
        ba[i].first = b;
        ba[i].second = a;
    }
    sort(ab.begin(), ab.end(), greater<pair<ll, ll>>());
    sort(ba.begin(), ba.end(), greater<pair<ll, ll>>());
    ll ans = 0;
    ll maxa = ab[0].first;
    rep(i, N) {
        if (ba[i].first >= maxa) {
            H -= ba[i].first;
            ans++;
            if (H <= 0) {
                cout << ans << endl;
                return 0;
            }
        }
    }
    ans += (ll)ceil((double)H / ab[0].first);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
int dp[201][201];
int main(void)
{
	int d,n,t[201],a[201],b[201],c[201];
	int i,j,k,w=0,x,max;
	scanf("%d%d",&d,&n);
	for(i=1;i<=d;i++) scanf("%d",&t[i]);
	for(i=1;i<=n;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]);
	for(i=1;i<=d;i++){
		for(j=1;j<=n;j++) dp[i][j]=-1;
	}
	for(i=1;i<=n;i++){
			if(t[1]<=b[i]&&t[1]>=a[i]) dp[1][i]=0;
	}
	for(i=1;i<d;i++){
		for(j=1;j<=n;j++){
			if(dp[i][j]!=-1){
				for(k=1;k<=n;k++){
					if(t[i+1]>=a[k]&&t[i+1]<=b[k]){
							w=c[j]-c[k];					
						if(w<0){
							w*=-1;
						}	
						if(dp[i+1][k]<dp[i][j]+w){
							dp[i+1][k]=dp[i][j]+w;
						}	
					}
				}
			}
		}
	}
	x=-1;
	for(i=1;i<=n;i++){
		if(x<dp[d][i]) x=dp[d][i];
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 2848
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define PUTS(x) cout << (x) << endl;
#define ALL(v) (v).begin(), (v).end()

vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}

int main() {
    Int n;
    cin >> n;
    auto p = IntsIn(n);
    sort(ALL(p));
    auto s = set<Int>();
    const Int m = 1000001;
    auto a = vector<bool>(m, true);
    auto prev = 0LL;
    for (auto x : p) {
        if (prev==x){
            s.erase(x);
            continue;
        }
        if (a[x]) {
            s.insert(x);
        }
        auto i = 2LL;
        auto y = i * x;
        while (y<m) {
            a[y] = false;
            i++;
            y = i * x;
        }
        prev = x;
    }
    PUTS(s.size())
}


Measured memory_bytes: 14236
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
bool check(int r,int c,int h,int w,vs &grid,int k)
{
    v row(h,0),col(w,0);
    for(int i=0;i<h;i++)
    {
        if(r &(1ll<<i))
        {
            row[i]=1;
        }
    }
    for(int i=0;i<w;i++)
    {
        if(c & (1ll<<i))
        {
            col[i]=1;
        }
    }
    int black=0;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(grid[i][j]=='#' && row[i]==0 && col[j]==0)
                black++;
        }
    }
    return (black==k);
}
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int h,w,k;cin>>h>>w>>k;
    vs grid(h);in(grid,h);
    int ans=0;
    for(int i=0;i<(1ll<<h);i++)
    {
        for(int j=0;j<(1ll<<w);j++)
        {
            if(check(i,j,h,w,grid,k))
                ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()

void shuru_krte_hai_bina_kisi_bakchodi_ke()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}


int32_t main()
{
    //shuru_krte_hai_bina_kisi_bakchodi_ke();
    string s,t;
    cin>>s>>t;
    int n = s.length();
    int m = t.length();
    int ans = INT_MAX;
    for(int i=0;i<n-m+1;i++){
        int count  =0;
        for(int j=0;j<m;j++){
            if(t[j]!=s[i+j]){
                count++;
            }
        }
        ans = min(ans,count);
    }
    cout<<ans<<" ";
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
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<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    string s;
    cin >> s;
    s[1] = s[1]^'R'^'B';
    cout << s << endl;
}


Measured memory_bytes: 3588
n = int(input())
ball = [list(map(int,input().split())) for i in range(n)]
ans = 0
for x in range(n):
    for y in range(n):
        if x == y:
            continue
        else:
            p = ball[x][0] - ball[y][0]
            q = ball[x][1] - ball[y][1]
            cou = 0
            for i in range(n):
                for j in range(n):
                    if ball[i][0]-ball[j][0] == p and ball[i][1]-ball[j][1] == q:
                        cou += 1
            ans = max(ans,cou)
print(n-ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {
	int N;
	double T, A;
	cin >> N >> T >> A;

	vector<double> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	double d_temp = 1e9;
	double now_d;
	int ans = -1;
	for (int i = 0; i < N; i++) {
		now_d = abs(A - (T - H[i] * 0.006));
		if (now_d < d_temp) {
			ans = i + 1;
			d_temp = now_d;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	for (int i = 0; i < H; ++i) {
		cin >> S[i];
	}
	vector<vector<int> > id(H, vector<int>(W, -1));
	int id_cur = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (S[i][j] == '.') {
				id[i][j] = id_cur++;
			}
		}
	}
	int N = id_cur;
	vector<vector<int> > G(N);
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (i >= 1 && id[i][j] != -1 && id[i - 1][j] != -1) {
				G[id[i][j]].push_back(id[i - 1][j]);
				G[id[i - 1][j]].push_back(id[i][j]);
			}
			if (j >= 1 && id[i][j] != -1 && id[i][j - 1] != -1) {
				G[id[i][j]].push_back(id[i][j - 1]);
				G[id[i][j - 1]].push_back(id[i][j]);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		vector<int> dist(N, -1);
		dist[i] = 0;
		queue<int> que;
		que.push(i);
		while (!que.empty()) {
			int u = que.front(); que.pop();
			for (int j : G[u]) {
				if (dist[j] == -1) {
					dist[j] = dist[u] + 1;
					que.push(j);
				}
			}
		}
		int sub = *max_element(dist.begin(), dist.end());
		ans = max(ans, sub);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  long long int h,w;
  scanf("%lld %lld",&h,&w);
  if(h==1||w==1)
    printf("1\n");
  else if((h*w)%2==0)
    printf("%lld\n",(h*w)/2);
  else
    printf("%lld\n",(w*h)/2+1);
  return 0;
}

Measured memory_bytes: 1720
#include <stdio.h>

#include <iostream>
#include <vector>
#include <string.h>

#pragma warning (push)
#pragma warning (disable : 4996)
#define mod 1000000007;

using namespace std;

int main()
{
    string S;
    cin >> S;
    if (S[0] == S[1] && S[1] == S[2]) {
        cout << "No";
    }
    else {
        cout << "Yes";
    }
}

#pragma warning (pop)

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

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


	// your code goes here
	return 0;
}

Measured memory_bytes: 256