akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std ;
typedef  long long int ll ;
#define inf ll(1e18)
#define mod 1000000007
#define mod1 998244353
#define mod2 999983
ll power(ll a,ll n,ll m) ;
ll power(ll a,ll n,ll m)
{  if(n==0)
   return 1 ;
   ll x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}
double PI=3.14159265357 ;
int32_t main()
{ ll n,i,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,temp;
  ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  cin>>n>>m>>k ;
  string s[n] ;
  for(i=0;i<n;i++)
    cin>>s[i] ;

  cnt=0 ;
  for(i=0;i<ll(pow(2,n));i++)
  {
      for(j=0;j<ll(pow(2,m));j++)
      {
          sum=0 ;
          z=1 ;
          for(a=1;a<=n;a++)
          { x=a ;
               if((z&i)!=0)
             { //cout<<i<<" " ;
                  z=z*2 ;
                 continue ; }
                 d=1 ;
              for(b=1;b<=m;b++)
              { x=b ;
               //cout<<b<<" " ;
                  if((d&j)!=0)
                 {  //cout<<b<<" "<<j<<" " ;
                      d=d*2 ;
                     continue ; }
              if(s[a-1][b-1]=='#')
                sum++ ;
                d=d*2 ;
              }
              z=z*2 ;
          }
      //   cout<<i<<" "<<j<<" "<<sum<<" " ;
          if(sum==k)
            { //cout<<i<<" "<<j<<" " ;
                cnt++ ; }
      }
     // cout<<i<<" " ;
  }
  cout<<cnt ;
  return 0; }


Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int a, b;
  cin >> a >> b;
  if (a > 0)
  {
    cout << "Positive" << endl;
  }
  else if (a <= 0 && b >= 0)
  {
    cout << "Zero" << endl;
  }
  else
  {
    int count = (-a) - (-b);
    if (count % 2 == 0)
      cout << "Negative" << endl;
    else
      cout << "Positive" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  string s;
  int size,count = 0;
  
  cin >> s;
  
  size = s.size();
  
  for(int i = 0; i < size ; i++){
      if(s.at(i) == 'x'){
          count = count +1;
      }
  }
  
  if(count >= 8){
      cout << "NO";
  }
  
  else{
      cout << "YES";
  }
  
}

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

int field[102][102];

int main(){
    int n;
    while(cin >> n, n != 0){
        int w, h;
        cin >> w >> h;
        for(int i=0;i<=h;++i)
            for(int j=0;j<=w;++j)
                field[i][j] = 0;
        for(int i=0;i<n;++i){
            int x, y;
            cin >> x >> y;
            field[y][x] = 1;
        }
        int s, t;
        cin >> s >> t;
        int ans = 0;
        for(int i=1;i<=h-t+1;++i){
            for(int j=1;j<=w-s+1;++j){
                int cnt = 0;
                for(int k=i;k<i+t;++k){
                    for(int l=j;l<j+s;++l){
                        cnt += field[k][l];
                    }
                }
                ans = max(ans, cnt);
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
import java.util.Scanner;

// https://atcoder.jp/contests/abc064/tasks/abc064_a

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();
    if ((100 * r + 10 * g + b) % 4 == 0) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 23764
while input = gets
$S = input.to_i
if $S <= 50
  $num = 0
  $a = 0
  begin
    if ($S - $a) <= 27
      $b = 0
      begin
        if ($S - $a - $b) <= 18
          $c = 0
          begin
            if ($S - $a - $b - $c) <= 9
              $d = 0
              begin
                if ($S - $a - $b - $c - $d) == 0
                  $num += 1
                end
                $d += 1
              end while $d <= 9
            end
            $c += 1
          end while $c <= 9
        end
        $b += 1
      end while $b <= 9
    end
    $a += 1
  end while $a <= 9

  puts $num
end
end

Measured memory_bytes: 6100
#include <iostream>
#include <cstdlib>

using namespace std;

int N;

int main(void){
  cin >> N;
  int x[N+1],y[N+1];
  int t[N+1];
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for ( int i=1; i<=N; i++){
    cin >> t[i] >> x[i] >> y[i];
  }

  for ( int i=1; i<=N; i++){
    int diff = t[i] - t[i-1] - abs(x[i] - x[i-1]) - abs(y[i] - y[i-1]);
    if ( diff >= 0 && (diff+1)%2 == 1){
      continue;
    } else {
      cout << "No";
      return 0;
    }
  }

  cout << "Yes";

  return 0;
}

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

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll fact[100005];

int N, K;
ll A[100005];

void init_fact() {
    ll f = 1;
    fact[0] = 1;
    for (int i = 1; i <= 100004; i ++) {
        f = (f * i) % MOD;
        fact[i] = f;
    }
}

void extgcd(ll a, ll b, ll *x, ll *y) {
    ll xx, yy;
    if (b == 0) {
        *x = 1;
        *y = 0;
    } else {
        ll q = a / b;
        ll r = a % b;
        extgcd(b, r, &xx, &yy);
        *x = yy;
        *y = xx - q * yy;
    }
}

ll inv(ll a) {
    ll x, y;
    extgcd(a, MOD, &x, &y);
    return (x + MOD) % MOD;
}

ll combination(int n, int r) {
    return fact[n] * inv(fact[r]) % MOD * inv(fact[n - r]) % MOD;
}

int main() {
    init_fact();
    cin >> N >> K;
    rep(i, N) cin >> A[i];
    sort(A, A + N);
    ll ans = 0;
    for (int i = K - 1; i < N; i ++) {
        ll c = combination(i, K - 1);
        ans = (ans + c * A[i] % MOD) % MOD;
    }
    for (int i = 0; i <= N - K; i ++) {
        ll c = combination(N - 1 - i, K - 1);
        ans = (ans + MOD - c * A[i] % MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author szawinis
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define long long long
const long MOD = 1e9+7, LINF = 1e18 + 1e16;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
const int N = 2e5+1;

class TaskC {
	int n, m, dsu[N], cnt[N][2];
	bool removed[N];
	string s;
	vector<int> g[N];

	int root(int v) {
		return (dsu[v] < 0 ? v : dsu[v] = root(dsu[v]));
	}

	void merge(int u, int v) {
		if((u = root(u)) == (v = root(v))) return;
		dsu[u] += dsu[v];
		dsu[v] = u;
	}

public:
	TaskC() {
		memset(dsu, -1, sizeof(dsu));
		memset(cnt, 0, sizeof(cnt));
		memset(removed, 0, sizeof(removed));
	}
	void solve(istream& cin, ostream& cout) {
		cin >> n >> m >> s;
		for(int i = 0, u, v; i < m; i++) {
			cin >> u >> v;
			--u, --v;
			g[u].push_back(v);
			g[v].push_back(u);
			++cnt[u][s[v] == 'B'];
			++cnt[v][s[u] == 'B'];
		}
		queue<int> q;
		for(int i = 0; i < n; i++) if(!cnt[i][0] || !cnt[i][1]) q.push(i), removed[i] = true;
		while(!q.empty()) {
			int u = q.front();
			q.pop();
			for(int v: g[u]) {
				--cnt[v][s[u] == 'B'];
				if(!removed[v] && (!cnt[v][0] || !cnt[v][1])) {
					q.push(v);
					removed[v] = true;
				}
			}
		}
		int ans = 0;
		for(int i = 0; i < n; i++) ans += !removed[i];
		assert(ans || ans != 1);
		cout << (ans ? "Yes" : "No") << endl;
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	TaskC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 13520
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Buffer(make([]byte, 0), 1e6) // maxTokenSize
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	/* --- code --- */
	n, k := nextInt(), nextInt()
	p := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = nextInt()
	}
	sort.Slice(p, func(i, j int) bool {
		return p[i] < p[j]
	})
	sum := 0
	for i := 0; i < k; i++ {
		sum += p[i]
	}
	fmt.Println(sum)
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

func max(a, b int) int {
	return int(max64(int64(a), int64(b)))
}

func max64(a int64, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	return int(min64(int64(a), int64(b)))
}

func min64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


Measured memory_bytes: 1744
N,Q = map(int, input().split())
ki = [[] for i in range(N+1)]
val = [0 for _ in range(N+1)]

for _ in range(N-1):
  a,b = map(int, input().split())
  ki[a].append(b)
  ki[b].append(a)
for _ in range(Q):
  p,x = map(int, input().split())
  val[p] += x

q = [(1,0)]
while q:
  c,p = q.pop()
  val[c] += val[p]
  for x in ki[c]:
    if x==p:
      continue
    q.append((x,c))
print(' '.join(map(str, val[1:])))

Measured memory_bytes: 65284
import math
a,b,h,m = map(int, input().split())

x = 30*h + (m/60)*30 # 1hあたりの角度 + 1mあたりの角度
y = 6*m # 1分あたりの角度
z = abs(x-y)

print((a**2+b**2-2*a*b*math.cos(math.radians(z)))**0.5)

Measured memory_bytes: 9512
#include <iostream>
#include <cmath>
#include <stdarg.h>
#include <string>
using namespace std;


int main()
{
    string S;
    cin >> S;
    int count = 0;
    
    for(int i=0;i<3;i++)
    {
        if(S[i]=='o'){
            count +=1;
        }
        
    }
    cout << 700+count*100<<endl;

    
}

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

#define ll long long int
#define mem(n) memset(n,0,sizeof(n))
#define LCM(a,b) (a / __gcd(a,b) ) * b
#define gcd(a,b) __gcd(a,b)
#define for0(l,n) for(int l=0;l<n;l++)
#define for1(l,n) for(int l=1;l<=n;l++)
#define bug(n) cout<<">> "<<n<<" <<";
#define pb push_back
#define P1(a) cout<<a<<endl;
#define P2(a,b) cout<<a<<" "<<b<<endl;
#define P3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define S1(a) cin>>a
#define S2(a,b)cin>>a>>b
#define S3(a,b,c) S2(a,b),S2(c)
#define squerit(n) (ll)n*n
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)

bool vowel(char a)
{
    a= toupper(a);
    if((a=='A')||(a=='E')||(a=='I')||(a=='O')||(a=='U'))return 1;
    return 0;
}

ll n,m,q,a,b,c,sum=0,cnt=0;
ll arr[1000055];
map<ll,bool>mp;
string str;
ll powit(int x,int m)
{
    ll a = 1;
    for0(i,m)a*=10;
//    cout<<" "<<a<<endl;
    return a;
}
int main()
{
    FastRead;

    cin>>a>>b;

    c = b;
    cnt = 0;
    while(c!=0)
    {
        c/=10;
        cnt++;
//        cout<<cnt<<" "<<c<<endl;
    }
    a= a*(powit(10,cnt));


//    cout<<a<<endl;
//
    a+=b;
//    cout<<a<<endl;
    c = sqrt(a);
    if(c*c==a)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;


}















Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int H, N;
    cin >> H >> N;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }

    ll sum = accumulate(all(A), (ll)0);
    if (sum >= H) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3932
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	ll r, d, x; cin >> r >> d >> x;
	for( int i = 0; i < 10; ++i ){
		x = r*x-d;
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
  ll n;
  cin>>n;
  ll a[n];
  ll sum =0;
  ll dp[3000][3000][2] ;
  for(ll i=0;i<n;i++){
    cin>>a[i];
    sum+= a[i];
    dp[i][i][0] = a[i];
    dp[i][i][1] = 0;
  }
  for(ll rml=1;rml<n;rml++){
    for(ll L=0;L+rml<n;L++){
      int R = rml+L;
      dp[L][R][0] = max(a[L]+dp[L+1][R][1],a[R]+dp[L][R-1][1]);
      dp[L][R][1] = min(dp[L+1][R][0], dp[L][R-1][0]);
    }
  }
  ll X = dp[0][n-1][0] ;
  cout<<2*X-sum ;
}


Measured memory_bytes: 85408
#include<bits/stdc++.h>
using namespace std;
#define SORT(A) std::sort(A.begin(), A.end())
#define RSORT(A) std::sort(A.begin(), A.end(), std::greater<>())
#define FR(A, e) for (auto& e : A)
#define SHOW(A) for (auto& e : A) {cout << e << " ";}; cout << endl;
#define within(x,_left,_right) (_left <= x && x <= _right)
#define rwithin(x, _l, _r) (_l < x && x < _r)
#define ALL(A) A.begin(),A.end()
#define RALL(A) (A).rbegin(),(A).rend()
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define sz(x) ((int)x.size())
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define bitcnt(x) (__builtin_popcountll(x))
#define fi first
#define se second
#define bg(A) A.begin()
#define ed(A) A.end()
#define rbg(A) A.rbegin()
#define red(A) A.rend()
using LL = long long;
using db = double;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
using VL = vector<LL>;
using VVL = vector<VL>;
const LL MOD = 1e9 + 7;
const LL LMAX = 0x7fffffffffffffff;
const LL LMIN = 0x8000000000000000;
typedef std::pair<int, int> PII;
typedef std::pair<LL, LL> PLL;
typedef std::pair<int, char> PIC;

void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int main(){
    int N, K;
    cin >> N >> K;
    
    VL pos, neg, zero, arr;

    for (int i = 0; i < N; ++ i){
        int t; cin >> t;
        arr.push_back(abs(t));

        if (t > 0) pos.emplace_back(t);
        else if (t == 0) zero.emplace_back(t);
        else neg.emplace_back(abs(t));
    }

    RSORT(pos); // 从大到小
    RSORT(neg);

    // for (auto&x: pos) cout << x << " "; cout << '\n';

    int64_t res = 1;
    int a(sz(pos)), b(sz(neg)), c(sz(zero));

    if (a + b / 2 * 2 >= K && (K % 2 == 0 || a > 0)){
        int pp = 0, pn = 0;
        if (K & 1){
            res = pos[0];
            pp ++;
            K --;
        }
        while (K){
            // cout << pos[0] << pos[1] << endl;
            LL v1 = (a-pp >= 2 ? pos[pp] * pos[pp+1] : 0);
            LL v2 = (b-pn >= 2 ? neg[pn] * neg[pn+1] : 0);
            // cout << v1 << endl;

            if (v1 >= v2){
                // res = (1LL * res * v1) % MOD;
                mul(res, v1 % MOD);
                pp += 2;
            }else {
                // res = (1LL * res * v2) % MOD;
                mul(res, v2 % MOD);
                pn += 2;
            }
            K -= 2;
            // cout << res << endl;
        }
    }else if (c){
        res = 0;
    }else {
        SORT(arr);
        for (int i = 0; i < K; ++ i)
            res = 1LL * res * arr[i] % MOD;
        res = (MOD - res) % MOD;
    }

    cout << res % MOD << endl;
    return 0;
}

// 1569325056

Measured memory_bytes: 7520
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    // fastIO();
    
    int a, b, c, cnt = 0;
    cin >> a >> b >> c;
    
    while (cnt < 1000) {
        if ((a & 1) or (b & 1) or (c & 1)) break;
        int da = a/2, db = b/2, dc = c/2;
        a = db + dc, b = da + dc, c = da + db;
        ++cnt;
    }
    
    cout << (cnt == 1000 ? -1 : cnt) << "\n";
    
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,k;

  while(cin >> n >> m ,n + m){
    vector<ll> h(n),t(m);
    ll sh = 0,st = 0;
    rep(i,n){
      cin >> h[i];
      sh += h[i];
    }
    rep(i,m){
      cin >> t[i];
      st += t[i];
    }
    pll ans = mp(inf,inf);
    rep(i,n){
      rep(j,m){
        if(sh - h[i] + t[j] == st - t[j] + h[i]){
          if(h[i] + t[j] < ans.fi + ans.se){
            ans = mp(h[i],t[j]);
          }
        }
      }
    } 
    if(ans == mp(inf,inf)){
      std::cout << -1 << std::endl;
    }
    else{
      cout << ans.fi <<  ' ' << ans.se << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D, N;
  cin >> D >> N;
  
  int ans = 0;
  
  if(D == 0){
    for(int i = 0; i < N; i++){
      ans = ans + 1;
    }
    
    if(N == 100){
      ans = 101;
    }
  }
  
  if(D == 1){
    for(int i = 0; i < N; i++){
      ans = ans + 100;
    }
    
    if(N == 100){
      ans = 10100;
    }
  }
  
  if(D == 2){
    for(int i = 0; i < N; i++){
      ans = ans + 10000;
    }
    
    if(N == 100){
      ans = 1010000;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
x = []
for i in range(3):
    x.append(input())
teban = 0
while True:
    if x[teban] == "":
        break

    card = x[teban][0]
    x[teban] = x[teban][1:]
    teban = ord(card) - ord('a')

print(chr(ord('A')+teban))


Measured memory_bytes: 2940
N = int(input())
res = 0
for num in range(1, N + 1):
    if num % 2 == 1:
        cnt = 0
        for d in range(1, num + 1):
            if num % d == 0:
                cnt += 1
                if cnt > 8:
                    break
        if cnt == 8:
            res += 1
print(res)


Measured memory_bytes: 9100
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

// int A[100000 + 10];
 
signed main(void) {
    int N, K;
    cin >> N >> K;
    int min_pos;
    rep(i, N) {
        int tmp;
        cin >> tmp;
        if (tmp == 1) min_pos = i;
    }
    // int l = ceil((double)min_pos/(K-1));
    // int where_l = min_pos % (K-1);
    // int r = ceil((double)(N-min_pos-1)/(K-1));
    // int where_r = K - ((N-min_pos-1) % (K-1));
    // if (where_r == where_l) {
    //     cout << l + r - 1 << endl;;
    // } else {
    //     cout << l + r << endl;
    // }
    if ((N-1) % (K-1) == 0) {
        cout << (N-1) / (K-1) << endl;
    } else {
        cout << ((N-1) / (K-1)) + 1<< endl;
    }
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define MOD = 998244353;
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define isYes(x) printf("%s\n", (x) ? "Yes" : "No")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define isIn(x, y, h, w) (x >= 0 && x < h && y >= 0 && y < w)
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
#define range(c, r) (c).begin(), (c).begin() + (r)    // Mainly used in sorting
#define present(c, x) ((c).find(x) != (c).end())      // for sets, maps, multi-maps
#define cpresent(c, x) (find(all(c), x) != (c).end()) // for vectors
#define run(x, c) for ((x) = (c).begin(); (x) != (c).end(); (x)++)
#define fo0(i, n) for (i = 0; i < n; i++)
#define fo1 (i, n) for (i = 1; i <= n; i++)
#define rfo(i, n) for (i = n - 1; i >= 0; i--)
#define rfor(i, n) for (i = n; i > 0; i--)
signed main()
{
    string s;
    cin >> s;
    int n = s.length(), i, current = 0, ans = 0;
    vi prefix_mod(200005, 0);
    prefix_mod[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        prefix_mod[i] = (prefix_mod[i - 1] * 10) % 2019;
    }
    vi rem(2019, 0);
    rfo(i, n)
    {
        current = (current + ((s[i] - '0') * prefix_mod[n - i - 1]) % 2019) % 2019;
        rem[current]++;
    }
    ans += rem[0];
    fo0(i, 2019)
    {
        ans += (((rem[i]) * (rem[i] - 1)) / 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5120
import sys


ticket = list(input())

op = [0] * 3

for i in range(2):
    if i == 0:
        op[0] = "+"
    else:
        op[0] = "-"
    for j in range(2):
        if j == 0:
            op[1] = "+"
        else:
            op[1] = "-"
        for k in range(2):
            if k == 0:
                op[2] = "+"
            else:
                op[2] = "-"

            eq = ""
            for n in range(3):
                eq += ticket[n] + op[n]
            eq += ticket[-1]

            if eval(eq) == 7:
                print(eq+"=7")
                sys.exit()


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

using namespace std;

long long power(int a, int b){
	long long ret = 1;
	for(int i=b;i>0;i--){
		ret *= a;
	}
	return ret;
}

int main(void){
	string a;
	cin >> a;
	a.insert(a.begin()+4, ' ');
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import collections
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    q = int(input())
    ans = [sum(a)]
    a = dict(collections.Counter(a))
    for i in range(q):
        b, c = map(int, input().split())
        if b in a.keys():
            ans.append(ans[i] + ((c - b) * a[b]))
            if c in a.keys():
                a[c] = a[b] + a[c]
            else:
                a[c] = a[b]
            del a[b]
        else:
            ans.append(ans[i])
    print(*ans[1:], sep='\n')

if __name__ == '__main__':
    main()

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
 
  if ( a == b && b == c ) {
   cout << 1 << endl;
  }
  else if ( a == b || b == c || c == a ) {
    cout << 2 << endl;
  }
  else {
    cout << 3 << endl;
  }
     
}


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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<string> &s, string a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> board(h, vector<char>(w));
    rep(y, h) rep(x, w) cin >> board[y][x];

    auto can = [&](int y, int x) {
        if (y == h) return false;
        if (x == w) return false;
        if (board[y][x] == '.') return false;
        return true;
    };
    auto set = [&](int y, int x) {
        if (!can(y, x)) return;
        board[y][x] = 'o';
    };

    board[0][0] = 'o';
    rep(y, h)rep(x, w) {
            if (board[y][x] == 'o') {
                if (can(y + 1, x)) {
                    set(y + 1, x);
                } else if (can(y, x + 1)) {
                    set(y, x + 1);
                }
            }
        }


    rep(y, h)rep(x, w) {
            if (board[y][x] == '#') {
                cout << "Impossible" << endl;
                return 0;
            }
        }

    cout << (board.back().back() == 'o' ? "Possible" : "Impossible") << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m, wh, ans, dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
char s[55][55];
struct P{int x, y, c;};
queue<P> qu;

int main(){
	scanf("%d %d\n", &n, &m);
	for(int i = 1; i <= n; i++){
		scanf("%s", s[i]+1);
		for(int j = 1; j <= m; j++) if(s[i][j] == '.') wh++;
	}
	if(s[1][1] == '.') qu.push((P){1, 1, 1});
	while(!qu.empty()){
		P tmp = qu.front(); qu.pop();
		if(tmp.x == n && tmp.y == m) ans = tmp.c;
		for(int i = 0; i < 4; i++) {
			int x = tmp.x + dx[i], y = tmp.y + dy[i];
			if(s[x][y] == '.'){
				qu.push((P){x, y, tmp.c+1});
				s[x][y] = '#';
			}
		}
	}
	printf("%d\n", ans ? wh - ans : -1);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static double Solve(int N, int[] T, int[] V)
        {
            double y = 0;
            double v1 = 0;
            for (int i = 0; i < N; ++i)
            {
                double V1 = V[i];
                double V2 = (i + 1) < N ? V[i + 1] : 0;
                for (int j = 0; j < T[i] * 2; ++j)
                {
                    var limits = new List<double>() { V[i] };
                    double t = T[i] - (j * 0.5 + 0.5);
                    for (int k = i + 1; k < N; ++k)
                    {
                        limits.Add(t + V[k]);
                        t += T[k];
                    }
                    limits.Add(t);
                    double v2 = Math.Min(v1 + 0.5, limits.Min());
                    y += (v1 + v2) * 0.25;
                    v1 = v2;
                }
            }
            return y;
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] T = ReadInts();
            int[] V = ReadInts();
            Console.WriteLine(Solve(N, T, V));
        }
    }
}


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

int main() {
	string s;
	cin >> s;
	int k;
	cin >> k;
	int n = s.length();
	for (int i = 0; i < n - 1; ++i) {
		if(s[i] == 'a') continue;
		if (26 - (s[i] - 'a') > k)
			continue;
		k -= 26 - (s[i] - 'a');
		s[i] = 'a';
	}
	k %= 26;
	while (k--) {
		s[n - 1] += 1;
		if (s[n - 1] == 'z' + 1)
			s[n - 1] = 'a';
	}
	cout << s;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int main(){
	LL n,ans;scanf("%lld",&n);
	int n1=sqrt(n);
	for(int i=1;i<=n1;i++){
		if(n%i==0)ans=i+n/i;
	}
	printf("%lld\n",ans-2);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[3][200009], ltr[3][200009];

long long chkmx(long long a, long long b){
	if (a >= b)
		return 1;
	else
		return 2;
}

int main()
{
	long long i, j, n, cnt=0, pos;
	string str, ans;
	cin >> str;
	n = str.size();
	dp[1][0] = 0; dp[2][0] = 0;
	for(i=1; i<=n; i++){

		if(str[i-1] == 'P'){
			dp[1][i]  =  max(dp[1][i-1], dp[2][i-1]);
			dp[2][i]  =  ltr[2][i]   = INT_MIN;
			ltr[1][i] =  chkmx(dp[1][i-1], dp[2][i-1]);
			
		}

		else if(str[i-1] == 'D'){
			dp[1][i]  =  ltr[1][i]   = INT_MIN;
			if (dp[1][i-1] > 0){
				dp[2][i]  =  max(dp[1][i-1] + 2, dp[2][i-1] + 1);
				ltr[2][i] =  chkmx(dp[1][i-1] + 2, dp[2][i-1] + 1);
			}
			else{
				dp[2][i]  =  max((long long)1, dp[2][i-1] + 1);
				ltr[2][i] =  chkmx((long long)1, dp[2][i-1] + 1);
			}
		}

		else{
			dp[1][i]  = max(dp[1][i-1], dp[2][i-1]);
			ltr[1][i] = chkmx(dp[1][i-1], dp[2][i-1]);
                        if (dp[1][i-1] > 0){
                                dp[2][i]  =  max(dp[1][i-1] + 2, dp[2][i-1] + 1);
                                ltr[2][i] =  chkmx(dp[1][i-1] + 2, dp[2][i-1] + 1);
                        }
                        else{
                                dp[2][i]  =  max((long long)1, dp[2][i-1] + 1);
                                ltr[2][i] =  chkmx((long long)1, dp[2][i-1] + 1);
                        }
		}
	}

	ans.clear();
	pos = 2;
	if(dp[1][n] >= dp[2][n])
		pos = 1;
	for(i=n; i>=1; i--){
		
		if(pos == 1)
			ans += "P";
		else
			ans += "D";
		pos = ltr[pos][i];
	}
	
	reverse(ans.begin(), ans.end());
	cout << ans << endl; 
	return 0;
}


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

int main(){
    
    int N;
    cin>>N;
    int AC, WA, TLE, RE ;
    AC = WA = TLE = RE = 0;
    // cout<<AC<<endl;
    for(int i = 0; i < N; i++){
        string s;
        cin>>s;
        if(s == "AC") AC++;
        else if(s == "WA") WA++;
        else if( s == "TLE") TLE++;
        else RE++;
    }
    cout<<"AC x "<<AC<<endl;
    cout<<"WA x "<<WA<<endl;
    cout<<"TLE x "<<TLE<<endl;
    cout<<"RE x "<<RE<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    bool f=0;
    if(a[0]==a[n-1]){
        if(a[0]==n-1)f=1;
        if(a[0]<=n/2)f=1;
    }
    else if(a[n-1]-a[0]==1){
        ll cnt=0;
        rep(i,n){
            if(a[i]==a[0])cnt++;
        }
        if(a[n-1]-cnt<=(n-cnt)/2&&a[n-1]-cnt>0)f=1;
    }
    cout<<(f?"Yes":"No")<<endl;
}

Measured memory_bytes: 1024
// -D_GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long int
// #include "../../Template.cpp"

const int mod = (1e9) + 7;

int n;
vector<vector<int>> g;
vector<pair<int, int>> dp;


void solve(int src = 1, int parent = -1) {
    dp[src].first = dp[src].second = 1;
    for(auto i:g[src]) {
        if(i != parent) {
            solve(i, src);
            dp[src].first = (dp[src].first*(dp[i].first + dp[i].second))%mod;
            dp[src].second = (dp[i].first*dp[src].second)%mod;
        }
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    g.resize(n+1);
    for(int i = 1; i < n; i ++) {
        int u, v; cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dp.assign(n+1, pair<int, int>(0, 0));
    solve();
    int ans = (dp[1].first + dp[1].second)%mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const ll MAX_M = 500001;

ll N, M;

ll modinv(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

vector<ll> mf(MAX_M, -1);
ll modfac(ll n, ll mod) {
    if (mf[n] != -1) return mf[n];
    if (n == 0) return mf[0] = 1;
    return mf[n] = n * modfac(n-1, mod) % mod; 
}

vector<ll> mif(MAX_M, -1);
ll modinvfac(ll n, ll mod) {
    if (mif[n] != -1) return mif[n];
    if (n == 0) return mif[0] = 1;
    return mif[n] = modinv(n, mod) * modinvfac(n-1, mod) % mod;
}

ll modperm(ll n, ll k, ll mod) {
    return modfac(n, mod) * modinvfac(n-k, mod) % mod;
}

ll modcomb(ll n, ll k, ll mod) {
    return modfac(n, mod) * modinvfac(k, mod) % mod * modinvfac(n-k, mod) % mod;
}

int main() {
    cin >> N >> M;
    ll ans = 0;
    for (ll i = 0; i <= N; i++) {
        if (i % 2 == 0) ans += modcomb(N, i, MOD) * modperm(M, i, MOD) % MOD * modperm(M-i, N-i, MOD) % MOD * modperm(M-i, N-i, MOD) % MOD;
        else            ans -= modcomb(N, i, MOD) * modperm(M, i, MOD) % MOD * modperm(M-i, N-i, MOD) % MOD * modperm(M-i, N-i, MOD) % MOD;
        ans %= MOD;
    }
    if (ans < 0) ans += MOD;
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 26668
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
	int N; cin>>N;
	vector<vector<int>> A(2,vector<int>(N));
	for(int i=0;i<2;i++){
		for(int j=0;j<N;j++){
			cin>>A[i][j];
		}
	}
	int ans=0;
	for(int i=0;i<N;i++){
		int tmp=0;
		for(int j=0;j<N;j++){
			if(j<i)tmp+=A[0][j];
			else if(i==j){
				tmp+=A[1][j];
				tmp+=A[0][j];
			}
			else tmp+=A[1][j];
		}
		ans=max(ans,tmp);
	}
	cout<<ans<<endl;
}

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

S = input()

s = ''
base = ('A', 'C', 'G', 'T')
max_len = 0

for c in S:
    if c not in base:
        s = ''
        continue

    s += c

    current_len = len(s)
    if max_len < current_len:
        max_len = current_len

print(max_len)


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

int main() {
    int32_t n;
    string s;
    cin >> n >> s;

    int32_t i;

    int32_t c = 0;
    for (i = 1; i < n; i++) {
        if (s.at(i) == 'E') {
            c++;
        }
    }
    int32_t min = c;
    for (i = 1; i < n; i++) {
        if (s.at(i) == 'E') {
            c--;
        }
        if (s.at(i - 1) == 'W') {
            c++;
        }
        if (c < min) {
            min = c;
        }
    }

    cout << min << endl;
    return 0;
}


Measured memory_bytes: 900
S = input()

former = int(S[0:2])
after = int(S[2:4])


if (13 <= former or former == 0)and 1 <= after <= 12:
    print("YYMM")
elif 1 <= former <= 12 and (13 <= after or after == 0):
    print("MMYY")
elif 1 <= former <= 12 and 1 <= after <= 12:
    print("AMBIGUOUS")
else:
    print("NA")

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

typedef unsigned long long ULL;
typedef long long LL;

const int PI = 3.1415926535;
const int inf = 1000111222;
const int mod = 1000000007;
const int N = 100007;


int main() {
	
	ios_base :: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	string str; cin >> str;
	int cnt = 0;
	int ans = 0;
	for (int i = 0; i < (int)str.length(); i++) {
		if (str[i] == 'R') {
			cnt++;
		}
		else {
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	ans = max(ans, cnt);
	cout << ans << endl;
	return 0;
}


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

void init();

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

int bit[10][10];
vector<int> y, x;

string s;

int main(){
  
  init();
    
  while(1){

    cin>>s;
    if(s=="#") break;

    bool ans=true;
    
    for(int i=0;i<(1<<19);i++){
      
      for(int j=0;j<19;j++){
	
	if(i&(1<<j)) bit[y[j]][x[j]] = 1;
	else bit[y[j]][x[j]] = 0;
	
      }
      
      int bit2[10][10];
      
      for(int j=0;j<7;j++){

	int sum=0;
	  
	for(int k=0;k<7;k++) sum = sum * 2 + bit[y[j] + dy[k]][x[j]+dx[k]];
	
	bit2[y[j]][x[j]] = s[sum] - '0';

      }

      int sum=0;
      
      for(int k=0;k<7;k++) sum = sum * 2 + bit2[y[0]+dy[k]][x[0]+dx[k]];
      
      if(s[sum] - '0' != bit2[y[0]][x[0]]) ans=false;
      
    }
    
    if(ans) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
    
  }
  
  return 0;
}


void init(){

  y.push_back(5); x.push_back(5);
  y.push_back(6); x.push_back(5);
  y.push_back(5); x.push_back(6);
  y.push_back(4); x.push_back(6);
  y.push_back(4); x.push_back(5);
  y.push_back(5); x.push_back(4);
  y.push_back(6); x.push_back(4);
  y.push_back(7); x.push_back(5);
  y.push_back(6); x.push_back(6);
  y.push_back(5); x.push_back(7);
  y.push_back(4); x.push_back(7);
  y.push_back(3); x.push_back(7);
  y.push_back(3); x.push_back(6);
  y.push_back(3); x.push_back(5);
  y.push_back(4); x.push_back(4);
  y.push_back(5); x.push_back(3);
  y.push_back(6); x.push_back(3);
  y.push_back(7); x.push_back(3);
  y.push_back(7); x.push_back(4);

}

Measured memory_bytes: 3108
from collections import defaultdict

def main():
    num, k = map(int, input().split())
    data = defaultdict(int)
    for i in range(k):
        a, b = map(int, input().split())
        data[a] += 1
        data[b] += 1

    for i in range(1, num + 1):
        print(data[i])

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char c;
    
    cin >> c;
    
    if(c == 'a') {
        cout << "vowel" << endl;
    }else if(c == 'i') {
        cout << "vowel" << endl;
    }else if(c == 'u') {
        cout << "vowel" << endl;
    }else if(c == 'e') {
        cout << "vowel" << endl;
    }else if(c == 'o') {
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int a, b, c, k; cin >> a >> b >> c >> k;
    ll ans = 0;
    ans = min(a, k);
    k -= min(a, k);
    k -= min(b, k);
    ans -= min(c, k);
    cout << ans << endl;
    return 0;
}

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


map<int, int> res;

int get_num (int n) {
    int cnt = 0;
    for (auto r: res) {
        if (r.second >= n) cnt++;
    }
    return cnt;
};


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

    int n;
    cin >> n;

    for (int j = 2; j <= n; ++j) {
        int k = j;
        for (int i = 2; i * i <= k; ++i) {
            if (k % i != 0) continue;
            while (k % i == 0) {
                ++res[i];
                k /= i;
            }
        }
        if (k != 1) res[k]++;
    }

    int total =
            get_num(74) +
            get_num(24) * (get_num(2) - 1) +
            get_num(14) * (get_num(4) - 1) +
            get_num(4) * (get_num(4) - 1) / 2 * (get_num(2) - 2);
    
    cout << total << '\n';

    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split.map(&:to_i)

s = []
a.length.times do |i|
  s << [i+1, a[i]]
end

s.sort_by!{|x| x[1]}

(n-1).times do |j|
  print "#{s[j][0]} "
end
print "#{s[-1][0]}"

Measured memory_bytes: 20368
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#define MOD 1000000007

using namespace std;

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


Measured memory_bytes: 256
LI = lambda: list(map(int, input().split()))

A, B, C = LI()
K = int(input())


def main():
    l = [A, B, C]
    l.sort()
    l[-1] *= 2 ** K
    ans = sum(l)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 8916
import itertools
import math 
def C(n,r):
    if n-r < 0:
        return 0 
    return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

n = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
    d[i] = d.get(i, 0)+1

c = 0
cc = {}
for key, val in d.items():
    temp = C(val,2)
    c += temp
    if cc.get(key) is None:
        cc[key] = temp - C(val-1,2)
for i in a:
    print(c - cc[i])


Measured memory_bytes: 119636
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll ans(n,0LL);
    REP(i,n-1){
        ll a;
        cin >> a;
        a--;
        ans[a]++;
    }
    REP(i,n){
        cout << ans[i] << endl;
    }

    return 0;
}

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

#define MAX_N 10

int N;
int L[MAX_N];

int main() {
    cin >> N;
    rep(i, N) {
        cin >> L[i];
    }

    sort(L, L + N);
    int max = L[N - 1];
    L[N - 1] = 0;

    int other = accumulate(L, L + N, 0);

    if (max < other) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> L, R;
    for (int i = 0; i < M; i++) {
        int temp_l, temp_r;
        scanf("%d %d", &temp_l, &temp_r);
        L.push_back(temp_l);
        R.push_back(temp_r);
    }

    int max_L, min_R;
    max_L = -1;
    min_R = N + 1;


    for (int i = 0; i < M; i++) {
        max_L = max(max_L, L[i]);
        min_R = min(min_R, R[i]);
    }
    cout << (min_R - max_L + 1 > 0 ? min_R - max_L + 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 1276
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < (int)n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

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

string S;
int main() {
	cin >> S;
	LL sum = 0;
	REP(i, 0, 26) {
		char a = 'a' + i;
		LL count = 0;
		REP(i, 0, S.size()) {
			if (S[i] == a) {
				++count;
			}
		}
		sum += count * (count + 1) / 2;
	}
	cout << S.size() * (S.size() + 1) / 2 + 1 - sum << endl;
	return 0;
}

Measured memory_bytes: 640
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
using namespace std;

inline int getint()
{
	int x = 0, c = getchar();
	while (c > 47 && c < 58)
	{
		x = x * 10 + c - 48;
		c = getchar();
	}
	return x;
}

constexpr int MAX = 300000;
int res[MAX * 4];

int main()
{
	int H = getint();
	int W = getint();
	int M = getint();

	int h, w, ans;
	int mxr = 0;
	int mxc = 0;
	int ctrow = 0;
	int ctcol = 0;
	for (int i = 0; i < M; ++i)
	{
		h = getint(), w = getint();
		--h, --w;
		res[i + 2 * MAX] = h, res[i + 3 * MAX] = w;
		int x = ++res[h], y = ++res[w + MAX];

		if (x == mxr) ++ctrow;
		else if (x > mxr) mxr = x, ctrow = 1;

		if (y == mxc) ++ctcol;
		else if (y > mxc) mxc = y, ctcol = 1;
	}
	ans = mxr + mxc;

	long ct = ctrow;
	ct *= ctcol;
	if (ct > M)
	{
		printf("%d\n", ans);
		return 0;
	}

	for (int i = 0; i < M; ++i)
		if (res[res[i + 2 * MAX]] == mxr && res[res[i + 3 * MAX] + MAX] == mxc)
			--ct;
	if (ct <= 0)
		--ans;
	printf("%d\n", ans);
}


Measured memory_bytes: 6276