akhauriyash/Code-Regression huggingface dataset:
_,*A = map(int,open(0).read().split())
A.sort()
M = 10**6 + 1
l = [0] * (M)
for a in A:
    if l[a] == 0:
        l[a] = 2
        for x in range(a*2, M, a):
            l[x] = 1
    elif l[a] == 2:
        l[a] += 1
print(l.count(2))


Measured memory_bytes: 121608
import java.util.Scanner;

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

	int k= scanner.nextInt();
    int[] a = new int[1000000];
    int count = -1;
    
    a[0] = 7%k;

    for(int i=1;i<k;i++) a[i] = ((a[i-1]*10)+7) % k;
    for(int i=0;i<k;i++) if((a[i]%k)==0){
      count = i+1;
      break;
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 40288
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = acos(-1);

int main()
{
    int n, k;
    int p[200000];
    cin >> n >> k;
    vector<double> cumsum(n+1,0.0);
    rep(i, n) {
        int p;
        cin >> p;
        double exp = (double)(p + 1) / 2.0;
        cumsum[i + 1] = cumsum[i] + exp;
    }
    double ans = 0.0;
    rep(i, n - k + 1) {
        ans = max(ans, cumsum[k + i] - cumsum[i]);
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 4840
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = a[n / 2] - a[n / 2 - 1];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
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 Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

int main()
{
	ll n,ans=0;
	string s;
	cin >> n >> s;
	rep(i,n-2){
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string s;
vector<string> sl;
ll A, B, C;
vector<char> cl;

void call(char p, char n) {
  cl.pb(p);
  if (p == 'A') A++;
  if (p == 'B') B++;
  if (p == 'C') C++;
  if (n == 'A') A--;
  if (n == 'B') B--;
  if (n == 'C') C--;
}

void eq1(char c1, char c2, ll next_i) {
  string next = sl[next_i];

  if (c1 == 'A' && c2 == 'B') {
    if (next == "AC") {
      call('A', 'B');
    } else {
      call('B', 'A');
    }
  } else if (c1 == 'B' && c2 == 'C') {
    if (next == "AB") {
      call('B', 'C');
    } else {
      call('C', 'B');
    }
  } else if (c1 == 'A' && c2 == 'C'){
    if (next == "BC") {
      call('C', 'A');
    } else {
      call('A', 'C');
    }
  }
}

int main(void){
  IN(N);
  IN(A);
  IN(B);
  IN(C);
  REP(i, N) {
    IN(s);
    sl.pb(s);
  }
  REP(i, N) {
    s = sl[i];
    if (s == "AB") {
      if (A == 0 && B == 0) {
        PRINT("No");
        return 0;
      } if (A == 1 && B == 1) {
        eq1('A', 'B', i+1);
      } else if (A == 0 || A < B) {
        call('A', 'B');
      } else if (B == 0 || A >= B) {
        call('B', 'A');
      }
    } else if (s == "BC") {
      if (B == 0 && C == 0) {
        PRINT("No");
        return 0;
      } if (B == 1 && C == 1) {
        eq1('B', 'C', i+1);
      } else if (B == 0 || B < C) {
        call('B', 'C');
      } else if (C == 0 || B >= C) {
        call('C', 'B');
      }
    } else if (s == "AC") {
      if (A == 0 && C == 0) {
        PRINT("No");
        return 0;
      } if (A == 1 && C == 1) {
        eq1('A', 'C', i+1);
      } else if (A == 0 || A < C) {
        call('A', 'C');
      } else if (C == 0 || A >= C) {
        call('C', 'A');
      }
    }
  }
  PRINT("Yes");
  REP(i, N) {
    PRINT(cl[i]);
  }

}


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

void main_()
{
    ll N;
    cin >> N;
    vector<ll> As;
    As.reserve(N + 1);
    As.push_back(0); // 1-origin
    copy_n(istream_iterator<ll>(cin), N, back_inserter(As));

    ll ans = As[1] + As[N]
        + accumulate(begin(As) + 2, end(As) - 1, 0LL,
            [minus = true](auto acc, auto n) mutable {
                ll res = acc + (minus ? -n : n);
                minus = !minus;
                return res;
            });

    cout << ans << " ";
    for (ll i = 1; i < N; ++i) {
        ans = 2 * As[i] - ans;
        cout << ans << " ";
    }
    cout << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 2176
a=list(map(int,input().split(" ")))
#範囲は座標に制限がなければa[1]-a[0]+1~a[1]+a[0]-1
if a[1]-a[0]+1<-10000:
  if a[1]+a[0]-1>10000:
    b=[i for i in range(-10000,10001)]
  else:
    b=[i for i in range(-10000,a[1]+a[0])]
else:
  b=[i for i in range(a[1]-a[0]+1,a[1]+a[0])]
for i in b:
  print(i,end=" ")

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

int main(){
  int D,G;
  cin >> D >> G;
  vector<int> p(11),c(11);
  for(int i=0;i<D;i++) cin >> p.at(i) >> c.at(i);
  int res = 10000;
  for(int bit=0;bit<(1<<D);bit++){
    int ans = 0;
    int sum = 0;
    int rest_max =0;
    for(int i=0;i<D;i++){
      if(bit>>i&1){
        sum += c.at(i) + 100*(i+1)*p.at(i);
        ans += p.at(i);
      }else{
        rest_max = i;
      }
    }
    int si = 100*(rest_max+1);
    int need;
    if(G>sum){
      need = (G-sum+si-1)/si;
      if(need>p.at(rest_max)) continue;
      else ans += need;
    }
    res = min(res,ans);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
/* -------------------------------- */
/* Name: MD. Khairul Basar          */
/* Institute: HSTU                  */
/* Dept: CSE                        */
/* Email: khairul.basar93@gmail.com */
/* -------------------------------- */

#include <bits/stdc++.h>
/* all header files */

#define fs            first
#define sc            second
#define sp            printf(" ")
#define nl            printf("\n")
#define pb(a)         push_back(a)

#define setzero(a)    memset(a,0,sizeof(a))
#define setneg(a)     memset(a,-1,sizeof(a))
#define setinf(a)     memset(a,126,sizeof(a))

#define tc1(x)        printf("Case %d: ",x)
#define tc2(x)        printf("Case #%d: ",x)
#define tc3(x)        printf("Case %d:\n",x)
#define tc4(x)        printf("Case #%d:\n",x)

#define iin(x)        scanf("%d",&x)
#define din(x)        scanf("%lf",&x)
#define lin(x)        scanf("%lld",&x)
#define clin(x)       scanf("%I64d",&x)

#define pr1(x)        cout<<x<<"\n"
#define pr2(x,y)      cout<<x<<" "<<y<<"\n"
#define pr3(x,y,z)    cout<<x<<" "<<y<<" "<<z<<"\n"
#define pr4(w,x,y,z)  cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define fast          ios::sync_with_stdio(0)
#define read          freopen("input.txt","r",stdin)
#define write         freopen("output.txt","w",stdout)
#define prflag1(flag) printf("%s\n",(flag)?"YES":"NO")
#define prflag2(flag) printf("%s\n",(flag)?"Yes":"No")
#define prflag3(flag) printf("%s\n",(flag)?"yes":"no")
/* macro definitions */

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int>pii;
typedef pair<LL, LL>pll;
typedef vector<int>vi;
typedef vector<LL>vll;
typedef vector<pii>vpii;
typedef vector<pll>vpll;
/* type definitions */

LL MOD_EXPO(LL b, LL p, LL m)
{
    if(p==0) return 1;
    LL ret=MOD_EXPO(b,p/2,m)%m;
    ret=(ret*ret)%m;
    return ((p&1) ? (ret*b)%m : ret%m);
}
LL POWER(LL N, LL K)
{
    LL i,ans=1;
    for(i=1;i<=K;i++) ans*=N;
    return ans;
}
int SET(int N, int pos)
{
    return (N | (1<<pos));
}
int RESET(int N, int pos)
{
    return (N & !(1<<pos));
}
bool CHECK(int N, int pos)
{
    return (N & (1<<pos));
}
/* necessary functions */

int dx4[]= {1,-1,0,0};
int dy4[]= {0,0,1,-1};
int dx6[]= {0,0,1,-1,0,0};
int dy6[]= {1,-1,0,0,0,0};
int dz6[]= {0,0,0,0,1,-1};
int dx8[]= {1,-1,0,0,-1,1,-1,1};
int dy8[]= {0,0,1,-1,1,1,-1,-1};
int dkx8[]= {-1,1,-1,1,-2,-2,2,2};
int dky8[]= {2,2,-2,-2,1,-1,1,-1};
/* direction arrays */

int tc=1;
const double eps=1e-9;
const double pi=acos(-1.0);
const long long int mx=1e5;
const long long int mod=1e9+7;
/* global declarations */

int main()
{
    int n,cnt;
    string str;
    while(cin>>str)
    {
        n=str.size();
        if(str[0]==str[n-1])
        {
            cnt=n-3;
        }
        else
        {
            cnt=n-2;
        }
        if(cnt%2) pr1("First");
        else pr1("Second");
    }
    return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
string w,t;
int count,f;
inline void touppers(string &s) {
	for(int i =0; i<s.length(); i++) s[i]=::toupper(s[i]);
}
int main() {
	getline(cin,w);
	getline(cin,t);
	touppers(w);
	while(t!="END_OF_TEXT") {
		touppers(t);
		for(int i=0; i<t.length(); i++) {  //循环文本 
			/*
				如果单词的首字母和文本相同则进行下列判断 
				首字符为空格或者是刚开始则证明是一个单独的单词然后进行循环 
			*/ 
			if(t[i]==w[0]&&(t[i-1]==32||i==0)) {  
				int j=1;			//单词偏移指针 
				for(; j<w.length(); j++) {		
					/*
						循环单词，如果有一位不相同则不匹配。 
					*/ 
					if(t[j+i]!=w[j])			
						break;
				}
				/*
					如果单词的偏移指针最后超过了单词的长度加1证明没有不相同则进行下列判断
					如果单词的末尾为空或者单词的末尾已经到达句子尾则直接计数。 
				*/
				if(j>=w.length()&&(j+i>=t.length()||t[i+j]==' ')) {	 	
					count++;
				}
			}
		}
		getline(cin,t);
	}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3176
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_085_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N      PIC 9(3).
    01 i      PIC 9(3).

    01 qary1.
        03 qary11 OCCURS 100.
            05 qary    PIC 9(3).

    01 stack1.
        03 stack11 OCCURS 1000.
            05 st    PIC 9(3).
            05 ed    PIC 9(3).

    01 sidx   PIC 9(4) VALUE 0.
    01 nowidx PIC 9(4) VALUE 0.

    01 sttmp  PIC 9(3).
    01 edtmp  PIC 9(3).

    01 a      PIC 9(3).
    01 b      PIC 9(3).

    01 t      PIC 9(3).
    01 x      PIC 9(3).

    01 qfirst PIC 9(3) VALUE 1.
    01 qlast  PIC 9(3).
    01 q      PIC 9(3).

    01 ret    PIC 9(3).
    01 bk     PIC 9(3).

    01 ZS     PIC Z(4).
    01 ans    PIC X(3).

    01 DUMMY  PIC X(1).

    01 FLG    PIC 9(1).

    01 tmp    PIC 9(3) VALUE 0.
    01 cnt    PIC 9(3) VALUE 0.

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT N.

    PERFORM VARYING i FROM 1 BY 1 UNTIL N < i
        ACCEPT qary(i)
    END-PERFORM.

    MOVE N TO qlast.

    PERFORM PARTITION.

    MOVE 1 TO FLG.

    PERFORM UNTIL FLG = 0
        PERFORM QSORT
        IF FLG = 0 THEN
            IF nowidx < sidx THEN
                MOVE 1 TO FLG
                ADD 1 TO nowidx
                MOVE st(nowidx) TO qfirst
                MOVE ed(nowidx) TO qlast
                PERFORM PARTITION
            END-IF
        END-IF
    END-PERFORM.

    PERFORM VARYING i FROM 1 BY 1 UNTIL N < i
        IF tmp < qary(i) THEN
            ADD 1 TO cnt
        END-IF

        MOVE qary(i) TO tmp
    END-PERFORM.

    MOVE cnt TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.

PARTITION                        SECTION.
    MOVE qary(qlast) TO x
    MOVE qfirst TO a

    SUBTRACT 1 FROM a

    PERFORM VARYING b FROM qfirst BY 1 UNTIL qlast <= b
        IF qary(b) <= x THEN
            ADD 1 TO a
            MOVE qary(a) TO t
            MOVE qary(b) TO qary(a)
            MOVE t TO qary(b)
        END-IF
    END-PERFORM

    ADD 1 TO a
    MOVE qary(a) TO t
    MOVE qary(qlast) TO qary(a)
    MOVE t TO qary(qlast)
    MOVE a TO q.

QSORT                            SECTION.
    IF qfirst < qlast THEN
        MOVE q TO ret

        MOVE qlast TO bk
        SUBTRACT 1 FROM ret GIVING qlast

        ADD 1 ret GIVING sttmp
        MOVE bk TO edtmp

        IF sttmp < edtmp THEN
            ADD 1 TO sidx
            MOVE sttmp TO st(sidx)
            MOVE edtmp TO ed(sidx)
        END-IF

        IF qfirst < qlast THEN
            PERFORM PARTITION
        ELSE
            MOVE 0 TO FLG
        END-IF
    ELSE
        MOVE 0 TO FLG
    END-IF.


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (b <= a) cout << "delicious" << endl;
  else if (b -a >= x + 1) cout << "dangerous" << endl;
  else cout << "safe" << endl;
}


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

int main()
{

 vector<ll>v,vv;
    map<ll,ll>m;
    ll a,b,c,d,i,j,k,l=0,x,y,z;
  cin>>a;
    v.push_back(0);
for(i=1;i<=a;i++)
{
cin>>b;v.push_back(b);
}
    for(i=0;i<=v.size();i++)
    vv.push_back(v[i]);
    
    sort(v.begin(),v.end());
for(i=1;i<=a;i++)
  {//cout<<vv[i]<<" ";
        
      if(i<=a/2)m[v[i]]=v[(a/2)+1];
       
    else m[v[i]]=v[(a/2)];
        }
    for(i=1;i<=a;i++)
    cout<<m[vv[i]]<<endl;
}

Measured memory_bytes: 17520
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<map>
#include<iomanip>
#include<limits>
#include<queue>
#include<set>


using namespace std;

int main(){

    int N;
    cin >> N;

    vector<int>sx(N,0);
    
    int x[200000];
    
    for(int i = 0;i < N;i++){
    	cin >> sx[i];
    	x[i] = sx[i];
    }

    int medi1 = N/2 - 1;
    int medi2 = N/2;
    
    sort(sx.begin(),sx.end());
    
    for(int i = 0;i < N;i++){
    	if(x[i] <= sx[medi1]){
    		cout << sx[medi2] << endl;
    	}else{
    		cout << sx[medi1] << endl;
    	}    	
    }
    
	return 0;

}


Measured memory_bytes: 3712
#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, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];

    int odd = 0, even = 0;

    rep(i, 0, 3) {
        if (v[i] % 2 == 0) even++;
        else odd++;
    }


    if (even == 3 || odd == 3) {
        sort(all(v));
        ll ans = 0;
        ans += (v[2] - v[0]) / 2;
        ans += (v[2] - v[1]) / 2;
        cout << ans << endl;

    } else if (even == 2) {
        rep(i, 0, 3) {
            if (v[i] % 2 == 0) {
                v[i]++;
            }
        }
        ll ans = 1;
        sort(all(v));
        ans += (v[2] - v[1]) / 2;
        ans += (v[2] - v[0]) / 2;
        cout << ans << endl;

    } else if (odd == 2) {
        rep(i, 0, 3) {
            if (v[i] % 2 == 1) {
                v[i]++;
            }
        }
        ll ans = 1;
        sort(all(v));
        ans += (v[2] - v[1]) / 2;
        ans += (v[2] - v[0]) / 2;
        cout << ans << endl;
    }


    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>

typedef struct{
  int p,l,r,d,h,s;
}N;

N T[30];
int rec1(int r,int p){
  T[r].d = p;
  if(T[r].r!=-1) rec1(T[r].r,p+1);
  if(T[r].l!=-1) rec1(T[r].l,p+1);
}
int rec2(int a){
  int l,r;
  if(a==-1) return 0;
  if(T[a].l==-1 && T[a].r==-1) return 0;
  l = rec2(T[a].l)+1;
  r = rec2(T[a].r)+1;
  return l > r ? l : r;
}
int main(){

  int n,id,l,r;
  int i;
  int degree;
  int a;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].r = T[i].l = T[i].p = T[i].s = -1;
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d%d",&l,&r);
    T[id].l = l;
    T[id].r = r;
    T[l].p = T[r].p = id;
    T[l].s = r;
    T[r].s = l;
  }
  for(i=0;i<n;i++) if(T[i].p==-1) a = i;
  rec1(a,0);
  for(i=0;i<n;i++) T[i].h = rec2(i);
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, ",i,T[i].p,T[i].s);
    degree = 0;
    if(T[i].l!=-1) degree++;
    if(T[i].r!=-1) degree++;
    printf("degree = %d, depth = %d, height = %d, ",degree,T[i].d,T[i].h);
    if(T[i].p==-1) printf("root");
    else if(T[i].r!=-1 || T[i].l!=-1) printf("internal node");
    else printf("leaf");
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
using namespace std;

int main()
{
    char s[4];
    int i, ans = 0;

    scanf("%s", &s);

    for (i = 0; i < 4; i++)
    {
        if (s[i] == '+')
        {
            ans++;
        }
        else
        {
            ans--;
        }
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(){
	int in;

	while(cin >> in){
		int rev = 0, max = 0;

		if(in == 0) break;

		int data[in];

		for(int i = 0; i < in; i++){
			cin >> data[i];
			if(data[i] > max) max = data[i];
		}

		while(1){

			int sum[max+1];

			for(int	i = 0; i <= max; i++){
				sum[i] = 0;
			}
		
			for(int i = 0; i < in; i++){
				sum[data[i]]++;
			}

			int status = 0;

			for(int i = 0; i < in; i++){
				if(data[i] != sum[data[i]]) status = 1;
			}

			/*for(int i = 0; i < in; i++) cout << data[i] << " ";
			cout << endl;*/

			if(status == 0){
				cout << rev << endl;
				for(int i = 0; i < in; i++){
					if(i != 0) cout << " ";
					cout << data[i];
				}
				cout << endl;
				break;
			}

			for(int i = 0; i < in; i++){
				data[i] = sum[data[i]];
			}
			rev++;
			max = in;
		}
	}

	return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static class Spell {
        private int strength;
        private int cost;

        private Spell(int strength, int cost) {
            this.strength = strength;
            this.cost = cost;
        }

        private double performance() {
            return (double) strength / (double) cost;
        }
    }

    private static void solve() {
        int h = in.nextInt();
        int n = in.nextInt();

        List<Spell> spells = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int s = in.nextInt();
            int c = in.nextInt();
            spells.add(new Spell(s, c));
        }

        memo = new int[h + 1];
        Arrays.fill(memo, Integer.MAX_VALUE / 2);
        out.println(minCost(spells, h));
    }

    private static int[] memo;

    private static int minCost(List<Spell> spells, int hp) {
        if (hp <= 0) return 0;
        if (memo[hp] != Integer.MAX_VALUE / 2) return memo[hp];
        int min = Integer.MAX_VALUE;
        for (Spell spell : spells) {
            min = Math.min(min, spell.cost + minCost(spells, hp - spell.strength));
        }
        memo[hp] = min;
        return min;
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

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

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

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

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

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

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 24916
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline void rdi(int &x){
	int f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	if(f) x=-x;
}
inline void rdi(ll &x){
	ll f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	if(f) x=-x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
inline void write(ll x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(ll x){
	write(x);
	putchar(' ');
}
inline void print(ll x){
	write(x);
	putchar('\n');
}
#define int ll
int res,n,d;
int a[200005];
int dpl[200005],dpr[200005]; 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	rdi(n),rdi(d);
	int i,j;
	for(i=0;i<n;++i) rdi(a[i]),res+=a[i];
	res+=(n-1)*d;
	dpr[0]=a[0];
	for(i=1;i<n;++i) dpr[i]=min(a[i],dpr[i-1]+d);
	dpl[n-1]=a[n-1];
	for(i=n-2;~i;--i) dpl[i]=min(a[i],dpl[i+1]+d);
	for(i=1;i<n-1;++i) res+=min(dpl[i],dpr[i]);
	print(res);
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  map<string,int> m;
  int cnt=0;
  vector <string> ans;
  map <string,int> m2;
  rep(i,n){
    cin >> s[i];
    m[s[i]]+=1;
    m2[s[i]]=0;
  }
  rep(i,n){
    if(cnt<=m[s[i]])cnt=m[s[i]];
    }
  rep(i,n){
    if(cnt==m[s[i]]){
      if(m2[s[i]]==0){
	ans.push_back(s[i]);
	m2[s[i]]+=1;
      }
    }
  }
  sort(ans.begin(), ans.end());
  for(string i: ans){
    cout << i << endl;
  }
  return 0;
}


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

int main(){
	int h, w;

	while(1){
		cin >> h >> w;

		if(h == 0 && w == 0){
			break;
		}

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cout << '#' << flush;
			}
			cout << endl;
		}
		cout << endl;
	}

	return(0);
}

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

#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define pb push_back
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std ;
typedef long long ll ;
int c[5] ;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n ;
	cin >> n;
	for(int i =1 ;i<= n ; i++){
		string s;
		cin >> s ;
		if(s=="AC"){
			c[1]++;
		}
		else if(s=="WA"){
			c[2]++ ;
		}
		else if(s=="TLE"){
			c[3]++;
		}
		else{
			c[4]++;
		}
	}
	cout << "AC x " <<c[1] << '\n' ;
	cout << "WA x " <<c[2] << '\n' ;
	cout << "TLE x " <<c[3] << '\n' ;
	cout << "RE x " <<c[4] ;
	
	return 0 ;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
const int MAX_V = 10000;
const int MAX_E = 100000;
vector<deque<int> > G(MAX_E);
vector<int> L;  // トポロジカルソートした結果を蓄積する空リスト.
deque<int> S;   // 入力辺を持たないすべてのノードの集合.
map<int, int> inCount;

// 各頂点から, トポロジカルソート を行い, 頂点の並び順を保存.
// https://ja.wikipedia.org/wiki/トポロジカルソート
// @param : 特に無し.
// @return : 特に無し.
void topologicalSort(){
    
    // 1. キュー S が 空になるまで, ループ.
    while(!S.empty()){

        // 2. S からノード n を削除.
        int n = S.front();
        S.pop_front();
        
        // 3. L に n を追加.
        L.push_back(n);

        while(!G[n].empty()){
            // 4. 辺 e (n -> m)をグラフから削除.
            int m = G[n].front();
            G[n].pop_front();
            inCount[m]--;
            // printf("n=%d m=%d\n", n, m);
            // 5. m がその他の入力辺を持っていなければ, m を S に追加.
            if(inCount[m] == 0) S.push_back(m);
        }
    }
    
    // 6. グラフに辺が残っている場合は, 閉路があり DAG でないので中断.
    // 本問では, 考慮しなくて良さそう.
    
    return;
}

int main(){
    
    // 1. 入力情報.
    int V, E;
    scanf("%d %d", &V, &E);
    for(int i = 0; i < E; i++){
        int s, t;
        scanf("%d %d", &s, &t);
        G[s].push_back(t);
        inCount[t]++; // 各頂点への入力辺の本数を保存.
    }
    
    // 2. 辺の数が, 0本の場合, 頂点を S に追加.
    // テストケース: in10.txt対応用.
    // if(E == 0) for(int i = 0; i < V; i++) S.push_back(i);
    // -> 入力情報に, 必ずしも, 頂点情報が与えらるとは, 限らないので注意.
    // -> ex. テストケース: in15.txt で, 頂点 13 が 出力されなかった.
    // -> 以下のロジックへ修正.
    for(int i = 0; i < V; i++) if(inCount[i] == 0) S.push_back(i);
    
    // 3. トポロジカルソートを行う.
    topologicalSort();
    
    // 4. 出力 ～ 後処理.
    for(int i = 0; i < L.size(); i++) printf("%d\n", L[i]);
    return 0;

}


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

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

    deque<pair<string, int>> time;
    rep(i, n) {
        string s;
        int t;
        cin >> s >> t;
        time.push_back({s,t});
    }
    // time.push_back({"p1",150});
    // time.push_back({"p2",80});
    // time.push_back({"p3",200});
    // time.push_back({"p4",350});
    // time.push_back({"p5",20});
 
    int passed_time = 0;
    vector<pair<string,int>> answer;
    while (not time.empty()) {
        pair<string, int> p = time.front();
        if (p.second > q) {
            time.pop_front();
            p.second -= q;
            time.push_back(p);
            passed_time += q;
        } else {
            time.pop_front();
            passed_time += p.second;
            answer.push_back({p.first, passed_time});
        }
    }

    rep(i, answer.size()) {
        printf("%s %d\n", answer[i].first.c_str(), answer[i].second);
    }
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int dish, inc, max_inc = 0, sum = 0;
    rep(0, 5) {
        cin >> dish;
        inc = 0;
        while ((dish + inc) % 10 != 0) inc++;
        sum += (dish + inc);
        max_inc = max(max_inc, inc);
    }

    cout << (sum - max_inc) << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

void solve(int test_case) {
	string s;
	cin>>s;
	int a=s.length(),z=0;
	for(int i=0;i<s.length();i++) {
		if(s[i]=='A')a=min(i,a);
		else if(s[i]=='Z')z=max(i,z);
	}
	cout<<z-a+1;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3752
from itertools import product 

n = int(input())
XY = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())          
        XY[i].append((x-1,y))
ans = 0
bits = list(product([0,1],repeat=n))
for bit in bits:
    honest_tes = []
    honest_idx = []
    honest_list = [0 for _ in range(n)]
    flag = True
    for who, h in enumerate(bit):
        if h == 1:
            honest_tes.append(XY[who])
            honest_idx.append(who)
            honest_list[who] = 1
    for idx in honest_idx:
        for x, y in XY[idx]:
            if honest_list[x] != y:
                flag = False
                break
    if flag:
        ans = max(ans, len(honest_idx))
print(ans)

Measured memory_bytes: 14520
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int n=nextInt();
		long sum=0;
		for(int i=1;i<=n;i++)
		{
			if(i%3!=0 && i%5!=0)
				sum+=i;
		}
		out.println(sum);
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();

		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 33032
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] hw = scanner.nextLine().split(" ", 2);
        int h = Integer.parseInt(hw[0]);
        int w = Integer.parseInt(hw[1]);

        char[][] board = new char[h][w];
        for (int i = 0; i < h; i++) {
            String line = scanner.nextLine();
            for (int j = 0; j < w; j++) {
                board[i][j] = line.charAt(j);
            }
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (board[i][j] == '#') continue;

                int count = 0;
                for (int k = Math.max(0, i - 1); k <= Math.min(h - 1, i + 1); k++) {
                    for (int l = Math.max(0, j - 1); l <= Math.min(w - 1, j + 1); l++) {
                        if ((k != i || j != l) && board[k][l] == '#') {
                            count++;
                        }
                    }
                }
                board[i][j] = (char)('0' + count);
            }
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                System.out.print(board[i][j]);
            }
            System.out.print("\n");
        }
    }
}


Measured memory_bytes: 23764
iA,iB,iK = [int(_) for _ in input().split()]




for i in range(iK):
    if i % 2 == 0 :
        if iA % 2 == 1:
            iA = (iA - 1) //2
            iB += iA
        else:
            iA = iA // 2
            iB += iA
    else:
        if iB % 2 == 1:
            iB = (iB - 1) //2
            iA += iB
        else:
            iB = iB // 2
            iA += iB
print(iA,iB)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int X, A, B, N;

  cin >> X >> A >> B >> N;

  for(int i=0; i<N; i++) {
    string order;

    cin >> order;

    if(order == "nobiro") X = max(0, X + A);
    if(order == "tidime") X = max(0, X + B);
    if(order == "karero") X = 0;
  }

  cout << X << endl;

  return 0;
}



Measured memory_bytes: 3168
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);

int minIndex(double[] a) {
    double m = a.reduce!(min);
    foreach (i, v; a) if (v == m) return i.to!int;
    return -1;
}

void main() {
    readln;
    int t, a; readf("%d %d\n", &t, &a);
    writeln(reads.to!(double[])
        .map!(h => t - 0.006 * h)
        .map!(h => abs(h - a)).array
        .minIndex + 1);
}

Measured memory_bytes: 380
while True:
    a, b = map(int, input().split())
    if (a == 0 and b == 0):
        break
    li = [ ''.join(map(str, [ '.' if j%2==0 else '#' for j in range(i,i+b) ])) for i in range(1, a+1)]
    print('\n'.join(li)+'\n')


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define lli long long int
#define ld long double
#define pb push_back
#define is insert
#define iamspid ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
    iamspid
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    lli n;
    cin>>n;
    vector<lli> ptr(n+1,0);
    for(lli i=1;i<=n;i++) cin>>ptr[i];
    vector<lli> kmt(n+1,0);
    kmt[2]=abs(ptr[2]-ptr[1]);
    for(lli i=3;i<=n;i++)
    {
        kmt[i]=min((kmt[i-1]+abs(ptr[i]-ptr[i-1])),(kmt[i-2]+abs(ptr[i]-ptr[i-2])));
    }
    cout<<kmt[n]<<endl;
    return 0;
}


Measured memory_bytes: 4740
#include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;

P c[50], d[50];
signed main() {
	int a, b; scanf("%d%d", &a, &b);
	for (int e = 0; e < a; e++) {
		scanf("%d%d", &c[e].first, &c[e].second);
	}
	for (int e = 0; e < b; e++) {
		scanf("%d%d", &d[e].first, &d[e].second);
	}
	for (int e = 0; e < a; e++) {
		int MIN = INT_MAX;
		int ans = 0;
		for (int f = 0; f < b; f++) {
			int g = abs(c[e].first - d[f].first) + abs(c[e].second - d[f].second);
			if (g < MIN) {
				MIN = g;
				ans = f + 1;
			}
		}
		cout << ans << endl;
	}
}

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

template<typename T>
class PriorityQueue{
private:
	vector<T> d;
public:
	void push(T t){
        int k = d.size();
		d.push_back(t);
        while(k && d[(k - 1) / 2] < d[k]){
            swap(d[(k - 1) / 2], d[k]);
            k = (k - 1) / 2;
        }
	}
    T top(){
        // assert(d.size() > 0);
        return d[0];
    }
    void pop(){
        // assert(d.size() > 0);
        d[0] = d.back();
        d.pop_back();
        maxHeapify(0);
    }
	void maxHeapify(int k){
		int l = 2 * k + 1;
		int r = 2 * k + 2;
		T largest;
		if(l < d.size() && d[l] > d[k]) largest = l;
		else largest = k;

		if(r < d.size() && d[r] > d[largest]) largest = r;

		if(largest != k){
			swap(d[k], d[largest]);
			maxHeapify(largest);
		}
    }
	void printHeap(){
		for(int i = 0; i < d.size(); i++){
			cout << " " << d[i];
		}
		cout << endl;
	}
};

int main(){
    PriorityQueue<int> pq;
    while(1){
        string s;
        cin >> s;
        if(s == "end") break;
        if(s == "insert"){
            int a;
            cin >> a;
            pq.push(a);
        }else{
            cout << pq.top() << endl;
            pq.pop();
        }
        // pq.printHeap();
    }
}

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

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> s(H);
  for (auto& v : s)cin >> v;
  vector<vector<int>> ans(H, vector<int>(W, 0));
  int k = 0;
  for (int h = 0; h < H; ++h) {
    size_t pos = s[h].find('#');
    int prev = -1;
    while (pos != string::npos) {
      ++k;
      for (int i = prev + 1; i <= pos; ++i)ans[h][i] = k;
      prev = pos;
      pos = s[h].find('#', prev + 1);
    }
    if (prev != -1)for (int i = prev + 1; i < W; ++i)ans[h][i] = k;
  }
  for (int h = 1; h < H; ++h) {
    if (ans[h][0] != 0)continue;
    ans[h] = ans[h - 1];
  }
  for (int h = H - 2; h >= 0; --h) {
    if (ans[h][0] != 0)continue;
    ans[h] = ans[h + 1];
  }
  for (auto& row : ans) {
    for (auto& elem : row) {
      cout << elem << " ";
    }
    cout << "\n";
  }
  cout << flush;
}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x)
#define COUNT2(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  map<pair<string, string>, ll> mp;
  cin >> n;
  cin >> s;
  string s1, s2;
  s1 = s.substr(0, n);
  s2 = s.substr(n, n);
  reverse(all(s2));
  rep(i, 1 << n) {
	string s3, s4;
	rep(j, n) {
	  if (i & 1 << j) s3 += s1[j];
	  else s4 += s1[j];
	}
	pair<string, string> ss = { s3,s4 };
	mp[ss]++;
  }

  rep(i, 1 << n) {
	string s3, s4;
	rep(j, n) {
	  if (i & 1 << j) s4 += s2[j];
	  else s3 += s2[j];
	}
	pair<string, string> ss = { s4,s3 };
	ans += mp[ss];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 91904
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_102_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N      PIC 9(10).
    01 X      PIC 9(10).
    01 D      PIC 9(10).
    01 ZS     PIC Z(11).
    01 ans    PIC X(10).
    01 DUMMY  PIC X(1).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT N.

    DIVIDE 2 INTO N GIVING X REMAINDER D.

    IF D NOT = 0 THEN
        MULTIPLY 2 BY N
    END-IF

    MOVE N TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 764
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

#a = list(map(int, input().split()))

h,n = list(map(int, input().split()))
waza=[]
for i in range(n):
    waza.append(list(map(int, input().split())))
    
dp = [10**10 for _ in range(h+1)]
dp[0]=0
for i in range(h):
    for j in range(n):
        dp[min(h,i+waza[j][0])] = min(dp[min(h,i+waza[j][0])], dp[i]+waza[j][1])
        #print(min(h,i+waza[j][0]))
    #print(dp)
    
print(dp[h])


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

int main() {
  int n, m, d;
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &d);
  long long denominator;
  if (d!=0) {
    denominator = (2*(double)n-2*(double)d)*(m-1);
  } else {
    denominator = (double)n*(m-1);
  }
  double ans = denominator/pow(n, 2);
  printf("%.10lf\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    string s;
    int x,y;
    cin>>s>>x>>y;
    int n=s.size(),cnt=0,it=0,t=1;
    while(it<n&&s[it]=='F'){
        it++;
        cnt++;
    }
    x-=cnt;
    vector<int> v[2];
    while(++it<n){
        cnt=0;
        while(it<n&&s[it]=='F'){
            cnt++;
            it++;
        }
        v[t].push_back(cnt);
        t^=1;
    }
    bool dpx[20000][2]={{}},dpy[20000][2]={{}};
    dpx[10000][0]=dpy[10000][0]=true;
    int p=0,q=0;
    for(int d:v[0]){
        for(int i=0;i<20000;i++){
            if(dpx[i][p]){
                dpx[i+d][p^1]=true;
                dpx[i-d][p^1]=true;
            }
            dpx[i][p]=false;
        }
        p^=1;
    }
    for(int d:v[1]){
        for(int i=0;i<20000;i++){
            if(dpy[i][q]){
                dpy[i+d][q^1]=true;
                dpy[i-d][q^1]=true;
            }
            dpy[i][q]=false;
        }
        q^=1;
    }
    if(dpx[x+10000][p]&&dpy[y+10000][q])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        char[] c = s.toCharArray();

        for (char q : c) {
            if (Character.isUpperCase(q)) {
                System.out.print((q + "").toLowerCase());
            } else {
                System.out.print((q + "").toUpperCase());
            }
        }

        System.out.println();

    }

}


Measured memory_bytes: 27084
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

int main()
{
	int a;
	string s;

	cin >> a >> s;

	if (a < 3200)
	{
		cout << "red" << endl;
	}
	else
	{
		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto X = RD;
	long ans;
	(){
	foreach_reverse (i; 1..X+1)
	{
		foreach_reverse (j; 1..i+1)
		{
			if (j*j > i) continue;
			foreach (k; 2..i+2)
			{
				if (j^^k == i)
				{
					ans = i;
					return;
				}
				if (j^^k > i) break;
			}
		}
	}}();

	writeln(ans);
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256