akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

using Pair = pair<ll, ll>;

signed main() {
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  vector<Pair> t(n);
  REP(i, n) {
    ll x, y;
    cin >> x >> y;
    t.emplace_back(x, y);
  }
  sort(all(t), [](Pair a, Pair b){return a.second > b.second;});
  ll ans = 0;
  map<ll, ll> a;
  REP(i, k) {
    if(a.count(t[i].first)) {
      a[t[i].first]++;
    }
    else {
      a[t[i].first] = 1;
    }
    ans += t[i].second;
  }
  ll tmp = ans;
  ans += (ll)(a.size() * a.size());
  int i = k - 1;
  int j = k;
  while(j < n && 0 <= i) {
    while(j < n && a.count(t[j].first) != 0) j++;
    while(0 <= i && a[(t[i].first)] < 2)  i--;
    if(j < n && 0 <= i) {
      tmp = tmp + t[j].second - t[i].second;
      a[t[j].first] = 1;
      a[t[i].first]--;
      i--;
      ans = max(ans, (ll) (tmp + a.size() * a.size()));
    } 
    else {
      break;
    }
  }
  cout << ans << endl;
  return 0; 
}


Measured memory_bytes: 7396
import java.util.Arrays;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.Collections;

class Main{
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		HashMap<Integer, Integer> map1 = new HashMap<Integer, Integer>();
		while(true){
			String str = sc.nextLine();
			if(str.equals("")){
				break;
			}
			
			String[] ss = str.split(",");
			int num = Integer.parseInt(ss[0]);
			if(map1.containsKey(num)){
				map1.put(num, map1.get(num)+1);
			}else{
				map1.put(num, 1);
			}
		}
		
		HashMap<Integer, Integer> map2 = new HashMap<Integer, Integer>();
		while(sc.hasNext()){
			String str = sc.next();
			if(str.equals("")){
				break;
			}
			
			String[] ss = str.split(",");
			int num = Integer.parseInt(ss[0]);
			if(map2.containsKey(num)){
				map2.put(num, map2.get(num)+1);
			}else{
				map2.put(num, 1);
			}
		}
		
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(Iterator ite = map1.keySet().iterator(); ite.hasNext(); ){
			int num = (Integer)ite.next();
			if(map2.containsKey(num)){
				list.add(num);
			}
		}
		Collections.sort(list);
		
		for(int i=0; i<list.size(); ++i){
			int num = list.get(i);
			System.out.println(num + " " + (map1.get(num) + map2.get(num)));
		}
	}
	
	public static void main(String[] args){
		new Main().solve();
	}
	
	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
#include<set>
//#include<map>
//#include<list>

using namespace std;

class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int main(void) {
	int N, M, K, a;
	int res = 0;
	vector<int>vec;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> K;
		for (int j = 0; j < K; j++) {
			cin >> a;
			vec.push_back(a);
		}
	}
	for (int i = 1; i <= M; i++) {
		if (count(vec.begin(), vec.end(), i) == N) {
			res++;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
ll cost(ll n,ll m){
    ll s = abs(n - m);
    return s * s;
}
int main() {
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> num(N);
    rep(i,N){
        cin >> num[i];
    }
    if((N - 1) % (M - 1) == 0){
    cout << (N - 1) / (M - 1) << endl;
    }
    else cout << (N - 1) / (M - 1) + 1 << endl;
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int n,k;
void in(){
    cin >> n >> k;
}

void solve(){

    print(n - k + 1);

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define MP make_pair
#define PB push_back
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int INF = 1e9 + 7;
const int maxn = 1e5 + 5;

int n, m;
ll f[maxn], g[maxn];
vector<int> nei[maxn];

inline void calcF(int u, int p){
	f[u] = 1;
	FOR(i, 0, nei[u].size()){
		int v = nei[u][i];
		if(v == p)
			continue;
		calcF(v, u);
		(f[u] *= (1 + f[v])) %= m;
	}
	return;
}

inline void calcG(int u, int p){
	if(!~p)
		g[u] = 1;
	ll pro = 1;
	FOR(i, 0, nei[u].size()){
		int v = nei[u][i];
		if(v == p)
			continue;
		g[v] = 1;
		(g[v] *= g[u]) %= m;
		(g[v] *= pro) %= m;
		(pro *= (1 + f[v])) %= m;
	}
	pro = 1;
	for(int i = nei[u].size() - 1; i >= 0; --i){
		int v = nei[u][i];
		if(v == p)
			continue;
		(g[v] *= pro) %= m;
		(pro *= (1 + f[v])) %= m;
	}
	FOR(i, 0, nei[u].size()){
		int v = nei[u][i];
		if(v == p)
			continue;
		(++g[v]) %= INF;
		calcG(v, u);
	}
	return;
}

int main(){
	scanf("%d%d", &n, &m);
	FOR(i, 1, n){
		int u, v;
		scanf("%d%d", &u, &v);
		--u; --v;
		nei[u].PB(v);
		nei[v].PB(u);
	}
	calcF(0, -1);
	calcG(0, -1);
	FOR(u, 0, n)
		printf("%lld\n", f[u] * g[u] % m);
	return 0;
}


Measured memory_bytes: 11008
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


def gcd_ab(a,b):
  a,b = sorted([a,b])
  if a == 0:
    return b
  return gcd_ab(b%a, a)

if __name__ == "__main__": 
  N = int(input())
  An = list(map(int, sys.stdin.readline().rstrip().split()))
  cum = [[0,0] for i in range(N+2)]

  for i in range(N):
    cum[i+1][0] = gcd_ab(cum[i][0], An[i])
    cum[N-i][1] = gcd_ab(cum[N-i+1][1], An[N-i-1])

  ans = [0 for i in range(N)]
  for i in range(1,N+1):
    ans[i-1] = gcd_ab(cum[i-1][0], cum[i+1][1])
  print(max(ans))



Measured memory_bytes: 18532
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int[] scInt = new int[3];
		scInt[0] = a;
		scInt[1] = b;
		scInt[2] = c;

		Arrays.sort(scInt);

		// 出力
		System.out.println(scInt[0] + scInt[1]);

		sc.close();
	}
}

Measured memory_bytes: 21844
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=505;
int line[N][N];
pair<int, int>p[200], v[200];
int girl[N],used[N];
int k,m,n;
bool found(int x)
{
    for(int i=1; i<=n; i++)
    {
        if(line[x][i]&&!used[i])
        {
            used[i]=1;
            if(girl[i]==0||found(girl[i]))
            {
                girl[i]=x;
                return 1;
            }
        }
    }
    return 0;
}
int main()
{
        scanf("%d", &n);
        memset(line,0,sizeof(line));
        memset(girl,0,sizeof(girl));
        for(int i = 1; i <= n; i++){
            scanf("%d%d", &p[i].first, &p[i].second);
        }
        for(int i = 1; i <= n; i++){
            scanf("%d%d", &v[i].first, &v[i].second);
            for(int j = 1; j <= n; j++){
                if(v[i].first > p[j].first && v[i].second > p[j].second){
                    line[i][j] = 1;
                }
            }
        }
        int sum=0;
        for(int i=1; i<=n; i++)
        {
            memset(used,0,sizeof(used));
            if(found(i)) sum++;
        }
        printf("%d\n",sum);

}

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

int main() {
    int n; cin >> n;
    vector<int> l(n);
    for (int &li: l) cin >> li;
    sort(l.begin(), l.end());
    int ans = 0;
    for (int c = 0; c < n; c++) for (int b = 0; b < c; b++) {
        int left = upper_bound(begin(l), end(l), l[c] - l[b]) - begin(l);
        ans += max(0, b - left);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define fill(a,val) memset(a,val,sizeof(a))
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first

#define M 315
using namespace std;
 

int main()
{
    std::ios::sync_with_stdio(false);
    int T = 1;
    //cin>>T;
    while(T--)
    {
       int x,n;
       cin>>x>>n;
       vector<int> a(n);
       for(int i = 0;i<n;i++)
       {
            cin>>a[i];
       }
       sort(a.begin(),a.end());
       int j = 0;
       int mini = 300;
       int ans = -1;
       for(int i = 0;i<=101;i++)
       {
            if(j < n)
            {
                if(i!=a[j])
                {
                    if(abs(i-x) < mini)
                    {
                        mini = abs(i-x);
                        ans = i;
                    }
                }
                else
                    j++;
            }
            else
            {
                    if(abs(i-x) < mini)
                    {
                        mini = abs(i-x);
                        ans = i;
                    }
            }
       }
       cout<<ans<<endl;
    }   
    
    return 0;
}


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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define INF LLONG_MAX

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  
  if(2*c>a+b){
    cout << a*x+b*y << endl;
    return 0;
  }
  else{
    ll price = 0;
    int common = min(x,y);
    price = common*c*2;
    
    if(2*c<a){
      price += c*(x-common)*2;
    }
    else{
      price += a*(x-common);
    }
    if(2*c<b){
      price += c*(y-common)*2;
    }
    else{
      price += b*(y-common);
    }
    cout << price << endl;
  }
  
  return 0;
}



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

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  
  int taka=A;
  int ao=C;
  
  bool takakati =false;

  
  for(int i=0;i<1000;i++){
  if(ao-B>0){
    	ao -=B;
    }
    else {
    	takakati=true;
      	break;
    }
    
    if(taka-D>0){
    	taka -=D;
      
    }
    else{
      	break;
    }
  }
  
  if(takakati){
  	cout<<"Yes"<<endl;
  }
  
  else{
  	cout<<"No"<<endl;
  }

 
    

  

}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
using P = pair<int, int>;

int main(){
  int n, m;
  cin >> n >> m;
  vector<P> p(m);
  rep(i,m) cin >> p[i].first >> p[i].second;
  rep(x, 1000){
    int keta = 1;
    int nx = x / 10;
    vector<int> d(1,x%10);
    while (nx){
      keta++;
      d.push_back(nx%10);
      nx /= 10;
    }
    if (keta != n) continue; //keta!=nとは桁数がnとは異なるということ
    bool ok = true;
    reverse(d.begin(),d.end());
    rep(i, m){
      if (d[p[i].first-1] != p[i].second) ok=false;
    }
    if (ok){
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
<?php
//error_reporting(0);
list($N,$Q) =  explode(" ",trim(fgets(STDIN)));
$S = trim(fgets(STDIN));
$len = strlen($S);
$v = array_fill(0,$len+1,0);
for($i=0;$i<$len-1;$i++) {
  $v[$i+1]=$v[$i];
  if ($S[$i]=='A' && $S[$i+1]=='C') {
    $v[$i+1]++;
  }
}
//$B = explode(" ",trim(fgets(STDIN)));
for($i=0;$i<$Q;$i++) {
  list($l,$r) =  explode(" ",trim(fgets(STDIN)));
  printf("%d\n",$v[$r-1]-$v[$l-1]);
}


Measured memory_bytes: 9336
// AOJ 2239 Nearest Station
// 2018.4.7 bal4u

#include <stdio.h>
#include <stdlib.h>

#define ABS(a)  ((a)>=0?(a):-(a))

long long d[50]; int sz;
char f[50];

int cmp(long long *a, long long *b)
{
	if (*a == *b) return 0;
	if (*a < *b) return -1;
	return 1;
}

// 見つからなければ、一つ小さい要素を返す
int binarySearch(long long x)
{
	int m, l = 1, r = sz;

    while (l < r) {
        m = (l+r) >> 1;
		if (d[m] == x) return m;
        if (d[m] < x) l = m + 1; else r = m;
    }
	return l-1;
}

int main()
{
	int  i, j;
	long long n, m, a, b, p, q;
	long long g, s, t, pa, pb, ans;

	scanf("%lld%lld%lld%lld%lld%lld", &n, &m, &a, &b, &p, &q);
	if (a == 1 && b == 1) {
		s = p + q, t = m/s;
		if (t > n) t = n;
		ans = ABS(m - t*s);
		if (t < n) {
			if (++t > n) t = n;
			t = ABS(m - t*s);
			if (ans > t) ans = t;
		}
	} else {
		sz = 0, pa = pb = 1;
		for (i = 0; i < n; i++) {
			d[sz++] = s = p*pa + q*pb;
			if (s > m) break;
			if (s == m) { ans = 0; goto done; }
			pa *= a, pb *= b;
		}
		qsort(d, sz, sizeof(long long), cmp);

		ans = g = m, s = 0;
		while (sz) {
			i = binarySearch(g);
			t = ABS(d[i]-g);
			if (t < ans) {
				ans = t;
				if (!ans) goto done;
			}

			j = i+1; while (j < sz && d[j] == d[i]) j++;
			if (j < sz) {
				t = ABS(d[j]-g);
				if (t < ans) ans = t;
			}
			s += d[i], g = ABS(m-s);
			while (++i < sz) d[i-1] = d[i];
			sz--;
		}
	}
done:
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2136
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()

def c(x):
    cnt = 0
    while x%2==0:
        cnt += 1
        x //= 2
    return cnt
mi = 0
for i in range(n):
    mi += c(a[i])
print(mi)

Measured memory_bytes: 67688
sx, sy, tx, ty = gets.split.map(&:to_i)
w = tx - sx
h = ty - sy
ans = 'U' * h + 'R' * w
ans += 'D' * h + 'L' * w
ans += 'L' + 'U' * (h + 1) + 'R' * (w + 1) + 'D'
ans += 'R' + 'D' * (h + 1) + 'L' * (w + 1) + 'U'
puts ans


Measured memory_bytes: 1916
import sys
a = []
for l in sys.stdin:
    a.append(l)

cnt = 0
for i in range(int(a[0].split(" ")[0])):
  x = int(a[i+1].split(" ")[0])
  y = int(a[i+1].split(" ")[1])
  d = x*x + y*y
  D = int(a[0].split(" ")[1])*int(a[0].split(" ")[1])
  if d <= D:
    cnt = cnt + 1

print(cnt)

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

const ll w_max = 100005;
const ll n_max = 105;

ll dp[w_max][n_max];

int main(){
  ll N,W;
  cin >> N >> W;
  
  vector<ll> v(N+1);
  vector<ll> w(N+1);
  
  for(ll i=1; i<=N; i++) cin >> w[i] >> v[i];
  
  for(ll i=0; i<=W; i++) dp[i][0] = 0;
  for(ll i=0; i<=N; i++) dp[0][i] = 0;
    
  for(ll i=1; i<=W; i++){
    for(ll j=1; j<=N; j++){
      if(i >= w[j]){
        dp[i][j] = max(dp[i-w[j]][j-1] + v[j], dp[i][j-1]);
      }else
        dp[i][j] = dp[i][j-1];
    }
  }
  
    cout << dp[W][N] << endl;
}

Measured memory_bytes: 82304
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  int N, K, C;
  scanf("%d", &N);
  scanf("%d", &K);
  scanf("%d", &C);
  std::string S;
  std::cin >> S;
  std::vector<int > left(N+4, 0); // i番目未満に何個おけるか
  std::vector<int > right(N+4, 0); // i番目以上に何個おけるか
  std::vector<int > leftindex(N+4, 0); // i番目未満のもっとも大きいインデックス
  std::vector<int > rightindex(N+4, 0); // i番目以上のもっとも大きいインデックス
  
  left[0]=0;
  leftindex[0]=-100000;
  int i=1;
  while (i<=N){
    if (S[i-1]=='o'){
      left[i]=left[i-1]+1;
      leftindex[i]=i-1;
      // left[i+1]~left[i+C]までを詰める
      for (int j=1;j<=C; j++){
        if (i+j>N) continue;
        left[i+j]=left[i];
        leftindex[i+j]=leftindex[i];
      }
      i+=C+1;
    } else {
      left[i]=left[i-1];
      leftindex[i]=leftindex[i-1];
      i++;
    }
  }

  right[N]=0;
  rightindex[N]=10000000;
  i=N-1;
  while (i>=0){
    if (S[i]=='o'){
      right[i]=right[i+1]+1;
      rightindex[i]=i;
      // right[i-1]~left[i-C]までを詰める
      for (int j=1;j<=C; j++){
        if (i-j<0) continue;
        right[i-j]=right[i];
        rightindex[i-j]=rightindex[i];
      }
      i-=C+1;
    } else {
      right[i]=right[i+1];
      rightindex[i]=rightindex[i+1];
      i--;
    }
  }

  /*for (int i=0; i<=N; i++){
    printf("left[%d]=%d\n", i, left[i]);
    printf("leftindex[%d]=%d\n", i, leftindex[i]);
  }
  for (int i=0; i<=N; i++){
    printf("right[%d]=%d\n", i, right[i]);
    printf("rightindex[%d]=%d\n", i, rightindex[i]);
    }*/

  for (int i=0; i<N; i++){
    if (S[i]=='x') continue;
    //printf("i=%d, (%d, %d)\n", i, left[i], right[i+1]);
    int count = left[i] + right[i+1];
    if (rightindex[i+1]-leftindex[i]<=C) {
      //printf("i--\n");
      count--;
    }
    if (count<K) printf("%d\n", i+1);
  }
  return 0;
}


Measured memory_bytes: 4988
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int array[3];
	for(int i = 0; i < 3; i++) scanf("%d",&array[i]);
	for(int i = 2; i > 0; i--){
		for(int j = 0; j < i; j++){
			if(array[j] > array[j+1])swap(array[j],array[j+1]);
		}
	}
	printf("%d %d %d\n",array[0],array[1],array[2]);
}


Measured memory_bytes: 2760
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long res = 0;
        long[] P = new long[n];
        long[] A = new long[n];
        Map<Long, Long> M = new HashMap<>();
        for(int i = 0; i < n; i++) {
            A[i] = Integer.parseInt(sc.next());
            P[i] = A[i] + i + 1;
            if(M.containsKey(i + 1 - A[i])) M.put(i + 1 - A[i], M.get(i + 1 - A[i]) + 1);
            else M.put(i + 1 - A[i], 1L);
        }
        for(int i = 0; i < n; i++) {
            if(M.containsKey(P[i])) {
                res += M.get(P[i]);
                if(P[i] == i + 1 - A[i]) res--;
            }
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 75524
#include <stdio.h>

int main(void) {
  char S[5];
  scanf("%s", S);
  int flag = 0;
  int i;
  for (i = 0; i < 3; i++) {
    if (S[i] == S[i + 1]) {
      flag++;
    }
  }

  if(flag == 0){
    printf("Good\n");
  } else {
    printf("Bad\n");
  }
 
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <climits>
#include <vector>
using namespace  std;

void fnInput(vector<int>& rvnMtrx)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  rvnMtrx.resize(nMaxSiz + 1);

  for (int i = 0; i < nMaxSiz; ++i)
    cin >> rvnMtrx[i] >> rvnMtrx[i + 1];
}

int fnMtrxChainMultpl(vector<vector<int>>& rvvnDetDP, const vector<int>& cnrvnMtrx)
{
  const int nMAXSIZ = cnrvnMtrx.size() - 1;
  for (int i = 1; i < cnrvnMtrx.size(); ++i)  rvvnDetDP[i][i] = 0;

  for (int nDif = 1; nDif <= nMAXSIZ - 1; ++nDif)
    for (int nRow = 1; nRow <= nMAXSIZ - nDif; ++nRow)
    {
      int nCol = nRow + nDif;
      for (int nx = nRow; nx <= nCol - 1; ++nx)
        rvvnDetDP[nRow][nCol] =
          min(rvvnDetDP[nRow][nCol],
              rvvnDetDP[nRow][nx] + rvvnDetDP[nx + 1][nCol] 
                                  + cnrvnMtrx[nRow - 1] * cnrvnMtrx[nx] * cnrvnMtrx[nCol]);
    }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int>> vvnDetDP; 
  vector<int> vnMtrx;

  fnInput(vnMtrx);
  vvnDetDP.resize(vnMtrx.size(), vector<int>(vnMtrx.size(), INT_MAX));

  fnMtrxChainMultpl(vvnDetDP, vnMtrx);
  cout << vvnDetDP[1][vnMtrx.size() - 1] << endl;
  return 0;
}

Measured memory_bytes: 3228
H, W = map(int, input().split())
C = [[i for i in input()] for _ in range(H)]

C2 = [[''] * W for i in range(H * 2)]

for i in range(H) :
    for j in range(W) :
        i2 = i * 2
        C2[i2][j] = C2[i2+1][j] = C[i][j]
        
for i in range(H * 2) :
    print(''.join(C2[i]))

Measured memory_bytes: 39536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll x;
int main(){
	x=read();
	for(int i=1;i<1000;i++)
		if(x*i%360==0){
			cout << i;
			break;
		}
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n;
long long ans=1;
long long ch(long long x)
{
	return ans/__gcd(ans,x)*x;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		long long x;
		cin>>x;
		ans=ch(x);
	}
	cout<<ans<<endl;
	return 0;
}

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


int main() {
	
	int N;
	cin >>N;
	
	vector<int> vec(N);
	for(int i=0; i<N; i++){
		
		cin >>vec.at(i);
		
	}
	
	sort(vec.begin(),vec.end());
	
	int total=0;
	
	for(int x:vec){
		
		total+=x;
		
	}
	
	
	cout <<total-vec.at(N-1)/2 <<endl;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int x,y;
        cin>>x>>y;
        if(x==0 && y==0){
            return 0;
        }
        cout<<min(x,y)<<" "<<max(x,y)<<endl;
    }
}


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

#define cnd(c, a, b) (c ? a : b);
#define fl(x,y,z) for(int x=y;x<z;x++)
#define fe(x,y,z) for(int x=y;x<=z;x++)
#define fge(x,y,z) for(int x=y;x>=z;x--)

#define debug(x) std::cerr << #x << " --> " << x << "\n";
#define fastIO std::ios_base::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define pb push_back
#define pob pop_back
 
#define ln '\n'
typedef long long int ll;

ll mod=1e9+7;

ll mod_pow(ll a, ll b) {
	ll ans = 1;
	while(b>0) {
		if(b%2) {
			ans = ((ans%mod)*(a%mod))%mod;
		}
		a = ((a%mod)*(a%mod))%mod;
		b /= 2;
	}
	return ans;
}

void decrypt() {
	ll n;
	cin>>n;
	if(n<=2) {
		if(n==1) {
			cout<<"0"<<ln;
		} else {
			cout<<"2"<<ln;
		}
	} else {
		ll ans = (mod_pow(10, n)- 2*mod_pow(9, n) + mod_pow(8, n))%mod;
		cout<<(ans+mod)%mod<<ln;
	}
	return;
}

int main() {
    fastIO
    int t = 1;
    // cin >> t;
    fl(i,0,t) {
    	// cout << "Case #"<< i+1 <<": ";
    	decrypt();
    }
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

char s[20];
int n;

int main() {
	scanf("%s",s+1);n=strlen(s+1);
	if(n%2!=0) cout<<"No";
	else {
		bool fl=1;
		for(int i=1;i<=n;i+=2) {
			if(s[i]!='h') fl=0;
			if(s[i+1]!='i') fl=0;
		}
		cout<<(fl?"Yes\n":"No\n");
	}
	return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int> b(n);
    for(int i=0;i<n;i++) cin>>b[i],b[i]--;
    vector<int> ans;
    for(int i=0;i<n;i++){
        bool isok=false;
        for(int j=n-i-1;j>=0;j--){
            if(b[j]==j){
                b.erase(b.begin()+j);
                ans.push_back(j);
                isok=true;
                break;
            }
        }
        if(!isok){
            cout<<-1<<endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++){
        cout<<ans[n-i-1]+1<<endl;
    }
    return 0;
}

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

int main(){
  int d,t,s;
  cin >> d >> t>> s;
  if(d<=t*s) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3608
const main = (lines: string) => {
  const data = lines.split(" ");
  const stoneLength = parseInt(data[0], 10);
  const stoneCoord = parseInt(data[1], 10);
  let stoneCoords = [stoneCoord];

  for (let i = 1; i < stoneLength; i++) {
    stoneCoords.push(stoneCoord - i);
    stoneCoords.push(stoneCoord + i);
  }

  let result = stoneCoords.sort(conmpareFunc).join(" ");

  console.log(result);
};

const conmpareFunc = (a: number, b: number) => {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
// May this submission get accepted
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll h = inp1;
    ll w = inp1;
    ll n = inp1;

    cout << min((n+h-1)/h, (n+w-1)/w) << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

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

    cout << (1900*m+100*(n-m)) * pow(2,m) << endl;

    
}

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

int main() {
  int N, L; cin >> N >> L;
  string ans = "";
  vector<string> s(N);
  rep(i, N) {
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  rep(i, N) {
    ans += s[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] x = new int[n];
		for(int i = 0; i < n; i++)
			x[i] = sc.nextInt();
		int answer = 1000000000;
		int[] distance = new int[n-k+1];
		for(int i = 0; i < n-k+1; i++) {
			distance[i] = Math.abs(x[i+k-1]-x[i]);
			distance[i] += Math.min(Math.abs(x[i+k-1]), Math.abs(x[i]));
		}
		for(int i = 0; i < n-k+1; i++)
			answer = Math.min(answer, distance[i]);
		System.out.println(answer);
	}

}

Measured memory_bytes: 52016
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
ll test[12345678];
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
const ll MAX_N = 1 << 17;
ll nn, dat[2 * MAX_N - 1]; //セグメント木を持つグローバル配列
void init(ll n_) { //初期化
	nn = 1; //簡単のため、要素数を2のべき乗に
	while (nn < n_)nn *= 2;
	//全ての値をINT_MAXに
	for (int i = 0; i < 2 * nn - 1; i++) dat[i] = INT_MAX;
}
void update(ll k, ll a) { //k番目の値(0-indexed)をaに変更
	k += nn - 1; dat[k] = a; //葉の節点
	while (k > 0) { //登りながら更新
		k = (k - 1) / 2;
		if (dat[k * 2 + 2] == INT_MAX) { dat[k] = dat[k * 2 + 1]; }
		else if (dat[k * 2 + 1] == INT_MAX) { dat[k] = dat[k * 2 + 2]; }
		else { dat[k] = gcd(dat[k * 2 + 1], dat[k * 2 + 2]); }
	}
}
//[a, b)の最小値を求める
//kは節点の番号、l, rはその節点が[l, r)に対応づいていることを表す。
//したがって外からはquery(a, b, 0, 0, nn)として呼ぶ。
ll query(ll a, ll b, ll k, ll l, ll r) {
	if (r <= a || b <= l) { return INT_MAX; }
	if (a <= l && r <= b) { return dat[k]; }
	else {
		int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		if (vr == INT_MAX) { return vl; }
		if (vl == INT_MAX) { return vr; }
		return gcd(vl, vr);
	}
}
signed main() {
	ll n, m = 0; cin >> n; init(n);
	for (int h = 0; h < n; h++) {
		cin >> test[h]; update(h, test[h]);
	}
	//cout << query(1, 2, 0, 0, nn) << endl;
	for (int h = 0; h < n; h++) {
		if (h == 0) { m = query(h + 1, n, 0, 0, nn); continue; }
		if (h == n - 1) { m = max(m, query(0, h, 0, 0, nn)); }
		m = max(m, gcd(query(0, h, 0, 0, nn), query(h + 1, n, 0, 0, nn)));
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MAXN 200000

int main() {
    int N, suffixMinB[MAXN + 3];
    pair<int, int> ranges[MAXN + 3];

    scanf("%d", &N);
    for (int i = 1; i <= N; i++)
        scanf("%d%d", &ranges[i].first, &ranges[i].second);

    sort(ranges + 1, ranges + N + 1);

    suffixMinB[N] = ranges[N].second;
    for (int i = N - 1; i >= 1; i--)
        suffixMinB[i] = min(ranges[i].second, suffixMinB[i + 1]);

    if (N%2 == 1) {
        int smallest = ranges[(N + 1)/2].first;

        int lo = smallest, hi = INF, mid;

        while (hi >= lo) {
            mid = (lo + hi)/2;

            int smaller = 0;
            for (int i = 1; i <= N; i++) {
                if (ranges[i].second < mid)
                    smaller += 1;
            }

            if (smaller > (N + 1)/2 - 1)
                hi = mid - 1;
            else
                lo = mid + 1;
        }

        int largest = hi;

        printf("%d\n", largest - smallest + 1);
    } else {
        int l1 = ranges[N/2].first;
        int l2 = ranges[N/2 + 1].first;

        int lo, hi, mid;

        lo = l1;
        hi = INF;
        while (hi >= lo) {
            mid = (lo + hi)/2;

            int smaller = 0;
            for (int i = 1; i <= N; i++) {
                if (ranges[i].second < mid)
                    smaller += 1;
            }

            if (smaller > N/2 - 1)
                hi = mid - 1;
            else
                lo = mid + 1;
        }

        int r1 = hi;

        lo = l2;
        hi = INF;
        while (hi >= lo) {
            mid = (lo + hi)/2;

            int smaller = 0;
            for (int i = 1; i <= N; i++) {
                if (ranges[i].second < mid)
                    smaller += 1;
            }

            if (smaller > N/2)
                hi = mid - 1;
            else
                lo = mid + 1;
        }

        int r2 = hi;

        printf("%d\n", (r1 + r2) - (l1 + l2) + 1);
    }
}


Measured memory_bytes: 5400
#include <iostream>

using namespace std;

int main(){
    int K, S, count = 0;
    cin >> K >> S;
    for(int x = 0; x <= K; x++){
        for(int y = 0; y <= K; y++){
            int z = S - x - y;
            if(0<= z && z <= K) count++;
        }
    }
    cout << count << endl;
}

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int a,b;

int main()
{
    cin>>a>>b;
    if (a<b)
    {
        for (int i=1;i<=b;++i)
            cout<<a;
    }
    else
    {
        for (int i=1;i<=a;++i)
            cout<<b;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

import java.math.BigInteger;
import java.util.*;

import java.util.ArrayList;

import java.util.Scanner;


public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static final int mod = 1000000007;
    static final int mod1=1073741824;

    public static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int a[]=new int[m];
        int s=0;

        for(int j=0;j<m;j++)
        {
            a[j]=sc.nextInt();
            s+=a[j];
        }
        if(s>n)
            System.out.println(-1);
        else
        {
            System.out.println(n-s);
        }



    }

}










Measured memory_bytes: 46416
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

int dp[N];

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

    
void test_case() {

  
    ll n,k;
    cin>>n>>k;


    ll ans = 0;
    
    for(int i=k; i>=1; i--) {


        ll val = binpow(k/i,n,mod);


        for(int j=2*i; j<=k; j=j+i) {
            val = val - dp[j];
            val= val % mod;
        }

        if(val<0) {
            val = val + mod;
        }

        ans+= i * val;
        ans = ans % mod;


        dp[i] = val;
    }

    cout<<ans<<endl;







}


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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int N; cin >> N;
  string S, T;
  cin >> S >> T;
  
  int pos;
  ll ans;
  bool vertical;

  if (S[0] == T[0]) {
    pos = 1;
    ans = 3;
    vertical = true;
  } else {
    pos = 2;
    ans = 6;
    vertical = false;
  }

  while (pos < N) {
    if (S[pos] == T[pos]) {
      if (vertical) (ans *= 2) %= MOD;
      else (ans *= 1) %= MOD;
      vertical = true;
      pos += 1;
    }
    else {
      if (vertical) (ans *= 2) %= MOD;
      else (ans *= 3) %= MOD;
      vertical = false;
      pos += 2;
    }
  }

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


Measured memory_bytes: 256
#include <stdio.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
typedef long long Int;
int main() {
    Int n, k;
    scanf("%lld %lld", &n, &k);
    if (k == 0) {
        printf("%lld\n", n * n);
        return 0;
    }
    Int ans = 0;
    for (Int b = k + 1; b <= n; b++) {
        Int q = n / b;
        Int r = n % b;
        Int c = 0;
        if (q >= 1) {
            c += (q - 1) * k + (k - 1);
        }
        c += MIN(r, k - 1) + 1;
        ans += n - c;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 7504
#include <bits/stdc++.h>
#define PII pair <int, int>
#define x first
#define y second

using namespace std;

map <PII, int> mmp;

PII A[55];

int n;

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d%d", &A[i].x, &A[i].y);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++) if(i != j) {
			mmp[PII(A[i].x - A[j].x, A[i].y - A[j].y)]++;
		}
	int mx = 0;
	for(map <PII, int>::iterator it = mmp.begin(); it != mmp.end(); it++) mx = max(mx, it->y);
	printf("%d\n", n - mx);
	return 0;
}	

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

int main(){
    int A,B,K,ans=0;
    cin >> A >> B;
    int c[5];
    for(int i=A;i<B+1;i++){
        K=i;
        for(int j=0;j<5;j++){
            c[j]=K%10;
            K/=10;
        }
        if(c[0]==c[4]&&c[1]==c[3]){
        ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;
int main()
{
    ll n,m,i,a,b;
    cin>>n>>m;
    a=min(n,m);
    b=max(n,m);
    for(i=0;i<b;i++) cout<<a;
    
}

Measured memory_bytes: 3544
#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;
#define ret() return 0;

bool contain(set<char> &s, char 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;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return 0;
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void calculate() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};

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

    CumulativeSum w(s.size()),
            e(s.size());

    rep(i, s.size()) {
        if (s[i] == 'W') w.set(i, 1);
        else e.set(i, 1);
    }
    w.calculate();
    e.calculate();

    int ans = INT_MAX;

    for (int i = 0; i < s.size(); i++) {

        int l = w.getSectionSum(0, i - 1),
                r = e.getSectionSum(i + 1, s.size() - 1);

        int now = l + r;
        cmin(ans, now);
    }
    cout << ans << endl;

}

Measured memory_bytes: 9988