akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<vector>

using namespace std;

#define N 2010
#define ll long long
#define RG register

inline int read(){
    RG int x=0,o=1; RG char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=((x<<3)+(x<<1))+ch-'0',ch=getchar();
    return x*o;
}

int deg[N];

int main(){
	for(RG int i=1;i<=6;++i) deg[read()]++;
	if(deg[1]==3||deg[2]==3||deg[3]==3||deg[4]==3) puts("NO");
	else puts("YES");
}


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

using namespace std;

struct dice{
	vector<int> diceindex{0,1,2,3,4,5};
    vector<int> dicenum{1,2,3,4,5,6};
    
    void setNumber(vector<int> &setnum){
        for(int i = 0; i < 6; i++){
            dicenum[diceindex[i]] = setnum[diceindex[i]];
        }
        return;
    }

    vector<int> getNumber(){
        vector<int> indexed(6);
        for(int i = 0; i < 6; i++)
            indexed[i] = dicenum[diceindex[i]];

        return indexed;
    }

    void roll(char d){
        vector<int> dump = diceindex;
        vector<int> newindex(6);
        switch(d){
            case 'N':{
                vector<int> n{4,0,2,3,5,1};
                newindex = n;
              break;
            }
            case 'S':{
                vector<int> n{1,5,2,3,0,4};
                newindex = n;
              break;
            }
            case 'W':{
                vector<int> n{3,1,0,5,4,2};
                newindex = n;
              break;
            }
            case 'E':{
                vector<int> n{2,1,5,0,4,3};
                newindex = n;
              break;
            }
        }
        for(int i = 0; i < 6; i++){
            diceindex[newindex[i]] = dump[i];
        }
        return;
    }
};

int main(){
    vector<int> dicenum(6);
    for(int i = 0; i < 6; i++){
        cin >> dicenum[i];
    }
    string s;
    cin >> s;
    dice d;
    d.setNumber(dicenum);
    
    for(int i = 0,iend = s.size(); i < iend; i++){
        d.roll(s[i]);
    }
    
    dicenum = d.getNumber();
    cout << dicenum[0] << endl;
	return 0;
}

Measured memory_bytes: 3120
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <numeric>
#include <vector>
#include <math.h>
#include <string>
#include <queue>

using namespace std;



bool cmp(pair<int, int> a, pair<int, int> b)
{
	return a.second < b.second;
}

int main()
{
	int N, M;
	cin >> N >> M;
	int br[100001];
	
	vector<pair<int, int>> req;

	for (int i = 0; i < N; i++)
	{
		br[i] = 1;
	}

	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;

		req.push_back(make_pair(a, b));
	}

	sort(req.begin(), req.end(), cmp);
	int count = 0;

	for (int i = 0; i < M; i++)
	{
		int f = req[i].second;
		int t = req[i].first;

		bool flag = true;

		for (int j = f; j > t; j--)
		{
			if (br[j - 1] != 1)
			{
				flag = false;
				break;
			}
		}

		if(flag)
		{
			br[f - 1] = 0;
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N >> K;
  Vec(P,lli,N,0);
  rep(i,0,N){
    cin >> A;
    P[A-1]++;
  }
  Sort(P);Rev(P);
  rep(i,K,N)sum+=P[i];
  Out(sum);
}

Measured memory_bytes: 1792
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

int n;
set<int> s[1000];
vpi ans;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

cin >> n;
if(n%2==0)
{
for(int i=1;i<=n/2;i++){
       s[i].insert(i);
       s[i].insert(n-i+1);
}
       for(int i=1;i<n/2;i++){
              for(auto t:s[i]){
                     for(auto u:s[i+1]){
                            ans.pb({t,u});
                     }
              }
       }
       if(n>4)
       for(auto t:s[(n+1)/2]){
              for(auto u:s[1]){
                     ans.pb({u,t});
              }
       }
}
else {
  for(int i=1;i<=n/2;i++){
       s[i].insert(i);
       s[i].insert(n-i);
}
s[(n/2)+1].insert(n);
       for(int i=1;i<=n/2;i++){
              for(auto t:s[i]){
                     for(auto u:s[i+1]){
                            ans.pb({t,u});
                     }
              }
       }
       if(n>4)
       for(auto t:s[(n+1)/2]){
              for(auto u:s[1]){
                     ans.pb({u,t});
              }
       }
}

cout << ans.size() << endl;
for(auto t:ans){
       cout << t.fs << " " << t.sc << endl;
}


return 0;
}
///....


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18
#define PI 3.1415926535

using ll = long long;



int main(){
  int N; cin >> N;
  vector<ll> A(N);
  ll cntmi = 0;
  ll m = LINF;
  ll sum = 0;
  ll ans = 0;
  rep(i,N){
    cin >> A[i];
    if(A[i] < 0) cntmi++;
    m = min(m,abs(A[i]));
    sum += abs(A[i]);
  }
  if(cntmi % 2 == 0) ans = sum;
  else ans = sum - 2 * m;
  cout << ans << endl;
  
}

Measured memory_bytes: 1024
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter

# import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    a = [0] + list(map(int, readline().split())) + [0]
    cost = 0

    for i in range(n + 1):
        cost += abs(a[i + 1] - a[i])

    for j in range(1, n + 1):
        omit = abs(a[j] - a[j - 1]) + abs(a[j + 1] - a[j])
        new = abs(a[j + 1] - a[j - 1])
        print(cost - omit + new)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65004
N=int(input())
def yakusu(n):
    y=set([n])
    for i in range(1, int(n//2)+1):
        if n%i==0:
            y.add(i)
    return len(y)
ans=0
for i in range(1,N+1,2):
    if yakusu(i)==8:
        ans+=1
print(ans)

Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
  int N,L;
  cin >> N >> L;

  vector<string>word(N);

  for(int i=0;i<N;i++){
    cin >> word[i];
  }

  sort(word.begin(),word.end());

  string ans = "";

  for(int i=0;i<N;i++){
    ans += word[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int flag=0;
  for(int i=0;i<s.size();i++){
    for(int j=0;j<i;j++){
      if(s[i]==s[j]){
        flag=1;
      }
    }
  }
  if (flag){cout << "no" << endl;}
  else{cout << "yes" << endl;}
}


Measured memory_bytes: 256
#include <stdio.h>

int linear_search(int s[], int n,  int t) {
  for (int i = 0; i < n; i++)
    if (s[i] == t)
      return 1;
  return 0;
}

int main(void) {
  int n ,q;
  int s[10000];
  int t[500];
  int i;
  int count = 0;
  
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &s[i]);
  scanf("%d", &q);
  for (i = 0; i < q; i++)
    scanf("%d", &t[i]);

  for (i = 0; i < q; i++) {
    count += linear_search(s, n, t[i]);
  }

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



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main(){
	double a,b,x;scanf("%lf%lf%lf",&a,&b,&x);
	if(x>=a*a*b/2){
		x=a*a*b-x;x/=a*a/2;
		printf("%.8lf\n",atan(x/a)*90/asin(1));
		return 0;	
	}
	x/=a*b/2;
	printf("%.8lf\n",90-atan(x/b)*90/asin(1));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

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

int main() {
  ll N,X;
  cin >> N >> X;
  ll S[N];
  for (int i = 0; i < N; i++) cin >> S[i];
  sort(S,S+N);
  reverse(S,S+N);
  ll DP[2][100100];
  for (ll i = 0; i <= 1; i++) {
    for (ll j = 0; j <= 100003; j++) {
      DP[i][j] = 0;
    }
  }
  ll v = 1;
  for (ll i = 2; i <= N; i++) {
    v *= i;
    v %= Mod;
  }
  DP[0][X] = v;
  for (ll i = 0; i < N; i++) {
    ll b = modinv(N - i,Mod);
    for (ll j = 0; j <= X; j++) {
      ll a = DP[0][j];
      ll c = a * b;
      c %= Mod;
      DP[1][j % S[i]] += c;
      DP[1][j % S[i]] %= Mod;
      c *= (N - i - 1LL);
      c %= Mod;
      DP[1][j] += c;
      DP[1][j] %= Mod;
    }
    for (ll j = 0; j <= X; j++) {
      DP[0][j] = DP[1][j];
      DP[1][j] = 0;
    }
  }
  ll ans = 0;
  for (ll i = 0; i <= X; i++) {
    ll d = i * DP[0][i];
    d %= Mod;
    ans += d;
    ans %= Mod; 
  }
  cout << (ans%Mod) << endl;
  return 0;
}

Measured memory_bytes: 5176
#include<stdio.h>
int main(void){
	int i,j,a,b;
	while(1){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0){
					break;
				}
		for(i = 0;i < a;i++){
			for(j = 0;j < b;j++){
				if(i == 0 || i == a-1 || j == 0 || j == b-1){
					printf("#");
				}else{
					printf(".");
				}
			}printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
h,w,m=map(int,input().split())
l=[]
for i in range(m):
    l.append(list(map(int,input().split())))
l.sort()
a={}
b={}
for i in l:
    if i[0] in a:
        a[i[0]]+=1
    else:
        a[i[0]]=1
    if i[1] in b:
        b[i[1]]+=1
    else:
        b[i[1]]=1
ma=max(list(b.values()))
c={}
for i in b:
    if b[i]==ma:
        c[i]=1
ans=0
i=0
for j in a:
    e=0
    while i<m and l[i][0]==j:
        if l[i][1] in c:
            e+=1
        i+=1
    tans=a[j]+ma
    if e==len(c):
        tans-=1
    ans=max(ans,tans)
print(ans)

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

int fnc(int a){

    int ans=0;
    while(a>0){
        ans += a%10;
        a /= 10;
    }
    return ans;
}


int main(void){

    int N; cin>>N;
    if(N % fnc(N) == 0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  int dem=1;
  for(int i=1; i<n; ++i)
  {
    if (s[i]!=s[i-1]) dem++;
  }
  cout << dem;
  return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(begin(a), end(a));
	reverse(begin(a), end(a));
	int add = 0, sub = 0;
	for (int j = 0; j < n; j++) {
		if (j != 0 && j % 2 != 0) sub+= a[j];
		else add+= a[j];
	}

	cout << abs(add - sub) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
  string str;

  cin >> str;

  sort(str.begin(), str.end());

  bool af = false;
  bool bf = false;
  bool cf = false;
  if (str[0] == 'a') af = true;
  if (str[1] == 'b') bf = true;
  if (str[2] == 'c') cf = true;

  string ans = "No";
  if (af && bf && cf) ans = "Yes";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int ans = 0;
		for (int i = 1; i * i <= N; i++) {
			ans = i * i;
		}
		
		System.out.println(ans);
	}
	
	
}


Measured memory_bytes: 23764
// clang-format off
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

// clang-format on
int main() {
    string s;
    cin >> s;

    llint n = s.size();
    llint whitenum = 0, blacknum = 0;
    REP(i, n) {
        if(s[i]=='B'){
            blacknum++;
        }else{
            whitenum++;
        }
    }
    llint now_white = 0,result=0;
    REP(i,n){
        if(s[i]=='W'){
            result += i - now_white;
            now_white++;
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Possible");}else{puts("Impossible");}

int main() {
    int n;
    cin >> n;
    int count[101] = {};
    int ma = 0;
    int flag = 0;
    rep(i,n){
        int a; cin >> a;
        count[a]++;
        ma = max(ma,a);
    }

    if(count[ma]<2){
        flag = 1;
    }

    if(ma%2==0){
        srep(i,1,ma+1){
            if(i<ma/2){
                if(count[i]!=0)flag=1;
            }else if(i==ma/2){
                if(count[i]!=1)flag=1;
            }else{
                if(count[i]<2)flag=1;
            }
        }
    }else{
        srep(i,1,ma+1){
            if(i<=ma/2){
                if(count[i]!=0)flag=1;
            }else if(i==(ma+1)/2){
                if(count[i]!=2)flag=1;
            }else{
                if(count[i]<2)flag=1;
            }
        }
    }

    if(flag==0)yn;

    return 0;
}
 
 


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int C[105][105];

int main(void) {

	int A, B;
	cin >> A >> B;

	for (int j = 0; j < 100; j++) {
		C[j][0] = 1;
	}

	for (int i = 0; i < 100; i += 2) {
		for (int j = 1; j < 99; j++) {
			C[i][j] = 1;
		}
	}

	B--; A--;

	for (int k = 1; k < 100; k+=6) {
		if (A == 0) { break; }
		for (int j = 2; j < 95; j+=2) {
			C[k][j] = 1; A--; if (A == 0) { break; }
		}
	}

	for (int k = 4; k < 100; k += 6) {
		if (B == 0) { break; }
		for (int j = 2; j < 95; j += 2) {
			C[k][j] = 0; B--; if (B == 0) { break; }
		}
	}

	cout << 100 << " " << 100 << endl;
	string tmp;
	for (int i = 0; i < 100; i++) {
		tmp.clear();
		for (int j = 0; j < 100; j++) {
			if (C[i][j] == 1) { tmp+="#"; }
			else { tmp+="."; }
		}
		cout << tmp << endl;
	}

	//system("pause");
	return 0;
}

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  // vector<int> A(N);
  // for (int i = 0; i < N; ++i) cin >> A[i];
  cout << ceil((double)(N - 1) / (K - 1)) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>

#define mod 1000000007
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOREACH(i, v) for(auto i = v.begin(); i != v.end(); i++)

using namespace std;
using ll = long long;

int X[] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Y[] = {1, 1, 1, 0, -1, -1, -1, 0};

int gcd(int a, int b) {
    int x = max(a, b);
    int y = min(a, b);
    int z = x % y;
    if(z == 0){
        return y;
    }else{
        return gcd(y, z);
    }
}

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

void solve() {
    int a, b;
    cin >> a >> b;
    if((a*b)%2 == 0){
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }
}

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

Measured memory_bytes: 764
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
d=deque([3,5,7])
# print(d)

ans=0
# dic={}
while d:
    tmp=d.popleft()
    if tmp<=n:
        s=Counter(str(tmp))
        if s["3"] and s["5"] and s["7"]:
            # print(tmp)
            ans+=1
        d.append(tmp*10+3)
        d.append(tmp*10+5)
        d.append(tmp*10+7)

print(ans)

Measured memory_bytes: 12720
#include <stdio.h>
#include <math.h>

typedef struct{
  double x;
  double y;
} Point;

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.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*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;
  scanf("%d",&n);
  a.x=a.y=b.y=0;
  b.x=100;
  printf("%.8f %.8f\n",a.x,a.y);
  Koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

}


Measured memory_bytes: 2088
import math

N, K = map(int, input().split())

ans = 0
for n in range(1, N+1):
  if n >= K:
    ans += 1/N
  
  else:
    m = math.ceil(math.log2(K/n))
    ans += (1/N)*(0.5**m)

print(ans)

Measured memory_bytes: 3188
N = int(input())
a = list(map(int,input().split()))

sum_list = [0]
sum_a = sum(a)

for i in range(0,N-1):
    sum_list.append(sum_list[i]+a[i])

min_a = 3*10**9    
for i in sum_list[1:]:
    abs_a=abs(sum_a-2*i)
    if min_a>abs_a:min_a=abs_a
print(min_a)
      

Measured memory_bytes: 23792
#include <iostream>

using namespace std;

int main()
{
    int n;
    int flag=0;
    cin>>n;
    while(n--)
    {

        int x;
        cin>>x;
        if(x%2==0)
        {
            if((x%3!=0)&&(x%5!=0))
                {
                    flag=1;
                    break;
                }
        }
    }
    if(flag==1)
        cout<<"DENIED"<<endl;
    else
        cout<<"APPROVED"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    int count=0,mini=INF;
    long long sum=0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        count+=(a[i]<0);
        sum+=abs(a[i]);
        mini=min(abs(a[i]),mini);
    }
    cout << (sum-2*(count%2==1?mini:0)) << endl;
    return 0;
}


Measured memory_bytes: 640
n, k = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(k):
  l = [0 for i in range(n)]
  r = [0 for i in range(n)]
  for i in range(n):
    l[max(0, i-a[i])] += 1
    r[min(i+a[i], n-1)] += 1
    
  lighted = 0
  for i in range(n):
    lighted += l[i]
    a[i] = lighted
    lighted -= r[i]
  if len(set(a)) == 1 and a[0] == n:
    break
print(' '.join(list(map(str, a))))


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

int main(){
    int c[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> c[j][i];
        }
    }
    int a[3];
    int b[3];
    for(int i=0;i<=c[0][0];i++){
        for(int j=0;j<=c[1][1];j++){
            for(int k=0;k<=c[2][2];k++){
                a[0]=i;a[1]=j;a[2]=k;
                b[0]=c[0][0]-a[0];b[1]=c[1][1]-a[1];b[2]=c[2][2]-a[2];
                if(a[0]+b[1]==c[0][1] && a[0]+b[2]==c[0][2] && a[1]+b[0]==c[1][0] && a[1]+b[2]==c[1][2] && a[2]+b[0]==c[2][0] && a[2]+b[1]==c[2][1]){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
//by Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<s32>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define fi first
#define se second
#define ln '\n'
#define debug(x) cout << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

const int N = 1e5 + 5;
graph g(N,s32());
set<p32> edge;
int outdeg[N],vis[N];

void dfs(int ii,int pp)
{
	vis[ii] = 1;
	for(auto jj : g[ii])
		if(!vis[jj] && edge.count({ii,jj}) && edge.count({jj,ii}))
			dfs(jj,ii);
	if(pp)
	{
		for(auto jj : g[ii])
		{
			if(jj == pp) continue;
			if(edge.count({ii,jj}) && edge.count({jj,ii}))
			{
				edge.erase({jj,ii});
				outdeg[ii]++;
			}
		}
		if(outdeg[ii] % 2)
		{
			edge.erase({pp,ii});
			outdeg[ii]++;
		}
		else
		{
			edge.erase({ii,pp});
			outdeg[pp]++;
		}
	}
}

int main()
{
	FASTIO;
	int n,m;
	cin >> n >> m;
	for(int i = 0;i < m;i++)
	{
		int u,v;
		cin >> u >> v;
		g[u].insert(v);
		g[v].insert(u);
		edge.insert({u,v});
		edge.insert({v,u});
	}
	if(m % 2)
		cout << "-1" << ln;
	else
	{
		dfs(1,0);
		for(auto itr : edge)
			cout << itr.fi << " " << itr.se << ln;
	}
	return 0;
}


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

 public class Main{
	 public static void main(String args[]) throws IOException{
		 BufferedReader bf = new BufferedReader(
				 new InputStreamReader(System.in));
		 String str = bf.readLine();
		 Integer[] result = new Integer[5];
		 String[] deta = str.split(" ",0);
		 for(int i = 0; i < deta.length; i++){
			 result[i] = Integer.parseInt(deta[i]);
		 }
		 Arrays.sort(result,Collections.reverseOrder());
		 for(int i = 0; i < result.length-1; i++){
			 System.out.print(result[i]+" ");
		 }
		 System.out.println(result[result.length-1]);
	}
}

Measured memory_bytes: 24364
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);

int main(){
  int N, D, tmp, cnt=0;
  cin >> N >> D;
  int S[N][D];
  rep(i, N){
    rep(j, D){
      cin >> S[i][j];
    }
  }
  rep(i, N){
    rep(k, N){
      tmp=0;
      rep(j, D){
        tmp += (int)pow((S[i][j] - S[k][j]), 2);
      }
      if(int(sqrt(tmp)) == sqrt(tmp) && tmp!=0)
        cnt ++;
    }
  }
  cout << (cnt/2) << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static List<Long> list;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt() - 1;
        
        list = new ArrayList<Long>();
        
        // ルンルン数: (次の桁に-1～+1で行ける)
        // ex. 334, 2123, 3234566667 (0はNG)
        
        // 10桁以下のルンルン数を全探索
        for (int i = 1; i <= 9; i++) {
            dfs(i);
        }
        
        // 昇順にソートし、k番目を出力
        list.sort(Comparator.naturalOrder());
        System.out.println(list.get(k));
    }
    
    public static void dfs(long cur) {
        // 終了条件: 最大のルンルン数は10桁なので11桁以上は不要
        if (cur > 10000000000L) {
            return;
        }
        
        // リストにルンルン数を追加
        list.add(cur);
        
        // 次項はlast-1, last+0, last+1のパターン
        long x10 = cur * 10;
        long last = cur % 10;
        if (last != 0) {
            dfs(x10 + last - 1);
        }
        // if (1 <= last <= 8)
            dfs(x10 + last);
        if (last != 9) {
            dfs(x10 + last + 1);
        }
    }
}

Measured memory_bytes: 33908
import random
import copy
import time
def evaluateSatisfaction(d, c, s, ans):
    score = 0
    last = [-1 for i in range(26)]
        
    for i in range(d):
        
        score += s[i][ans[i]]
        last[ans[i]] = i
        for j in range(26):
            if j != ans[i] or True:
                score -= c[j]*(i - last[j])
    return score
    
def valuationFunction(d,c,s,contestType,day,last):
    las = copy.copy(last)
    las[contestType] = day
    gain = s[day][contestType]
    lost = 0
    for i in range(8):
        for j in range(26):
            lost += c[j]*(i - las[j])
    return gain - lost

def Input():
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for i in range(d)]
    #s[3][25] =   contest(25+1) of day(3+1)
    return d, c, s

def evolution(d, c, s, ans):
    score_before = evaluateSatisfaction(d, c, s, ans)
    ans_after = copy.copy(ans)
    x = random.randint(0,(d-1)-10)
    idx1 = x
    idx2 = x+random.randint(1,5)
    
    tmp = ans_after[idx1]
    ans_after[idx1] = ans_after[idx2]
    ans_after[idx2] = tmp

    score_after = evaluateSatisfaction(d,c,s,ans_after)

    if score_after > score_before:
        return ans_after
    else:
        return ans

if __name__ == "__main__":
    
    d, c, s = Input()
    
    #print("val =", evaluateSatisfaction(d, c, s, [1, 17, 13, 14, 13]))

    #calc start
    t1 = time.time()
    ans = [0 for i in range(d)]
    last = [-1 for i in range(26)]
    for i in range(d):
        evalValueList = [0 for j in range(26)]
        for j in range(26):
            evalValueList[j] = valuationFunction(d, c, s, j,i,last)

        max_idx = 0
        max = evalValueList[0]

        for j in range(26):
            if (max < evalValueList[j]):
                max_idx = j
                max = evalValueList[j]
        
        ans[i] = max_idx
        last[ans[i]] = i


    
    #ans = [1, 2, 3, 4, 5]
    t2 = time.time()
    while(float(t2-t1) < 1.8):
        ans = evolution(d, c, s, ans)
        #print("ans = ",evaluateSatisfaction(d,c,s,ans))
        t2 = time.time()
    for x in ans:
        print(x + 1)
    #print(evaluateSatisfaction(d,c,s,ans))

Measured memory_bytes: 10072
/*
  Chebyshev's Theorem
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1172&lang=jp
*/

#include <iostream>

using namespace std;

bool isPrime[456912];
int  already;

int main(void){
  already = 1;
  isPrime[0] = 0;
  isPrime[1] = 0;
  isPrime[2] = 1;

  for(int i = 3 ; i < 456912 ; i++){
    isPrime[i] = 1;
  }

  for(int i = 2 ; i < 456912 ; i++){
    if(isPrime[i] == 1){
      for(int j = 2 ; i * j < 456912 ; j++){
        isPrime[i * j] = 0;
      }
    }
  }

  while(1){
    int n;
    cin >> n;
    if(n == 0) break;

    int cnt = 0;

    for(int i = n + 1 ; i <= 2 * n ; i++){
      if(isPrime[i] == 1){cnt++;}
    }

    cout << cnt << endl;

  }

  return 0;
}

Measured memory_bytes: 3408
import sys
from math import sqrt

def calc(min_v):
    min_t = min_v / 9.8
    N = 2
    while True:
        height = 5 * N - 5
        if sqrt(height / 4.9) > min_t:
            return N
        else:
            N += 1

for line in sys.stdin.readlines():
    line = line.strip()
    n = float(line)
    print calc(n)

Measured memory_bytes: 5396
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**6)

"""
def dfs(balls,B=-1,C=-2,cp=0):
	if cp==len(balls): 	return True
	ball = balls[cp]
	if B<ball:
		is_find = dfs(balls,ball,C,cp+1)
		if is_find: return True
	if C<ball:
		is_find = dfs(balls,B,ball,cp+1)
		if is_find: return True
	return False
"""

def dfs(balls):
	B, C = -2, -1
	for ball in balls:
		if C<ball:
			C = ball
			continue
		if B<ball:
			B = ball
			continue
		return False
	return True

def main():
	N = int(input().strip())
	for _ in range(N):
		balls = list(map(int,input().split(' ')))
		is_find = dfs(balls)
		if is_find:		print('YES')
		else:			print('NO')

if __name__=='__main__':
	main()

"""
2
3 1 4 2 5 6 7 8 9 10
10 9 8 7 6 5 4 3 2 1
"""

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

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<ll> x(n, k-q);
    vector<int> a(q);
    rep(i,q){
        int a;
        cin >> a;
        --a;
        x[a]++;
    }
    rep(i,n) {
        if(x[i]>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

int main(void)
{
	int num, x, i, j, n = 0;
	float y;
	int a = 1;

	scanf("%d", &num);

	for (j = 0; j < num; j++) {
		scanf("%d", &x);
		if (x == 2) {
			n++;
		}
		else if (x > 2 && x % 2 == 1) {
			i = 3;
			y = sqrt(x);
			a = 1;
			while (i <= y) {
				if (x % i == 0) {
					a = 0;
					break;
				}
				i = i + 2;
			}
			
			if (a == 1) {
				n++;
			}
		}

	}

	printf("%d\n", n);

	return 0;
}


Measured memory_bytes: 2124
N, K = map(int, input().split())
lst = [0] * (10**5 + 1)
length = 0


for i in range(N):
    ai, bi = map(int, input().split())
    lst[ai] += bi

for ai, bi in enumerate(lst):
    length += bi
    if length >= K:
        ans = ai
        print(ans)
        break


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

int n,m;
vector<vector<int>> dat(1000000);
vector<int> ans(10000000);

int main(){
    int n,x,y;
    cin>>n>>x>>y;
    rep(i,n){
        for(int j=i+1;j<=n;j++){
            int m=j-i;
            ans[min(j-i,abs(i-x)+abs(j-y)+1)]++;

        }
    }
    rep(i,n-1){
        cout<<ans[i]<<endl;
    }
    return 0;
}

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

int main() {
    int H, W; cin >> H >> W;
    int a[501][501];
    for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) cin >> a[i][j];
    int x = 0, y = 0;
    int count = 0;
    vector<vector<int> > ans;
    for (int i = 1; i <= H; i++) {
        int j0 = i % 2 == 0 ? W : 1;
        int dj = i % 2 == 0 ? -1 : 1;
        for (int j = j0; 0 < j && j <= W; j += dj) {
            if (count % 2 == 1) ans.push_back({x, y, i, j});
            if (a[i][j] % 2 == 1) count++;
            x = i; y = j;
        }
    }
    cout << ans.size() << endl;
    for (auto x : ans) printf("%d %d %d %d\n", x[0], x[1], x[2], x[3]);
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    string S;
    cin >> S;
    ll sum = 0;
    REP(i,0,SZ(S)) {
        sum = (sum + (S[i] - '0')) % 9; 
    }
    if(sum == 0) PR("Yes");
    else PR("No");

    return 0;
}

/*



*/

Measured memory_bytes: 3748
#include <iostream>
using namespace std;
int main(){
int n;
cin>>n;
bool flg=false;
for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
        if(i*4+j*7==n){
        flg=true;
        break;
    }}
}
if(flg){cout<<"Yes";}
else {cout<<"No";}}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
	cin >> H >> W;
    int cnt = 0;
    for(int i = 0; i < H; i++){
    	for(int j = 0; j < W; j++){
    		char A; cin >> A;
    		if(A == '#') cnt++;
    	}
    }
    if(cnt == H+W-1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

void solve() {
    int n;
    string s, t;
    cin >> n >> s >> t;

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

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


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

int main(void)
{
    string s;
    cin >> s;
    string s1;

    char c;
    c = s[s.size()-1];
    size_t same_num = 1;
    for (int i = s.size()-2; i >= 0; i--) {
        if (c == s[i]) {
            same_num++;
        } else {
            break;
        }
    }

    int k = 1;
    s1 = s.substr(0, 1);
    size_t current_pos = 1;
    if (s.size() == same_num) {
        current_pos = 0;
        k = 0;
    }
    for (; current_pos < s.size() - same_num;) {
        if (s1 == s.substr(current_pos, 1)) {
            s1 = s.substr(current_pos, 2);
            current_pos += 2;
            k++;
        } else {
            s1 = s.substr(current_pos, 1);
            current_pos += 1;
            k++;
        }
    }
    int j = s.size() - current_pos;
    k += (j / 3 * 2) + ((j % 3 == 0) ? 0 : 1);
    cout << k << endl;

    return 0;
}



Measured memory_bytes: 640
def main():
    N = int(input())
    A = list(map(int, input().split()))
    current = 1000
    prev = A[0]
    for a in A[1:]:
        if prev < a:
            n = current // prev
            current = a * n + (current % prev)
        prev = a
    print(current)


if __name__ == "__main__":
    main()


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


int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  int num=0;
  for(int i=0;i<m;++i){
    cin >> a[i];
    num+=a[i];
  }
  if(num>n){
    cout << "-1" << endl;
    return 0;
  }
  int ans=n-num;
  cout << ans << endl;
  return 0;

}


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

int main(){
    ll n,a,b,count=0,countb=0;
    string s;
    cin>>n>>a>>b>>s;
    for(int i=0; i<s.size(); i++) {
        if(s[i]=='a' && count<a+b) {
            cout<<"Yes"<<"\n";
            count++;
        }
        else if(s[i]=='b' && count<a+b && countb<b) {
            cout<<"Yes"<<"\n";
            count++;
            countb++;
        }
        else cout<<"No"<<"\n";
    }
}

Measured memory_bytes: 896
S = input()
check = ['A', 'C', 'G', 'T']
ans = 0
L = len(S)
for i in range(L):
    count  = 0
    if S[i] in check:
        count += 1
        j = i + 1
        while j < L:
            if S[j] in check:
                count += 1
            else:
                break
            j += 1
    ans = max(ans, count)
print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>
#include<chrono>
#include<random>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

long double constexpr pi = 3.141592653589793;

template<class T>
constexpr T sigma1(T i, T n){
    return (n - i + 1) * (i + n) / 2;
}

template<class T>
constexpr T sigma2(T i, T n){
    return (i == 1 ? n * (n + 1) * (2 * n + 1) / 6 :
            sigma2(1, n) - sigma2(1, i - 1));
}

template<class T>
constexpr T sigma3(T i, T n){
    if (i == 1) {
        auto temp = sigma1(i, n);
        return temp * temp;
    }
    return sigma2(1, n) - sigma2(1, i - 1);
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    ll n;
    cin >> n;

    vll a(n);
    unordered_map<ll, ll> m;

    for0(i, n){
        cin >> a[i];
        ++m[a[i]];
    }

    unsigned long long s = accumulate(a.begin(), a.end(), 0LL);
    ll q;
    cin >> q;

    for0(i, q){
        ll b, c;
        cin >> b >> c;

        ll x = m[b];
        m[b] = 0;
        m[c] += x;

        cout << (s += (c - b) * x) << "\n";

    }


    return 0;
}


Measured memory_bytes: 7804
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
using namespace std;
int main() {
    long double L;
    cin >> L;
    long double ans = (long double)((L * L * L) / 27);
    cout << fixed << setprecision(8) << ans << endl;
}


Measured memory_bytes: 256
while True:
  try:
    n, m = map(int, input().split())
  except EOFError:
    break
  costs = []
  vocals = []
  dances = []
  looks = []
  for _ in range(n):
    input()
    c, v, d, l = map(int, input().split())
    costs.append(c)
    vocals.append(v)
    dances.append(d)
    looks.append(l)
  
  def max_param(params):
    dp = [0] * (m + 1)
    for i in range(n):
      c = costs[i]
      p = params[i]
      for j in range(m - c + 1):
        dp[j + c] = max(dp[j + c], dp[j] + p)
    return dp[-1]

  print(max(max_param(vocals), max_param(dances), max_param(looks)))
  



Measured memory_bytes: 5624
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<iomanip>
#include<math.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
const long long INF = 1LL << 60;

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(q);
    REP(i,q){
        cin >> a[i];
    }

    vector<int> ansnum(n);
    REP(i,q){
        ansnum[a[i]-1]++;
    }

    REP(i,n){
        if(k-q+ansnum[i]>0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll MOD = 1e9 + 7;
const ll dx[4] = { -1,1,0,0 };
const ll dy[4] = { 0,0,-1,1 };
const ll MAX = 1e5 + 50 ;
const ll oo = 1e16;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
long long gcd(long long  a, long long  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll n , m , ans , k ; string s ;
ll t[5];

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

    cin >> n ;

    for(int i = 0 ; i < 5 ; ++i)
        cin >> t[i];

   ans = 4 ;
   ll mn = 1e16;
   for(int i = 0 ; i < 4 ; ++i)
        mn = min(mn , (t[i + 1] > t[i]) ? t[i] : t[i + 1]);

   ans += n/mn + ((n%mn) > 0);

   cout << ans << '\n';


     return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// 01Trie BIT CHT DFT FFT avl cmd cusum dijkstra dinic geo2 gin graph kruskal lca lcm matrix ncm next_combination ppuf segtree st tmp topcoder uf vi 

struct UnionFind {
    vector<int> parent;
    int size;
    UnionFind(int n) :parent(n, -1), size(n) {}
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y)return false;
        if (sizeOf(x) < sizeOf(y))swap(x, y);
        parent[x] += parent[y]; parent[y] = x; size--;
        return true;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
    int sizeOf(int x) { return -parent[root(x)]; }
};

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

    int2(n, m);
    UnionFind uf(n + m);

    vi lang(m, 0);
    rep(i, n) {
        Int(yui);
        rep(j, yui) {
            Int(tmp); tmp--;
            uf.unite(i, n+tmp);
            lang[tmp]++;
        }
    }

    int cnt = 0;
    rep(i, lang.size()) cnt += !lang[i];

    if (uf.sizeOf(0) == (n + m - cnt)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    


            

    return 0;
}


Measured memory_bytes: 2560
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Tue Dec 25 03:29:25 2018
//
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	ans, sum, l := 0, 0, 0
	for r, a := range arr {
		for sum&a != 0 && l <= r {
			sum &= ^arr[l]
			l++
		}
		sum |= a
		ans += r - l + 1
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int>
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key

//const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0);
const int32_t mod = 1e9+7;
const int32_t maxn=2e5+5;
int inf=1e18;

void solve(){
    int n;cin>>n;
    int a[n];rep(i,0,n) cin>>a[i];
    int res=0;
    rep(i,0,n){
        rep(j,i+1,n){
            if(a[i]==a[j]) continue;
            rep(k,j+1,n){
                if(a[i]==a[k] or a[j]==a[k]) continue;
                if(a[i]>=a[j]+a[k] or a[j]>=a[i]+a[k] or a[k]>=a[i]+a[j]) continue;
                res++;                
            }
        }
    }
    cout<<res<<'\n';
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
n = int(input())
h = list(map(int, input().split()))

ans = 0
tmp = 0

chain = False
ans = 0
tmp = 0
now = h[0]

for a in range(1, n):
    if now >= h[a]:
        if chain:
            tmp += 1
        else:
            tmp += 1
            chain = True
    else:
        chain = False
        tmp = 0
    ans = max(ans, tmp)
    now = h[a]

print(ans)


Measured memory_bytes: 20444