akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;
int n, m;
char ssd[100010];
int nmsl[100010];
struct node{
    int first;
    int last;
    int R, L;
}num[100010 / 2];
int cnt = 0;
int flag = 1;

int judgeR(int cnt){
    int sum = 0;
    int flag = 1;
//    cout << endl << "testR:";
//    cout << num[cnt].first << " " << num[cnt].R << " " << num[cnt].L << " " << num[cnt].last;
 //   cout << endl;
    for(register int i = num[cnt].R; i >= num[cnt].first; --i){
        if(flag){sum++;flag = 0;}
        else flag = 1;
    }
    flag = 0;
    for(register int i = num[cnt].L; i <= num[cnt].last; ++i){
        if(flag){sum++;flag = 0;}
        else flag = 1;
    }
    return sum;
}

int judgeL(int cnt){
//    cout << endl << "testL:";
//    cout << num[cnt].first << " " << num[cnt].R << " " << num[cnt].L << " " << num[cnt].last;
//    cout << endl;
    int sum = 0;
    int flag = 0;
    for(register int i = num[cnt].R; i >= num[cnt].first; --i){
        if(flag){sum++;flag = 0;}
        else flag = 1;
    }
    flag = 1;
    for(register int i = num[cnt].L; i <= num[cnt].last; ++i){
        if(flag){sum++;flag = 0;}
        else flag = 1;
    }
    return sum;
}

int main(){
    int i, j, k;
    scanf("%s",ssd+1);
    memset(nmsl,0,sizeof(nmsl));
    ssd[0] = 'x';
    n = strlen(ssd) - 1;
    for(i = 1; i <= n; ++i){
        if(ssd[i] == 'R' && flag == 1){
            flag = 0;
            num[cnt].last = i-1;
            num[++cnt].first = i;
        }
        if(ssd[i] == 'L' && flag == 0){
            flag = 1;
            nmsl[i] = cnt;
            nmsl[i-1] = cnt;
            num[cnt].L = i;
            num[cnt].R = i - 1;
        }
    }
    num[cnt].last = n;
    for(i = 1; i <= n; ++i){
        //printf("nmsl:%d\n",nmsl[i]);
        if(nmsl[i] == 0)printf("0 ");
        else {
            if(i == num[nmsl[i]].R){
                printf("%d ",judgeR(nmsl[i]));
            }
            if(i == num[nmsl[i]].L){
                printf("%d ",judgeL(nmsl[i]));
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1664
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  string s;
  cin >> s;
  bool flag = true;
  if(s.length()%2 != 0) flag = false;
  for(int i=0;i<s.length();i++){
    if(i%2 == 0 && s[i]!='h') flag = false;
    if(i%2 == 1 && s[i]!='i') flag = false;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main() {
  int N, D;
  cin >> N >> D;
  vector<vector<int>> Z(N,vector<int>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> Z[i][j];
    }
  }
  
  int pos = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      int d2 = 0;
      for (int k = 0; k < D; k++) {
        d2 += (Z[i][k]-Z[j][k]) * (Z[i][k]-Z[j][k]);
      }
      int dr = sqrt(d2);
      if (d2 == dr*dr) {
        pos += 1;
      }
    }
  }
  
  cout << pos << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
    if(c == '-') f = -1;
    c = getchar();
    }
    while(c >= '0' && c <= '9') {
    res = res * 10 + c - '0';
    c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,a[MAXN],s,cur;
bitset<4000005> dp[2];
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {read(a[i]);s += a[i];}
    dp[cur].reset();
    dp[cur][0] = 1;
    for(int i = 1 ; i <= N ; ++i) {
	dp[cur ^ 1] = (dp[cur] << a[i]) | dp[cur];
	cur ^= 1;
    }
    for(int i = (s - 1) / 2 + 1; i <= s ; ++i) {
	if(dp[cur][i]) {
	    out(i);enter;return;
	}
    }
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 2816
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

using ull_t = unsigned long long;

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    auto judge = [&]()
    {
        while (true)
        {
            C -= B;
            if (C <= 0) return true;
            A -= D;
            if (A <= 0) return false;
        }
    };

    cout << (judge() ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define N 100009
using namespace std;

int n,m,a[N],b[N],p[N],q[N],np[N]; long long tot;
int main(){
	scanf("%d",&n);
	int i; long long now; 
	for (i=1; i<=n; i++) scanf("%d",&a[i]);
	scanf("%d%lld",&m,&tot);
	for (i=1; i<=m; i++) scanf("%d",&b[i]);
	for (i=1; i<n; i++) p[i]=i;
	for (i=1; i<=m; i++) swap(p[b[i]-1],p[b[i]]);
	for (i=1; i<n; i++) q[i]=i;
	for (; tot; tot>>=1){
		if (tot&1){
			for (i=1; i<n; i++) np[i]=q[p[i]];
			for (i=1; i<n; i++) q[i]=np[i];
		}
		for (i=1; i<n; i++) np[i]=p[p[i]];
		for (i=1; i<n; i++) p[i]=np[i];
	}
	for (i=n; i>1; i--) a[i]-=a[i-1];
	for (i=1,now=a[1]; i<=n; now+=a[q[i]+1],i++)
		printf("%lld\n",now);
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> fac(ll n){
    vector<ll> v;
    for (int i=1; i<=sqrt(n); i++){
        if (n%i==0){
            if (i == n/i)v.push_back(i);
            else {
                v.push_back(i);
                v.push_back(n/i);
            }
        }
    }
    return v;
}
ll check(vector<ll> v, ll n){
    ll ans = n;
    for (int i=0; i<=v.size(); i++){
        if (n*v[i] <= ll(1e9))ans = n*v[i];
    }
    return ans;
}
int main(){
    int n; cin>>n;
    ll a[n];
    for (int i=0; i<n; i++)cin>>a[i];
    ll l[n], r[n];
    l[0] = a[0], r[n-1] = a[n-1];
    for (int i=1; i<n; i++)l[i] = __gcd(l[i-1], a[i]);
    for (int i=n-2; i>=0; i--)r[i] = __gcd(r[i+1], a[i]);
    // for (int i=0; i<n; i++)cout<<l[i]<<" ";cout<<endl;
    // for (int i=0; i<n; i++)cout<<r[i]<<" ";cout<<endl;
    ll arrgcd = r[0];
    ll ans = arrgcd;
    for (int i=0; i<n; i++){
        if (i==0){
            ll left = 0, right = r[i+1];
            ll gcd = __gcd(left, right);
            ans = max(ans, gcd);
        }
        else
        if (i==n-1){
            ll left = l[n-2], right = 0;
            ll gcd = __gcd(left, right);
            ans = max(ans, gcd);
        }
        else{
            ll left = l[i-1], right = r[i+1];
            ll gcd = __gcd(left, right);
            ans = max(ans, gcd);
        }
        // cout<<ans<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5944
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

int main() {
	string s;
	cin >> s;
	int sum = 0;
	for (auto c : s)sum += c == 'o';
	cout << 700 + 100 * sum << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(raw_input())
A = list(map(int,raw_input().split()))
B = list(map(int,raw_input().split()))
ans = 0
for i in range(0,N):
  if A[i] <= B[i]:
    ans = ans + A[i]
    B[i] = B[i] - A[i]
    A[i] = 0
    if A[i+1] >= B[i]:
      ans = ans + B[i]
      A[i+1] = A[i+1] -B[i]
    elif A[i+1] < B[i]:
      ans = ans + A[i+1]
      A[i+1] = 0
  elif A[i] > B[i]:
    ans = ans + B[i]
print ans

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

using namespace std;
typedef long long ll;

#define out(ans) cout << ans << endl
#define in(n) cin >> n
#define floop(i, N) for (ll i = 0; i < N; i++)
#define floop1(i, N) for (ll i = 1; i <= N; i++)
#define floopi(i, j, N) for (ll j = i + 1; j < N; j++)

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;
}

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

void solve();

int main()
{
    solve();
}

void solve()
{
    int n;
    in(n);
    string s;
    in(s);
    bool k = true;
    if (n % 2 == 1)
    {
        k = false;
    }
    floop(i, n / 2)
    {
        if (s[i] != s[n / 2 + i])
        {
            k = false;
            break;
        }
    }
    if (k)
    {
        out("Yes");
    }
    else
    {
        out("No");
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = 998244353;
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
void radd(int &a, int b)
{
	a=add(a,b); 
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
void rmult(int &a, int b)
{
	a=mult(a,b);
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
	
int a[3][111111];
vi adj[3][111111];
//wtf FWHT for 900 pts
int c[3][200000];

void fwht(int *data, int dim=131072) {
    for (int len = 1; 2 * len <= dim; len <<= 1) {
        for (int i = 0; i < dim; i += 2 * len) {
            for (int j = 0; j < len; j++) {
                int a = data[i + j];
                int b = data[i + j + len];
                
                data[i + j] = add(a,b);
                data[i + j + len] = add(a,MOD-b);
            }   
        }
    }
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int z=0;z<3;z++)
	{
		int m; cin>>m;
		for(int i=0;i<m;i++)
		{
			int u,v; cin>>u>>v;u--; v--;
			if(u>v) swap(u,v);
			adj[z][u].pb(v);
		}
	}
	ll C = ll(1e18);
	C%=MOD;
	int ans=0;
	for(int z=0;z<3;z++)
	{
		for(int i=n-1;i>=0;i--)
		{
			set<int> S;
			for(int v:adj[z][i])
			{
				S.insert(a[z][v]);
			}
			a[z][i]=0;
			while(S.find(a[z][i])!=S.end())
			{
				a[z][i]++;
			}
		}
	}
	for(int z=0;z<3;z++)
	{
		int curC=C;
		for(int i=0;i<n;i++)
		{
			c[z][a[z][i]]=add(c[z][a[z][i]],curC);
			curC=mult(curC,C);
		}
	}
	fwht(c[0]);
	fwht(c[1]);
	fwht(c[2]);
	for(int i=0;i<131072;i++)
	{
		c[0][i]=mult(c[0][i],c[1][i]);
		c[0][i]=mult(c[0][i],c[2][i]);
	}
	fwht(c[0]);
	int invv = modpow(131072,MOD-2);
	cout<<mult(c[0][0],invv)<<'\n';
}


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

int N, M, C;
int B[20];
int A[20][20];

int main() {
    cin >> N >> M >> C;
    rep(i, M) {
        cin >> B[i];
    }

    rep(i, N)rep(j, M) cin >> A[i][j];

    int ans = 0;
    rep(i, N) {
        int target = 0;
        rep(j, M) {
            target += A[i][j] * B[j];
        }

        if (target + C > 0) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
// #define mp make_pair
#define nt _int128 
#define fir first
#define sec second
#define fast_as_levi ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define inf 0x3f3f3f3f

const ll wx[4]={0,0,1,-1},wy[4]={1,-1,0,0}; 
const ll mod = 998244353;
#define mx 100005
const ll mxi = 2e3 + 5;

ll n,m;
bool mp[21][21];
bool ar[21][21];

struct Node 
{
    ll x,y,bt;
}
q[100000];
ll bfs(ll x,ll y)
{
    ll i,j;
    ll l=1,r=1;
    memset(ar,0,sizeof(ar));
    q[1].bt=0;
    q[1].y=y;
    q[1].x=x;
    ar[x][y]=1;
    while(l<=r)
    {
        for(i=0;i<4;++i)
        {
            ll tx=q[l].x+wx[i],ty=q[l].y+wy[i];
            if(mp[tx][ty]==1||ar[tx][ty]==1||tx<=0||ty<=0||tx>n||ty>m)
            continue;
            q[++r].x=tx,q[r].y=ty;
            q[r].bt=q[l].bt+1;
            ar[tx][ty]=1;
        }
        ++l;
    }
    return q[r].bt;
}
int main()
{
    ll i,j,ans=0;
    cin>>n>>m;
    for(i=1;i<=n;++i)
    {
        for(j=1;j<=m;++j)
        {
            char ch;
            cin>>ch;
            if(ch=='#')
            mp[i][j]=1;
        }
    }
    for(i=1;i<=n;++i)
    {
        for(j=1;j<=m;++j)
        {
            if(!mp[i][j])
            ans=max(ans,bfs(i,j));
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int k = sc.NextInt();
        Console.WriteLine((k / 2) * ((k + 1) / 2));

    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27444
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> paii;
typedef complex<double> P;

double ccw(P& p1, P& p2, P& p3)
{
	return ((p2.real() - p1.real())*(p3.imag() - p1.imag()) 
				- (p2.imag() - p1.imag())*(p3.real() - p1.real())) > 0;
}// ccw>0 ...ccw, ccw=0 ...colinear, ccw<0 ...cw

int main()
{
	int n;
	cin >> n;
	
	while(n--)
	{
		double x1, x2, x3, y1, y2, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		
		double a1 = 2*(x2-x1);
		double b1 = 2*(y2-y1);
		double c1 = x1*x1-x2*x2+y1*y1-y2*y2;
		double a2 = 2*(x3-x1);
		double b2 = 2*(y3-y1);
		double c2 = x1*x1-x3*x3+y1*y1-y3*y3;
		
		double xp = (b1*c2-b2*c1)/(a1*b2-a2*b1);
		double yp = (c1*a2-c2*a1)/(a1*b2-a2*b1);
		double r = hypot((xp-x1), (yp-y1));
		
		cout.precision(3);
		printf("%.3f %.3f %.3f\n", xp,yp, r);
	}
	
	return 0;
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

const int N = 10005;

int dp[N];
int A[N], B[N];

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int h, n;
    cin >> h >> n;
    FOR(i,1,n){
        cin >> A[i] >> B[i];
    }
    FOR(i,0,h){
        dp[i] = N * N;
    }
    dp[0] = 0;
    FOR(i,1,h){
        FOR(j,1,n){
            dp[i] = min(dp[i], B[j] + dp[max(0, (int)i - A[j])]);
        }
    }
    cout << dp[h];

    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
const int MAX_N = 85;
const int MAX_E = MAX_N * 4 + 10;

int main() {
  int T; cin >>T;
  REP(t, T){
    int N; cin >>N;
    vector<int> v(N); REP(i, N) cin >>v[i];
    if(N <= 2) { cout <<v[N - 1] <<endl; continue; }

    int dp[MAX_N][MAX_E];
    memset(dp, -1, sizeof(dp));
    dp[1][v[0]] = v[1];
    FOR(i, 1, N - 1){
      REP(j, MAX_E){
        if(dp[i][j] == -1) continue;
        dp[i + 1][dp[i][j]] = max(dp[i + 1][dp[i][j]], v[i + 1]);
        if(dp[i][j] > 0) dp[i + 1][dp[i][j] - 1] = max(dp[i + 1][dp[i][j] - 1], v[i + 1] + j);
      }
    }
    int ans = 0;
    REP(i, MAX_E) ans = max(ans, dp[N - 1][i]);
    cout <<ans <<endl;
  }
  return 0;
}

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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

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

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

ll getans(int a, int b) {
	ll k = 1;
	ll ans = 0;
	REP(i,b) {
		ans += a*k;
		k*=10;
	}
	return ans;
}

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

	if(n<m) {
		ans = getans(n,m);
	} else {
		ans = getans(m,n);
	}
	cout << ans << endl;

	return 0;
}




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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, y;
    cin >> x;
    y = int((100 * x)/108);
    for(int i = 1; i <= 46297; i++) {
        if((i*108)/100 == x) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


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

using namespace std;

int main(){
    int N, Q;
    while(cin >> N >> Q){
        vector<int> A(N);
        for(int& t : A) cin >> t;
        vector<long long> sum(N+1, 0);
        for(int i=0;i<N;i++) sum[i+1] = sum[i] + A[i];
        vector<long long> rest(N, 0);
        if(N%2==0){
            rest[1] = A[1];
            for(int i=3;i<N;i+=2) rest[i] = rest[i-2] + A[i];
        } else {
            rest[0] = A[0];
            for(int i=2;i<N;i+=2) rest[i] = rest[i-2] + A[i];
        }
        for(int i=0;i<Q;i++){
            int X; cin >> X;
            int L = 1, R = N;
            while(R-L > 1){
                int mid = (L+R)/2;
                int last = N-mid;
                int last_a = N-2*mid+1;
                if(last_a >= 0 && abs(A[last]-X) >= abs(A[last_a]-X)) L = mid;
                else R = mid;
            }
            long long res = sum.back() - sum[N-L];
            if(N-1-2*L>=0) res += rest[N-1-2*L];
            cout << res << endl;
        }
    }
}

Measured memory_bytes: 3712
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include <tuple>

using namespace std;
using ll = long long;
using ld = long double;
//#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define rng(i,s,n) for(int (i) = (s) ; (i) < (n) ; (i)++)
#define req(i,n) for(int (i) = (n) - 1 ; (i) >= 0 ; (i)--)
#define mkp make_pair
#define mem0(x) memset(x,0,sizeof(x))
#define vec vector
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
#define ctoi(c) (int)(c-'A')
#define itoc(c) (char)(c+'A')
#define pb push_back
#define cauto const auto&
#define itn int
#define pri_que priority_queue
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll inf = 3 * 1e18;
const int Inf = 15 * 1e8;
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; }
ll read() { ll u, k = scanf("%lld", &u); return u; }
string reads() { string s; cin >> s; return s; }
ll gcd(ll i, ll j) { return j ? gcd(j, i % j) : i; }
ll mod_pow(ll x, ll n, ll p = mod) {
	ll res = 1;
	while (n > 0) { if (n & 1) res = res * x % p; x = x * x % p; n >>= 1; }
	return res;}
ll bitcount(ll x) {
	int sum = 0; for (int i = 0; i < 60; i++)if ((1ll << i) & x) sum++;
	return sum;}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------------------
signed main() {
	int n;
	vec<string>s;
	vec<int>t;
	string r;
	cin >> n;
	rep(i, n) {
		s.pb(reads());
		t.pb(read());
	}
	cin >> r;
	bool l = 0;
	int ans = 0;
	rep(i, n) {
		if (l) ans += t[i];
		if (s[i] == r) {
			l = 1;

		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int T;
    cin >> T;
    rep(t, T){
        int N; cin >> N;
        ll A[N];
        rep(i, N) cin >> A[i];
        string S; cin >> S;
        vector<ll> mat;
        int ref[60];
        fill(ref, ref+60, -1);
        int ans = 0;
        rep3(i, N-1, 0){
            ll memo = A[i];
            rep(j, 60){
                if(ref[j] != -1 && (memo & (1LL<<j))) memo ^= mat[ref[j]];
            }
            mat.pb(memo);
            rep(j, 60){
                if(memo & (1LL<<j)){
                    ref[j] = N-1-i;
                    if(S[i] == '1') ans = 1;
                    break;
                }
            }
        }
        cout << ans << endl;
    }
}

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

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v){
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}


void solve(int &test) {
    map<string , int> m;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        m[s]++;
    }
    std::vector<string > v = {
         "AC", "WA", "TLE", "RE",
    };
    for(auto u : v){
        cout << u << " x " << m[u] << endl;
    }
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;

    start = clock(); 

    cout << fixed << setprecision(2);
    
   
     
    for(int i = 1; i <= t; ++i){
        solve(i);
    }
    cerr << time(start);
    return 0;
}

Measured memory_bytes: 3852
using System;

namespace Atcoder0629
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            char c = S[0];
            for(int i = 1;i < 4; i++)
            {
                if (S[0] == S[i])
                {
                    S = S.Remove(i,1);
                    S = S.Remove(0, 1);
                    break;
                }
            }
            if (S[0] == S[1] && S[0]!=c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadLine();
            return;
        }
    }
}


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

int main(int argc, const char * argv[]) {
    
    char s[5];
    
    cin >> s;
    
    if(s[0] == s[1]){
        if(s[2] == s[3] && s[0] != s[2]){
            cout << "Yes";
        } else{
            cout << "No";
        }
    } else if(s[0] == s[2]){
        if(s[1] == s[3] && s[0] != s[1]){
            cout << "Yes";
        } else{
            cout << "No";
        }
    } else if(s[0] == s[3]){
        if(s[2] == s[1] && s[0] != s[2]){
            cout << "Yes";
        } else{
            cout << "No";
        }
    } else cout << "No";
    
    return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

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() {
  int N, M, K;
  cin >> N >> M >> K;
  vector<vector<int>> graph_m(N);
  vector<vector<int>> graph_k(N);
  vector<set<int>> set_k(N);

  int A, B;
  rep(i, 0, M) {
    cin >> A >> B;
    A--; B--;
    graph_m[A].pb(B);
    graph_m[B].pb(A);
  }

  int C, D;
  rep(i, 0, K) {
    cin >> C >> D;
    C--; D--;
    graph_k[C].pb(D);
    graph_k[D].pb(C);
    set_k[C].insert(D);
    set_k[D].insert(C);
  }

  vector<bool> color(N, false);

  vector<int> ans(N, 0);

  rep(i, 0, N) {
    vector<int> tree;
    set<int> s_tree;

    int u = i;
    queue<int> q;
    q.push(u);

    while (!q.empty()) {
      int v = q.front(); q.pop();
      if (color[v]) continue;
      color[v] = true;
      tree.pb(v);
      s_tree.insert(v);

      for (int w: graph_m[v]) {
        if (color[w]) continue;
        q.push(w);
      }
    }

    // for (int tmp: tree) {
    //   cout << tmp;
    // }
    // cout << endl;

    int size = tree.size();

    for (auto v: tree) {
      int block_cnt = 0;
      for(auto w: graph_k[v]) {
        if (Find(s_tree, w) ) {
          block_cnt++;
        }
      }
      ans[v] = (size - 1) - block_cnt - graph_m[v].size();
    }
  }

  rep(i, 0, ans.size()) {
    if (i < ans.size() - 1) {
      printf("%d ", ans[i]);
    } else {
      printf("%d\n", ans[i]);
    }
  }
};


Measured memory_bytes: 30960
#include<stdio.h>
int main(){
	int a=38;
	char A;
	while(1){
	while(A!='\n'){
	scanf("%c",&A);
	a+=A-'0';
}
a-=1;
if(a==-1)
break;
a++;
printf("%d\n",a);
A='a';
a=38;
	}
	return 0;
}

Measured memory_bytes: 536
#include <bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define sz size()
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

#define ll long long

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

	int n,k;
	cin>>n>>k;

	std::vector<int> a(n);
	int i;
	for (i=0;i<n;i++) cin>>a[i];

	ll lo = 1, hi = *max_element(all(a));

	while (lo<hi) {
		ll mid = lo+((hi-lo)>>1);
		ll br=0ll;
		for (i=0;i<n;i++)
		if (a[i]>mid) {
			br += ceil((double)a[i]/mid);

			if (br>n+k) {
				break;
			}
		} else
			br++;

		if (br>n+k) {
			lo = mid+1;
		} else
			hi = mid;
	}

	cout<<hi<<"\n";

    return 0;
}

Measured memory_bytes: 3908
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

const double PI = acos(-1);

int main() {
    double a = read(), b = read(), x = read();
    if (fabs(x - a * a * b) < 1e-9) {
        puts("0");
        return 0;
    }
    double l1 = 2 * x / a / a - b;
    if (l1 >= 0) {
        long double l2 = b - l1;
        printf("%.19Lf\n", atan(l2 / a) * 180 / PI);
        cerr << "=======\n";
    } else {
        long double l = 2 * x / a / b;
        printf("%.19Lf\n", atan(b / l) * 180 / PI);
        cerr << "====\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
typedef double db;
const int N=1e6+5,mo=1e9+7;
int fac[N],rev[N],i,cnt1,f[N],w[N],ans,n;
int ksm(int x,int y)
{
	if (y<0) y=1ll*(-y)*(mo-2)%(mo-1);
	int ret=1;
	while (y)
	{
		if (y&1) ret=1ll*ret*x%mo;
		y>>=1;
		x=1ll*x*x%mo;
	}
	return ret;
}
int c(int m,int n)
{
	return 1ll*fac[m]*rev[n]%mo*rev[m-n]%mo;
}
void predo(int n)
{
	fac[0]=1;
	fo(i,1,n) fac[i]=1ll*fac[i-1]*i%mo;
	rev[n]=ksm(fac[n],mo-2);
	fd(i,n,1) rev[i-1]=1ll*rev[i]*i%mo;
}
int calc(int x)
{
	//2*x-n+2=cnt1
	cnt1=2*x-n+2;
	if (cnt1>x||cnt1<0) return 0;
	return c(x,cnt1);
}
int main()
{
	scanf("%d",&n);
	predo(n);
	fo(i,0,n-2)
	{
		f[i]=1ll*c(n-2,i)*fac[i]%mo;
		w[i]=calc(i-1);
		f[i]=(f[i]+1ll*c(n-2,i-1)*fac[i]-1ll*w[i]*fac[i])%mo;
		if (!i) f[i]=1;
		ans=(ans+1ll*f[i]*fac[n-1-i])%mo;
	}
	if (ans<0) ans+=mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 15744
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

int n; 
ll a[20][20];
ll dp[1<<21];
bool flag[1<<21];

ll f(int S) {
    if(flag[S]) return dp[S];
    flag[S] = 1;
    ll res = 0; //切らないという選択肢
    rep(i, n) {
        for(int j = i + 1; j < n; ++j) {
            if(S & (1<<i)) {
                if(S & (1<<j)) {
                    res += a[i][j];
                }
            }
        }
    }
    for(int T = S;; T = (T - 1) & S) {
        ll tmp = f(T) + f(S ^ T);
        if(res < tmp) res = tmp;
        if(T == 0) break;
    }
    return dp[S] = res;
}

void solve() {
    cin >> n;
    rep(i, n) {
        rep(j, n) {
            cin >> a[i][j];
        }
    }
    memset(flag, 0, sizeof(flag));
    ll ans = f((1<<n) - 1);
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 4352
N=int(input())
A=list(map(int,input().split()))
p=[None]*N
for i,a in enumerate(A):
    p[a-1]=i
ans=0
l,r=[i for i in range(N)],[i for i in range(N)]
for i in range(N-1,-1,-1):
    left,right=l[p[i]],r[p[i]]
    ans+=(i+1)*(p[i]-left+1)*(right-p[i]+1)
    if left>0:
        r[left-1]=right
    if right<N-1:
        l[right+1]=left
print(ans)

Measured memory_bytes: 35808
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  string s;
  cin>>k;
  cin>>s;
  if(s.length()<=k)
    cout<<s;
  else{
    for(int i=0;i<k;i++)
      cout<<s[i];
    cout<<"...";
  }
}


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

int main(){

    int i, j;
    int N, M;
    string s[101], t[101];
    
    cin >> N;
    for(i = 0; i < N; i++){
        cin >> s[i];
    }
    cin >> M;
    for(i = 0; i < M; i++){
        cin >> t[i];
    }

    int count, max = 0;
    for(i = 0; i < N; i++){
        count = 0;
        for(j = 0; j < N; j++){
            if(s[i] == s[j]) count++;
        }
        for(j = 0; j < M; j++){
            if(s[i] == t[j]) count--;
        }
        if(max < count) max = count;
    }

    cout << max << endl;

    return 0;
}

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

const int nax = 1e5 + 5;
vector<int> edges[nax];
int in_degree[nax];
int dist[nax];
bool visited[nax];
void dfs(int a){
    visited[a] = true;
    for(int b:edges[a])
    {
        dist[b] = max(dist[b],dist[a]+1);
        --in_degree[b];
        if(in_degree[b] == 0)
        {
            dfs(b);
        }
    }
}

int main()
{
    int n,m;
    cin >> n >> m;
    
    while(m--)
    {
        int a,b;
        cin >> a >> b;
        edges[a].push_back(b);
        ++in_degree[b];
    }
    for(int i=1;i<=n;++i)
    {
        if(!visited[i] && in_degree[i]==0)
        dfs(i);
    }
    int answer = 0;
    for(int i=1;i<=n;++i)
    {
        answer = max(answer,dist[i]);
    }   
    cout << answer;
}

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

using namespace std;
using ll = long long;

int main() {
  int b;
  int lb, num;
  while (cin >> b, b) {
    for (int k = 1; k < 1e5; k++) {
      double l = 1.0 * (2 * b - k * k + k) / (2 * k);
      if (l < 1) break;
      if (floor(l) != ceil(l)) continue;
      lb = l;
      num = k;
    }
    cout << lb << ' ' << num << endl;
  }
  return 0;
}



Measured memory_bytes: 3068
#include<bits/stdc++.h>
#define boost ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long ll;
const int maxn=1e5+5;
using namespace std;
int n,m;
inline int read() {
	char ch = getchar();
	int x = 0, f = 1;
	while (ch < '0' || ch > '9')
		f = (ch == '-' ? -1 : 1), ch = getchar();
	while (ch >= '0' && ch <= '9')
		x = x * 10 + ch - 48, ch = getchar();
	return x * f;
} 

int main(){
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2;
	return 0;
}

Measured memory_bytes: 256
upper_lim, sum_min, sum_max = gets.split.map(&:to_i)

sum_range = (sum_min..sum_max)

sum_of_n = 0

1.upto upper_lim do |n|
  dsum = 0
  d = n
  loop do
    if d < 10
      dsum += d
      break
    end

    d, m = d.divmod(10)
    dsum += m
  end

  if sum_range.include?(dsum)
    sum_of_n += n
  end
end

puts sum_of_n


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN=1000+100;
struct routes
{
	int c,t; 
}a[MAXN];
bool cmp(routes a,routes b)
{
	return a.c<b.c;
}
int main()
{
	int N,T;
	bool pd=true;
	cin>>N>>T;
	for(int i=0;i<N;i++)
		cin>>a[i].c>>a[i].t;
	sort(a,a+N,cmp);
	for(int i=0;i<N;i++)
	{
		if(a[i].t<=T)
		{
			cout<<a[i].c;
			pd=false;
			break;
		}
	}
	if(pd)
	cout<<"TLE";	
	return 0;		
}

Measured memory_bytes: 256
use std::collections::HashMap;
use std::io::stdin;

fn solve(matrix: HashMap<u32, HashMap<u32, u64>>, num_node: u32) -> u32 {
    let mut visited: Vec<bool> = vec![false; num_node as usize];
    let mut count = 0;

    while let Some(&root_index) = matrix.keys().filter(|&&i| !visited[i as usize - 1]).next() {
        count += 1;
        let mut index_stack: Vec<u32> = Vec::new();
        visited[root_index as usize - 1] = true;
        index_stack.push(root_index as u32);

        while let Some(index) = index_stack.pop() {
            if let Some(col) = matrix.get(&(index)).map(|it| it.iter()) {
                for (&i, _) in col {
                    if !visited[i as usize - 1] {
                        index_stack.push(i);
                        visited[i as usize - 1] = true;
                    }
                }
            }
        }
    }
    return visited.into_iter().filter(|&it| !it).count() as u32 + count;
}

fn main() {
    let mut input = String::new();
    let _ = stdin().read_line(&mut input).unwrap();
    let n_m = input
        .trim()
        .split(" ")
        .map(|s| s.to_string().parse::<u32>().unwrap())
        .collect::<Vec<u32>>();

    let num_node = n_m[0];
    let m = n_m[1];

    let mut graph: HashMap<u32, HashMap<u32, u64>> = HashMap::new();

    for (x, y, z) in (1..(m + 1)).map(|_| {
        let mut input = String::new();
        let _ = stdin().read_line(&mut input).unwrap();
        let input: Vec<String> = input.trim().split(" ").map(|s| s.to_string()).collect();
        assert_eq!(3, input.len());
        (
            input[0].parse::<u32>().unwrap(),
            input[1].parse::<u32>().unwrap(),
            input[2].parse::<u64>().unwrap(),
        )
    }) {
        if !graph.contains_key(&x) {
            graph.insert(x, HashMap::new());
        }
        if !graph.contains_key(&y) {
            graph.insert(y, HashMap::new());
        }
        graph.get_mut(&x).unwrap().insert(y, z);
        graph.get_mut(&y).unwrap().insert(x, z);
    }

    println!("{}", solve(graph, num_node));
}


Measured memory_bytes: 94460
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int s;
    cin>>s;
    int P[1000]={};
    P[0]=s;
    for(int i=1;i<1000;i++){
        if(P[i-1]%2==0){
            P[i]=P[i-1]/2;
        }
        else{
            P[i]=P[i-1]*3+1;
        }
        for(int j=0;j<=i;j++){
            if(P[j]==P[i] & j!=i){
                cout<<i+1<<endl;
                return 0;
            }
        }
    }
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(b%a==0)cout << a+b << endl;
  else cout << b-a << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

# dは隣接頂点間のコスト、Nは頂点の個数
def warshall_floyd(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if d[i][j] > d[i][k] + d[k][j]:
                    print(-1)
                    sys.exit()
                elif d[i][j] == d[i][k] + d[k][j] and k != i and k != j:
                    delete[i][j] = True
                    delete[j][i] = True                 
    return d

N = int(input())
inf = float("inf")
delete = [[False]*N for _ in range(N)]
# input

# d[i][v]:辺(i, v)間のコスト、存在しなければinf
d = [[int(x) for x in input().split()] for _ in range(N)]
d = warshall_floyd(d)

ans = 0

for i in range(N):
    for j in range(i + 1, N):
        if delete[i][j]:
            continue
        ans += d[i][j]
print(ans)

Measured memory_bytes: 45148
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

vector<int> G[MAX_N];
bool flag[MAX_N];
vector<int> rt;
bool ed;
int n;

void dfs(int u,int *dp)
{
    int res = 1;
    flag[u] = true;
    rep(i,G[u].size()){
        if(!flag[G[u][i]]){
             dfs(G[u][i],dp);
             res += dp[G[u][i]];
        }
    }
    dp[u] = res;
}

void check(int u)
{
    flag[u] = true;
    rt.pb(u);
    if(u == n-1){
        ed = true;
        return;
    }
    rep(i,G[u].size()){
        if(!flag[G[u][i]]){
            check(G[u][i]);
            if(ed){
                break;
            }
            rt.pop_back();
        }
    }
}

int dp1[MAX_N];
int dp2[MAX_N];

int main()
{
    cin >> n;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        G[a-1].pb(b-1);
        G[b-1].pb(a-1);
    }
    rep(i,n){
        dp1[i] = 0;
        dp2[i] = 0;
    }
    rep(i,n){
        flag[i] = false;
    }
    dfs(0,dp1);
    rep(i,n){
        flag[i] = false;
    }
    dfs(n-1,dp2);
    rep(i,n){
        flag[i] = false;
    }
    check(0);
    int cnt = (int)rt.size();
    int id = (cnt+1)/2 -1;
    int res1 = dp2[rt[id]];
    int res2 = dp1[rt[id+1]];
    if(res1 > res2){
        cout << "Fennec\n";
    }else{
        cout << "Snuke\n";
    }
    return 0;
}


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

#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)

int s[16][16] = {};

int sol(int i, int j) {
	if(s[i][j] > 0)return s[i][j];
	if(s[i][j] < 0)return 0;
	if(i>0) s[i][j] += sol(i-1, j);
	if(j>0) s[i][j] += sol(i, j-1);
	return s[i][j];
}

int main() {
	ios::sync_with_stdio(false);
	
	int a, b, n, x, y;
	
	while(1) {
		cin >> a >> b;
		if(!(a|b))break;
		cin >> n;
		
		rep(i, a) {
			rep(j, b) {
				s[i][j] = 0;
			}
		}
		
		s[0][0] = 1;
		
		rep(i, n) {
			cin >> x >> y;
			s[x-1][y-1] = -1;
		}
		
		cout << sol(a-1, b-1) << endl;
		
	}
	
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  int ans=1;
  for(int i=0;i<n-1;i++){
    if(a[i]!=a[i+1]){
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll k,x;
    while(cin>>k>>x)
    {

        if((k*500)>=x)
        {

            cout<<"Yes"<<'\n';
        }
        else
            cout<<"No"<<'\n';
    }

}



Measured memory_bytes: 256