akhauriyash/Code-Regression huggingface dataset:
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>   
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n,m;
vi A,B;
int dp[52][52][110][2];
int mem[52][52][110][2][3];
int f(int a,int b,int co,int tu,int pas){
	if(pas==3)return 0;
	if(mem[a][b][co][tu][pas]+inf)return mem[a][b][co][tu][pas];
	 
	int A,B,TU=(tu+co)%2;
	if(!tu)A=a+(1+co)/2,B=b+co/2;
	else A=a+co/2,B=b+(1+co)/2;
	int out;
	if(TU==0){
		out=-inf;
		if(A<n)out=max(out,f(a,b,co+1,tu,0));
		out=max(out,dp[a][b][co][tu]+f(A,B,0,TU^1,pas+1));
	}else{
		out=inf;
		if(B<m)out=min(out,f(a,b,co+1,tu,0));
		out=min(out,dp[a][b][co][tu]+f(A,B,0,TU^1,pas+1));
	}
	return mem[a][b][co][tu][pas]=out;
}
int main(){
	cin>>n>>m;
	A=vi(n);rep(i,n)cin>>A[i];
	B=vi(m);rep(i,m)cin>>B[i];
	
	rep(l,2)rep(i,n+1)rep(j,m+1){
		int suma=0,sumb=0;
		int L=l,I=i,J=j;
		int co=0;
		while(1){
			dp[i][j][co][l]=suma-sumb;
			if(L&&J>=m||!L&&I>=n)break;
			if(L){
				if(B[J]+1)sumb+=B[J];
				else suma=0;
				J++;
			}else{
				if(A[I]+1)suma+=A[I];
				else sumb=0;
				I++;
			}
			L^=1;
			co++;
		}
	}   
	rep(i,52)rep(j,52)rep(k,110)rep(l,2)rep(q,3)
		mem[i][j][k][l][q]=-inf;
	cout<<f(0,0,0,0,1)<<endl;
}








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

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

	if (a + b == 15){
		cout << "+" << endl;
	} else if (a * b == 15){
		cout << "*" << endl;
	} else {
		cout << "x" << endl;
	}

	return 0;
}


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

const int INF = 1<<30;

using namespace std;

int main()
{
  int N, a[100];
  long ans = INF, tmp;
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> a[i];
  for(int i = -100; i <= 100; ++i) {
    tmp = 0;
    for(int j = 0; j < N; ++j) tmp += ((i - a[j]) * (i - a[j]));
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace

#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);        
    ll n;
    cin >> n;
    vll a(n);
    FOR(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    vector<vll> dp(2, vll(n + 1));
    dp[0][0] = 0;
    dp[1][0] = 0;
    FORN(i, 1, n + 1)
    {
        dp[0][i] = gcd(dp[0][i - 1], a[i - 1]);
        dp[1][i] = max(gcd(dp[1][i - 1], a[i - 1]), dp[0][i - 1]);
        if (i > 1) dp[1][i] = max(dp[1][i], gcd(dp[0][i - 2], a[i - 1]));
    }
    cout << dp[1][n] << '\n';
}



Measured memory_bytes: 3456
s=input()
ans=0
for i in range(2**(len(s)-1)):
  t=0
  for j in range(len(s)-1):
    if((i>>j)&1==1):
      ans+=int(s[t:j+1])
      t=j+1
  ans+=int(s[t:])
print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int[] memo = new int[101];
            int max = 0;

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                int a = int.Parse(input);

                memo[a]++;
                max = Math.Max(max, memo[a]);
            }

            for (int i = 1; i < 101; i++)
            {
                if (memo[i] == max) sb.AppendLine(i.ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    string S;cin>>S;
    set<char> sSet;
    for(auto c:S) sSet.insert(c);

    string ans="None";
    for(char c='a';c<='z';c++){
        if(sSet.count(c)==0){
            if(ans=="None") ans=c;
            else ans=min(ans.at(0),c);
        } 
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define arr array

using namespace std;

const int e = 2e6 + 69;
const ll mod = 1e9 + 7;

ll a[e];
int n, m;
vector<int>adj[e];
bool vs[e];

void dfs(int u)
{
    vs[u] = false;
    for(auto j : adj[u]){
        if(vs[j]) dfs(j);
    }
}

int main()
{
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        int x, y, z;
        cin >> x >> y >> z;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    int dem =0;
    memset(vs, true, sizeof(vs));
    for(int i=1; i<=n; i++){
        if(vs[i] == true){
            dem ++;
            dfs(i);
        }
    }
    cout << dem;
}


Measured memory_bytes: 58484
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

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

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
  ll h;
  ll now = 1;
  ll ans = 0;

  cin >> h;

  for(;;){ /*ぴえん*/

    if( h == 0 ) break;

    ans += now;

    h /= 2;
 
    now *= 2;
  
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    int l, r;
    cin >> l >> r;
    int a[2020] = {};
    for (int i = l; i <= r; i++)
        if (!a[i % 2019])
            a[i % 2019] = 1;
        else
            break;

    int m = 2020;
    for (int i = 0; i < 2020; i++) {
        if (!a[i])
            continue;
        for (int j = i + 1; j < 2020; j++) {
            if (!a[j])
                continue;
            m = min((i * j) % 2019, m);
        }
    }
    cout << m;
    return 0;
}


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

void main() {
    long n;
    scan(n);

    string ans;
    while (n > 0) {
        auto c = n % 26;
        if (c == 0)
            c += 26;
        auto ch = ('a' - 1 + c).to!char;
        ans ~= ch;
        n = (n - 1) / 26;
    }
    ans = ans.retro.to!string;
    writeln(ans);
}

void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


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

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

Measured memory_bytes: 2560
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
////////////////いろいろあるよ//////////////////////////////////
int main(){
	int K;
  	cin >> K;
  
  	ll sum=0;
  
  	FOR(i,1,K+1){
    	FOR(ii,1,K+1){
    		FOR(iii,1,K+1){
    			sum += gcd(gcd(i,ii),iii);
              	//cout << gcd(gcd(i,ii),iii) << endl;
    		}
    	}
    }
  
  	cout << sum << endl;
}

Measured memory_bytes: 3648
def solve():
    N, M = map(int,input().split())
    A = list(map(int,input().split()))
    A.sort()
    operate = []
    for _ in range(M):
        b, c = map(int,input().split())
        operate.append([b,c])
    operate.sort(reverse=True, key=lambda x:x[1])    

    rewrite = [0] * N
    idx = 0
    for b,c in operate:
        for i in range(b):
            rewrite[idx] = c
            idx += 1
            if idx == N:
                break
        if idx == N:
            break
    
    ans = 0
    for i in range(N):
        ans += max(A[i],rewrite[i])
    
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 81688
using System;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    partial class Program
    {
        static void Main(string[] args)
        {
			//↓

            var n = int.Parse(Console.ReadLine());
            var hs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var s = hs[hs.Length - 1];
            var r = true;

            for (int i = hs.Length - 1; i >= 0; i--)
            {
                var c = hs[i];
                if (s < c)
                {
                    if (c - s == 1)
                    {
                        continue;
                    }
                    else
                    {
                        r = false;
                        break;
                    }
                }
                else
                {
                    s = c;
                }
            }
            if (r)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }


			//↑
        }
	}
}

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

int n, k;
int a[200005];

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	for (int i = k; i < n; i++) {
		if (a[i] > a[i - k]) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 4464
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define endl '\n'
//#define int long long
#define inf 10000000000000001ll
#define fi first
#define se second
typedef long long ll;
using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;cin>>n;
    vector<pair<int,int> >v(n);
    for (int i=0;i<n;i++) cin>>v[i].fi,v[i].se=i;
    sort(v.begin(),v.end());
    for (auto i:v) cout<<i.se+1<<" ";

    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct UnionFindTree{
    vector<int>par,sz;
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool areSame(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int N,M;
int A[111111],B[111111];

int ans[111111];

signed main(){
    cin>>N>>M;
    rep(i,M)cin>>A[i]>>B[i],A[i]--,B[i]--;

    ans[M-1]=N*(N-1)/2;
    UnionFindTree uf(N);
    for(int i=M-1;i>0;i--){
        ans[i-1]=ans[i];
        if(!uf.areSame(A[i],B[i])){
            ans[i-1]-=uf.size(A[i])*uf.size(B[i]);
            uf.unite(A[i],B[i]);
        }
    }
    rep(i,M)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll K,N;
  cin>>K>>N;
  
  vector<ll>A(N);
  vector<ll>pile(N);
  vector<ll>ans(N);
  ll now=0;
  rep(i,N){
cin>>A[i];
    now+=A[i];
    pile[i]=now;
  }

  rep(i,N){
    //右
    ll sum=0;
   sum+=(A[N-1]-A[i]);

    if(i!=0){
sum+=(A[i-1]-0)+K-A[N-1];
    }
    //左
  ll sum2=0;
   sum2+=(A[i]-A[0]);
    if(i!=N-1){
sum2+=(K-A[i+1])+(A[0]-0);
    }
    
    ans[i]=min(sum,sum2);
  }
ll num=ans[0];
  rep(i,N){
num=min(ans[i],num);
  }
  
  cout<<num<<endl;
  


}


Measured memory_bytes: 4992
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${@q!EWL(6ukQ@o>Y}4C6HEoS)r!K{Q_>gtH{_6Saob;JGAWA?{fmdfx-dH<9YLD;+H%Cmp*hsD!&3n^|qs1QL*`)JftU5Gu3fXbLo6l?o2C6W^@ofP#wypGK{KH$xUgGVQ2J@<<HW~AQqOg4;1vJ?pk}q8Yjw=7B*l#c?BEOY3|t$$<;5aydaG;EubD-`rxGA0+X#ZE<h_<FT&)U<9a!#3e6PII3WmO;b;XH4Jd;eYXstkDe65mLVrs35s<hdfWQ7s>HxLA?AP$jX`rM>B2d>%Y8mP}O9a3R)f9cP&Ih$r!9oRZxW1q4Wg4Er%YVW&**ech{tzy+1-uk+hZ8$3YmJI}ibb1<+SDo+eZOzaCNATn%0`KtT*4oW<Ul#U6BT`~;VV(HFt6Zs+<xw)5(vIkXV(|%#P)9s3wZq-tG_0UUeLk}7M7%U;=A^aCp9cCapgqloIY8oW2wurU$R&EM126i*LSzq>+z|-T!nV<4lh?}W0p%~*GHZ(5UTJG)4Ch;WIFQFj1%t})o9M*YZ4kV4zVs^UjRkd1%v{+0uH37W>1g&kv|nML&|KQ4<%{ZjSLtmK{B0_#yF6u3=TgM5gF2rl2MQjV~X|5I5pUr-W2Yy3(s!Q<P2TT4ugnnAS9F3r$f5pe>AdVi+D*f*6HOC_}#b^oIUge@*mdeY(o")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 12976
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define mex 10000005
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//vector<int> adj[mex];
//a+b=a^b+2*(a&b)
#define int long long 

int p[mex];
void sieve(int n){
	for(int i=1;i<=n;i++)
	 p[i]=i;
	 
	for(int i=2;i*i<=n;i++){
		if(p[i]==i){
			for(int j=i*i;j<=n;j+=i){
				if(p[j]==j)
				 p[j]=i;
			 }
		 }
	 }
}

signed main(){
	fast
	
	int n,m,k;
	cin>>n>>m>>k;
	int a[n],b[m];
	for(int i=0;i<n;i++)
	 cin>>a[i];
	for(int i=0;i<m;i++)
	 cin>>b[i];
	vector<int> a1(n),b1(m);
	a1[0]=a[0],b1[0]=b[0];
	for(int i=1;i<n;i++)
	 a1[i]=a[i]+a1[i-1];
	for(int i=1;i<m;i++)
	 b1[i]=b[i]+b1[i-1];
	
	int m1=0;
	for(int i=0;i<n;i++){
		if(a1[i]>k)
		 break;
		int y=i+1;
		int s1=k-a1[i];
		auto it=lower_bound(b1.begin(),b1.end(),s1);
		if(it==b1.end())
		 y=y+m;
		else{
			int idx=it-b1.begin()+1;
			if(*it>s1)
			 idx-=1;
			
			y=y+idx;
		}
		if(y>m1)
		 m1=y;
	 }
	 for(int i=0;i<m;i++){
		 if(b1[i]>k)
		  break;
		 int y=i+1;
		 int s1=k-b1[i];
		 auto it=lower_bound(a1.begin(),a1.end(),s1);
		if(it==a1.end())
		 y=y+n;
		else{
			int idx=it-a1.begin()+1;
			if(*it>s1)
			 idx-=1;
			
			y=y+idx;
		}
		if(y>m1)
		 m1=y;
	 }     
	 cout<<m1;   
}


Measured memory_bytes: 9532
n, m = map(int, input().split())
c_list = list(map(int, input().split()))
c_list.sort()
dp_list = [0] + [10**9]*(n)
for i in range(1, n+1):
    for c in c_list:
        if i - c >= 0:
            dp_list[i] = min(dp_list[i], dp_list[i-c]+1)
        else:
            break
print(dp_list[-1])



Measured memory_bytes: 7256
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

difference = []

sunuke = 0
arai = 0

0.upto(n-1) do |i|
  arai += a[i]
end


0.upto(n-2) do |i|
  sunuke += a[i]
  arai -= a[i]
  difference << (sunuke - arai).abs
end

puts difference.min


Measured memory_bytes: 20228
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

class UnionFind {
public:
    vector<int> par, rank;
    int cnt;

    UnionFind(int n) : cnt(n) {
        par = vector<int>(n);
        iota(par.begin(), par.end(), 0);
        rank = vector<int>(n, 0);
    }

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

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

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll N,K,L;
  cin >> N >> K >> L;
  UnionFind uf1= UnionFind(N);
  UnionFind uf2= UnionFind(N);

  for(int i=0;i<K;i++){
    int p,q;
    cin >> p >> q;
    p--,q--;
    uf1.unite(p,q);
  }
  for(int i=0;i<L;i++){
    int r,s;
    cin >> r >> s;
    r--,s--;
    uf2.unite(r,s);
  }
  ll root1[N+10];
  ll root2[N+10];
  map<P,ll> m;

  for(int i=0;i<N;i++){
    root1[i]=uf1.root(i);
    root2[i]=uf2.root(i);
    m[P(root1[i],root2[i])]++;
  }

  for(int i=0;i<N;i++){
    cout << m[P(root1[i],root2[i])];
    if(i==N){
      cout << endl;
    }else{
      cout << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 18176
import math

a = [int(x) for x in input().split(" ")]
n = a[0]
m = a[1]
ans = 0
if n >= 2 :
    ans += math.factorial(n) // (2 * math.factorial(n - 2))
if m >= 2 :
    ans += math.factorial(m) // (2 * math.factorial(m - 2))
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll pow_mod(ll a, ll b, ll m){
    ll ret = 1;
    while (b > 0) {
        if (b & 1) {
            ret = ret * a % m;
        }
        a = a * a % m;
        b >>= 1;
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll N, K;
    cin >> N >> K;
    ll sum = K * (K + 1) / 2;
    (sum *= N) %= mod;
    (sum *= pow_mod(K + 1, N - 1, mod)) %= mod;
    
    vector<vector<ll>> dp(N + 2, vector<ll>(10010, 0));
    dp[N + 1][0] = 1;
    for(int i = (int)N; i >= 1; i--){
        rep(j, 3300){
            rep(k, K + 1){
                if(k <= i){
                    (dp[i][j + (k + j) / i] += dp[i + 1][j]) %= mod;
                }
                else {
                    (dp[i][j] += dp[i + 1][j]) %= mod;
                }
            }
        }
    }
    
    ll sub = 0;
    rep(i, N * N + 1){
        (sub += (dp[1][i] * i) % mod) %= mod;
    }
    
    output((sum - sub + mod) % mod);
    
    return 0;
}


Measured memory_bytes: 8320
#include <stdio.h>
#include<math.h>
int main(void)
{
	int n,i,flag=1;
	scanf("%d",&n);
	long long t[n],x[n],y[n],m,s;
	for(i=0;i<n;i++)
	{
		scanf("%lld%lld%lld",&t[i],&x[i],&y[i]);
		if(i==0)
		{
			s=llabs(x[i])+llabs(y[i]);
			if((s%2!=(t[i]%2))||s>t[i])
		        flag=0;
		}
		else
		{
			m=llabs(x[i]-x[i-1])+llabs(y[i]-y[i-1]);
			if((m%2!=((t[i]-t[i-1])%2))||m>(t[i]-t[i-1]))
		        flag=0;
		}
	}
	if(flag==1)
	  printf("Yes");
	else
	  printf("No");
}

Measured memory_bytes: 2560
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define M 1000000007
long fac(int n){
    if(n==1)return 1;
    else return (n%M*(fac(n-1)%M))%M;
}
int main(void){
    long n,m,s,t;
    scanf("%ld %ld",&n,&m);
    if(labs(n-m)>1){
        printf("0\n");
        return 0;
    }
    s=fac(n);
    t=fac(m);
    //10^9で割った余りにしたい
    if(n==m){
        printf("%ld\n",(2*(s%M)*(t%M))%M);
    }
    else{
        printf("%ld\n",(s%M)*(t%M)%M);}
    return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>

main()
{
  int count=0,i,k,line1[10000],line2[500],num1,num2;

  scanf("%d",&num1);

  for(i=0;i<num1;i++)
    {
      scanf("%d",&line1[i]);
    }

  scanf("%d",&num2);

  for(i=0;i<num2;i++)
    {
      scanf("%d",&line2[i]);
    }
  
  for(i=0;i<num2;i++)
    {
      k = 0;
      line1[num1] = line2[i];
  while(line1[k] != line2[i])
    {
      k++;
    } 
  if(k != num1)count++;
    }
  printf("%d\n",count);

return 0;

}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int r; cin>>r;
    double ans = 2 * r * 3.141592;
    cout<<fixed<<setprecision(12)<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 3800
# 自分の改造
n = int(input())
A = list(map(int, input().split()))
s = 0 
M = 0
for i in range(n-1):
    if A[i] <= A[(i+1)] and M <= A[(i+1)]:
        M = 0
        continue
    else:
        if M == 0:
            s += A[i] - A[(i+1)]
            M = A[(i+1)] + (A[i] - A[(i+1)])
        else:
            s += M - A[(i+1)]
print(s)


Measured memory_bytes: 32068
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,ans=0; cin>>n;
    string s; cin>>s;
    reverse(al(s));
    rep(i,1000){
        int num=i,cnt=0;
        rep(j,n){
            if(num%10==s[j]-'0'){
                num/=10;
                cnt++;
                if(cnt==3){
                    ans++; break;
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#hanafuda
N,r=(int(i) for i in input().split())
while N!=0 or r!=0:
    H=[int(N-i) for i in range(N)]
    for i in range(r):
        p,c=(int(i) for i in input().split())
        T=[]
 #       print(H)
        for j in range(p-1,p+c-1):
  #          print("T")
            T.append(H[p-1])
            H.pop(p-1)
        H=T+H
    print(H[0])
    N,r=(int(i) for i in input().split())

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

int main() {
    int X;
    cin >> X;
    if (X == 3 || X == 5 || X == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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


// dp[i][w] := i番目までの品物で重さがw以下となる選び方の勝ちの最大値
ll dp[101][101010];

int main() {
    int N, W;
    cin >> N >> W;
    vector<ll> w(N+1), v(N+1);

    rep(i, N) cin >> w[i+1] >> v[i+1];

    for (int v = 0; v <= 100000; ++v) dp[0][v] = 1e15;
    dp[0][0] = 0;

    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j <= 100000; ++j) {
            dp[i][j] = dp[i-1][j];
            if (j - v[i] >= 0) {
                dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]]+w[i]);
            }
        }
    }

    ll ans = 0;
    for (int i=0; i<=100000; ++i) {
        if (dp[N][i] <= W) ans = max(ans, (ll)i);
    }

    cout << ans << endl;

}


Measured memory_bytes: 80000
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <memory.h>
#include <algorithm>
#include <cassert>

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(c) (c).begin(), (c).end()
#define sz(c) int((c).size())
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define fst first
#define snd second

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using pii = pair<int, int>;

#define FNAME "a"

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr);
#else
#define eprintf(args...) ;
#endif

int n;
vi a;

bool read() {
    if  (!(cin >> n)) {
        return 0;
    }
    a.resize(n);
    forn(i, n) {
        cin >> a[i];
    }
    return 1;
}

void solve() {
    map<ll, int> cnt;
    ll pref = 0;
    ll ans = 0;
    forn(i, n) {
        ++cnt[pref];
        pref += a[i];
        ans += cnt[pref];
    }
    cout << ans << endl;
}

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

#ifdef LOCAL
    freopen(FNAME ".in", "r", stdin);
    freopen(FNAME ".out", "w", stdout);
#endif

    while (read()) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 13568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define fi first
#define se second

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef double ld;

int n, m;
const int N = 2e5 + 3;
vi adj[N];
vi dp(N, 0);
vi vis(N, 0);

void dfs(int src)
{
	vis[src] = 1;
	for (int child : adj[src])
	{
		if (!vis[child]) dfs(child);

		dp[src] = max(dp[src], 1 + dp[child]);
	}
}

int main()
{
	fastio
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	cin >> n >> m;

	for (int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;

		adj[u].pb(v);
	}

	for (int i = 1; i <= n; i++)
	{
		if (!vis[i]) dfs(i);
	}

	int max_path = *max_element(dp.begin(), dp.end());

	cout << max_path;

	return 0;
}

Measured memory_bytes: 14096
#include <iostream>

using namespace std;

int main(){
    string str1,str2;
    while(cin >> str1 >> str2){
        int total=0;
        for(int i=0;i<str1.length();i++){
            if(str1[i]!=str2[i]){
                total+=1;
            }
        }cout << total << endl;
    }
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>

using namespace std;

// dp[i] := i文字目までを作ることができるか?
bool dp[100010];
string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

  dp[0] = true;
  for (int i = 0; i < s.length(); i++) {
    if (!dp[i]) { continue; }
    for (int j = 0; j < 4; j++) {
      string t = divide[j];
      if (s.substr(i, t.size()) == t) {
        dp[i+t.size()] = true;
      }
    }
  }
  cout << (dp[s.length()] ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 512
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);
    vector< vector< pair<int, int> > > G(N);
    for(int i=0; i<N; i++) {
        int u, k; scanf("%d%d", &u, &k);
        for(int j=0; j<k; j++) {
            int v, c; scanf("%d%d", &v, &c);
            G[u].emplace_back(v, c);
        }
    }

    vector<int> dist(N, INF), checked(N);
    dist[0] = 0, checked[0] = true;

    int u = 0;
    for(int i=0; i<N; i++) {
        for(auto e : G[u]) {
            int v, c; tie(v, c) = e;
            chmin(dist[v], dist[u] + c);
        }

        int ma = INF, v = 0;
        for(int k=0; k<N; k++) {
            if(checked[k]) continue;
            if(ma > dist[k]) {
                ma = dist[k];
                v = k;
            }
        }
        checked[v] = true;
        swap(u, v);
    }

    for(int i=0; i<N; i++) {
        printf("%d %d\n", i, dist[i]);
    }
    return 0;
}



Measured memory_bytes: 7448
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define Graph vector<vector<int>>
#define MOD 1000000007 
typedef pair<int, int> PII;
typedef long long ll;

const int MAX = 700000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  ll N;
  cin >> N;

  ll j = 1;
  ll MAX_j = j;

  while(N >= j * j){
    if((N % j) == 0){
      MAX_j = j;
    }
    j++;
  }

  ll tmp = max(MAX_j, (N / MAX_j));
  int digits = 1;
  while(tmp > 9){
    tmp /= 10;
    digits++;
  }

  cout << digits << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int	main(void)
{
  char ball1[11], ball2[11], throw_ball[11];
  int	num1, num2;
  scanf("%s %s", ball1, ball2);
  scanf("%d %d", &num1, &num2);
  scanf("%s", throw_ball);
  
  int	bool = 1;
  int	i = 0;
  while (ball1[i] != '\0')
  {
    if (ball1[i] == throw_ball[i])
		i++;
    else
    {
      bool = 0;
      break ;
    }
  }
  if (bool)
    printf("%d %d", num1 - 1, num2);
  else
    printf("%d %d", num1, num2 - 1);
  return (0);
}

Measured memory_bytes: 128
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


int main()
{
    int N,A,B;
    cin >> N >> A >> B;
    int cost = min(B,A*N);
    cout << cost << endl;
    return 0;
}


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

int main()
{
  int a[10000],b[10000];
  int n, num = 0;
  cin >> n;
  rep(i,n) {
    cin >> a[i];
    if(a[i] % 2 == 0) {
      b[num] = a[i];
      num++;
    }
  }
  string s = "APPROVED";
  rep(i,num){
    if(b[i] % 3 != 0 && b[i] %5 != 0){
      s = "DENIED";
    }
  }
  cout << s << endl;

  return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

struct UF{
    int n;
    //??£?????£????????????????????????,????????£???????????§??£?????????????????°
    vector<int> d;
    // root??¨?????????????????????????????????
    vector<int> w;

    UF() {}
    UF(int N):n(N), d(N,-1), w(N,0){}

    int root(int v){
        if(d[v]<0) return v;

        int par = d[v];

        int r = root(d[v]);
        d[v] = r;
        w[v] += w[par];

        return d[v];
    }
    bool unite(int X,int Y,int W){
        int rx = root(X), ry = root(Y);
        if(rx==ry) return false;

        int RW = -w[Y] + w[X] + W;

        if(size(rx) < size(ry))
        {
            swap(rx,ry);
            swap(X,Y);
            RW = -RW;
        }


        d[rx]+=d[ry];
        d[ry]=rx;

        w[ry] = RW;

        // printf(" UNITE : %d -> %d : w[%d]=%d\n", ry,rx, ry, w[ry]);
        return true;
    }
    int size(int v){ return -d[root(v)]; }
    bool same(int X,int Y){ return root(X)==root(Y); }

    int query(int X, int Y){
        root(X);
        root(Y);
        // printf(" query : %d -> %d  = %d\n", X,Y,w[Y]-w[X]);
        return w[Y]-w[X];
    }
};

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

        while(m--)
        {
            char q;
            int a,b;
            scanf(" %c %d %d", &q, &a, &b);
            --a;
            --b;

            if(q=='?')
            {
                if(!uf.same(a,b)) printf("UNKNOWN\n");
                else printf("%d\n", uf.query(b,a));
            }
            else
            {
                int w;
                scanf(" %d", &w);
                uf.unite(b,a,w);
            }
        }
    }
    return 0;
}

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


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

void Koch(int d,Point left,Point right) {
  if(d == 0) return;
  Point s,t,u;
  double theta = M_PI / 3;

  s.x = (2 * left.x + right.x) / 3;
  s.y = (2 * left.y + right.y) / 3;

  u.x = (left.x + 2 * right.x) / 3;
  u.y = (left.y + 2 * right.y) / 3;

  t.x = (u.x - s.x) * cos(theta) - (u.y - s.y) * sin(theta) + s.x;
  t.y = (u.x - s.x) * sin(theta) + (u.y - s.y) * cos(theta) + s.y;

  Koch(d - 1,left, s);
  printf("%.8f %.8f\n",s.x,s.y);
  Koch(d - 1,s,t);
  printf("%.8f %.8f\n",t.x,t.y);
  Koch(d - 1,t,u);
  printf("%.8f %.8f\n",u.x,u.y);
  Koch(d - 1,u,right);
}

int main() {

  int n;
  cin >> n;
  Point left,right;
  left.x = 0,left.y = 0;
  right.x = 100,right.y = 0;

  printf("%.8f %.8f\n",left.x,left.y);
  Koch(n,left,right);
  printf("%.8f %.8f\n",right.x,right.y);
 
}



Measured memory_bytes: 3160
#include<stdio.h>

int main()
{
	int a, b;
	
	scanf("%d %d", &a, &b);
	if(a > b)
	{
		printf("a > b\n");
	}
	else if(a < b)
	{
		printf("a < b\n");
	}
	else
	{
		printf("a == b\n");
	}
	
	return 0;
} 


Measured memory_bytes: 2692
A=int(input())
B=int(input())
C=int(input())
X=int(input())

cnt = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      ch = i*500 + j*100 + k*50
      if ch == X:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
N = int(input())
letters = 'zabcdefghijklmnopqrstuvwxy'

def solve(N):
    md = N%26
    l = letters[md]
    if md==0: md=26
    if N>26:
        return solve((N-md)//26) + l
    else:
        return l

print(solve(N))


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if(i >= 1 && i <= 9) res++;
    else if(i >= 100 && i <= 999) res++;
    else if(i >= 10000 && i <= 99999) res++;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
a=[]
a.append(list(map(int,input().split())))
a.append(list(map(int,input().split())))
a.append(list(map(int,input().split())))
n=int(input())
b=[]
for i in range(n):
    b.append(int(input()))
    
c=[]   
for j1 in range(3):
    c.append([0,0,0])

for i in range(n):
    for j1 in range(3):
        for j2 in range(3):
            if b[i]==a[j1][j2]:
                c[j1][j2]=1

csum1=0                
csum2=0                
csum3=0                
for j1 in range(3):
    csum1=csum1+c[j1][0]                
    csum2=csum2+c[j1][1]                
    csum3=csum3+c[j1][2]
                
csum4=0                
csum5=0                
csum6=0                
for j1 in range(3):
    csum4=csum4+c[0][j1]                
    csum5=csum5+c[1][j1]                
    csum6=csum6+c[2][j1]

csum7=c[0][0]+c[1][1]+c[2][2]                
csum8=c[2][0]+c[1][1]+c[0][2]  

if csum1==3 or csum2==3 or csum3==3:
    print("Yes")
elif csum4==3 or csum5==3 or csum6==3:
    print("Yes")
elif csum7==3 or csum8==3 :
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<int> time(n+1);
  for(int i=0;i<n;i++){
    cin >> time.at(i);
  }
  int m;
  cin >> m;
  long long sum=0;
  for(int i=0;i<n;i++){
    sum+=time.at(i);
  }
  for(int i=0;i<m;i++){
    int P,X;
    cin >> P >> X;
    int sub;
    sub=X-time.at(P-1);
    sum+=sub;
    cout << sum << endl;
    sum-=sub;
  }
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n-2):
  if ((p[i]>p[i+1]) and (p[i+1]>p[i+2]) and (p[i]>p[i+2])) or ((p[i]<p[i+1]) and (p[i+1]<p[i+2]) and (p[i]<p[i+2])):
    count += 1
print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> freq(100100);
  freq[0] = 3;
  ll ans = 1;
  rep(i, n) {
    ans *= freq[a[i]];
    ans %= mod;
    freq[a[i]]--;
    freq[a[i] + 1]++;
  }
  cout << ans << endl;
}

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

template <typename T>
vector<pair<T, T>> prime_factor(T n) {
    vector<pair<T, T>> ret;
    for (T i = 2; i * i <= n; i++) {
        T tmp = 0;
        while (n % i == 0) {
            tmp++;
            n /= i;
        }
        if (tmp > 0) {
          ret.push_back(make_pair(i, tmp));
        }
    }
    if (n != 1) ret.push_back(make_pair(n, 1));
    return ret;
}

ll count(ll x, ll N) {
  ll l = 1, r = N;
  ll m;
  while (l < r - 1) {
    m = (l + r) / 2;
    ll tmp = m * (m + 1) / 2;
    if(tmp <= x) {
      l = m;
    } else {
      r = m;
    }
    // cout << l << ' ' <<  m << ' ' << r << endl;
  }
  // cout << l << ' ' <<  m << ' ' << r << endl;
  return l;
};

int main() {
  ll N;
  cin >> N;
  vector<P> res = prime_factor(N);

  ll M = 0;
  ll tmp = 1;
  while(tmp <= N) {
    tmp *= 2;
    M += 1;
  }
  // cout << M << endl;

  ll ans = 0;
  for (auto r : res) {
    if (r.second > 0) {
      ll t = count(r.second, M);
      // cout << r.first << ' ' << r.second << ' ' << t << endl;
      ans += t;
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define REP(i,x) for(ll i=0;i<x;i++)
#define INF 1e18
typedef long long ll;
using namespace std;
#define MOD 1000000007


int main(){
  int N;
  cin>>N;
  if(N%2==0)cout<<N/2<<endl;
  else cout<<N/2+1<<endl;

}


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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 0; i*4<=N;i++) {
    for (int j = 0; i*4+j*7<=N;j++) {
      if (i*4+j*7==N) ans++;
    }
  }
  if (ans!=0) cout << "Yes"<<endl;
  else cout << "No" << endl;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    ll cnt = 0;
    ll ans = 0;
    rep (i, s.size()) {
        if (!cnt) {
            if (s[i] == 'p') {
                ans--;
            }
            cnt++;
        } else {
            if (s[i] == 'g') {
                ans++;
            }
            cnt--;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
// Problem : 
// 			Q - Flowers
// 			Editorial
// 		
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_q
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int st[5*maxn],n,a[maxn];
vector<pair<int,int> > v;
int query(int p,int l,int r,int j)
{
	if(l > j)
		return 0;
	if(r <= j)
		return st[p];
	int m=(l+r)/2;
	return max(query(2*p,l,m,j),query(2*p+1,m+1,r,j));
}
void update(int p, int l,int r,int j,int val)
{
	if(l > j || r < j)
		return;
	if(l == r)
	{
		st[p]=val;
		return;
	}
	int m=(l+r)/2;
	update(2*p,l,m,j,val);
	update(2*p+1,m+1,r,j,val);
	st[p]=max(st[2*p],st[2*p+1]);
}
void solve()
{
	cin >> n;
	rep(i,0,n)
	{
		int x;
		cin >> x;
		v.pb({x,i});
	}
	sort(all(v));
	rep(i,0,n)
		cin >> a[i];
	for(auto &x:v)
	{
		int tmp = query(1,0,n-1,x.ss);
		update(1,0,n-1,x.ss,tmp+a[x.ss]);
	}
	cout << st[1];
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 12224