akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

ll N, gA, sA, bA, gB, sB, bB;
vector<ll> abW, abV, baW, baV;

ll ks(ll weight, auto ws, auto vs) {
  vector<ll> tbl(weight+1);
  iota(tbl.begin(), tbl.end(), 0);
  for (int idx = 0; idx < (int)ws.size(); idx++) {
    ll wt = ws.at(idx);
    ll val = vs.at(idx);
    for (int j = 0; j <= weight; j++) {
      if (j >= wt) {
	tbl.at(j) = max(tbl.at(j), tbl.at(j-wt) + val);
      }
    }
  }
  return tbl.at(weight);
}


void setWV(ll a, ll b) {
  if (a < b) {
    abW.push_back(a);
    abV.push_back(b);
  }else if (b < a) {
    baW.push_back(b);
    baV.push_back(a);
  }
}

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif
  cout << setprecision(20);

  cin >> N >> gA >> sA >> bA >> gB >> sB >> bB;
  setWV(gA, gB);
  setWV(sA, sB);
  setWV(bA, bB);
  cout << ks(ks(N, abW, abV), baW, baV) << endl;
  return 0;
}



Measured memory_bytes: 195584
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int D = scanner.nextInt();

        switch (D) {
            case 25:
                System.out.println("Christmas");
                return;
            case 24:
                System.out.println("Christmas Eve");
                return;
            case 23:
                System.out.println("Christmas Eve Eve");
                return;
            case 22:
                System.out.println("Christmas Eve Eve Eve");
                return;
        }


    }

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;


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

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      // cout << "i: " << i << endl;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main () {

  int N;
  vector<ll> A;

  cin >> N;

  ll temp;
  vector<ll> v;
  REP(i, 0, N) {
    cin >> temp;
    A.push_back(temp);
  }
  ll big = 10000000;
  REP(i, 0, big) {
    v.push_back(0);
  }

  REP(i, 0, N) {
    map< int64_t, int > ret;
    ret = prime_factor(A[i]);
    for(auto it = ret.begin(); it != ret.end(); ++it) {
      // cout << "(*it).first : " << (*it).first << ", (*it).second : " << (*it).second << endl;
      if ( v[(*it).first] < (*it).second ) {
        // cout << "pow(" << (*it).first << ", " << (*it).second << ")" << endl;
        v[(*it).first] = (*it).second;
      }
    }
  }

  ll lcm_ = 1;
  REP(i, 1, big) {
    if ((v[i]) == 0) {
      continue;
    }
    lcm_ = (lcm_ * (ll)pow((ll)i, (ll)v[i])) % mod;
    // cout << "i: " << i << ", v[i]: " << v[i] << endl;
  }
  // cout << "lcm_: " << lcm_ << endl;

  ll ans = 0;
  REP(i, 0, N) {
    ll gyakugen = modinv(A[i], mod);
    ans = ans + ((lcm_ * gyakugen) % mod);
    ans = ans % mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 133120
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;

typedef signed long long ll;

int main()
{
	
	int n;
	cin >> n;
	n = 999 - n;
	n = n + 111;
	cout << n << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int n;
vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
VI a(20);
int counter (int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}
//int Counter(int x)
int main(){
    cin >> n;
     for(int i = 1; i <= n; i++) {
        cin >> a[i];
        for(int j = 1; j <= a[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int bits = 1; bits < (1 << n); bits++) {
               // cout << bitset<8>(x) << ' ' << bitset<8>(counter(x))<< endl;;
               bool flg=true;
               for(int i = 1; i <= n; i++) {
            if(!(bits & (1 << (i-1)))) continue;
            for(int j = 1; j <= a[i]; j++) {
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) flg = false;
            }
        }
               
               
        
        if(flg==true) ans=max(ans,counter(bits));
    }
    cout << ans << endl;
}  


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

using lint = long long int;

int main(){
    long n;
    lint a[100002];

    cin >> n;
    for(long i=0;i<n;i++) cin >> a[i];
    sort(a,a+n);

    lint maxa = a[n-1];
    auto itr_up = lower_bound(a,a+n,maxa/2);
    auto itr_down = itr_up - 1;
    
    if(*itr_up == maxa){
        cout << maxa << " " << *itr_down << endl;
        return 0;
    }
    if(*itr_down == maxa){
        cout << maxa << " " << *itr_up << endl;
        return 0;
    }
    if( (*itr_up - maxa/2) <= (maxa/2 - *itr_down) ){
        cout << maxa << " " << *itr_up << endl;
    }
    else{
        cout << maxa << " " << *itr_down << endl;
    }

    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) {
        cin >> v[i];

    }

    int l, r;
    l = r = 0;
    LL res = 0;
    int bic = 0;
    int bi[21] = {};
    while(l < n) {
        bool f = true;
        while(r < n && f) {
            int t = v[r];
            int b = 0;
            while(t > 0) {
                if(t & 1) {
                    ++bi[b];
                    if(bi[b] == 2) {
                        ++bic;
                        f = false;
                    }
                }
                t >>= 1;
                ++b;
            }
            if(f) {
                res += r - l + 1;
                ++r;
            }
        }

//        cout << l << " " << r << " " << res << endl;
        if(f) {
            ++l;
            continue;
        }

        while(l < r && !f) {
            int t = v[l];
            int b = 0;
            while(t > 0) {
                if(t & 1) {
                    --bi[b];
                    if(bi[b] == 1) {
                        --bic;

                    }
                }
                t >>= 1;
                ++b;
            }
            ++l;
            if(bic == 0) {
                f = true;
                res += r - l + 1;

            }
        }
        ++r;
//        cout << l << " " << r << " " << res << endl;
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 1024
import java.util.ArrayDeque
import kotlin.Comparator
import kotlin.String

fun main(args: Array<String>) {
    val (h, w) = readIntList()
    val (ch, cw) = readIntList().map { it - 1 }
    val (dh, dw) = readIntList().map { it - 1 }
    val s = List(h) { readString() }

    val q = ArrayDeque<Triple<Int, Int, Int>>()
    val ans = List(h) { MutableList(w) { Int.MAX_VALUE } }
    q.addLast(Triple(ch, cw, 0))

    val af = listOf(Pair(0, 1), Pair(0, -1), Pair(1, 0), Pair(-1, 0))

    while (q.isNotEmpty()) {
        val (x, y, p) = q.removeFirst()
        if (p < ans[x][y]) {
            ans[x][y] = p

            af.forEach { (xf, yf) ->
                val tx = x + xf
                val ty = y + yf
                if (tx >= 0 && ty >= 0 && tx < h && ty < w && s[tx][ty] == '.' && ans[x][y] < ans[tx][ty]) {
                    q.addFirst(Triple(tx, ty, ans[x][y]))
                }
            }

            for (xf in -2..2) {
                for (yf in -2..2) {
                    val tx = x + xf
                    val ty = y + yf

                    if (xf == 0 && yf == 0) continue
                    if (tx == x + 1 && ty == y) continue
                    if (tx == x - 1 && ty == y) continue
                    if (tx == x && ty == y + 1) continue
                    if (tx == x && ty == y - 1) continue

                    if (tx >= 0 && ty >= 0 && tx < h && ty < w && s[tx][ty] == '.' && ans[x][y] + 1 < ans[tx][ty]) {
                        q.addLast(Triple(tx, ty, ans[x][y] + 1))
                    }
                }
            }
        }
    }

    if (ans[dh][dw] == Int.MAX_VALUE) {
        println(-1)
    } else {
        println(ans[dh][dw])
    }
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)

Measured memory_bytes: 100720
#include<iostream>
#include <iomanip>
using namespace std;
int main(){
	int N,i;
   cin>>N;
   double a=0;
     double d;
   for(i=1;i<=N;i++){
   	if(i%2!=0){
   		a=a+1;
	   }
   }
     d=a/N;
    cout<<setiosflags(ios::fixed)<<setprecision(10)<<d;
} 

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

int x[530][530],c[530][530];

int main(void){
    
    int n,m,q;
    int l[200003],r[200003];
    cin>>n>>m>>q;
    for(int i=0;i<m;i++){
        cin>>l[i]>>r[i];
        x[l[i]][r[i]]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)c[i][j]=c[i][j-1]+x[i][j];
    }
    
    for(int i=0;i<q;i++){
        int a,b;
        cin>>a>>b;
        int ans=0;
        for(int j=a;j<=b;j++)ans+=c[j][b]-c[j][a-1];
        cout<<ans<<endl;
    }
    
}


Measured memory_bytes: 4608
#include <stdio.h>
#define MAX 10000
#define NIL -1

typedef struct
{
  int parent,left,right;
}Node;

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d)
{
  if(u==NIL);
  else
    {
      D[u]=d;
      setDepth(T[u].left,d+1);
      setDepth(T[u].right,d+1);
    }
}
int setHeight(int u)
{
  int h1=0,h2=0;
  if(T[u].left!=NIL)
    h1=setHeight(T[u].left)+1;
  if(T[u].right!=NIL)
    h2=setHeight(T[u].right)+1;
  return H[u]=(h1>h2?h1:h2);
}
int getSibling(int u)
{
  if(T[u].parent==NIL)return NIL;
  if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL)
    return T[T[u].parent].left;
  if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL)
    return T[T[u].parent].right;
  return NIL;
}
void print(int u)
{
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg=0;
  if(T[u].left != NIL)deg++;
  if(T[u].right!=NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  if(T[u].parent ==NIL)
    {
      printf("root\n");
    }
  else if(T[u].left == NIL && T[u].right==NIL)
    printf("leaf\n");
  else
    printf("internal node\n");
}

int main()
{
  int v,l,r,root=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++)T[i].parent=NIL;
  for(int i=0;i<n;i++)
    {
      scanf("%d%d%d",&v,&l,&r);
      T[v].left=l;
      T[v].right=r;
      if(l!=NIL)T[l].parent=v;
      if(r!=NIL)T[r].parent=v;
    }
  for(int i=0;i<n;i++)if(T[i].parent==NIL)root=i;
  setDepth(root,0);
  setHeight(root);
  for(int i=0;i<n;i++)print(i);
  return 0;
}



Measured memory_bytes: 2132
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int n;
    cin>>n;
    
    vector<int> d(n);
    for(int i=0;i<d.size();i++){
        cin >> d.at(i);
    }
    
    int sum = 0;
    REP(i,n){
        FOR(j,i+1,n){
            sum += d.at(i)*d.at(j);
        }
    }

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

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

int main(){
    int a, b;
    cin >> a >> b;

    string m;
    if(a > 0 and b > 0) m = "Positive"; 
    else if(a <= 0 and b >= 0) m = "Zero";
    else if(a < 0 and b < 0){
        if((b - a) % 2 != 0) m = "Positive";
        else m = "Negative";
    }
    cout << m << endl;


    return 0;
}

Measured memory_bytes: 256
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n,i,j,ans=hell,k;
	cin>>n;
	ll x[n+2],y[n+2];
	map<pii,ll>m,f;
	for(i=1;i<=n;i++){
		cin>>x[i]>>y[i];
		m[mp(x[i],y[i])]=i;
	}
	ll a,b,mx=0;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(i!=j){
				f[mp(x[i]-x[j],y[i]-y[j])]++;	
				if(f[mp(x[i]-x[j],y[i]-y[j])]>mx)a=x[i]-x[j],b=y[i]-y[j],mx=f[mp(x[i]-x[j],y[i]-y[j])];
			}
		}
	}
	ll vis[n+2]={0},cnt=0;
	for(k=1;k<=n;k++){
		if(!vis[k]){
			cnt++;
			vis[k]=1;
			ll aa=x[k],bb=y[k];
			while(m[mp(aa-a,bb-b)]!=0){
				aa-=a;
				bb-=b;
				vis[m[mp(aa,bb)]]=1;
			}
			aa=x[k],bb=y[k];
			while(m[mp(aa+a,bb+b)]!=0){
				aa+=a;
				bb+=b;
				vis[m[mp(aa,bb)]]=1;
			}
		}
	}
	ans=min(ans,cnt);
	if(n==1)cout<<"1";else
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**9)

h,w = map(int, input().split())
board = [[int(j=="#") for j in input()] for i in range(h)]
dxdy = ((0,1), (0,-1), (1,0), (-1,0))

def dfs(i, j, k, prev):
    if used[i][j] or board[i][j] == prev:
        return
    used[i][j] = 1
    k[board[i][j]] += 1
    for dx, dy in dxdy:
        nx, ny = i+dx, j+dy
        if 0 <= nx < h and 0 <= ny < w and not used[nx][ny] and board[nx][ny] != board[i][j]:
            dfs(nx,ny,k,board[i][j])

used = [[0]*w for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if used[i][j]:
            continue
        k = [0]*2
        dfs(i,j,k, -1)
        ans += k[0]*k[1]
print(ans)

Measured memory_bytes: 201200
#include <stdio.h>
int main(void){
    int A,B;
    
    scanf("%d %d",&A,&B);
    if(A>=1 && A<=9){
        if(B>=1 && B<=9){
            printf("%d\n",A*B);
        }
        else{
            printf("-1\n");
        }
    }
    else{
        printf("-1\n");
    }
    return 0;
}


Measured memory_bytes: 128
C=[0]*3;A=[0]*3
d1=0;d2=0;e1=0;e2=0;z=0;p=0
for i in range(3):
  c1,c2,c3=map(int,input().split())
  C[i]=[c1,c2,c3]
  A[i]=[0,0,0]
 
d1=C[1][0]-C[0][0];d2=C[2][0]-C[0][0]
e1=C[0][1]-C[0][0];e2=C[0][2]-C[0][0]
z=C[0][0]
A[0][0]=z;A[0][1]=z+e1;A[0][2]=z+e2
A[1][0]=z+d1;A[1][1]=z+e1+d1;A[1][2]=z+d1+e2
A[2][0]=z+d2;A[2][1]=z+d2+e1;A[2][2]=z+d2+e2
 
#print(C)
for i in range(3):
  for j in range(3):
    if C[i][j]==A[i][j]:
      p=p+1
print("Yes" if p==9 else "No")

Measured memory_bytes: 3064
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int N,K;
  cin >> N >> K;
  vector<ll> A(N+1);
  rep(i,N+1){
    A.at(i) = i;
  }
  if(N<K){
    cout << 1 << endl;
  }else{
    ll ans = 0;;
    for(ll i = K;i <= N+1;i++){
      ll res = ((N-i+1)%MOD*i%MOD)%MOD+1;
      ans += res;
      ans = ans%MOD;
    }
    cout << ans << endl;
  }


}


Measured memory_bytes: 4748
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int w[11] = {0, 1, 2, 4, 7, 12, 20, 29, 38, 52, 73};

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int N, p[11];
ll ed[11][11], M = 0;

int main(){
	getint(N);
	for(register int i = 2; i <= N; i++){
		for(register int j = 1; j < i; j++) ed[i][j] = ed[j][i] = (M + 1) * w[j];
		if(i == N) break;
		for(register int j = 1; j <= i; j++) p[j] = j;
		do {
			register ll len = 0;
			for(register int j = 1; j < i; j++) len += ed[p[j]][p[j + 1]];
			M = max(M, len);
		} while(next_permutation(p + 1, p + i + 1));
	}
	for(register int i = 1; i <= N; i++, puts(""))
		for(register int j = 1; j <= N; j++) printf("%lld ", ed[i][j]);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int sum(char a[1000]){
    int i = 0;
    int sum = 0;
    while (a[i] != '\0'){
        sum += a[i] - '0';
        i++;
    }
    return sum;
}

int main(void){
    char x[1000];
    while (1)
    {
        scanf("%s", x);
        if(x[0] == '0'){
            break;
        }
        printf("%d\n", sum(x));
    }
    return 0;
}


Measured memory_bytes: 2080
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		double x = 0.0;
		double y = 0.0;
		double d = 90.0;
		
		String str = "";
		while ((str = sc.nextLine()).equals("0,0") == false) {
			String[] params = str.split(",");
			
			int meter = Integer.parseInt(params[0]);
			int degree = Integer.parseInt(params[1]);
			
			x = x + meter * Math.cos(Math.toRadians(d));
			y = y + meter * Math.sin(Math.toRadians(d));
			d = d - degree;
		}

		System.out.println((int)x);
		System.out.println((int)y);
	}
}

Measured memory_bytes: 26120
#abc 103 b
s=input()
t=input()
flag=False
for i in range(-1,-len(s)-1,-1):
    new_t=""
    for j in range(len(s)):
        new_t+=t[i+j]
    #print(i,s,new_t)
    if new_t==s:
        flag=True
        break
if flag:
    print("Yes")
else:
    print("No")


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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999;
	
	public static void Main(string[] args)
	{
		var k = Input();
		
		if(k[0][0] < k[1][0])
		{
			Console.WriteLine("<");
		}
		else if(k[0][0] > k[1][0])
		{
			Console.WriteLine(">");
		}
		else
		{
			Console.WriteLine("=");
		}
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
 
    ll n, a;
    cin >> n;
 
    bool all_even = true;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a % 2 == 1) all_even = false;
    }
 
    if (all_even) cout << "second\n";
    else cout << "first\n";
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VVS = vector<VS>;
using VI = vector<int>;
using VVI = vector<VI>;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll MOD = 1e+9 + 7;
// --------------------------------------------------------


const int MAX_N = 3e+3;
VVI dp(MAX_N + 1, VI(MAX_N + 1, 0));
VVP dr(MAX_N + 1, VP(MAX_N + 1, make_pair(0, 0)));
VVS ds(MAX_N + 1, VS(MAX_N + 1, ""));

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

    string S; cin >> S;
    string T; cin >> T;

    int N = SZ(S);
    int M = SZ(T);
    S = ' ' + S;
    T = ' ' + T;
    FOR(i, 1, N + 1) FOR(j, 1, M + 1) {
        if (S[i] == T[j]) {
            dp[i][j] = dp[i - 1][j - 1] + 1;
            dr[i][j] = make_pair(i - 1, j - 1);
            ds[i][j] = S[i];
        } else {
            if (dp[i - 1][j] >= dp[i][j - 1]) {
                dp[i][j] = dp[i - 1][j];
                dr[i][j] = make_pair(i - 1, j);
                ds[i][j] = ds[i - 1][j];
            } else {
                dp[i][j] = dp[i][j - 1];
                dr[i][j] = make_pair(i, j - 1);
                ds[i][j] = ds[i][j - 1];
            }
        }
    }

    // LCS 復元
    string ans = "";
    int i = N, j = M;
    int x, y;
    while (true) {
        if (i == 0 && j == 0) break;
        tie(x, y) = dr[i][j];
        if (dp[x][y] < dp[i][j]) {
            ans.insert(0, ds[i][j]);
        }
        i = x; j = y;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 390980
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define heap_min priority_queue<int,vector<int>,greater<int>>
#define heap_max priority_queue<int>
#define precision(x) cout << setprecision(x) << fixed;
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " "; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;


int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif

   string s,t;
   cin >> s >> t;
   int ans = INT_MAX;
   int n = s.size();
   int m = t.size();
   for(int i = 0 ; i < n ; i++){
      int pos = i;
      int c = 0;
      if(i+m<=n){
          for(int j = 0 ; j < m ; j++){
            if(s[pos]!=t[j]){
              c++;
            }
            pos++;
        }
        ans = min(ans,c);  

      }
      
   }
   cout << ans;

}


Measured memory_bytes: 3612
S = input()
for i in range(len(S)):
    S = S[0:len(S)-1]
    if(len(S) % 2 == 0):
        if((S[0:(len(S)//2)]) == (S[(len(S)//2):len(S)+1])):
            print(str(len(S)))
            exit()

Measured memory_bytes: 9024
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MOD = 998244353;
const ll MAX_N = 100010;
typedef pair<ll,ll> P;

int main() {
    cin>>A>>B;
    ll ans = max(A+B,A-B);
    ans = max(ans,A*B);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int MAX_N = 400;
const int di[] = {1, 0, -1, 0};
const int dj[] = {0, 1, 0, -1};
bool color[MAX_N][MAX_N];
int H, W;
char ch[MAX_N + 1];

void input(){
	cin >> H >> W;
	for(int i = 0; i < H; ++i){
		cin >> ch;
		for(int j = 0; j < W; ++j){
			color[i][j] = (ch[j] == '#');
		}
	}
}

bool isin_(int i, int j){
	return i >= 0 && i < H && j >= 0 && j < W;
}

bool check_(int i, int j, int d){
	int ni = i + di[d];
	int nj = j + dj[d];
	if(!isin_(ni, nj)) return false;
	if(color[i][j] == color[ni][nj]) return false;
	return true;
}

bool used[MAX_N][MAX_N];

long long solve(){
	long long ans = 0;
	long long b = 0, w = 0;
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			if(used[i][j]) continue;
			b = 0;
			w = 0;
			queue<P> que;
			used[i][j] = true;
			que.push(P(i, j));
			while(!que.empty()){
				P p = que.front();
				que.pop();
				int ci = p.first, cj = p.second;
				if(color[ci][cj]) b++;
				else w++;
				for(int d = 0; d < 4; ++d){
					if(!check_(ci, cj, d)) continue;
					int ni = ci + di[d], nj = cj + dj[d];
					if(used[ni][nj]) continue;
					used[ni][nj] = true;
					que.push(P(ni, nj));
				}
			}
			ans += b * w;
		}
	}
	return ans;
}

int main(){
	input();
	long long ans = solve();
	cout << ans;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Toll Gates
            var line = ReadLine();
            int N = line[0];
            int M = line[1];
            int X = line[2];

            var A = ReadLine();

            int left = A.Count(a => a < X);
            int right = A.Count(a => a > X);

            Console.WriteLine(Math.Min(left, right));
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 100000
#define mod 998244353
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int fa[maxn+5];
int getfa(int x)
{
    if(fa[x]==x) return x;
    return fa[x]=getfa(fa[x]);
}

int main()
{
    int n,m; scanf("%d%d",&n,&m);
    rep(i,1,n) fa[i]=i;
    rep(i,1,m)
    {
        int x,y; scanf("%d%d",&x,&y);
        int fx=getfa(x),fy=getfa(y);
        if(fx!=fy) fa[fx]=fy;
    }
    int cnt=0;
    rep(i,1,n) if(getfa(i)==i) cnt++;
    printf("%d\n",cnt-1);
    return 0;
}

Measured memory_bytes: 4204
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

const int N=2009;

int n,k;
int to[N<<1],nxt[N<<1],beg[N],tot=1;

inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

inline void add(int u,int v)
{
	to[++tot]=v;
	nxt[tot]=beg[u];
	beg[u]=tot;
}

inline int dfs(int u,int fa,int dep)
{
	int ret=(dep<0);
	for(int i=beg[u],v;i;i=nxt[i])
		if((v=to[i])!=fa)
			ret+=dfs(v,u,dep-1);
	return ret;
}

int main()
{
	n=read();
	k=read();
	for(int i=1,u,v;i<n;i++)
	{
		u=read();v=read();
		add(u,v);add(v,u);
	}

	if(!(k&1))
	{
		int ans=1e9;
		for(int i=1;i<=n;i++)
			ans=min(ans,dfs(i,0,k>>1));
		printf("%d\n",ans);
	}
	else
	{
		int ans=1e9;
		for(int i=2,a,b;i<=tot;i+=2)
		{
			a=dfs(to[i],to[i^1],k>>1);
			b=dfs(to[i^1],to[i],k>>1);
			ans=min(ans,a+b);
		}
		printf("%d\n",ans);
	}

	return 0;
}


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

const int MOD = 1000000007;
const int MAXM = 105;
const int MAXS = 20;

long long modpow(long long x, long long p){
	if(p == 0)return 1;
	if(p % 2 == 1)return x * modpow(x, p - 1) % MOD;
	
	long long r = modpow(x, p / 2);
	return r * r % MOD;
}
long long modinv(long long x){
	return modpow(x, MOD - 2);
}

long long inv[MAXM];

long long C(int n, int r){
	long long ret = 1;
	for(int i = 0; i < r; i++)
		ret = ret * (n - i) % MOD * inv[i + 1] % MOD;
	return ret;
}

int t, n;
long long dp[MAXS][MAXS][MAXS];

int main(){
	for(int i = 1; i < MAXM; i++)
		inv[i] = modinv(i);
	
	scanf("%d", &t);
	while(t--){
		scanf("%d", &n);
		
		for(int a = 0; a <= 5; a++)
		for(int b = 0; b <= 16; b++)
		for(int c = 0; c <= min(b, 5); c++){
			if(a > 0){
				dp[a][b][c] = (dp[a - 1][b + 1][c] - dp[a - 1][b][c] + MOD) % MOD;
			}else{
				if(c == 0){
					dp[a][b][c] = C(n + b - 1, b - 1);
				}else if(b == c){
					if(n % 2 == 0)dp[a][b][c] = C(n / 2 + b - 1, b - 1);
					else dp[a][b][c] = 0;
				}else{
					dp[a][b][c] = (dp[a][b][c - 1] + dp[a][b - 1][c]) * inv[2] % MOD;
				}
			}
		}
		
		printf("%lld\n", dp[5][11][5]);
	}
	return 0;
}


Measured memory_bytes: 3868
#include<bits/stdc++.h>
#include<queue>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>

using namespace std;

const int maxn = 2e5 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef long long ll;

/*
ll modpow(ll a, ll n,int md) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % md;
        a = a * a % md;
        n >>= 1;
    }
    return res;
}
*/

//const int N=200005;
ll A,B,N,maxxx,buff;
int main(){
    if(B <= N){
        maxxx = 0;
        cin >> A >> B >> N;
        ll x = ((ll)(N/B) * B) - 1;
        maxxx = ((ll)((A*x)/B)) - ( A * ((ll)(x/B)) );
        buff = ((ll)((A*N)/B)) - ( A * ((ll)(N/B)) );
        if(maxxx < buff)maxxx = buff;
        printf("%lld\n",maxxx);
    }else{
        maxxx = 0;
        cin >> A >> B >> N;
        maxxx = ((ll)((A*N)/B)) - ( A * ((ll)(N/B)) );
        printf("%lld\n",maxxx);
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

void solve()
{
	int b, r, g, c, s, t;
	while(cin >> b >> r >> g >> c >> s >> t, b || r || g || c || s || t)
	{
		int sum = 100;
		sum += 77 * b;
		t -= 6 * b;
		sum += 51 * r;
		t -= 4 * r;
		sum += 4 * g;
		t -= g;
		sum -= c;
		t -= c;
		sum -= s * 3;
		t -= s * 2;
		sum -= 3 * t;
		cout << sum << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1160
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

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

    int n=N;
    int sum=0;
    int dig;
    while(n){
        dig = n%10;
        sum += dig;
        n /= 10;
    }
    string ans;
    if(N%sum==0){
        ans="Yes"; 
    }else{
        ans="No";
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,a[N];
map<ll,P> m;
vector<ll> num,cnt,mini;
ll ans[N]={};

int main(){
  cin>>n;
  for(ll i=0;i<n;i++){
    cin>>a[i];
    if(m.count(a[i]))m[a[i]].first++;
    else m[a[i]]=P(1,i);
  }
  map<ll,P>::iterator ite=m.begin();
  while(ite!=m.end()){
    num.push_back((*ite).first);
    cnt.push_back((*ite).second.first);
    mini.push_back((*ite).second.second);
    ite++;
  }
  for(ll i=cnt.size()-2;i>=0;i--)cnt[i]+=cnt[i+1];
  for(ll i=num.size()-2;i>=0;i--)
    mini[i]=min(mini[i],mini[i+1]);
  for(ll i=0;i<num.size();i++){
    ll x=num[i];
    if(i)x-=num[i-1];
    ans[mini[i]]+=cnt[i]*x;
  }
  for(ll i=0;i<n;i++)cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 11872
#include <cstdio>
#include <cstring>
int main(){
  char str[99+1];
  scanf("%s",str);
  int len=strlen(str),flag=0;
  
  for(int i=0;i<len;i++){
    if(str[i]!=str[len-i-1])flag++;
  }
  
  for(int i=0;i<(len-1)/2;i++){
    if(str[i]!=str[(len-1)/2-i-1])flag++;
  }

  for(int i=0;i<(len-1)/2;i++){
    if(str[(len-1)/2+i+1]!=str[len-i-1])flag++;
  }

  printf("%s\n",(flag==0?"Yes":"No"));
  return 0;
}

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

const string joi = "JOI";
int h,w;
string g[1010];
string flag;

inline int check(int y, int x){
  if(!range(y,0,h-1) || !range(x,0,w-1))return 0;
  for(int i=0;i<4;i++){
    if(g[y+i/2][x+i%2] != flag[i])return 0;
  }
  return 1;
}
  
int main(){
  cin.tie(0); ios::sync_with_stdio(0);

  cin >> h >> w;
  rep(i,h)cin >> g[i];
  string a,b;
  cin >> a >> b;
  flag = a + b;

  int sum = 0;
  rep(i,h-1)rep(j,w-1)sum += check(i,j);

  int ans = sum;
  rep(i,h)rep(j,w){
    int before = 0;
    rep(ii,2)rep(jj,2)before += check(i-ii,j-jj);

    char tmp = g[i][j];
    rep(k,3){
      g[i][j] = joi[k];
      int after = 0;
      rep(ii,2)rep(jj,2)after += check(i-ii,j-jj);
      ans = max(ans, sum - before + after);
    }
    g[i][j] = tmp;
  }
  cout << ans << endl;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

ll calc(ll a, ll x)
{
	if(a == -1)return 0;
	return a / x + 1;
}

int main()
{
	ll a,b,x;
	cin >> a >> b >> x;
	ANS(calc(b,x) - calc(a-1,x));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint K; cin >> K;
    vec<lint> A_list(K);
    range(i, 0, K) cin >> A_list.at(i);
    lint l = 2, r = 2;
    reversed_range(i, 0, K) {
        lint A = A_list.at(i);
        lint nl = (l + A - 1) / A;
        lint nr = r / A;
        if (nr == 0 or nl > nr) {
            cout << -1 << "\n";
            return 0;
        }
        nl = max(nl, 1LL);
        l = nl * A, r = (nr + 1) * A - 1;
        // cout << A << "\n";
        // cout << l << " " << r << "\n";
    }
    cout << l << " " << r << "\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,c,cntw;
  vector<pair<int,int> > V;
  while(1){
    cntw=0;
    cin >> n;
    if(n==0) break;
    for(int i=1;i<=n;i++){
      cin >> c;
      if(i%2==0){
	if(c==0&&V[V.size()-1].first==1) V[V.size()-1].first=0;
	else if(c==1&&V[V.size()-1].first==0) V[V.size()-1].first=1;
      }
      if(V.size()!=0&&c==0&&V[V.size()-1].first==0) V[V.size()-1].second++;
      else if(c==0) V.push_back(make_pair(c,1));
      else if(V.size()!=0&&c==1&&V[V.size()-1].first==1) V[V.size()-1].second++;
      else if(c==1) V.push_back(make_pair(c,1));
      while(1){
	int flag=0;
	if(V.size()>=2){
	  for(int j=0;j<V.size()-1;j++){
	    if(V[j].first==V[j+1].first){
	      V[j].second+=V[j+1].second;
	      V.erase(V.begin()+j+1);
	      flag=1;
	      break;
	    }
	  }
	}
	if(flag==0) break;
      }
    }
    for(int i=0;i<V.size();i++){
      if(V[i].first==0) cntw+=V[i].second;
    }
    cout << cntw << endl;
    V.clear();
  }
  return 0;
}

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

ll ans = 0;

const int N = 26;
ll x[N] = {},y[N] = {};

int main(){
    string s,t;
    cin >> s >> t;

    for(int i = 0;i < s.size(); ++i){
        x[s[i] - 'a']++;
        y[t[i] - 'a']++;
    }

    sort(x,x+N);
    sort(y,y+N);

    for(int i = 0; i < N; ++i){
        if(x[i] != y[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 776
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    S,T=input().split()

    A,B = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    s=input()
    if s==S:
        print(max(0,A-1),B)
    else:
        print(A,max(B-1,0))





if __name__ == "__main__":
    main()

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

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

    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        mp[a]++;
    }

    int ans = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++)
    {
        if (itr->second % 2)
        {
            ans++;
        }
    }
    cout << ans << '\n';
    return (0);
}


Measured memory_bytes: 8184
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

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

	double a, b, x; cin >> a >> b >> x;
	if (x <= a * a*b / 2) {
		double ans = atan(b*b*a / 2.0 / x);
		cout << setprecision(15) << ans * 180.0 / PI << endl;
	}
	else {
		double y = 2.0*x / a / a - b;
		double ans = atan((b - y) / a);
		cout << setprecision(15) << ans * 180.0 / PI << endl;
	}

	return 0;
}

Measured memory_bytes: 512