akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int s[500000],n;
long long count;

void Merge(int left,int mid,int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1 + 1],R[n2 + 1];
    for(int i = 0;i < n1;i++)
        L[i] = s[left + i];
    for(int i = 0;i < n2;i++)
        R[i] = s[mid + i];
    L[n1] = 2000000000;
    R[n2] = 2000000000;
    int i = 0;
    int j = 0;
    for(int k = left;k < right;k++){
        if(L[i] <= R[j])
            s[k] = L[i++];
        else
            s[k] = R[j++];
        count++;
    }
}

void MergeSort(int left,int right){
    if(left + 1< right){
        int mid = (left + right)/2;
        MergeSort(left,mid);
        MergeSort(mid,right);
        Merge(left,mid,right);
    }
}

int main(void){
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%d",&s[i]);
    }

    MergeSort(0,n);

    for(int i = 0;i < n;i++){
        printf("%d",s[i]);
        if(i < n - 1)
            printf(" ");
    }
    printf("\n%lld\n",count);
    return 0;
}

Measured memory_bytes: 6516
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


   String[] xy = br.readLine().split(" ");
   double a = Double.parseDouble(xy[0]);
   double b = Double.parseDouble(xy[1]) ;
   double c = Double.parseDouble(xy[2]) ;

   double S = 0.5 * a * b * Math.sin( Math.toRadians(c) );
   double L = a + b + Math.sqrt( Math.pow( a , 2 )  + Math.pow( b , 2 ) - 2* a * b * Math.cos( Math.toRadians(c) ) );
   double h = b * Math.sin( Math.toRadians(c) );

   System.out.println(S);
   System.out.println(L);
   System.out.println(h);

  }
}

Measured memory_bytes: 24412
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int H, W, K;
vector<string> c;

void input(void){
    cin >> H >> W >> K;
    c.resize(H);
    for (auto& ci : c)
        cin >> ci;
}

bool judge(int f1, int f2){
    int cnt = 0;
    for (int i = 0; i < H; ++i){
        for (int j = 0; j < W; ++j){
            if (!(f1 & (1 << i)) && !(f2 & (1 << j)) && c[i][j] == '#')
                ++cnt;
        }
    }
    return cnt == K;
}

int main(void){
    input();
    int res = 0;
    for (int i = 0; i < (1 << H); ++i)
        for (int j = 0; j < (1 << W); ++j)
            if (judge(i, j)) ++res;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3632
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
a=[-1]+a+[n+1]
d=[a[i+1]-a[i]-2 for i in range(m+1)]
def fib(x):
    if x==1:
        return [1,1]
    else:
        ans=[1,1]
        for i in range(2,x+1):
            ans.append(ans[-1]+ans[-2])
        return ans
md=max(d)
l=fib(md)
ans=1
for i in range(m+1):
    if d[i]==-1:
        ans=0
        break
    else:
        ans=ans*l[d[i]]
print(ans%1000000007)


Measured memory_bytes: 460020
import heapq
import sys
input = sys.stdin.readline
Q = int(input())
Query = [[int(_) for _ in input().split()] for _ in range(Q)]
H1 = []
H2 = []
a = b = sum1 = sum2 = 0
for query in Query:
    if query[0] == 1:
        m0 = query[1]
        if len(H1) == len(H2):
            if len(H2):
                m1 = heapq.heappop(H2)
                sum2 -= m1
                m0, m1 = sorted([m0, m1])
                heapq.heappush(H1, -m0)
                heapq.heappush(H2, m1)
                sum1 -= m0
                sum2 += m1
            else:
                heapq.heappush(H1, -m0)
                sum1 -= m0
        else:
            m1 = -heapq.heappop(H1)
            sum1 += m1
            m0, m1 = sorted([m0, m1])
            heapq.heappush(H1, -m0)
            heapq.heappush(H2, m1)
            sum1 -= m0
            sum2 += m1
        b += query[2]
    else:
        x = -H1[0]
        print(x, x * len(H1) + sum1 + sum2 - x * len(H2) + b)


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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Yes or No
void yesno(bool ok, string yes = "Yes", string no = "No") {
  cout << (ok ? yes : no) << endl;
}

// Paste snippets here!!

//

void solve(long long N, std::vector<long long> A) {
  ll ret = 0LL;
  rep(i,N){
    rep(j,i+1,N){
      ret = max(abs(A[i]-A[j]), ret);
    }
  }
  cout << ret << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long N;
  std::cin >> N;
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main(){
    int a, b;
    char op;
    while (cin >> a >> op >> b)
        switch (op) {
            case '+': cout << a+b << endl; break;
            case '-': cout << a-b << endl; break;
            case '*': cout << a*b << endl; break;
            case '/': cout << a/b << endl; break;
        }
    return 0;
}


Measured memory_bytes: 3108
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
N = int(input())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

A, B = map(int, input().split())
ans = 0
if (A % 2 == 0 and B % 2 == 0) or (A % 2 != 0 and B % 2 != 0):
    ans = (A + B) // 2

print(ans if ans != 0 else 'IMPOSSIBLE')




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

int main()
{
    string S;
    cin >> S;
    string T = "AKIHABARA";
    auto s = S.begin(), t = T.begin();
    if (S == "AKIHABARA"
            || S == "KIHABARA"
            || S == "AKIHBARA"
            || S == "AKIHABRA"
            || S == "AKIHABAR"
            || S == "KIHBARA"
            || S == "KIHABRA"
            || S == "KIHABAR"
            || S == "AKIHBRA"
            || S == "AKIHBAR"
            || S == "AKIHABR"
            || S == "KIHBRA"
            || S == "KIHBAR"
            || S == "KIHABR"
            || S == "AKIHBR"
            || S == "KIHBR"
            ) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

int main() {
	// your code goes here
	string s;
	cin >> s;
	int a;
	a=s.size();
	int i;
	for(i=0;i<a;i++){
		cout << "x";
	}	
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

void main() {
  auto input = readln.split.to!(ulong[]);
  ulong L = input[0], R = input[1];
  int ans = int.max;
  ulong end = L + min(R - L, 2019) + 1;
  foreach(i; L..(end - 1)) {
    foreach(j; (i+1)..end) {
      ans = min(ans, ((i % 2019) * (j % 2019)) % 2019);
    }
  }
  ans.writeln;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func base(x, b int) string {
	abs := func(x int) int {
		if x < 0 {
			return -x
		}
		return x
	}

	bs := ""
	for x != 0 {
		r := abs(x % b)
		bs = strconv.Itoa(r) + bs
		x -= r
		x /= b
	}
	if bs == "" {
		bs = "0"
	}
	return bs
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	fmt.Println(len(base(n, k)))
}


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

long long int q = pow(10, 9) + 7;

long long int S[2001];
long long int count(long long int s) {
	S[1] = S[2] = 0;
	S[0] = 1;
	S[3] = 1;
	for (int i = 4; i<=s; ++i) {
		for (int j = 3; i-j>=0; ++j)
			S[i] += S[i-j]%q;
			S[i] = S[i]%q;
	}
	return S[s];
}

int main() {
	long long int s;
	cin>>s;
	for (int i = 0; i<=s; ++i) {
		S[i] = 0;
	}
	cout<<count(s);
	return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef tuple<string, int, int> T;

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

    vector<vector<int>> vec(m);

    rep(i, m) {
        int k;
        cin >> k;
        vec[i].resize(k);
        rep(j, k) {
            cin >> vec[i][j];
            vec[i][j]--;
        }
    }

    vector<int> p(m);
    rep(i, m) {
        cin >> p[i];
    }

    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        bool ok = true;
        rep(j, m) {
            int c = 0;
            for (int id : vec[j]) {
                if ((i >> id) & 1) {
                    c++;
                }
            }
            c %= 2;
            if (c != p[j]) {
                ok = false;
            }
        }
        if (ok) {
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    string N;
    in(N);

    int s = 0;
    rep(i, N.size())
    {
        s += N[i] - '0';
        s %= 9;
    }

    if (s == 0)
    {
        outl("Yes");
    }
    else
    {
        outl("No");
    }

    return 0;
}

Measured memory_bytes: 3740
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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 <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

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

	if (n % 2 == 0) {
		if (k <= n / 2) {
			ANS("YES")
		}
		else {
			ANS("NO")
		}
	}
	else {
		if (k <= n / 2+1) {
			ANS("YES")
		}
		else {
			ANS("NO")
		}
	}

	return 0;

}


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

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

template<typename T1,typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 & a, T2 b) { if (a < b) a = b; }

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

template <class T>
void PrintVector(const vector<T> & v) {
  for (const auto & e: v) {
    cout << e << endl;
  }
}

template <class T>
void PrintVector(const vector<T> & v, int n) {
  rep(i, 0, n - 1) {
    cout << v[i] << endl;
  }
}

int main(int argc, char const *argv[]) {
  // long n, m, h, w, x, y;
  long n;
  // long ans = 0;
  // vector<int> a, b;
  // cin >> n >> m;
  // rep(i, 1, n) {
  //   int a0, b0;
  //   cin >> a0 >> b0;
  //   a.pb(a0);
  //   b.pb(b0);
  // }
  cin >> n;
  long m = (long)(sqrt(n));
  per(i, m, 1) {
    long p = n / i;
    if (n == i * p) { cout << i + p - 2 << endl; return 0; }
  }
  // for (const auto & a0: a) {
  //
  // }

  // cout << ans << endl;
  // cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
# import numpy as np
# import scipy as sp
# import sys
# input = sys.stdin.readline
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=list(map(int, input().split()))  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# a=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# a=[int(input()) for _ in range (n)]  #リスト入力  改行でa1 ... anのとき
# s=[list(map(str,list(input()))) for i in range(h)]  # 文字列の二次元配列入力
# s = [list(map(int, input().split())) for i in range(n)] # 数値の二次元配列入力
# a = b[:], a = [x[:] for x in b] # deepcopy
# chr(ord('a') + 1) # chrのインクリメント
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#　

k = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[k-1])


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vs = vector<string>;
using vvs = vector<vs>;
using pli = pair<long long, int>;
using vpli = vector<pli>;

int main() {
  ll A, B, C;
  cin >> A >> B >> C;
  
  if (A + B + C < 22) cout << "win" << endl;
  else cout << "bust" << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    string S;
    cin >> S;
    int sum = 0;

    for (int i = 0; i < S.size(); ++i) {
        sum += (S[i] - '0');
    }

    cout << (sum%9 == 0 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3696
//Keep Working Hard
  // I__Like__Food
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define f first
  #define s second
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 3005
  #define INF 1e16
  const double PI = acos(-1);


  int dp[N][N];
  int path[N][N];

int32_t main()
{




    // dp[i][j] denotes the longest common subsequence ending at i in string s, j in string t


    string s,t;
    cin >> s >> t;

    int n = s.length();
    int m = t.length();


    for(int i = 1; i <= n; i++)
    {
      for(int j = 1; j <= m; j++)
      {
        if((s[i-1] == t[j-1]))
        {
          dp[i][j] = dp[i-1][j-1] + 1;
        }
        else 
        {
            dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
        
      }
    }



    //cout << dp[n][m] << endl;

    int i = n;
    int j = m;

    string ans;

    while((i&&j))
    {
      if(s[i-1] == t[j-1])
      {
        ans.PB(s[i-1]);
        i--;
        j--;
      }
      else if(dp[i-1][j] > dp[i][j-1])
      {
        i--;
      } 
      else
      {
        j--;
      }
   }

   reverse(all(ans));
   cout << ans ;
  return 0;
}  

Measured memory_bytes: 71680
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

int add(int a,int b){
  return (a+b)%MOD;
}
int prod(int a,int b){
  return (a*b)%MOD;
}

int beki(int a,int b)
{
	if(b==0)return 1;
	int x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
}

int inv(int a)
{
	return beki(a,MOD-2);
}

void combi(int n,vector<int> &v){
  rep(i,n+1){
    if(i==0)v.pb(1);
    else{
      int po=prod(v[i-1],prod(n+1-i,inv(i)));
      v.pb(po);
    }
  }
}


signed main(){
  int n,k;cin>>n>>k;
  vector<int> v,w;
  int ans=0;
  if(k>=n-1)k=n-1;
  combi(n,v);
  combi(n-1,w);
  for(int i=0;i<=k;i++){
    //cout<<v[i]<<" "<<w[i]<<endl;
    (ans+=prod(v[i],w[i]))%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 7936
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
int main(){
    int long long  a , b , n ; 
  cin >> a >> b >> n ;
  int long long  i = min(b-1,n) ;
  int long long  ans  = floor(a*i/b) - a*floor(i/b) ;
                
  
  cout << ans << endl;

}


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

using namespace std;

typedef long long ll;

ll gcd(ll x, ll y) {
    if(x < y) return gcd(y, x);
    while (y != 0LL) {
        ll tmp = x%y;
        x = y;
        y = tmp;
    }
    return x;
}

ll lcm(ll a, ll b) {
    return (a/gcd(a,b)) * b;
}

int main() {
    int n; cin >> n;
    vector<ll> t(n);
    REP(i,n) cin >> t[i];
    sort(t.begin(), t.end());
    t.erase(unique(t.begin(), t.end()), t.end());
    ll ans = t[0];
    for(int i = 1; i < t.size(); i++) {
        if(t[i]%ans==0LL) ans = t[i];
        else ans = lcm(ans, t[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,a[1000005];
string s;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(;i++<100;)
	{
		for(j=i-1;j++<100;)
		{
			for(k=j-1;k++<100;)a[i*i+j*j+k*k+i*j+j*k+k*i]+=i<j?j<k?6:3:j<k?3:1;
		}
	}
	for(i=0;i++<n;)cout<<a[i]<<endl;
}

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

int main()
{
    while(true){
        string s1;
        cin >> s1;

        if(s1==".")
            break;

        string s2;
        cin >> s2;

        if(s1==s2){
            cout << "IDENTICAL" << endl;
            continue;
        }

        string t1 = s1;
        string t2 = s2;

        while(true){
            size_t d1b = t1.find('\"');
            if(d1b==string::npos)
                break;
            t1.replace(d1b, 1, "@");

            size_t d1e = t1.find('\"');
            t1.replace(d1e, 1, "@");

            size_t d2b = t2.find('\"');
            if(d2b==string::npos)
                break;
            t2.replace(d2b, 1, "@");

            size_t d2e = t2.find('\"');
            t2.replace(d2e, 1, "@");

            string u1 = s1;
            u1.replace(d1b+1, d1e-d1b-1, "");
            string u2 = s2;
            u2.replace(d2b+1, d2e-d2b-1, "");

            if(u1==u2){
                t1 = u1;
                t2 = u2;
                break;
            }
        }

        if(t1==t2){
            cout << "CLOSE" << endl;
        }
        else{
            cout << "DIFFERENT" << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3232
#encoding:utf-8
rectangle = []
while true
 length_width = gets.split
 if length_width == ["0","0"]
  break
 end
 rectangle.push length_width
end

i = 0 #rectangleの要素のインデックス

while i < rectangle.length
 j = 0 #縦の繰り返し回数をカウント
 while j < rectangle[i][0].to_i
  puts "#"*rectangle[i][1].to_i
  j += 1
 end
 puts
 i += 1
end

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

#define MAX 1000000000000000000

int main()
{
  long long A;
  int inte=0;
  long double B,few;
  
  cin >> A >> B;
  
  while(B - inte >= 1)
  	inte++;
  
  few=B-inte;
  long long ans=few*A + inte*A;
   cout << ans << endl;
}

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


int main(){
int n;
int d;
int ans=0;
cin>>n>>d;
vector<double>x(n);
vector<double>y(n);
rep(i,n)cin>>x[i]>>y[i];
rep(i,n){
    if(sqrt(x[i]*x[i]+y[i]*y[i])<=d){
        ans++;
    }


}
cout<<ans;
    
}

Measured memory_bytes: 6332
#include<iostream>
#include<algorithm>
#include<cstring>
#include<utility>
using namespace std;
int main(){
	int a,b,c,s;
	cin>>a>>b>>c;
	if(a>b){
		swap(a,b);
	}
	if(b>c){
		swap(b,c);
	}
	if(a>b){
		swap(a,b);
	}
	if(a==5 & b==5 && c==7){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}


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

int main() {
  ll N; cin >> N;
  ll f[N];
  for (ll i = 0; i < N; i++) {
    ll num = 0;
    for (ll j = 0; j < 10; j++) {
      ll x; cin >> x; num+= x << j;
    }
    f[i] = num;
  }
  ll P[N][11];
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j <= 10; j++) {
      cin >> P[i][j];
    }
  }
  ll res = -1e9;
  for (ll bits = 1; bits < 1 << 10; bits++) {
    ll num = 0;
    for (ll i = 0; i < N; i++) {
      ll x = __builtin_popcountll(bits & f[i]);
      num += P[i][x];
    }
    res = max(res,num);
  }
  cout << res << endl;
}

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


int main(){
  long long N,K;
  cin >> N >> K;
  long long ans = 0;
  for(int i = K; i<= N+1; i++){
    ans += (i*(N-i+1) + 1);
    ans %= 1000000007;
  }
  
  cout << ans << endl;
  
}



Measured memory_bytes: 3596
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string>
using namespace std;
char S[2001];
char T[2001];
int M,N;
int dp[2001][2001][2]={};

int calc(int a,int b,int c){
	int ans=0;
	if(dp[a][b][c]>-1)return dp[a][b][c];
	if(c==1){
		if(S[a]=='I')ans=calc(a+1,b,0)+1;
		if(T[b]=='I')ans=max(ans,calc(a,b+1,0)+1);
	}
	if(c==0){
		if(S[a]=='O')ans=calc(a+1,b,1)+1;
		if(T[b]=='O')ans=max(ans,calc(a,b+1,1)+1);
	}
	dp[a][b][c]=ans;
	return ans;
}
int main() {
	cin>>M>>N;
	for(int i=0;i<M;++i)cin>>S[i];
	for(int i=0;i<N;++i)cin>>T[i];

	for(int i=0;i<2001;++i){
		for(int j=0;j<2001;++j){
			dp[i][j][0]=-1;
			dp[i][j][1]=-1;
		}
	}
	S[M]='S';
	T[N]='S';
	int R=0,R2;
	for(int i=0;i<M;++i){
		for(int j=0;j<N;++j){
			R2=calc(i,j,1);
			if(R2%2==0)R2-=1;
			R=max(R,R2);
		}
	}
	cout<<R<<endl;
	return 0;
}

Measured memory_bytes: 34604
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-03-22 14:10:15
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
#define pii std::pair<i64,i64>
const int N=510;
i64 n,l[N],r[N],mod;
i64 ans,f[N],F[N],s[N];
pii a[N];
i64 &Add(i64 &a,i64 b){ return a=(a+b%mod+mod)%mod; }
int main()
{
	n=read(); mod=read();
	fr(i,0,n*2-1)
	{
		l[i]=n*2;
		fr(j,0,n*2-1) if(i*i+j*j<=4*n*n&&i*i+j*j>=n*n)
		{
			l[i]=std::min(l[i],1ll*j); r[i]=std::max(r[i],1ll*j);
		}
		if(l[i]==0) a[i]=pii(r[i],0);
		else a[i]=pii(l[i]-1,r[i]);
	}
	std::sort(a,a+n*2);
	fr(i,0,n*2) s[i]=(i?s[i-1]:0)+(a[i].second==0);
//	fr(i,0,n*2-1) printf("%d %d\n",int(l[i]),int(r[i]));
	fr(i,0,n*2)
	{
		memset(f,0,sizeof(f)); f[0]=1;
		fr(j,0,n*2-1)
		{
			fr(k,0,i){ F[k]=f[k]; f[k]=0; }
			fr(k,0,i)
				if(a[j].second)
				{
					Add(f[k],F[k]*(a[j].second+1-(j-1)-(s[n*2]-s[j])-(i-k))); Add(f[k+1],F[k]*(a[j].first+1-s[j-1]-k));
				}
				else Add(f[k],F[k]*(a[j].first+1-s[j-1]-k));
		}
		Add(ans,(i&1?-1:1)*f[i]);
	}
	printf("%d\n",int(ans));
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF INT32_MAX / 2
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    string s;
    cin >> s;
    if (s[s.size() - 1] == 's')
        s.push_back('e');

    s.push_back('s');
    cout << s << endl;
}

Measured memory_bytes: 3628
#include <cassert>
#include <cctype>
#include <cerrno> #include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main() {
    int n,m;
    cin >> n>>m;
    cout << n*m <<endl;
       }


Measured memory_bytes: 3624
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

A, B = map(int, input().split())


def f(n):
    fl = ((n-1)//2) % 2
    if n % 2 == 0:
        return fl ^ n
    else:
        return fl


print(f(B) ^ f(A-1))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int n;
	cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];
	int t = 0;
	rep(i, n) t ^= a[i];
	rep(i, n) {
		int ans = t ^ a[i];
		cout << ans << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 4396
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

import javax.swing.tree.TreeNode;
class Main{


	static final int MOD = 1000000007;

	static int MAX = 10000000;
	static	ArrayList<TreeNode> tree;
	static HashSet<Integer> set;
	static int[] ans;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		
		HashMap<String,Integer> map = new HashMap<>();
		long ans = 0;

		for(int i = 0;i < n;i++){
			char[] cc = sc.next().toCharArray();
			Arrays.sort(cc);
			String s = new String(cc);
			int num = map.getOrDefault(s, 0);
			map.put(s, num+1);
			if(num >= 1){
				ans += num;
			}
		}
//		COMinit();  					//二項定理デーブル作成
		
//		for(int num:map.values()){
//			ans += COM(num, 2);
//
//		}
		System.out.println(ans);
		
		
		
	}

	static long fac[] = new long[MAX];
	static long finv[] = new long[MAX];
	static long inv[] = new long[MAX];

	

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

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








	static int upperbond(int k,ArrayList<Integer> data){		//k以下で最大の値をdataの中から探し、返す二分探索
		if(data == null){
			return -1;
		}
		int max = data.size();
		int min = -1;
		while(max-min > 1){
			int mid = (max+min)/2;
			if(data.get(mid) <= k){
				min = mid;
			}else{
				max = mid;
			}
		}

		
//		if(min != -1){
//			min = data.get(min);
//		}
		
//		System.out.println(max);
		return min;					//indexを返している
	}

	static int lowerbond(int k,ArrayList<Integer> data){		//k以上で最小の値をdataの中から探し、返す二分探索
		if(data == null){
			return -1;
		}
//		System.out.println("lo");
//		System.out.println("lo");
		int max = data.size();
		int min = -1;

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data.get(mid) >= k){
				max = mid;
			}else{
				min = mid;
			}
		}

		return max;			//indexを返している
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}

class Pair implements Comparable{
	int from;
	int end;
	public Pair(int from,int end) {
		this.from = from;
		this.end = end;
		// TODO 自動生成されたコンストラクター・スタブ
	}

	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return  from - otherpair.from;
	}








}






Measured memory_bytes: 288408
n, m = map(int, input().split())

ans = 0
for i in range(1, int(m ** 0.5) + 1):
    if m % i == 0:
        if m // i >= n:
            ans = max(ans, i)
        if i >= n:
            ans = max(ans, m // i)
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>
#include<map>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
typedef pair<ll,ll> LL_LLP;
#define INF 1000000007
#define MAX_H 20000

#define ARRAY_MAX 100005

typedef struct union_find{
    
    int pa[ARRAY_MAX];
    int ra[ARRAY_MAX];  
    //vector<int> pa(ARRAY_MAX);//親
    //vector<int> ra(ARRAY_MAX);//木の深さ
    //n要素で初期化
    void init(int n){
        for(int i = 0;i < n;i++){
            pa[i] = i;/*各ノードに番号を振る,この時par[x]=xとなる時は木の根となる*/
            ra[i] = 0;/*各ノード自体の高さは0*/
        }
    }
    //木の根を求める
    int find(int x){
        if(pa[x] == x){
            return x;/*根ならそのノードの番号を返す*/
        }else{
            return pa[x] = find(pa[x]);/*根でないならさらにノードの根を探す*/
        }
    }

    //xとyの属する集合を併合する
    void unite(int x,int y){
        x = find(x);//xの根の番号を探す
        y = find(y);//yの根の番号を探す
        if(x == y){//一致すればつながっている
            return;
        }
        if(ra[x] < ra[y]){//xの高さが低いなら高いほうにつなぐ、そして高さは大きい方(y)になる
            pa[x] = y;
        }else{
            pa[y] = x;//yの高さが低いなら高いほうにつなぐ、そして高さは大きいほう(x)になる
            if(ra[x] == ra[y]){//高さが一致しているなら併合の高さは1増える
                ra[x]++;
            }
        }
    }

    //xとyが同じ集合に属するか判定
    bool same(int x,int y){
        return find(x) == find(y);//同じ集合なら1、違うなら0が返る
    }
}UF;

UF num;

int main(){

    int n,m;
    cin >> n >> m;
    vector<int> arr(n);
    REP(i,n){
        cin >> arr[i];
        arr[i]--;
    }
    num.init(n);

    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;
        b--;//配列の添え字に合わせる
        num.unite(a,b);
    }

    int ans = 0;
    REP(i,n){

        if(num.same(i,arr[i])){
            ans++;
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1408
readline()
a=0
b=0
T=zeros(Int,114514)
for x=map(x->parse(Int,x),split(readline()))
  if x<3200
    x=div(x,400)
    if T[x+1]==0
      a+=1
    end
    T[x+1]=1
  else
    b+=1
  end
end
println("$(a==0?1:a) $(a+b)")

Measured memory_bytes: 109956
#include <cstdio>

char str[2][200030];
int main() {
	scanf("%s", str[0]);
	scanf("%s", str[1]);
	int cnt = 0;
	for (int i = 0; str[0][i]; i++) {
		cnt += str[0][i] != str[1][i];
	}
	printf("%d", cnt);
  return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main()
{
    int n,m,x;
    vector<int>a;
    cin>>n>>m;
    for(int i=0; i<n; i++){
        cin>>x;
        a.push_back(x);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int p=0;
    for(int j=0;j<n;j++){
        p=p+a[j];
    }
    int q;
    if(p%(4*m)==0){
            q=p/(4*m);
    }
    else if(p%(4*m)!=0){
            q=p/(4*m)+1;
    }

    if(a[m-1]<q || n<m){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
}




Measured memory_bytes: 256
from math import sqrt
li=[]
for i in range(10000):
    n=int(input())
    if n>0:
        m=2*n
        b=int(sqrt(2*m))
        for i in range(b,0,-1):
            if m%i==0:
                A=(m/i+1-i)
                if A%2==0 and A>0:
                    a=int(A/2)
                    li.append([a,i])
                    break
    if n==0:
        break
for hoge in li:
    print(*hoge)


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main() {
  cin.sync_with_stdio(false);
  int d, n;
  cin >> d >> n;
  int ans = 1;
  if (d == 1) ans = 100;
  else if (d == 2) ans = 10000;
  if (n == 100) n++;
  cout << ans * n << endl;
  return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
using namespace std;

int main(){
  
  int n; cin >> n;
  vector<pair<int,int>> p(n);
  for (int i=0; i<n; i++){
    int a,b;
    cin >> a >> b;
    p[i]=make_pair(b,a);
  }
  
  sort(p.begin(),p.end());
  
  int s=0;
  int flag=1;
  
  for (int i=0; i<n; i++){
    s+=p[i].second;
    if (s>p[i].first){
      cout << "No";
      flag = 0;
      break;
    }
  }
  
  if (flag ==1) cout << "Yes"; 
 
  return 0;
}


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

void  ExtendedEuclid(int a, int b) {
  int r0 = a, r1 = b;
  int x0 = 1, x1 = 0;
  int y0 = 0, y1 = 1;
  int q, r2, x2, y2;

  while(r1 != 0) {
    q = r0 / r1;
    r2 = r0 % r1;
    x2 = x0 - q * x1;
    y2 = y0 - q * y1;
    r0 = r1;
    r1 = r2;
    x0 = x1;
    x1 = x2;
    y0 = y1;
    y1 = y2;
  }
  cout << x0 << " " << y0 << endl;
}

int extgcd(int a, int b, int &x, int &y) {
  int d = a;
  if(b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  }
  else {
    x = 1;
    y = 0;
  }
  return d;
}

int main() {
  int a, b, x, y;
  cin >> a >> b;
  //ExtendedEuclid(a, b);
  extgcd(a, b, x, y);
  cout << x << ' ' << y << endl;
  return 0;
}



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

using namespace std;

vector<int> d, A;

int calc(int p, int sum){
  if(p == d.size()) return sum % 10 == 0;
  int res = 0;
  for(int i=0;i<A.size();i++){
    int tmp = A[i] * d[p];
    res += calc(p + 1, sum + tmp / 10 + tmp % 10);
  }
  return res;
}

main(){
  int n, m;
  cin >> n;
  int f = n % 2 + 1, sum = 0;
  for(int i=0;i<n;i++){
    f = 3 - f;
    char c;
    cin >> c;
    if(c == '*'){
      d.push_back(f);
    }else{
      int tmp = (c - '0') * f;
      sum += tmp / 10 + tmp % 10;
    }
  }
  cin >> m;
  for(int i=0;i<m;i++){
    int in;
    cin >> in;
    A.push_back(in);
  }
  cout << calc(0, sum) << endl;
}

Measured memory_bytes: 1212
#include <iostream>
#include <iterator>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <cstring>
#include <stack>
#include <vector>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <limits>
#include <utility>
#define EPS (1e-10)
#define REP(i,n) for(int i=0;i<n;i++)
#define equals(a,b) (fabs((a) - (b)) < EPS)
#define ll long long
using namespace std;

//typedef pair<int,int> P;
//const ll MOD = 1000000007;
//const ll INF = 100000000;

const int max_K = 1000;
const int max_A = 1000;
int K, A, B;

//stack<int> stack;
//queue<int> que;
//priority_queue<int> pque;
//set<int> s; set<int>::iterator ite;
//multiset<int> ms; multiset<int>::iterator ite;
//map<int, int> m; map<int, int>::iterator ite;
//multimap<int, int> mm; multimap<int, int>::iterator ite;

//int dp[][];
//int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, -1, 0, 1};
//int dx[8] = {1, 1, 1, 0, -1, -1, -1, 0};
//int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};

void solve() {
  for(int i = A; i <= B; i++) {
    if(i % K == 0) {
      printf("OK\n");
      return;
    }
  }
  printf("NG\n");
  return;
}

int main(int argc, char const *argv[]) {

  scanf("%d", &K);
  scanf("%d %d", &A, &B);

  solve();
  return 0;
}



Measured memory_bytes: 3764
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <ctime>
#include <cstring>
#define ll long long
#define INF 1000000000
#define For(i,a,b) for(int i=a;i<=b;++i)
#define Rev(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define pq priority_queue
#define PI acos(-1)

namespace IO
{
#define p(x) ('0'<=x&&x<='9')
	char cc; int C;
	template <class T>
	void read( T &x )
	{
		x=0; cc=getchar(); C=1;
		while(!p(cc)) { if(cc=='-') C=-1; cc=getchar(); }
		while(p(cc)) { x=x*10+cc-48; cc=getchar(); }
		x*=C;
	}
#undef p
}

using namespace IO;
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	srand(time(0));
#ifdef LOCAL
	freopen("./tmp/input.txt", "r", stdin);
#endif

	int pt1[2],pt2[2],_[2],__[2];
	read(pt1[0]);read(pt1[1]); read(pt2[0]); read(pt2[1]);
	_[0]=pt2[0]-pt1[0];
	_[1]=pt2[1]-pt1[1];

		__[0]=-_[1];
		__[1]=_[0];
		pt1[0]=pt2[0]+__[0];
		pt1[1]=pt2[1]+__[1];

		_[0]=-__[1];
		_[1]=__[0];
		pt2[0]=pt1[0]+_[0];
		pt2[1]=pt1[1]+_[1];

	cout << pt1[0] << " " << pt1[1] << " " << pt2[0] << " " << pt2[1] << endl;



	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
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; }
const lint mod = 1e9 + 7, _INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };
typedef pair<double, lint> Pa;

lint N, arr[100];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N) cin >> arr[i];
	sort(arr, arr + N);
	lint cnt = 0;
	REP(i, N - 2) {
		FOR(j, i + 1, N - 1) {
			FOR(k, j + 1, N) {
				if (arr[i] != arr[j] && arr[j] != arr[k] && arr[i] + arr[j] > arr[k]) cnt++;
			}
		}
	}
	cout << cnt << endk;
}	

Measured memory_bytes: 3644
#include <iostream>
#include <utility>
using namespace std;
int main(void){
    int N;
    scanf("%d",&N);
    int A[N];
    for(int i=0;i<N;i++)scanf("%d",&A[i]);
    int minn=1145141919;
    int maxx=0;
    for(int i=0;i<N;i++){
        maxx=max(maxx,A[i]);
        minn=min(minn,A[i]);
    }
    printf("%d",maxx-minn);
    return 0;
}


Measured memory_bytes: 256
// 去吧！皮卡丘! 把AC带回来！
//      へ　　　　　／|
// 　　/＼7　　　 ∠＿/
// 　 /　│　　 ／　／								AC		AC		AC		AC
//    │　Z ＿,＜　／　　 /`ヽ						AC		AC		AC		AC
//    │　　　　　ヽ　　 /　　〉					AC		AC		AC		AC
// 　Y　　　　　`　 /　　/  /						AC		AC		AC		AC
// 　亻●　.　●　　〈　/　/						AC		AC		AC		AC
// 　()　 へ　　　　|　＼〈							AC		AC		AC		AC
// 　　>- ._　 ィ　 │ ／／							AC		AC		AC		AC
// 　 / へ　　 /　/＜| ＼＼							AC		AC		AC		AC
// 　 ヽ_/　　(_／　 │／／							AC		AC		AC		AC
// 　　 7　　　　　　　|／							AC		AC		AC		AC
// 　　 ＞―r￣￣`-―＿/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	string t;cin>>t;
	for(int i=0;i<t.size();i++)
	{
		if(t[i]=='?')cout<<'D';else cout<<t[i];
	}
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 3776