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

template <typename T>
string pairToString(const pair<T, T>& p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

void solve() {
  int R, C;
  cin >> R >> C;
  vector<pair<int, int>> intervals(R);
  for (int i = 0; i < R; ++i) {
    cin >> intervals[i].first >> intervals[i].second;
    --intervals[i].first;
    --intervals[i].second;
  }

  multiset<int> values;
  set<pair<int, int>> paths;  // { ending point, starting point }
  for (int i = 0; i < C; ++i) {
    paths.insert({ i, i });
    values.insert(0);
  }

  const int INFTY = 10 * (R + C);
  for (int i = 0; i < R; ++i) {
    // Update.
    pair<int, int> path_to_add = { -1, -1 };
    auto it = paths.lower_bound(make_pair(intervals[i].first, -1));
    while (it != paths.end()) {
      const int endpoint = it->first;
      const int startpoint = it->second;
      if (endpoint > intervals[i].second) {
        break;
      }
      const int old_value = endpoint - startpoint;
      path_to_add = { intervals[i].second + 1, startpoint };
      values.erase(values.find(old_value));
      paths.erase(it);
      it = paths.lower_bound(make_pair(intervals[i].first, -1));
    }

    if (intervals[i].second != C - 1 && path_to_add.first != -1) {  // Don't add INFTY values.
      paths.insert(path_to_add);
      values.insert(path_to_add.first - path_to_add.second);
    }

    // Vertical component.
    const int vertical = i + 1;

    // Horizontal component.
    if (values.empty()) {
      cout << -1 << endl;
    } else {
      int horizontal = *values.begin();
      cout << horizontal + vertical << endl;
    }

  }
}

int main() {
  solve();
}

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

using namespace std;



int main() {
 	long long x, y, Max, cnt = 0, n, D;
 	cin >> n >> D; D = D * D;
 	while(n--) {
 		cin >> x >> y;
 		if(x * x + y * y <= D)
 			cnt++;
 	}
 	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
  string S;
  cin >> S;
  map<char, int> mp;
  rep(i, S.size()) mp[S[i]]++;
  if((mp['N'] && mp['S'] || !mp['N'] && !mp['S']) && (mp['W'] && mp['E'] || !mp['W'] && !mp['E']))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
	while(1){
		int h, w;
		scanf(" %d %d", &h, &w);
		if(h==0 && w==0) break;
		
		for(int i=0; i<h; ++i){
			for(int j=0; j<w; ++j){
				if(i==0 || i==h-1 || j==0 || j==w-1) printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");

	}
	return 0;
}

Measured memory_bytes: 1000
#include <stdio.h>

int main()
{
	long long i, K;
	scanf("%lld", &K);
	printf("50\n%lld", K / 50 + 49 - K % 50);
	for (i = 2; i <= 50 - K % 50; i++) printf(" %lld", K / 50 + 49 - K % 50);
	for (i = 50 - K % 50 + 1; i <= 50; i++) printf(" %lld", K / 50 + 50);
	printf("\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 92233720368ll;


void solve()
 { 
   int r;
   cin>>r;
   double pi = atan(1);
   double ans = 2*pi*r*4;
   cout<<fixed<<setprecision(10);
   cout<<ans;
 }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 

     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define f first
#define s second
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define fast 
#define f first
#define s second
#define endl "\n"
#define pie 3.1415926535

int main (){
    long long n,k;
    cin >> n >> k;
    long long d = n/k;
    long long rem = n%k;
    if(n>=k){
       if(rem == 0)
        cout << 0 <<endl;
    else{
        cout << abs(k-rem) <<endl;
    } 
    }
    else
        cout << min (n,abs(n-k))<<endl;
    
    
    return 0;
    
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;cin >> N;
    vector<int> V(N);
    REP(i,N) cin >> V[i];
    sort ALL(V);
    REP(i,N-1){
        if(V[i] == V[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def ShellSort(bb):
    aa = bb[:]

    def InsertionSort(d):
        shift = 0
        for i in range(n):
            a = aa[i]
            j = i
            while j - d >= 0 and aa[j - d] > a:
                aa[j] = aa[j - d]
                shift += 1
                j -= d
            aa[j] = a
        return shift

    cnt = 0
    n = len(aa)
    dd = [1]
    while dd[-1] * 3 + 1 < n:
        dd.append(dd[-1] * 3 + 1)
    dd.reverse()
    print(len(dd))
    print(*dd)
    for d in dd:
        cnt += InsertionSort(d)
    print(cnt)
    return aa

def main():
    n = int(input())
    # aa = list(map(int, input().split()))
    aa = [int(input()) for _ in range(n)]
    aa = ShellSort(aa)
    for a in aa:
        print(a)

main()



Measured memory_bytes: 52988
#include <iostream>
#include <vector>
using namespace std;
#define myfill(a, val, type) fill((type *)a, (type *)a+sizeof(a)/sizeof(type), val)
const int MOD = 1000000007;

long long mod(long long a) {
	a %= MOD;
	return a >= 0 ? a : a+MOD;
}

int main() {
	string s;
	cin >> s;
	int len = s.size();
	long long dp[len+1][4]; myfill(dp, 0, long long);
	dp[0][0] = 1;
	for (int i = 0; i < len; i++) {
		for (char c : {'A', 'B', 'C'}) {
			if (s[i] != '?' && s[i] != c) continue;
			for (int x = 0; x < 4; x++) {
				dp[i+1][x] = mod(dp[i+1][x] + dp[i][x]);
			}
			int y = c - 'A';
			dp[i+1][y+1] = mod(dp[i+1][y+1] + dp[i][y]);
		}
	}
	long long ans = dp[len][3];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6416
# coding: utf-8
# Your code here!

import sys
read = sys.stdin.read
readline = sys.stdin.readline


def dfs(G, v, d, f, time):
    time += 1
    d[v] = time

    for e in G[v]:
        if d[e] == 0:
            time = dfs(G, e, d, f, time)

    time += 1
    f[v] = time

    return time


def main():
    n = int(readline())

    E = [[]]
    for _ in range(n):
        u,k,*v = map(int, readline().split())
        E.append(v)

    d = [0] * (n+1)
    f = [0] * (n+1)
    time = 0
    
    for i in range(1,n+1):
        if d[i] == 0:
            time = dfs(E, i, d, f, time)
    
    for i in range(1, n+1):
        print(i, d[i], f[i])


if __name__ == "__main__":
    main()




Measured memory_bytes: 5668
#include <iostream>
using namespace std;
int n,m,dp[1<<12],a,b,c,cnt;
int main(void){
    cin>>n>>m;
    for(int i=1;i<(1<<n);i++){
        dp[i]=1e9;
    }
    while(m--){
        cin>>a>>b;
        cnt=0;
        for(int i=0;i<b;i++){
            cin>>c;
            c--;
            cnt+=(1<<c);
        }
        for(int i=(1<<n)-1;i>=0;i--){
            if(dp[i]!=1e9){
                dp[i|cnt]=min(dp[i|cnt],dp[i]+a);
            }
        }
    }
    if(dp[(1<<n)-1]==1e9)cout<<-1<<endl;
    else cout<<dp[(1<<n)-1]<<endl;
}


Measured memory_bytes: 256
Bingo=[]
Bingo.append(list(map(int, input().split())))
Bingo.append(list(map(int, input().split())))
Bingo.append(list(map(int, input().split())))
N=int(input())
Num=[]
for i in range(N):
    Num.append(int(input()))
    
ans="No"
for i in range(3):
    if Bingo[i][0] in Num and Bingo[i][1] in Num and Bingo[i][2] in Num:
        ans="Yes"
for i in range(3):
    if Bingo[0][i] in Num and Bingo[1][i] in Num and Bingo[2][i] in Num:
        ans="Yes"

if Bingo[1][0] in Num and Bingo[1][1] in Num and Bingo[2][2] in Num:
    ans="Yes"
    
if Bingo[0][2] in Num and Bingo[1][1] in Num and Bingo[2][0] in Num:
    ans="Yes"

print(ans)

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

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  int a,b;
  cin>>a>>b;
  int ans = a - b*2;
  cout << ((ans >= 0) ? ans : 0) << endl;
}


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

def main():
    A, B, N = map(int, readline().rstrip().split())
    x = B - 1
    if x > N:
        x = N
    ans = (A * x) // B - A * (x // B)
    print(ans)
    

if __name__ == '__main__':
    main()

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

int main() {
 int a,b;
 string c;
  cin>>a>>b;
    cin>>c;
 
  if(c.at(b-1)=='A') c.at(b-1)='a';
   if(c.at(b-1)=='B') c.at(b-1)='b';
   if(c.at(b-1)=='C') c.at(b-1)='c';
  cout<<c<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n;  scanf("%d", &n);
    int m;  scanf("%d", &m);

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

    int c[m], d[m];
    for(i = 0; i < m; i++){
        scanf("%d%d", &c[i], &d[i]);
    }

    int dir;
    int tmp;
    int j;
    for(i = 0; i < n; i++){
        int pnt = 0;
        dir = (((a[i] - c[0]) > 0) ? (a[i] - c[0]) : -(a[i] - c[0]))
                    + (((b[i] - d[0]) > 0) ? (b[i] - d[0]) : -(b[i] - d[0]));

        for(j = 1; j < m; j++){
            tmp = (((a[i] - c[j]) > 0) ? (a[i] - c[j]) : -(a[i] - c[j]))
                    + (((b[i] - d[j]) > 0) ? (b[i] - d[j]) : -(b[i] - d[j]));
                    
            if(tmp < dir){
                dir = tmp;
                pnt = j;
            }
        }
        printf("%d\n", pnt + 1);
    }

    return 0;
}

Measured memory_bytes: 128
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
using namespace std;
const int MAXN = (int) 2e6 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int n;

struct Node{
    int val;
    int pre,next;
}List[MAXN];
int head,tail;

void print(){
    int x=List[head].next;
//    printf("List:\n");
    while(x!=tail){
        printf("%d",List[x].val);
        if(List[x].next==tail) printf("\n");
        else printf(" ");
        x=List[x].next;
    }
}

void work(){
    scanf("%d",&n);
    head=0;
    tail=1;
    List[head].pre=-1;
    List[head].next=tail;
    List[tail].pre=head;
    List[tail].next=-1;
    int len=tail;
//    print();
//    for(int i=0;i<=len;i++) printf("%d %d\n",List[i].pre,List[i].next);
    for(int i=1;i<=n;i++){
        char s[10];
        scanf("%s",s);
        if(s[0]=='i'){
            ++len;
            scanf("%d",&List[len].val);
            List[len].next=List[head].next;
            List[len].pre=head;
            List[List[len].next].pre=len;
            List[head].next=len;
//            for(int i=0;i<=len;i++) printf("%d %d\n",List[i].pre,List[i].next);
//            print();
        }
        else if(s[6]=='\0'){
            int cur=List[head].next;
            int x; scanf("%d",&x);
            while(cur!=tail){
                if(List[cur].val==x){
                    int p=List[cur].pre;
                    int nxt=List[cur].next;
                    List[p].next=nxt;
                    List[nxt].pre=p;
                    break;
                }
                cur=List[cur].next;
            }
        }
        else if(s[6]=='F'){
            int x=List[head].next;
            if(x!=tail){
                int xx=List[x].next;
                List[head].next=xx;
                List[xx].pre=head;
            }
        }
        else if(s[6]=='L'){
            int x=List[tail].pre;
            if(x!=head){
                int xx=List[x].pre;
                List[xx].next=tail;
                List[tail].pre=xx;
            }
        }
    }
    print();
}

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











Measured memory_bytes: 15524
n, k = map(int, input().split())
p = list(map(int, input().split()))
R = [0] * n
R[0] = p[0]
for i in range(1, n):
    R[i] = R[i - 1] + p[i]

tmp = 0
m = 0
index = 0
for i in range(n - k + 1):
    if m < R[i + k - 1] - tmp:
        m = R[i + k - 1] - tmp
        index = i
    tmp = R[i]
ans = 0

for i in range(index, index + k):
    ans += (p[i] + 1) / 2
print(ans)


Measured memory_bytes: 71792
N,Q = map(int, input().split())
import collections
dqn = collections.deque()
dqt = collections.deque()

def f(s):
    lst = s.split()
    return lst[0], int(lst[1])

for _ in range(N):
    ele = f(input())
    dqn.append(ele[0])
    dqt.append(ele[1])

Time = 0
while len(dqt) > 0:
    dqtime = dqt.popleft()
    dqname = dqn.popleft()
    if dqtime > Q:
        Time += Q
        dqt.append(dqtime - Q)
        dqn.append(dqname)
    else:
        Time += dqtime
        print(dqname,Time)


Measured memory_bytes: 9884
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int b,c,d,e,k;
  int a[5];
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
  for(b = 0; b < 5;b++){
    for(c = 0;c < 5 - b;c++){
      if(a[b] - a[c] > k || a[c] - a[b] > k){
        cout << ":( "<< endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
}

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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <


// CODE STARTS HERE

// 0-indexed
template<typename T>
class FenwickTree {
private:

	const int n;
	vector<T> bits;

public:

	FenwickTree(int N) : n(N), bits(n + 1, 0) {}

	FenwickTree(vector<T>& arr) : FenwickTree(arr.size()) {
		for(int i = 0; i < n; ++i)
			add(i, arr[i]);
	}

	void add(int idx, T delta){
		for (; idx <= n; idx += (idx & -idx))
			bits[idx] += delta;
	}

	T sum(int r){
		T ret = 0;
		for (; r > 0; r -= (r & -r))
			ret += bits[r];
		return ret;
	}

	T sum(int l, int r){
		return sum(r + 1) - sum(l);
	}
};

void solve(){
	int n, q;
	cin >> n >> q;

	vector<int> arr(n);
	for(auto& i : arr) cin >> i, --i;

	struct Query { int l, r, idx; };
	auto cmp = [](const auto lhs, const auto rhs){
		if(lhs.r == rhs.r) return lhs.l < rhs.l;
		return lhs.r < rhs.r;
	};

	vector<Query> queries(q);
	for(int i = 0; i < q; ++i){
		cin >> queries[i].l >> queries[i].r;
		--queries[i].l, --queries[i].r;
		queries[i].idx = i;
	}
	sort(queries.begin(), queries.end(), cmp);

	vector<int> ans(q);

	FenwickTree<int> fen{n};
	vector<int> last(n, -1);

	for(int i = 0, cnt = 0; i < n; ++i){
		if(last[arr[i]] != -1)
			fen.add(last[arr[i]] + 1, -1);

		last[arr[i]] = i;
		fen.add(i + 1, 1);

		while(cnt < q and queries[cnt].r == i){
			ans[queries[cnt].idx] = fen.sum(queries[cnt].l, queries[cnt].r);
			++cnt;
		}
	}

	for(auto i : ans) cout << i << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 17400
#include<iostream>
using namespace std;
int main()
{
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	while(1){
		c = c - b;
		a = a - d;
		if(c <= 0){
			cout<<"Yes"<<endl;
			break;
		}else if(a <= 0){
			cout<<"No"<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define repm(i,a,b) for(ll i=(ll)(a);i>(ll)(b);i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb =vector<bool>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

int main(){
    ll n;
    cin >> n;
    vll a(n);
    vll b(n);
    rep(i, n) cin >> a[i]>>b[i];
    sort(all(a));sort(all(b));reverse(all(b));
    if(n%2==1){
        cout << b[(n-1)/2]-a[(n-1)/2]+1<< endl;
    }else{
        cout << b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1] +1<< endl;
    }
}

Measured memory_bytes: 6416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

struct Point { double x,y; };

void koch(int n, Point a, Point b){
    if(n == 0) return;

    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2*a.x + b.x)/3.0;
    s.y = (2*a.y + b.y)/3.0;
    t.x = (a.x + 2*b.x)/3.0;
    t.y = (a.y + 2*b.y)/3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n-1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n-1, t, b);
    
}

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

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);  
    printf("%.8f %.8f\n", b.x, b.y);
}


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

int main() {

  char c;
  cin >> c;

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }

}



Measured memory_bytes: 3628
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import deque

n = ni()
a = na()

q = deque()
for i in range(n):
    if i % 2 == 0:
        q.append(a[i])
    else:
        q.appendleft(a[i])

if n % 2 == 0:
    for i in range(n):
        if i:
            print(" ", end="")
        print(q.popleft(), end="")
    print()
else:
    for i in range(n):
        if i:
            print(" ", end="")
        print(q.pop(), end="")
    print()

Measured memory_bytes: 25524
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N, L;
  cin >> N >> L;
  VEC<int> aji(N);
  LL sum = 0;
  LL mi = 1 << 30;
  LL del = 1 << 30;
  REP(i, 0, N) {
    aji[i] = L + (i + 1) - 1;
    sum += aji[i];
    if (abs(aji[i]) < mi) {
      mi = abs(aji[i]);
      del = aji[i];
    }
  }
  // if(L<=0){
  //   cout<<sum<<endl;
  //   return 0;
  // }
  // sort(ALL(aji));
  // sum-=aji[0];
  cout << sum - del << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;

int main()
{
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB")
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    
    return 0;
}


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

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

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

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

  int N;
  cin >> N;

  int ans = 0;
  for (int x = 1; x <= 50000; x++) {
    int tmp = (double)x * 1.08;
    if (N == tmp) {
      ans = x;
    }
  }
  if (ans == 0) {
    cout << ":(" << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! get_char {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().chars().collect::<Vec<_>>()
        }
    };
}

fn main() {
    let (d, g) = get!(usize, i64);
    let pc_arr = get!(i64, i64; d);

    let pc_arr = pc_arr
        .into_iter()
        .enumerate()
        .map(|(i, (num, bonus))| ((i as i64 + 1) * 100, num, bonus))
        .collect::<Vec<_>>();

    let mut ans = i64::max_value();
    for bit in 0..(1 << d) {
        let mut total = 0;
        let mut count = 0;
        let mut ri = None;
        for (i, (point, num, bonus)) in pc_arr.clone().into_iter().enumerate() {
            if bit & (1 << i) != 0 {
                total += point * num + bonus;
                count += num;
            } else {
                ri = Some((point, num));
            }
        }

        if total < g {
            let remain = g - total;
            match ri {
                None => continue,
                Some((point, num)) => {
                    let n = (remain + point - 1) / point;
                    if n <= num {
                        count += n;
                    } else {
                        continue;
                    }
                }
            }
        }
        ans = std::cmp::min(ans, count);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>

namespace {
using namespace std;
using ll = long long;
using ull = unsigned long long;
}

ll A, B;

void input() {
    cin >> A >> B;
}

ll solve() {
    return max(A, B) + (A == B ? A : max(A, B)-1);
}

int main() {
    input();
    cout << solve() << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
unsigned long long f[50][140000],a[140000][15];
int main(){
    int n,x,y,z;
    cin>>n>>x>>y>>z;
    y+=x;z+=y;
    int i,j,k;
    for(i=1;i<=1<<z;i++)
    for(j=1;j<=10;j++){
        a[i][j]=1;
        for(k=0;k+j<=z;k++)if(i&(1<<k))
        if(!(k<x&&k+j>x)&&!(k<y&&k+j>y))
        a[i][j]|=1<<(j+k);
        if((i==(1<<z))||a[i][j]>=1<<z)a[i][j]=1<<z;
    }
    f[0][1]=1;
    for(i=1;i<=n;i++)
    for(j=1;j<=1<<z;j++)
    for(k=1;k<=10;k++)
    f[i][a[j][k]]=(f[i][a[j][k]]+f[i-1][j])%(1000000007);
    cout<<f[n][1<<z]<<endl;
    return 0;
}


Measured memory_bytes: 61696
A, B = [int(i) for i in input().rstrip().split(' ')]
cnt = 0
for i in range(A, B+1):
    arr = [i for i in list(str(i))]
    if not arr[0] == arr[-1]:
        continue
    
    asc = ''.join(arr)
    desc = ''.join(list(reversed(arr)))
    if asc == desc:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

const ll large = 2e9+5;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll minminus = large, minplus = large;
    ll maxminus = -large, maxplus = -large;
    int n; cin >> n;
    FOR(i,n){
        ll x, y; cin >> x >> y;
        minminus = min(minminus, x-y);
        minplus = min(minplus, x+y);
        maxminus = max(maxminus, x-y);
        maxplus = max(maxplus, x+y);
    }
    cout << max(maxminus-minminus, maxplus-minplus) << "\n";
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)

int main(){
    int H,W;
    cin >> H >> W;
    vector<int> left,right;
    rep(i,H){
        int r = -1;
        rep(j,W){
            char A; cin >> A;
            if(A == '#'){
                if(r == -1) left.emplace_back(j);
                r = j;
            }
        }
        right.emplace_back(r);
    }

    bool possible = true;
    rep(i,H-1) if(right[i] > left[i+1]) possible = false;

    if(possible) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
n = int(input())

tree_dict = {}
node_info_dict = {}

for _ in range(n):
    row = list(map(int, input().split(" ")))
    
    tree_dict[row[0]] = {
        "left": row[1],
        "right": row[2], 
    }
    
    node_info_dict[row[1]] = {
        "parent": row[0], 
        "sibling": row[2], 
    }
        
    node_info_dict[row[2]] = {
        "parent": row[0], 
        "sibling": row[1], 
    }
        
def get_depth(node_id):
    count = 1
    parent_node_id = node_info_dict[node_id]["parent"]
    while parent_node_id in node_info_dict:
        count += 1
        parent_node_id = node_info_dict[parent_node_id]["parent"]
    
    return count

def get_height(node_id, height):
    right_height, left_height = 0, 0
    if tree_dict[node_id]["right"] != -1:
        right_height = get_height(tree_dict[node_id]["right"], height) + 1
    
    if tree_dict[node_id]["left"] != -1:
        left_height = get_height(tree_dict[node_id]["left"], height) + 1

    height = right_height if right_height > left_height else left_height
    return height
    
for i in range(n):
    if i in node_info_dict:
        parent = node_info_dict[i]['parent']
        sibling = node_info_dict[i]['sibling']
        depth = get_depth(i)
    else:
        parent = -1
        sibling = -1
        depth = 0
        
    degree = 0
    if tree_dict[i]["right"] != -1:
        degree += 1
    if tree_dict[i]["left"] != -1:
        degree += 1
        
    height = get_height(i, 0)
    
    if parent == -1:
        node_type = "root"
    elif tree_dict[i]["right"] == -1 and tree_dict[i]["left"] == -1:
        node_type = "leaf"
    else:
        node_type = "internal node"
        
    print(f"node {i}: parent = {parent}, sibling = {sibling}, degree = {degree}, depth = {depth}, height = {height}, {node_type}")



Measured memory_bytes: 5624
n = int(input())
hot = list(map(int,input().split())) 
n_ = n.bit_length()
db = [[n-1]*(n)]
L = int(input())
r = 1
for i in range(n-1):
  while r < n-1 and hot[r+1]-hot[i] <= L:
    r += 1
  db[0][i] = r
for j in range(1,n_+1):
  new = [db[-1][db[-1][i]] for i in range(n)]
  db.append(new)
  if new[0] == n-1:
    break
n_ = len(db)

def query(s,t):
  dt = 0
  for j in range(n_-1,0,-1):
    if db[j][s] < t:
      dt += 2**j
      s = db[j][s]
  while s < t:
    dt += 1
    s = db[0][s]
  return dt 

q = int(input())
for _ in range(q):
  s,t = map(int,input().split())
  if t < s:
    s,t = t,s
  print(query(s-1,t-1))
   

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

typedef long long ll;
typedef long double ld;
//#define int ll
//#define endl '\n'

// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// print number in binary -> cout << bitset<20>(n);

const int N=101,W=100010,inf=1e9;
int n,m;
ll dp[N][W];
int w[N],v[N];

main(){
	cin.tie(0);cin.sync_with_stdio(0);
	cin>>n>>m;
	for(int i=0;i<n;++i)cin>>w[i]>>v[i];
	for(int i=0;i<n;++i)
		for(int j=0;j<m;++j){
			dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
			if(j+w[i]<=m)dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
		}
	ll res=0;
	for(int i=0;i<=m;++i)res=max(res,dp[n][i]);
	cout<<res<<endl;
}


Measured memory_bytes: 81724
#include<stdio.h>
int main(void){
	int a,b,c,d,i,t,n,f,w,x;
	scanf("%d",&w);
	int l[w];
	for(i=0;i<=w-1;i++) l[i]=i+1;
	scanf("%d",&n);
	for(i=0;i<=n-1;i++){
		scanf("%d,%d",&a,&b);
		x=l[a-1];
		l[a-1]=l[b-1];
		l[b-1]=x;
	}
	for(i=0;i<=w-1;i++) printf("%d\n",l[i]);
	return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >>n;
    vl a(n),b(n),c(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    rep(i,n)cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));
    ll ans=0;
    vl count(n);
    rep(i,n){
        ll key=b[i];
        count[i]=c.end()-upper_bound(all(c),key);
    }
    for(int i=n-1;i>=1;i--){
        count[i-1]+=count[i];
    }
    rep(i,n){
        ll key=a[i];
        ll x=upper_bound(all(b),key)-b.begin();
        ans+=count[x];
    }
    cout <<ans <<endl;
}


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

struct edge { int u, v, cost; };
bool comp(const edge& e1, const edge& e2){
  return e1.cost < e2.cost;
}
int par[100];
int rank[100];

void init_union_find(int n){
  for ( int i=0;i<n;i++){
    par[i]=i;
    rank[i]=0;
  }
}

int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;
  if(rank[x]<rank[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}




int n,m;
edge es[10000];
int V,E;

int kruskal(){
  sort (es,es + m, comp);
  init_union_find(n);
  int res = 0;
  for(int i=0;i<m;i++){
    edge e = es[i];
    if(!same(e.u,e.v)){
      unite(e.u,e.v);
      res+=e.cost;
    }
  }
  return res;
}

int main(){
  while(cin>>n>>m){
    if(n==0&&m==0)break;
    for(int i=0;i<m;i++){
      cin>>es[i].u>>es[i].v>>es[i].cost;
    }
    cout<<kruskal()<<endl;
  }
  
  return 0;
}

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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP(x) cerr << #x << " = " << (x) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent=false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);

template<typename T = int> inline T in() { T x; cin >> x; return x; }
template<typename T = int> inline vector<T> in(int n) { vector<T> xs(n); rep(i, n) cin >> xs[i]; return xs; }
template<typename T = int> inline vector<vector<T>> in(int n, int m) { vector<vector<T>> xs(n, vector<T>(m)); rep(i, n) rep(j, m) cin >> xs[i][j]; return xs; }

int main(void) {
    set<int> a;
    rep(i, 3) {
        int x = in();
        a.insert(x);
    }
    cout << a.size() << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 100000;
int n;
string s;

int main() {
  cin >> s;
  n = s.size();

  bool exist = true;
  if (s[0] == '0' || s[n-1] == '1') {
    exist = false;
  }
  for (int i = 0; i < n-1; ++i) {
    if (s[i] != s[n-i-2]) exist = false;
  }

  if (!exist) {
    cout << -1 << endl;
    return 0;
  }

  vector<int> pars;
  int current = n;
  for (int i = n-2; i >= 0; --i) {
    if (s[i] == '0') {
      pars.push_back(current);
    } else {
      pars.push_back(current);
      current = i+1;
    }
  }
  reverse(all(pars));

  for (int i = 0; i < pars.size(); ++i) {
    cout << i+1 << ' ' << pars[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 2104
import datetime

str = raw_input()
while True:
    str = str.split()
    num = []
    for s in str:
        num.append(int(s))
    if num[0] < 0:
        break
    
    d1 = datetime.date(num[0], num[1], num[2])
    d2 = datetime.date(num[3], num[4], num[5])
    print (d2 - d1).days
    str = raw_input()

Measured memory_bytes: 4416
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int n;
vector <vector <pair <int,int> > > v; 
int test;
vector <int> val;
void cal(int cur);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    n=nxt();
    vector <pair <int,int> > row;
    v.resize(n,row);
    for(int i=1;i<=n;i++)
    {
        int m=nxt();
        for(int j=0;j<m;j++)
        {
            int x=nxt(),y=nxt();
            v[i-1].push_back({x,y});
        }

    }
    val.resize(n);
    test=0;
    cal(0);
    cout<<test<<endl;

    return 0;   
}

void cal(int cur)
{
    if(cur==n)
    {
        bool flag=1;
        int x=0;
        for(int i=0;i<n;i++)
            if(val[i])
            {x++;
                for(int j=0;j<v[i].size();j++)
                    if(val[v[i][j].first-1]!=v[i][j].second)
                    {
                        flag=0;
                        break;
                    }
                    if(!flag)
                        break;
            }

        if(flag&&test<x)
            test=x;
    }
    else
    {
        for(int i=0;i<2;i++)
        {
            val[cur]=i;
            cal(cur+1);
        }
    }
}


 
 


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    
    static int a,b,c,x,ans=0 ;
    scanf ("%d%d%d%d",&a,&b,&c,&x) ;
    
    while ( a>=0 ){
        
        int tmp1 = x ;
        tmp1 -= 500*a ;
        int b2 = b ;
        
        while ( b2>=0 ){
            
            int tmp2 = tmp1 ;
            tmp2 -=100*b2 ;
            int c2 = c ;
            
            while ( c2>=0){
                
                int tmp3 = tmp2 ;
                if ( 50*c2==tmp3 ){
                    ans ++ ;
                }
                
            c2-- ;
            }
        b2-- ;    
        }
    a-- ;
    }    
    
    printf ("%d\n",ans) ;
    return 0 ;
}

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

void draw(int width, int x, int y, vector<string>& a) {
    if (width == 1) {
        a[x][y] = '#';
    } else if (width == 2) {
        a[x][y] = a[x+1][y] = a[x][y+1] = '#';
    } else if (width == 3) {
        a[x][y] = a[x][y+1] = a[x][y+2] = '#';
        a[x+1][y] = a[x+1][y+2] = '#';
        a[x+2][y] = a[x+2][y+2] = '#';
    } else if (width == 4) {
        a[x][y] = a[x][y+1] = a[x][y+2] = a[x][y+3] = '#';
        a[x+1][y] = a[x+1][y+3] = '#';
        a[x+2][y] = a[x+2][y+3] = '#';
        a[x+3][y] = a[x+3][y+2] = a[x+3][y+3] = '#';
    } else {
        for (int j = 0; j < width; ++j) {
            a[x][y+j] = '#';
        }
        for (int j = 1; j < width; ++j) {
            a[x+j][y] = '#';
            a[x+j][y+width-1] = '#';
        }
        for (int j = 2; j < width; ++j) {
            a[x+width-1][y+j] = '#';
        }
        a[x+width-2][y+2] = '#';
        draw(width-4, x+2, y+2, a);
    }
}

int main() {
    int N;
    cin >> N;
    for (;N--;) {
        int W;
        cin >> W;
        vector<string> a(W, string(W, ' '));

        draw(W, 0, 0, a);
        for (int j = 0; j < W; ++j) {
            cout << a[j] << endl;
        }
        if (N > 0) {
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3100