akhauriyash/Code-Regression huggingface dataset:
#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 <climits>

#define rep(i, a, n) for(int i=a;i < n;i++)
#define all(e) e.begin(), e.end()
#define INF (1 << 30)
#define INFL (1LL << 55)
#define EPS 1e-9

using namespace std;

struct Solve {
    vector<int> bh;
    int r;
    int zero = 20;

    bool gt(double a, double b) {
        double tmp = a - b;
        return tmp > EPS;
    }


    bool check(double y) {
        for (int i = -19; i < 20; ++i) {
//            if (2 * abs(i) > r) continue;
//            if (r * r < i * i) continue;
            vector<double> kouho;
            for (int di = -1; di <= 0; ++di) {
//                if (abs(i + di) <= r) {
//                    kouho.push_back(bh[zero + i + di]);
//                }
                if (i == 0) {
                    kouho.push_back(bh[zero + i + di]);
                } else if (i < 0) {
                    if (abs(i + di) <= r)
                        kouho.push_back(bh[zero + i + di]);
                } else if (i > 0) {
                    if (abs(i + di) < r)
                        kouho.push_back(bh[zero + i + di]);
                }
            }
            if (kouho.size() == 0) continue;
            double h = *min_element(all(kouho));
//            double h = bh[zero + i];
//            if (i > 0) h = bh[zero + i - 1];
//            if (i == 0) h = min(bh[zero + i - 1], bh[zero + i]);

            double sh = sqrt(1.0 * r * r - i * i) + (1.0 * y - r);
            if (gt(sh, h))
                return false;
        }
        return true;
    }

    bool solve() {
        bh.resize(40, 0);
        int n;
        cin >> r >> n;
        if (r == 0 && n == 0) return false;
        for (int i = 0; i < n; ++i) {
            int xl, xr, h;
            cin >> xl >> xr >> h;
            for (int x = xl + zero; x < xr + zero; ++x) {
                bh[x] = max(bh[x], h);
            }
        }

//        double lb = 0, ub = 100.0;
        double ok = 0.0, ng = 100.0;
        check(3.0);

        for (int _ = 0; _ < 100; ++_) {
            double mid = (ok + ng) / 2;
            if (check(mid)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
//        cout << lb << endl;
        printf("%.5f\n", ok);
        return true;
    }
};

int main() {
    while (Solve().solve()) {
    }
    return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>
 
#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
 
ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);
 
 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}
 
void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}
 
void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
 
    ll q=1;
    //cin>>q;
    while(q--)
    {
        ll n,k;
        cin>>n>>k;
        ll a[n];
        REP(i,0,n)
        {
            ll t;
            cin>>t;
            a[i]=t;
        }
        ll dp[k+1];
        dp[0]=1;
        REP(i,1,k+1)
        {
            dp[i]=1;
            REP(j,0,n)
            {
                if(i-a[j]>=0)
                {
                    if(dp[i-a[j]]==1)
                    {
                        dp[i]=0;
                    }
                }
            }
        }
        if(dp[k]==0) cout<<"First";
        else cout<<"Second";
    }
 
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> ans;
  for (int i = min(a, b); i >= 1; --i) {
    if (a % i == 0 && b % i == 0) ans.push_back(i);
  }
  cout << ans[k - 1] << endl;
  return 0;
}

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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;

int main(int argc, char *argv[]) {
    ll n;
    cin >> n;
    vector<ll> t(n);
    ll sum = 0;

    REP(i, n) {
        cin >> t[i];
        sum += t[i];
    }

    ll m;
    cin >> m;
    vector<pair<ll, ll>> v;
    REP(i, m) {
        ll tp, tx;
        cin >> tp >> tx;
        v.emplace_back(tp, tx);
    }

    REP(i, m) {
        MSG(sum - t.at(v.at(i).first - 1) + v.at(i).second)
    }
}


Measured memory_bytes: 256
n=int(input())
l=0
r=n
print(0)
l_color=input()[0]
for i in range(19):
	ans=(r-l)//2+l
	print(ans)
	x=input()[0]
	if x=="V":
		exit()
	elif (x==l_color and (ans-l)%2==1) or (x!=l_color and (ans-l)%2==0):
		r=ans
	else:
		l=ans
		l_color=x

Measured memory_bytes: 3660
import java.util.Scanner;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = 0;
    if(a > 9 || b > 9){
      System.out.println(-1);
      System.exit(0);
    }
    c = a * b;
    System.out.println(c);
  }
}

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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair <int, int> pii;
typedef long double ld;
typedef vector <ll> vi;

const int N = 2e6 + 1;
const ll INF = 1e18 + 9;
const int B = 1e9 + 7;

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    int n;
    string s, t;
    cin >> n >> s >> t;
    int ans = n * 2;
    forn(i, 1, n) {
        bool shit = 0;
        forn(j, n - i, n - 1)
            if (s[j] != t[j - (n - i)]) shit = 1;
        if (!shit) ans = n * 2 - i;
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main () {
    int i, j, n, x, y, z;
    int m[200][200] = { 0 };
 
    scanf("%d", &n);
 
    for (i = 0; i < n; i++) {
        scanf("%d", &x);
        scanf("%d", &y);
 
        for (j = 0; j < y; j++) {
            scanf("%d", &z);
            m[x - 1][z - 1]++;
        }
    }
     
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            printf("%d", m[i][j]);
 
            if (j != n - 1) {
                putchar(' ');
            }
        }
        putchar('\n');
    }
 
    return 0;
}



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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n; cin >> n;
	vector<string>s(n);
	rep(i, n)cin >> s[i];

	map<char, int>mp;
	vector<ll>p(5);
	rep(i, n) {
		if (s[i].at(0) == 'M')p[0]++;
		if (s[i].at(0) == 'A')p[1]++;
		if (s[i].at(0) == 'R')p[2]++;
		if (s[i].at(0) == 'C')p[3]++;
		if (s[i].at(0) == 'H')p[4]++;
		}
	ll ans = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = i + 1; j < 4; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += p[i] * p[j] * p[k];
			}
		}
	}
	cout << ans << endl;
}


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

using namespace std;

int n, W, wt[100001], v[100001];
long long dp[2][100001];

int main()
{
	cin >> n >> W;
	for (int i = 0; i < n; i++)
		cin >> wt[i] >> v[i];
	for (int i = 0; i <= n; i++)
	{
		int index = i & 1;
		for (int j = 0; j <= W; j++)
		{
			if (i == 0 || j == 0)
				dp[index][j] = 0;
			else if (j >= wt[i - 1])
				dp[index][j] = max(v[i - 1] + dp[1 - index][j - wt[i - 1]], dp[1 - index][j]);
			else
				dp[index][j] = dp[1 - index][j];
		}
	}
	cout << dp[n & 1][W] << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

const int TRUE = 1;
const int FALSE = 0;
int main(){
    int a, b;
    scanf("%d%d", &a, &b);
    char s[100];
    scanf("%s", s);

    int ans = TRUE;
    int i = 0;
    for(; i < a; i++){
        if(s[i] >= '0' && s[i] <= '9'){
            continue;
        }else{
            ans = FALSE;
        }
    }

    if(s[i++] != '-'){
        ans = FALSE;
    }

    for(; i < a + b + 1; i++){
        if(s[i] >= '0' && s[i] <= '9'){
            continue;
        }else{
            ans = FALSE;
        }
    }

    printf("%s\n", ans ? "Yes" : "No");

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second
const long long mod = 1000000007;
 
int N;
string s;
vector<pair<int, int> > vp; // 0--F  1--T
vector<int> hor, ver;
int xf, yf, xin = 0, yin = 0, abx, aby;
 
const int U = 2, V = 18000;
int dp[U][V];
void initialize() {
    for(int i = 0;i < U;i++) {
        for(int j = 0;j < V;j++) {
            dp[i][j] = 0;
        }
    }
}
 
bool possible(int n, vector<int> &A, int ax) {
    //cout << ax << endl;
    dp[0][9000] = 1;
    for(int i = 0;i <= n;i++) {
        for(int j = 0;j < V;j++) {
            if(dp[0][j]) {
                dp[1][j-A[i]] = dp[1][j+A[i]] = 1;
            }
        }
        for(int j = 0;j < V;j++) {
            dp[0][j] = dp[1][j];
            dp[1][j] = 0;
        }
    }
    return dp[0][9000+ax];
}
 
int main() {
    cin >> s;
    N = s.size();
    cin >> xf >> yf;
    int i = 0, j = 0;
    while(j < N) {
        if(s[j] == s[i]) {j++;continue;}
        vp.push_back({s[i] == 'T', j-i});
        i = j;
    }
    vp.push_back({s[i] == 'T', j-i});
 
    if(vp[0].F == 0) {
        xin = vp[0].S;
        vp.erase(vp.begin());
    }
    abx = abs(xf-xin);
    aby = abs(yf-yin);
 
    if(vp.size() != 0 && vp[vp.size()-1].F) {
        vp.pop_back();
    }
 
    if(vp.size() == 0) {
        if(abx == 0 and aby == 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }
 
    xf -= xin;
    bool hori = 1;
    for(int i = 0;i < vp.size();i += 2) {
        if(vp[i].S % 2 != 0) hori = !hori;
        if(hori) hor.push_back(vp[i+1].S);
        else ver.push_back(vp[i+1].S);
    }

    initialize();
    bool ans = possible(hor.size()-1, hor, xf);    
    initialize();
    ans = ans && possible(ver.size()-1, ver, yf);    
 
    if(ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
    int a=0,i;
    char st[5];
    scanf("%s", st);
    for(i=0;i<4;i++){
        if(i<3){
            if(st[i] == st[i+1]){
                a=1;
                break;
            }
        }
    }

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


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#define F first
#define S second

using namespace std;

typedef long long ll;

const long double PI = acos(-1.0);
const long double X = 20 - 5 * PI;
ll sx, sy, ex, ey;
ll n;
ll cnt;
long double ans;

pair<ll, ll> a[200005];

vector<ll> ve;

int main()
{
    scanf("%lld%lld%lld%lld", &sx, &sy, &ex, &ey);
//    if(sy > ey) swap(sy, ey);
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld%lld", &a[i].F, &a[i].S);
    }
    sort(a, a + n);
    if(sx > ex)
    {
        swap(sx, ex), swap(sy, ey);
    }
    if(sy > ey)
    {
        sy = -sy;
        ey = -ey;
        for(ll i = 0; i < n; i++) a[i].S = -a[i].S;
    }
    ans = (ex - sx) + (ey - sy);
    ans *= 100;
    if(sx == ex)
    {
        for(ll i = 0; i < n; i++)
        {
            if(a[i].F == sx && a[i].S < ey && a[i].S > sy) ans += 10 * PI - 20;
        }
        printf("%.15llf\n", ans);
        return 0;
    }
    if(sy == ey)
    {
        for(ll i = 0; i < n; i++)
        {
            if(a[i].S == sy && a[i].F < ex && a[i].F > sx) ans += 10 * PI - 20;
        }
        printf("%.15llf\n", ans);
        return 0;
    }
    for(ll i = 0; i < n; i++)
    {
        if(sx > a[i].F || ex < a[i].F || sy > a[i].S || ey < a[i].S) continue;
        ll t = lower_bound(ve.begin(), ve.end(), a[i].S) - ve.begin();
        if(ve.size() == 0 || t == ve.size()) ve.push_back(a[i].S);
        else ve[t] = a[i].S;
    }
    if(ve.size() == min(ex - sx + 1, ey - sy + 1)) ans += 5 * PI;
    printf("%.15llf\n", ans - ve.size() * X);
    return 0;
}


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

int countNum(int num) {
	int n = 0;
	for (int a = 0; a < 10 && a <= num ; a++) {
		if (num - a > 27)
			continue;
		for (int b = 0; b < 10 && b + a <= num ; b++) {
			if (num - b - a > 18)
				continue;
			for (int c = 0; c < 10 && c + b + a <= num ; c++) {
				if (num - b - a - c > 9)
					continue;
				n++;
			}
		}
	}
	return n;
}

int main() {
	int n = 0;
	vector<int> dst;
	while (cin >> n) {
		dst.push_back(countNum(n));
	}
	for (vector<int>::iterator it = dst.begin(); it < dst.end(); it++)
		cout << *it << endl;
	return 0;
}


Measured memory_bytes: 3000
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

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

ll dp[3001][3001][2];
int main() {
	int N, M;
	cin >> N >> M;
	dp[0][0][1] = 1;
	for (int i = 1; i <= N; i++) dp[0][i][0] = 1;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j <= N; j++) {
			for (int k = 0; k < 2; k++) {
				if (j > 0) {
					//RR
					(dp[i + 1][j - 1][k | (j == 1)] += dp[i][j][k]) %= MOD;
					//RB
					(dp[i + 1][j][k | (j == 1)] += dp[i][j][k]) %= MOD;
				}
				if (N - j > 0) {
					//BB
					(dp[i + 1][j + 1][k] += dp[i][j][k]) %= MOD;
					//BR
					(dp[i + 1][j][k] += dp[i][j][k]) %= MOD;
				}
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i <= N; i++) (ans += dp[M][i][1]) %= MOD;
	cout << ans << endl;
}


Measured memory_bytes: 140928
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#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 long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,num[3]={0};
ld dp[400][400][400]={0};

void solve(){
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        num[a-1]+=1;
    }
    //cout << num[0] << " " << num[1] << " " << num[2] << endl;
    rep(a3,n+1){
        rep(a2,n+1){
            rep(a1,n+1){
                if (a1==0 && a2==0 && a3==0) continue;
                dp[a1][a2][a3]=(ld)n/(a1+a2+a3);
                if (a1>=1) dp[a1][a2][a3]+=((ld)a1/(a1+a2+a3))*dp[a1-1][a2][a3];
                if (a2>=1) dp[a1][a2][a3]+=((ld)a2/(a1+a2+a3))*dp[a1+1][a2-1][a3];
                if (a3>=1) dp[a1][a2][a3]+=((ld)a3/(a1+a2+a3))*dp[a1][a2+1][a3-1];

                //cout << a1 << " " << a2 << " " << a3 << " " << dp[a1][a2][a3] << endl;
            }
        }
    }
    cout << dp[num[0]][num[1]][num[2]] << endl;
}

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

Measured memory_bytes: 753792
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    cout << min(b,n*a) << endl;
    return 0;
}

Measured memory_bytes: 256
if __name__ == "__main__":
  l = [0,2,5,5,4,5,6,3,7,6]
  n,m = list(map(int,input().split()))
  a = list(map(int,input().split()))
  res = ''
  INF = 10**4
  
  dp = [[0,0] for i in range(n+1)]
  for i in range(n):
    for j in range(m):
      if dp[i][1] + l[a[j]] != i + l[a[j]] or i + l[a[j]] > n:
        pass
      else:
        dp[i + l[a[j]]][0] = max(dp[i][0] + 1, dp[i + l[a[j]]][0])
        dp[i + l[a[j]]][1] = dp[i][1] + l[a[j]]
  for i in range(1,n): dp[i][0] = -INF if dp[i][0] == 0 else dp[i][0]
  
  a.sort(reverse = True)
  i = n
  while i > 0:
    for j in range(m):
      if i >= l[a[j]] and dp[i - l[a[j]]][0] + 1 == dp[i][0]:
        res += str(a[j])
        i -= l[a[j]]
        break
      else:
        pass
  print(res)

Measured memory_bytes: 4700
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);
		
		String a = scan.next();
		String b = scan.next();
		
		String[] a1 = a.split("");
		String[] b1 = b.split("");
		
		boolean judge = false;
		
		for(int i = 0; i < a1.length; i++) {
			if(a1[i].equals(b1[i])) {
			}
			else {
				judge = true;
			}
		}
		
		if(judge == false) {
			System.out.println("Yes");
		}
		else if(judge == true) {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35664
def strongPalindrome(S):
    S2 = S[0:(len(S)-1)//2]
    S3 = S[(len(S)+3-1)//2:]
    return "Yes" if S == S[::-1] and S2 == S2[::-1] and S3 == S3[::-1] else "No"

S = input()
print(strongPalindrome(S))

Measured memory_bytes: 3060
n, q = map(int, input().split())
s = ' ' + input()
heap = [0] * (n + 1)
cnt = 0
for i in range(2, n + 1):
    if s[i - 1] == 'A' and s[i] == 'C':
        cnt += 1;
    heap[i] = cnt
for i in range(q):
    l, r = map(int, input().split())
    print(heap[r] - heap[l])

Measured memory_bytes: 6084
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f3f3f3f
#define N 100010
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    int n,t;
    cin>>n;
    t=0;
    while(n)
    {
        t+=n%10;
        n/=10;
    }
    if(t!=1)
        cout<<t<<endl;
    else
        cout<<10<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

struct P{
  int d;
  int x, y;
  int mem;
  P(int x,int y,int d,int mem):x(x),y(y),d(d),mem(mem) {}
};
bool operator<(const P &a, const P &b) {
  return (a.x!=b.x)? a.x<b.x : a.y!=b.y? a.y<b.y : a.d!=b.d ? a.d < b.d : a.mem < b.mem;
}

int main() {
  int H,W;
  cin >> H >> W;
  char ba[W][H];
  REP(y,H) {
    REP(x,W)
      cin >> ba[x][y];
  }
  int dx[] = {0,1,0,-1};
  int dy[] = {-1,0,1,0};
  queue<P> Q;
  Q.push(P(-1,0,1,0));
  set<P> se;
  bool goal = 0;
  while(!Q.empty()) {
    P now = Q.front();
    Q.pop();
    if (se.count(now)) continue;
    se.insert(now);

//    printf("%d, %d d = %d mem = %d\n", now.x, now.y,now.d, now.mem);
    
    int xx = now.x + dx[now.d];
    int yy = now.y + dy[now.d];
    if (xx<0) xx = W-1;
    else if (xx>=W) xx = 0;
    if (yy<0) yy = H-1;
    else if (yy>=H) yy = 0;
    char c = ba[xx][yy];
    //  cout << c << endl;
    int d = now.d;
    int mem = now.mem;
    if (c == '<') {
      d = 3;
    } else if (c == '>') {
      d = 1;
    } else if (c == '^') {
      d = 0;
    } else if (c == 'v') {
      d = 2;
    } else if (c == '_') {
      if (mem == 0) d = 1;
      else d = 3;
    } else if (c == '|') {
      if (mem == 0) d = 2;
      else d = 0;  
    } else if (c == '?') {
    } else if (c == '.') {
    } else if (c == '@') {
      goal = 1;
      break;
    } else if (isdigit(c)) {
      mem = c-'0';
    } else if (c == '+') {
      if (mem == 15) mem = 0;
      else mem++;
      
    } else if (c == '-') {
      if (mem == 0) mem = 15;
      else mem--;
    }
    if (c == '?') {
      Q.push(P(xx,yy,0,mem));
      Q.push(P(xx,yy,1,mem));
      Q.push(P(xx,yy,2,mem));
      Q.push(P(xx,yy,3,mem));      
    } else {
      Q.push(P(xx,yy,d,mem));
    }
  }
  if (goal) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
}

Measured memory_bytes: 0
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <iostream>
using namespace std;

vector<int> solve(vector<int> as, int k){
	int n = as.size() - 1;
	set<int> all;
	for(int i = 1; i <= n; ++i){ all.insert(i); }
	set<int> cand = all;
	vector<int> ans;
	while(true){
		int maxa = -1, pos = -1;
		for(int c : cand){
			if(as[c] > maxa){
				maxa = as[c];
				pos = c;
			}
		}
		if(maxa <= 0){ return {}; }
		ans.push_back(pos);
		--as[pos];
		if(cand.size() <= 1){
			if(!k){ return ans; }
			--k;
			cand = all;
		}
		cand.erase(pos);
	}
}

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> as(n + 1);
	for(int i = 1; i <= n; ++i){
		cin >> as[i];
	}
	vector<int> ans = solve(as, k);
	if(ans.empty()){
		cout << "-1\n";
	}
	else{
		cout << ans.size();
		char spl = '\n';
		for(int x : ans){
			cout << spl << x;
			spl = ' ';
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
bool ListSearch(int a[],int n,int b)
{
	a[n]=b;
	int i=0;
	while(a[i]!=b)i++;//不能写成while(a[i++]!=b);这样的话如果a[n-1]=b,i也会变成i+1(n),就误判为不在了.
	return i!=n;
}//找到且不是末尾返回1 
int main()
{
	int S[10001],n,q,s=0,i,t;
	cin>>n;
	for(i=0;i<n;i++)cin>>S[i];
	cin>>q;
	for(i=0;i<q;i++)
	{
		cin>>t;
		if(ListSearch(S,n,t))
			s++;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v,n) reverse(v,v+n)
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix[i]<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

#define iP pair<int,P>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

int main(void){
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	
	int A,B,K;
	cin>>A>>B>>K;
	FOR(i,A,B+1)
		if(abs(i-A)<K||abs(i-B)<K) print(i);
	return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int LCM(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    VI r(5); 
    int time = 0, mini = 10;
    rep(i,5){
        cin >> r[i];
        r[i] += 9;
        time += r[i]/10*10;
        mini = min(mini,r[i]%10);
    }
    cout << time + mini - 9 << endl;
    
    return 0;
}

Measured memory_bytes: 764
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

typedef struct edge{
  int a,b;
} edge;

int calcDepth(int v,edge *e,int n){
  int res=0;
  for(int i=0;i<n-1;i++){
    if(e[i].a!=v && e[i].b!=v) continue;
    const edge t=e[i];
    e[i]=(edge){-1,-1};
    int k=calcDepth(t.a^t.b^v,e,n)+1;
    res=MAX(res,k);
    e[i]=t;
  }
  return res;
}

void calcLeaf(int v,edge *e,int n,int *dp){
  int cnt=0;
  for(int i=0;i<n-1;i++){
    if(e[i].a!=v && e[i].b!=v) continue;
    cnt++;
    const edge t=e[i];
    e[i]=(edge){-1,-1};
    calcLeaf(t.a^t.b^v,e,n,dp+1);
    e[i]=t;
  }
  dp[0]=MAX(dp[0],cnt);
}

void run(void){
  int n;
  scanf("%d",&n);
  edge *e=(edge *)calloc(n-1,sizeof(edge));
  int i;
  for(i=1;i<n;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    e[i-1]=(edge){a-1,b-1};
  }
  int min=n;
  for(i=0;i<n;i++){
    int d=calcDepth(i,e,n);
    min=MIN(min,d);
  }
  for(i=0;i<n-1;i++){
    const edge t=e[i];
    e[i]=(edge){-1,-1};
    int a=calcDepth(t.a,e,n);
    int b=calcDepth(t.b,e,n);
    e[i]=t;
    min=MIN(min,MAX(a,b));
  }
  const int depth=min;
  int *dp=(int *)calloc(depth,sizeof(int));
  int64 ans=1000000000000000000LL;
  for(i=0;i<n;i++){
    int d=calcDepth(i,e,n);
    if(d!=depth) continue;
    memset(dp,0,sizeof(int)*depth);
    calcLeaf(i,e,n,dp);
    int64 local=1;
    for(int j=0;j<depth;j++) local*=dp[j];
    ans=MIN(ans,local);
  }
  for(i=0;i<n-1;i++){
    const edge t=e[i];
    e[i]=(edge){-1,-1};
    int a=calcDepth(t.a,e,n);
    int b=calcDepth(t.b,e,n);
    e[i]=t;
    if(MAX(a,b)!=depth) continue;
    e[i]=(edge){-1,-1};
    memset(dp,0,sizeof(int)*depth);
    calcLeaf(t.a,e,n,dp);
    calcLeaf(t.b,e,n,dp);
    e[i]=t;
    int64 local=2;
    for(int j=0;j<depth;j++) local*=dp[j];
    ans=MIN(ans,local);
  }
  printf("%d %lld\n",depth+1,ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

int n,m;
int d;

struct DATA{
	int ban;
	int hyo;
}data[1000];

int compare( const void *s1, const void *s2 ){
	DATA *d1 = (DATA*)s1;
	DATA *d2 = (DATA*)s2;
	if( d2->hyo - d1->hyo )
		return d2->hyo - d1->hyo;
	return d1->ban - d2->ban;
}

int main(){
	int i,j;
	
	while(1){
		scanf("%d%d",&n,&m);
		if( !n )break;
		for( j = 0; j < m; j++ ){
			data[j].ban = j+1;
			data[j].hyo = 0;
		}
		
		for( i = 0; i < n; i++ ){
			for( j = 0; j < m; j++ ){
				scanf("%d",&d);
				data[j].hyo += d;
			}
		}
		qsort( data,m,sizeof(data[0]),compare );
		for( j = 0; j < m-1; j++ ){
			printf("%d ",data[j].ban);
		}
		printf("%d\n",data[j].ban);
	}
	return 0;
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String str = in.readLine();
    String[] array = new String[3];
    array[0] = "Sunny";
    array[1] = "Cloudy";
    array[2] = "Rainy";
    if(str.equals(array[0]))
      System.out.println(array[1]);
    else if(str.equals(array[1]))
      System.out.println(array[2]);
    else
      System.out.println(array[0]);
  }
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	vector<pair<int, int>> res;
	for (int i = 1; i < N - 1; i++) {
		if (A[i] < 0) {
			res.emplace_back(A[N - 1], A[i]);
			A[N - 1] -= A[i];
		}
		else {
			res.emplace_back(A[0], A[i]);
			A[0] -= A[i];
		}
	}
	res.emplace_back(A[N - 1], A[0]);
	cout << A[N - 1] - A[0] << endl;
	for (auto p : res) {
		printf("%d %d\n", p.first, p.second);
	}
	return 0;
}


Measured memory_bytes: 3188
using System;
class Program
{
    static void Main(string[] args)
    {
        //入力の受け取り
        string[] input = Console.ReadLine().Split(' ');
        int price = int.Parse(input[0]);
        int wallet = int.Parse(input[1]);
        int satisfaction = int.Parse(input[2]);

        if(wallet >= price * satisfaction)
        {
            Console.WriteLine(satisfaction);
        }
        else
        {
            Console.WriteLine(wallet / price);
        }
    }
}

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

int main (){
  int n, t;
  
  string ans;
  
  cin >> n;
  t = n % 10;
  if( t == 3) ans = "bon";
  else if ( t == 0 || t == 1 || t == 6 || t == 8) ans = "pon";
  else ans = "hon";
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3628
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int ans = 0;
            string[] s = Console.ReadLine().Split(' ');

            int[] h = new int[N];

            for(int i=0;i<N;i++)
            {
                h[i] = int.Parse(s[i]);
            }

            for(int i=0;i<N;i++)
            {
                while(h[i] > 0)
                {
                    ans++;

                    h[i]--;

                    for(int j=i+1;j<N;j++)
                    {
                        if(h[j] == 0)
                        {
                            break;
                        }

                        h[j]--;
                    }
                }
            }

            Console.WriteLine(ans.ToString());
        }
    }
}


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

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

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

    for(int i = 0; i < n; ++i)
        cout << s[i] << t[i];

    cout << "\n";
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int
#define INF					1e9+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(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; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

int main()
{
	int ans = 0;
	int r;
	cin >> r;

	cout << r*r << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<int> b(n-1);
  for(int i=0;i<n-1;++i) {
    cin >> b[i];
  }
  vector<int> a(n);
  a[0] = b[0];
  for(int i=1;i<n-1;++i) {
    a[i] = min(b[i-1], b[i]);
  }
  a[n-1] = b[n-2];
  ll su = 0;
  for(int i=0;i<n;++i) {
    su += a[i];
  }
  cout << su << endl;
}


Measured memory_bytes: 256
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_B&lang=jp
*/

#include <stdio.h>
int main()
{
    char buffer[4];
    // 初期化
    memset( buffer, 0x00, sizeof(buffer) );

    // 文字列受取
    scanf("%255s", buffer);

    // 数値変換
    int x = atol(buffer);

    // ３乗
    int y = x * x * x;

    // 答え表示
    printf( "%d\n", y );
}




Measured memory_bytes: 2144
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){
	double x1,x2,x3,x4,y1,y2,y3,y4,ansx,ansy;
	int q;
	scanf("%d",&q);

	for(int i=0;i<q;i++){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		ansx = ((x2-x1)*(y3*(x4-x3)+x3*(y3-y4))-(x4-x3)*(y1*(x2-x1)+x1*(y1-y2)))/((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1));
		if(x1 != x2){
			ansy = ((y2-y1)*ansx+y1*(x2-x1)+x1*(y1-y2))/(x2-x1);
		}else{
			ansy = ((y4-y3)*ansx+y3*(x4-x3)+x3*(y3-y4))/(x4-x3);
		}
		printf("%.10lf %.10lf\n",ansx,ansy);
	}

    return 0;
}



Measured memory_bytes: 2752
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //printf(f,##__VA_ARGS__),fflush(stdout)

typedef long long ll;
typedef int inte;
#define int ll

const int N=1e5+50;

int fail,n,a[N],ans1,ans2;

inte main(inte argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	scanf("%lld",&n);
	rep(i,1,n)scanf("%lld",a+i);
	int cl=2,cr=2;
	dec(i,n,1){
		int x=a[i],rr,ll;
		rr=cr-cr%x;
		ll=cl+(x-cl%x)%x;
		if(ll>cr||rr<cl)fail=true;
		else{
			cl=ll;
			cr=rr+x-1;
		}
	}
	if(fail)puts("-1");
	else printf("%lld %lld\n",cl,cr);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

void f(int n){
  int num = n;
  bool isOdd = false;
  if(n%2){
    isOdd = true;n--;
  }
  int s = n+1;
  int sum = 0;
  repd(i,1,n){
    repd(j,i+1,n+1){
      if(i+j == s)continue;
      sum++;
    }
  }
  if(isOdd){
    repd(i,1,n+1){
      sum++;
    }
  }
  cout << sum << endl;
  //vector<int> v(num+5,0);
  repd(i,1,n){
    repd(j,i+1,n+1){
      if(i+j == s)continue;
      cout << i << " " << j << endl;
      //v[i] += j; v[j] += i;
    }
  }
  if(isOdd){
    repd(i,1,n+1){
      cout << i << " " << n+1 << endl;
      //v[i] += n+1;v[n+1] += i;
    }
  }
}

signed main(){
  int n;cin>>n;f(n);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

#define MAX_NUM 1024

int min_data[MAX_NUM * 2 - 1];
int max_data[MAX_NUM * 2 - 1];

int get_min(int a, int b) {
	return a <= b ? a : b;
}

int get_max(int a, int b) {
	return a >= b ? a : b;
}

int segtree(const int array[], int (*merge)(int, int), int inf_value,
int idx, int idx_left, int idx_right, int q_left, int q_right) {
	if (idx_right <= q_left || q_right <= idx_left) return inf_value;
	else if (q_left <= idx_left && idx_right <= q_right) return array[idx];
	else {
		int center = (idx_right - idx_left) / 2 + idx_left;
		int lv = segtree(array, merge, inf_value, idx * 2 + 1, idx_left, center, q_left, q_right);
		int rv = segtree(array, merge, inf_value, idx * 2 + 2, center, idx_right, q_left, q_right);
		return merge(lv, rv);
	}
}

int get_min_segtree(int begin, int end) {
	return segtree(min_data, get_min, INT_MAX, 0, 0, MAX_NUM, begin, end);
}

int get_max_segtree(int begin, int end) {
	return segtree(max_data, get_max, INT_MIN, 0, 0, MAX_NUM, begin, end);
}

int main(void) {
	int n, q, i;
	if (scanf("%d", &n) != 1) return 1;
	for (i = 0; i < n; i++) {
		if (scanf("%d", &min_data[MAX_NUM - 1 + i]) != 1) return 1;
		max_data[MAX_NUM - 1 + i] = min_data[MAX_NUM - 1 + i];
	}
	for (i = MAX_NUM - 1 - 1; i >= 0; i--) {
		min_data[i] = get_min(min_data[i * 2 + 1], min_data[i * 2 + 2]);
		max_data[i] = get_max(max_data[i * 2 + 1], max_data[i * 2 + 2]);
	}
	if (scanf("%d", &q) != 1) return 1;
	for (i = 0; i < q; i++) {
		int com, b, e;
		if (scanf("%d%d%d", &com, &b, &e) != 3) return 1;
		printf("%d\n", (com == 0 ? get_min_segtree : get_max_segtree)(b, e));
	}
	return 0;
}



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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 300005, M = 1000000007;
ll a[N], cnt[66];

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
        for (ll j = 0; (1LL << j) <= a[i]; j++) {
            if ((1LL << j) & a[i]) {
                cnt[j]++;
            }
        }
    }
    ll res = 0;
    for (ll i = 0; i < 66; i++) {
        ll temp = (cnt[i] * (n - cnt[i])) % M;
        res += (temp * ((1LL << i) % M)) % M;
        res %= M;
    }
    printf("%lld", res);
    return 0;
}


Measured memory_bytes: 6052
#include <stdio.h>
#include <stdlib.h>

int N,p[100],m[100][100];
#define INF 10000000
void matrixChainOrder();

int main(){
  int i,l;
scanf("%d",&N);
for(i=0;i<N;i++){
  scanf("%d%d",&p[i],&p[i+1]);
}
matrixChainOrder();
printf("%d\n",m[1][N]);
return 0;
}

void matrixChainOrder(){
  int i,j,l,k,q;
  for(i=1;i<=N;i++){
    m[i][i] = 0;
  }

  for(l=2;l<=N;l++){
    for(i=1;i<=N-l+1;i++){
      j=i+l-1;
      m[i][j] = INF;
      for(k=i;k<=j-1;k++){
        q=m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
        if(m[i][j]>q){
          m[i][j]=q;
        }
      }
    }
  }
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<int>v;
   // vector<int>::iterator it;
    int a,b,c;
    cin>>a>>b>>c;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(),v.end());
    
    cout<<v[0]<<' '<<v[1]<<' '<<v[2]<<endl;
}



Measured memory_bytes: 3132
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_N (100000)
#define SIZE_BUF (30)

int main(int argc, char *argv[]) {
  // read inputs
  int K;
  char s[MAX_N + 1], buf[SIZE_BUF];
  scanf("%s", s);
  fgets(buf, SIZE_BUF, stdin);
  scanf("%d", &K);
  const int N = strlen(s);

  // solve
  for (int i = 0; i < N; i++) {
    const char c = s[i];
    const int diff = 26 - (c - 'a');
    if (c != 'a' && K >= diff) {
      s[i] = 'a';
      K -= diff;
    }
  }
  if (K > 0) {
    s[N - 1] = ((s[N - 1] - 'a') + K) % 26 + 'a';
  }
  printf("%s\n", s);

  return 0;
}


Measured memory_bytes: 384
n, t = gets.split.map(&:to_i)
plans = []
n.times do
  plans << gets.split.map(&:to_i)
end

min = 10000
plans.each do |plan|
  if plan[1] <= t
    cost = plan[0]
    min = [min, cost].min
  end
end
puts min!=10000 ? min : "TLE"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll mod = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

ll h,w;
vector<vector<char>> maze(21,vector<char>(21));
vector<vector<ll>> dist(21,vector<ll>(21));

ll bfs(ll s1, ll s2){
    rep(i,0,h)rep(j,0,w){
        dist[i][j]=INF;
    }
    queue<pair<ll,ll>> que;
    dist[s1][s2]=0;
    que.push({s1,s2});
    while(!que.empty()){
        pair<ll,ll> p = que.front();
        que.pop();
        ll y=p.first;
        ll x=p.second;
        rep(i,0,4){
            ll nx=x+d4x[i];
            ll ny=y+d4y[i];
            if(0<=ny&&ny<h&&0<=nx&&nx<w&&(dist[ny][nx]==INF)&&(maze[ny][nx]=='.')){
                dist[ny][nx]=dist[y][x]+1;
                que.push({ny,nx});
            }
        }
    }
    ll temp=0;
    rep(i,0,h)rep(j,0,w)if(dist[i][j]!=INF) temp=max(temp,dist[i][j]);
    return temp;
}


int main(){
    cin>>h>>w;
    rep(i,0,h)rep(j,0,w)cin>>maze[i][j];
    ll ans=0;
    rep(i,0,h)rep(j,0,w)if(maze[i][j]=='.') ans=max(ans,bfs(i,j));
    cout<<ans<<endl;
}

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

const int mod = 1000000007;

int n, m;
int col[200005];

int calc(int n){
	int fib[200005];
	fib[1] = fib[2] = 1;
	for(int i = 3; i <= n + 1; i++){
		fib[i] = (fib[i - 1] + fib[i - 2]) % mod;
	}
	
	// force first one to be 1, last one to be 0: fib[n - 1]
	// force first one to be 0: fib[n + 1]
	return (fib[n - 1] + fib[n + 1]) % mod;
}

int calc2(int n, int ub){
	assert(ub & 1);
	
	// want a bunch of numbers, in [2, ub], to sum to n
	
	ub++;
	ub = min(ub, n); // coz it can actually be HUGE
	
	int dp[200005]; // dp[i]: number of possible sums, that sum to i
	int cumu[200005];
	
	memset(dp, 0, sizeof(dp));
	memset(cumu, 0, sizeof(cumu));
	dp[0] = 1;
	cumu[0] = 1;
	
	for(int i = 2; i <= n; i += 2){
		// sum dp[l_index .. i - 2].. oh, only the even ones!
		int l_index = i - ub;
	//	printf("%d: sum %d..%d\n", i, l_index, r_index);
		dp[i] = cumu[i - 2];
		
		if(l_index > 0){
			dp[i] -= cumu[l_index - 2];
			if(dp[i] < 0){
				dp[i] += mod;
			}
		}
//		printf("%d: %d\n", i, dp[i]);
		cumu[i] = (cumu[i - 2] + dp[i]) % mod;
	}
	
	int ret = 0;
	
	for(int space = 0; space < ub; space++){
		// last 1 is at (n - space), leaving _ space at the end
		// where can the first 1 be?
		int most_remain = n - (space + 1);
		int least_remain = n - ub;
		
		if(most_remain & 1) most_remain--;
		
		// sum up dp[least_remain..most_remain] (even indices only)
		
		int combin = cumu[most_remain];
		if(least_remain > 0){
			combin = (combin - cumu[least_remain - 2] + mod) % mod;
		}
		ret = (ret + combin) % mod;
	}
	return ret;
}

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++){
		char c;
		scanf(" %c", &c);
		col[i] = (c == 'B');
	}
	
	if(col[1] != 0){
		for(int i = 1; i <= m; i++){
			col[i] = 1 - col[i];
		}
	}
	
	// WLOG first one is 0
	bool monochrome = true;
	for(int i = 2; i <= m; i++){
		if(col[i]){
			monochrome = false;
			break;
		}
	}
	if(monochrome){
		// ok as long as 1s are not adjacent
		printf("%d\n", calc(n));
		return 0;
	}else{
		// 00...010..010..0
		// each block of 0 is of add length
		// so, n odd -> definitely no solution
		// more conditions depending on specifics of col[]
		if(n % 2 == 1){
		 	printf("0\n");
		 	return 0;
		}
		int first_run = 0, subseq_run = n - 1;
		for(int i = 1; i <= m; i++){
			int len = 0;
			while(i + len <= m && col[i + len] == 0){
		 		len++;
		 	}
		 	if(first_run == 0){
		 		first_run = len;
		 	}else if(i + len <= m && len % 2 == 1){
		 		subseq_run = min(subseq_run, len);
		 	}
		 	i += len;
		}
		int ub = first_run + (first_run % 2 == 0);
		ub = min(ub, subseq_run);
		printf("%d\n", calc2(n, ub));
	}
	return 0;
}

Measured memory_bytes: 2560
N, M, Q = gets.split.map(&:to_i)
ABCDs = readlines.map{|l| l.split.map(&:to_i)}

score = ->(as){ABCDs.map{|a, b, c, d| as[b - 1] - as[a - 1] == c ? d : 0}.sum}
puts [*1 .. M].repeated_combination(N).map{score[_1]}.max

Measured memory_bytes: 16500