akhauriyash/Code-Regression huggingface dataset:
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;
ll modd = 998244353;


ll modpow(ll a,ll n,ll mod){ // a^n の mod を計算
    ll res = 1;
    while(n>0){
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}

signed main(){
    ll n,m,k;
    cin>>n>>m>>k;
    ll mpt[200009];
    rep(i,n+3){
        if(i==0) mpt[i] = m;
        else{
            mpt[i] = (m-1)*mpt[i-1];
            mpt[i] %= modd;
        }
        // cout<<i<<" "<<mpt[i]<<endl;
    }
    ll fac[200009];
    rep(i,n+3){
        if(i==0) fac[i]=1;
        else{
            fac[i] = i*fac[i-1];
            fac[i] %= modd;
        }
    }
    ll ans=0;
    ll tp_nck = 0;
    rep(i,k+1){
        if(i==0) ans += mpt[n-1];
        else{
            tp_nck = fac[n-1] * modinv(fac[i],modd);
            tp_nck %= modd;
            tp_nck *= modinv(fac[n-1-i],modd);
            tp_nck %= modd;
            ans += tp_nck * mpt[n-1-i];
            ans %= modd;
        }
    }
    ans %= modd;
    cout<<ans<<endl;
}


Measured memory_bytes: 6692
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	llint A;cin>>A;
	cout<<360/gcd(360,A)<<endl;
	return 0;
}


Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            //var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();

            long[] ABSa = new long[N];
            int m = 0;

            long ans = 0;
            for(var i = 0; i < N; i++)
            {
                if (a[i] < 0) { m++; }
                ABSa[i] = Math.Abs(a[i]);
            }

            if (m % 2 == 0)
            {
                ans = ABSa.Sum();
            }
            else
            {
                ans = ABSa.Sum() - 2 * ABSa.Min();
            }

            Console.WriteLine(ans);

                
            //Console.Out.Flush();

        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}




Measured memory_bytes: 29788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
int main() {
	int num;
	cin >> num;
	VEP vec(num);
	REP(i, num) {
		cin >> vec[i].first >> vec[i].second;
	}
	if (num == 1) {
		cout << 1 << endl;
		return 0;
	}
	VEP tmp;
	REP(i, num) {
		for (int t = i + 1; t < num; ++t) {
			tmp.push_back(make_pair(vec[i].first - vec[t].first, vec[i].second - vec[t].second));
		}
	}
	VE looked(tmp.size(),0);
	VE times(tmp.size(), 1);
	REP(i, tmp.size()) {
		if (looked[i] == 0) {
			FOR(t, i + 1, tmp.size()) {
				if (tmp[i] == tmp[t] || ((tmp[i].first == -tmp[t].first) && (tmp[i].second == -tmp[t].second))) {
					looked[t] = 1;
					times[i]++;
				}
			}
		}
	}
	auto ma = max_element(times.begin(),times.end());
	cout << num - *ma << endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import combinations

n, k = map(int, input().split())
a = [int(i) for i in input().split()]  #;print(a)
bar = [0] * n
for i in range(1, n):
    bar[i] = max(a[i-1], bar[i-1])
#print(bar)  

ans = float('inf')
for idx in combinations(range(1, n), k-1):
    x0 = a[0] ;dif = 0
    #print(idx)
    for i in range(k-1):
        if x0 < bar[idx[i]]:
            x0 = bar[idx[i]] #break   #    x0 = bar[i]
        if a[idx[i]] > x0:
            x0 = a[idx[i]]
        else:
            dif += x0 - a[idx[i]] + 1
            x0 = x0 + 1
    ans = min(ans, dif)
print(ans)    

Measured memory_bytes: 9240
#include <stdio.h>
#include <stdlib.h>
#define int long long

int ABS(int a){
	return a >= 0 ? a : 0;
}

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

signed main(){
	int N, K, i, ans = 0;
	scanf("%lld%lld", &N, &K);
	int *a = (int *)malloc(sizeof(int) * (N + 1));
	int *sum = (int *)malloc(sizeof(int) * (N + 1));
	int *absum = (int *)malloc(sizeof(int) * (N + 1));
	sum[0] = 0;
	absum[0] = 0;
	for(i = 1; i <= N; i++){
		scanf("%lld", &a[i]);
		sum[i] = sum[i - 1] + a[i];
		absum[i] = absum[i - 1] + ABS(a[i]);
	}
	for(i = 0; i + K <= N; i++){
		ans = max(ans, absum[N] - absum[i + K] + absum[i] + ABS(sum[i + K] - sum[i]));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

const int bad = numeric_limits<int>::min();
vector<int> match, digits, dp;

int count(int n) {
  if (n < 0) {
    return bad;
  }

  if (n == 0) {
    return 0;
  }

  if (dp[n] == -1) {
    dp[n] = bad;
    for (auto d : digits) {
      int ret = 1 + count(n - match[d]);
      dp[n] = max(dp[n], ret);
    }
  }

  return dp[n];
}

int main() { IO;
  int n, m;
  cin >> n >> m;

  digits.resize(m);
  for (auto &x : digits) cin >> x;
  sort(digits.begin(), digits.end());

  match = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  dp.resize(n + 1, -1);

  int len = count(n);

  string ans;
  while (len--) {
    int next = 0;
    for (auto d : digits) {
      if (count(n - match[d]) == len) {
        next = d;
      }
    }

    n -= match[next];
    ans.push_back(next + '0');
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll n;
    cin>>n;
    ll ans=0;
    rep(1,i,n)ans+=i;
    cout<<ans;
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
using lint=long long;
#define debug(output) cout<<#output<<"= "<<output<<endl
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  string s;cin>>s;
  string t;cin>>t;
  s+=s;
  int n=t.length();
  bool flag=false;
  for(int i=n;i>0;--i){
      if(s.substr(i,n)==t)flag=true;
  }
	if(flag){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
  return 0;
}

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define int long long

int k, x;

int32_t main()
{
	IOS;
	cin >> k >> x;
	for (int i = x - k + 1; i < x + k; i++) {
		if (i < -1000000 || i > 1000000)
			continue;
		cout << i << ' ';
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int main() {
    map<int, int> m;
    for (int i = 0; i < 3; i++) {
        int a;
        cin >> a;
        m[a]++;
    }

    cout << (m[5] == 2 && m[7] == 1 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
// Created by arvybhatt

#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

ll power(ll x, ll y) { ll temp; if( y == 0) return 1; temp = power(x, y/2); if (y%2 == 0) return temp*temp; else return x*temp*temp; } 

int main()
{
    fast;
    int n;
    cin>>n;
    int x=n%10;
    if(x==3)
    {
    	cout<<"bon"<<"\n";
    }
    else if( x==2 || x==4 || x==5 || x==7 || x==9)
    {
    	cout<<"hon"<<"\n";
    }
    else
    	cout<<"pon \n";

    
}





Measured memory_bytes: 3604
n=int(input())
f=[]
P=[]
for i in range(n):
    a=list(map(int,input().split()))
    f.append(a)
for i in range(n):
    a=list(map(int, input().split()))
    P.append(a)
from itertools import product
ans=-(10**10)
for p in product([0, 1], repeat = 10):
    if sum(p)!=0:
        ret = 0
        for i in range(n):
            cnt = 0
            for j in range(10):
                if p[j] == f[i][j] and p[j] == 1:
                    cnt += 1
            ret += P[i][cnt]
        ans = max(ans, ret)
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define FOR(i, c) \
  \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
int counter(int x){
  if(x==0) return 0;
  return counter(x>>1) + (x&1);
}

int main() {
  ll z=0,k,n,m,h,w,Min=1e9+1;
  double sum=0,Max=-1e9;
  string s,t,u;
  bool ok = false;
  cin >> n;
  VI a(n+1);
  VII x(n+1,VI(n+1)),y(n+1,VI(n+1));
  
  for(int i=1; i<=n; i++){
    cin >> a[i];
    for(int j=1; j<=a[i]; j++){
      cin >> x[i][j] >> y[i][j];
    }
  }
  int ans=0;
  for(int bits = 1; bits < (1<<n); bits++){
    ok = true;
    for(int i=1; i<=n; i++){
      if(!(bits & (1<<(i-1)))) continue;
      for(int j=1; j<=n; j++){
        if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j])
          ok = false;
      } 
    }
    if(ok) ans = max(ans, counter(bits));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define pb push_back
#define mod 998244353

ll power(ll a,ll b){
    ll res=1ll;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res%mod;
}
ll ncr(ll n,ll k){
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro)%mod;
}

void swap(char *a,char *b) {
    char temp=*a;
    *a=*b;
    *b=temp;
}
vector<ll> prime;
vector<ll> isprime;
void seive(){
    isprime = vector<ll>(2000001,-1);
    for(int i=2;i*i<=2000000;i++){
        if(isprime[i]==-1){
            for(int j=i*i;j<=2000000;j+=i){
                if(isprime[j]==-1) isprime[j]=i;
            }
        }
    }
    for(int i=2;i<=2000000;i++){
        if(isprime[i]==-1) prime.push_back(i);
    }
}
void solve() {
    ll k;
    string str;
    cin>>k>>str;
    if(str.size()<=k) {
        cout<<str;
        return ;
    }
    else {
        string ans="";
        
        ans+=str.substr(0,k);
        ans+='.';
        ans+='.';
        ans+='.';
        cout<<ans;
        return ;
    }
}




int main(void){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<endl;
    }
    return 0; 

}


Measured memory_bytes: 3656
n = int(input())
s = sorted([input() for _ in range(n)])
m = int(input())
t = sorted([input() for _ in range(m)])
ans = -100
for i in range(n):
    cnt = 0
    for j in range(n):
        if s[i] == s[j]:
            cnt += 1
    for j in range(m):
        if s[i] == t[j]:
            cnt -= 1
    ans = max(ans,cnt)
ans = max(ans,0)
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define gcd(a,b)        __ gcd(a,b)
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
#define sz(v)           ((int)(v).size())
#define rep(i,a,b)      for(int i=a;i<=b;i++)
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
int power(int b,int e)
{
    if(e==0)
    return 1;
    if(e%2)
    return ((b*power((b)*(b),(e-1)/2)));
    else
    return power((b)*(b),e/2);
}
int modpower(int b,int e,int q)
{
    int MOD=q;
    if(e==0)
    return 1;
    if(e%2)
    return ((b%MOD)*modpower((b%MOD)*(b%MOD),(e-1)/2,q))%MOD;
    else
    return modpower((b%MOD)*(b%MOD),e/2,q)%MOD;
}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
vector < vi > adj(200006);
bool vis[200006];
int cnt=0;
void dfs(int x)
{
    cnt++;
    vis[x]=true;
    for(auto i:adj[x])
    {
        if(!vis[i])
        {
            dfs(i);
        }
    }
}
void oblivious()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    int ma=-1;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            cnt=0;
            dfs(i);
            ma=max(ma,cnt);
        }
    }
    cout<<ma<<endl;
}
signed main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    //int z=t;
    while(t--)
    {
        //cout<<"Case #"<<(z-t)<<": ";
        oblivious();
    }
    return 0;
}
//Editorial
/*

    */

Measured memory_bytes: 20596
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const long long INF = LLONG_MAX / 2;

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

    vector<pair<long long, bool> > v(n+m);
    for(int i=0; i<n+m; ++i){
        cin >> v[i].first;
        v[i].second = (i < n);
    }
    sort(v.begin(), v.end());

    vector<long long> prev(2, -INF);
    vector<long long> cost(n+m);
    for(int i=0; i<n+m; ++i){
        int j = (v[i].second ? 0 : 1);
        cost[i] = v[i].first - prev[j^1];
        prev[j] = v[i].first;
    }
    prev.assign(2, INF);
    for(int i=n+m-1; i>=0; --i){
        int j = (v[i].second ? 0 : 1);
        cost[i] = min(cost[i], prev[j^1] - v[i].first);
        prev[j] = v[i].first;
    }

    while(--q >= 0){
        long long x;
        cin >> x;
        int i = lower_bound(v.begin(), v.end(), make_pair(x, false)) - v.begin();
        long long ans = INF;
        if(i < n + m){
            ans = cost[i] + (v[i].first - x);
        }
        if(i > 0){
            -- i;
            ans = min(ans, cost[i] + (x - v[i].first));
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 6016
#include<iostream>
#include<string>
using namespace std;main(){for(int n,r,p,c;cin>>n>>r,n;){string d;for(int i=0;i<n;i++)d=char(48+i)+d;for(;r;r--){cin>>p>>c;d = d.substr(p-1,c)+d.substr(0,p-1)+d.substr(p+c-1);}cout<<(d[0]-47)<<"\n";}}

Measured memory_bytes: 0
#include <stdio.h>
#include <math.h>
typedef struct { 
    double x, y; 
 }point;

void alg(int n, point a, point b) {
	if (n==0)return;
	point i, j, k;
	double th=M_PI*60.0/180.0;
	i.x=(2.0*a.x+1.0*b.x)/3.0;
	i.y=(2.0*a.y+1.0*b.y)/3.0;
	j.x=(1.0*a.x+2.0*b.x)/3.0;
	j.y=(1.0*a.y+2.0*b.y)/3.0;
	k.x=(j.x-i.x)*cos(th)-(j.y-i.y)*sin(th)+i.x;
	k.y=(j.x-i.x)*sin(th)-(j.y-i.y)*cos(th)+j.y;
	alg(n - 1, a, i);
	printf("%.8f %.8f\n", i.x, i.y);
	alg(n - 1, i, k);
	printf("%.8f %.8f\n", k.x, k.y);
	alg(n - 1, k, j);
	printf("%.8f %.8f\n", j.x, j.y);
	alg(n - 1, j, b);
}

int main() {
	point t, s;
	int n;
	scanf("%d", &n);
	s.x=0;
	s.y=0;
	t.x=100;
	t.y=0;
	printf("%.8f %.8f\n", s.x, s.y);
	alg(n, s, t);
	printf("%.8f %.8f\n", t.x, t.y);
	return 0;
}


Measured memory_bytes: 2140
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int maxiA,pointA,N,u,v,A,B,costA[200200],costB[200200],ans=0;
vector<int> G[100100];

void dfsb(int now, int cost){
    costB[now]=cost;
    for(int next:G[now]){
        if(costB[next]==-10){
            dfsb(next,cost+1);
        }
    }

}

void dfsa(int now, int cost){
    costA[now]=cost;
    if(costB[now]%2==cost%2){
        ans=max(ans,costB[now]-1);
    }
    else{
        ans=max(ans,costB[now]-1);
    }
    for(int next:G[now]){
        if((costB[next]>(cost+1))&&costA[next]==-10){
            dfsa(next,cost+1);
        }
    }
}

int main(){
    cin>>N>>u>>v;
    u--;
    v--;
    rep(i,200100){
        costA[i]=-10;
        costB[i]=-10;
    }
    rep(i,N-1){
        cin>>A>>B;
        A--;
        B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    dfsb(v,0);
    dfsa(u,0);
    out(ans);

    
    
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll A;
  scanf("%lld",&A);
  ll B;
  scanf("%lld",&B);
  ll K;
  scanf("%lld",&K);
  for (int i=A; i<=B; i++) {
    if (i<=A+K-1||i>=B-K+1) cout << i << endl;
  }
}

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


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

int main()
{
	int m, h;
	string s;
	while (cin >> s, s != "-") {
		cin >> m;
		int sum = 0;
		while (m--) {
			cin >> h;
			sum += h;
		}
		for (int i = 0; i < s.size(); i++) {
			cout << s[(sum + i) % s.size()];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3144
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define pred(x) ((x)-1)
#define succ(x) ((x)+1)
//============================================================================
typedef struct{
    long number;
    char suit;
    long order;
}TCard;
//----------------------------------------------------------------------------
const char suits[5]="SHCD";
//----------------------------------------------------------------------------
void exchange(TCard *x, TCard *y)
{
    TCard z;
    z=*x, *x=*y, *y=z;
}
//----------------------------------------------------------------------------
long Partition(TCard *A, long p,  long r)
{
    long i,j,x;

    x = A[r].number;
    i = p-1;
    for (j = p; j<r; j++)
        if (A[j].number <= x){
            i++;
            exchange(&A[i], &A[j]);
        }
    exchange(&A[i+1], &A[r]);
    return i+1;
}
//----------------------------------------------------------------------------
void Quicksort(TCard *A, long p, long r)
{
    long q;

    if (p<r){
        q = Partition(A, p, r);
        Quicksort(A, p, q-1);
        Quicksort(A, q+1, r);
    }
}
//----------------------------------------------------------------------------
/*
12
13 19 9 5 12 8 7 4 21 2 6 11
*/
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void input(FILE *file)
{
    long i,n,x; TCard *A; char buffer[20];

    fgets(buffer, sizeof(buffer)-1, file);
    sscanf(buffer, "%ld", &n);
    A = malloc(succ(n)*sizeof(TCard));
    for (i=0; i<n; i++){
        fgets(buffer, sizeof(buffer)-1, file);
        sscanf(buffer, "%c",  &A[i].suit);
        sscanf(buffer+2, "%ld", &A[i].number);
        A[i].order=i;
    }
    Quicksort(A, 0, pred(n));
    for (i=x=0; i<n && !x; i++){
        if (A[i].number==A[succ(i)].number)
            if (A[i].order>A[succ(i)].order)
                x++;
    }
    printf("%s\n", (x)?"Not stable":"Stable");
    for (i=0; i<n; i++){
        printf("%c %d\n", A[i].suit, A[i].number);
    }
    //printf("\n");
    free(A);
}
//============================================================================
#ifndef DESKTOP
int main()
{
    input(stdin);
    return 0;
}
#endif

Measured memory_bytes: 2736
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

intmax_t N;
char P[9] = {}, Q[9] = {};
intmax_t ans = 0;
char tmp[9] = {};
char p[8 * 7 * 6 * 5 * 4 * 3 * 2 * 1][9] = {};
size_t idx = 0;
bool used[8] = {};

void f(intmax_t pos)
{
    if (pos >= N) {
        strcpy(&p[idx][0], tmp);
        idx++;
        return;
    }
    for (intmax_t i = 1; i <= N; i++) {
        if (used[i - 1])
            continue;
        tmp[pos] = i + '0';
        used[i - 1] = true;
        f(pos + 1);
        used[i - 1] = false;
    }
}

int main(void)
{
    scanf("%jd", &N);
    for (size_t i = 0; i < N; i++) {
        intmax_t pi;
        scanf("%jd", &pi);
        P[i] = pi + '0';
    }
    for (size_t i = 0; i < N; i++) {
        intmax_t qi;
        scanf("%jd", &qi);
        Q[i] = qi + '0';
    }

    f(0);

    size_t a, b;
    for (size_t i = 0; p[i][0]; i++) {
        if (strcmp(P, &p[i][0]) == 0) {
            a = i;
        }
        if (strcmp(Q, &p[i][0]) == 0) {
            b = i;
        }
    }

    ans = a - b;
    if (ans < 0)
        ans = -ans;

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    string s,t;cin>>s>>t;
    int m=s.length(),n=t.length();
    vector<vector<int>> dp(m+1,vector<int>(n+1,0));
    vector<vector<int>> dp0(m+1,vector<int>(n+1,0));
    int res = 0;
    int u=0,v=0;
    for(int i=0;i<m;++i){
        for(int k=0;k<n;++k){
            dp[i+1][k+1] = dp[i][k+1];
            if(dp[i+1][k]>dp[i+1][k+1]){
                dp0[i+1][k+1]=1;
                dp[i+1][k+1]=dp[i+1][k];
            }
            if(s[i]==t[k]&&dp[i][k]+1>dp[i+1][k+1]){
                dp0[i+1][k+1]=2;
                dp[i+1][k+1]=dp[i][k]+1;
            }
            if(dp[i+1][k+1]>res){
                res = dp[i+1][k+1];
                u = i+1;
                v = k+1;
            }
            res = max(dp[i+1][k+1],res);
        }
    }
    string r = "";
    while(u>0&&v>0){
        if(dp0[u][v]==2){
            r = s[u-1]+r;
            u--;
            v--;
        }
        if(dp0[u][v]==1)v--;
        if(dp0[u][v]==0)u--;
    }
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 70912
#include <iostream>
#include <string>
#include<iomanip>
#include <algorithm>
#include <map>
#include <vector>
#include<queue>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include <map>
#include<string.h>
#include<sstream>
#include<stack>
#include<unordered_map>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <cstdio>
#include <cstdlib>
#include <complex>
#define ll long long
#define  point complex<double>
#define  pi acos(-1)
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define arr2dof vector  vector<vector<int>>dp(N,vector<int>(2, inf));
using namespace std;
const ll N = 2e5 + 5, mod = 1e9 + 7, inff = -1e12, inf = 1e9 + 7;
const double ep = 0.0000000001;
//const double pi = 3.14159265359;

double dot(point a, point b) {
	return  (conj(a)*b).real();
}
double cross(point a, point b) {
	return  (conj(a)*b).imag();
}
double angle(point a, point b)
{
	double dt = dot(a, b);
	dt /= abs(a);
	dt /= abs(b);
	return acos(dt) * 180.0 / pi;
}

bool isrightangel(int ind) {//90 degree
	vector<point>v;
	return(angle(v[ind] - v[(ind + 1) % 3], v[ind] - v[(ind + 2) % 3]) == 90);//bshof hal eldot producty3ny fe
	//dl3en 3moden 3ashn yb2a right trinagle
}

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
	if (exp == 0)
		return 1;
	ll ans = fp(base, exp / 2);
	ans = (ans * ans) % mod;
	if (exp % 2 != 0)
		ans = (ans * (base % mod)) % mod;
	return ans;
}

void calcFacAndInv(ll n)
{
	fact[0] = inv[0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		fact[i] = (i * fact[i - 1]) % mod;
		inv[i] = fp(fact[i], mod - 2);
	}
}

ll ncr(ll n, ll r)
{
	return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
	return (fact[n] * inv[n - r]) % mod;
}

int GCD(int a, int b) {
	if (b == 0)
		return a;
	else
		return GCD(b, a%b);
}
int LCM(int a, int b) {
	return (a*b) / GCD(a, b);
}


ll  n, m, arrn[100005], arrb[100005];
int main() {
	ios
		cin >> n;
	for (int i = 0; i < n + 1; ++i) {
		cin >> arrn[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> arrb[i];
	}
	ll ans=0;
	for (int i = 0; i < n; ++i) {
		ans += min(arrb[i], arrn[i]);
		
		if (arrb[i] > arrn[i]) {
			arrb[i] -= arrn[i];
			ans += min(arrb[i], arrn[i + 1]);
			arrn[i + 1] = max((ll)0, arrn[i +1] - arrb[i]);
		}
	}
	cout << ans;
	return 0;


}


Measured memory_bytes: 5108
#pragma GCC optimize(2)
#include <iostream>
#include <queue>
#include <vector>
#include <string>
using namespace std;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for (int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i != (int)R; --i)
#define IOS                                                                    \
    cin.tie(NULL);                                                             \
    cout.tie(NULL);                                                            \
    ios_base::sync_with_stdio(false);
vector<string> room;
int n, m;
int ans;
int d[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

void dfs(int x, int y)
{
    // cout << x << ' ' << y << '\n';
    FOR(i, 0, 4)
    {
        int _x = x + d[i][0];
        int _y = y + d[i][1];
        //     cout << _x << '-' << _y << '\n';
        // if (_x >= 0 && _x < n && _y >= 0 && _y < m)
        // {
        //     cout << room[_x][_y] << '\n';
        // }
        if (_x >= 0 && _x < m && _y >= 0 && _y < n && room[_x][_y] == '.')
        {
            room[_x][_y] = '@';
            ++ans;
            dfs(_x, _y);
        }
    }
}

int main()
{
    IOS;
    while (cin >> n >> m, n || m)
    {
        room.resize(m);
        FOR(i, 0, m) { cin >> room[i]; }
        int x = 0, y = 0;
        FOR(i, 0, m) FOR(j, 0, n)
        {
            if (room[i][j] == '@')
            {
                x = i;
                y = j;
            }
        }
        ans = 1;
        // cout << x << ' ' << y << '\n';
        dfs(x, y);
        cout << ans << '\n';
    }
}


Measured memory_bytes: 3128
#include<stdio.h>
int main()
{
   long long int i,j,ans;
   scanf("%lld %lld",&i,&j);
    ans=GCD(i,j);
    printf("%lld\n",ans);
    return 0;
}
int GCD(long long int i, long long int j)
{
    if (j!=0)
    {
        return GCD(j,i%j);
    }
    else
    {
        return i;
    }
}



Measured memory_bytes: 2124
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i, n) for ( int i = 0; i < (int)n; i++)
#define NMAX 100
#define MAX 1000000
#define INFTY (1<<21)


void setTable(int maxv, pair<int, int> v[NMAX], int vs,  int T[MAX+1]){
    rep(i, maxv+1) T[i] = INFTY;
    T[0] = 0;
    rep(i, vs){
	for ( int j = 1; j <= v[i].second; j++ ) T[j] = min(T[j], v[i].first);
	for ( int j = v[i].second+1; j <= maxv; j++ ){
	    T[j] = min(T[j], T[j-v[i].second] + v[i].first);
	}
    }
}

main(){
    int n, M[NMAX], TS[MAX+1], TA[MAX+1], ss, as;
    pair<int, int> S[NMAX], A[NMAX];

    string name, type;
    int maxh = 0;
    while( cin >> n && n ){
	ss = as = 0;
	rep(i, n) { cin >> M[i]; maxh = max(maxh, M[i]); }
	int m, cost, damage; 
	cin >> m;
	rep(i, m){
	    cin >> name >> cost >> type >> damage;
	    if ( type == "Single") S[ss++] = make_pair(cost, damage);
	    if ( type == "All") A[as++] = make_pair(cost, damage);
	}
	setTable(maxh, S, ss, TS);
	setTable(maxh, A, as, TA);
	
	int ans = INFTY;
	for( int a = 0; a <= maxh; a++ ){
	    int cost = TA[a];
	    for ( int i = 0; i < n; i++ ){
		int rem = M[i] - a;
		if ( rem <= 0 ) continue;
		cost += TS[rem];
	    }
	    ans = min(ans, cost);
	}
	cout << ans << endl;
    }
}

Measured memory_bytes: 8720
#include <stdio.h>

int main(void){
  int i,j,k,n,m,l,a[100][100],b[100][100];
  long int s;
  scanf("%d%d%d",&n,&m,&l);

//行列A
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);

//行列B
  for(i=0;i<m;i++)
    for(j=0;j<l;j++)
      scanf("%d",&b[i][j]);

//行列C
  for(i=0;i<n;i++)
    for(j=0;j<l;j++){
      s = 0;
      for(k=0;k<m;k++)
        s += a[i][k] * b[k][j] ;
      printf("%ld", s);
      if(j+1 == l)
        printf("\n");
      else
        printf(" ");
    }

  return 0;
}



Measured memory_bytes: 2780
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN



int main(void){
	int n;
	ll a[200002];
	cin>>n;
	reg(i,1,n){
		cin>>a[i];
	}
	int cnt=n;
	bool go=false;
	while(1){
		if(cnt>n)break;
		cout<<a[cnt]<<" ";
		if(cnt==2 && !go){
			cnt=1;
			go=true;
		}else if(cnt==1 && !go){
			cnt=2;
			go=true;
		}else{
			if(go){
				cnt+=2;
			}else{
				cnt-=2;
			}
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3712
N, K = map(int,input().split())
h = list(map(int,input().split()))
dp = [-1]*N
 
def rec_dp(i,K,dp):
    minArray = []
    if i == 0:
        minArray = [0]
    for j in range(K):
        if i - (j+1) >= 0:
            stepMin = dp[i-(j+1)] + abs(h[i] - h[i-(j+1)])
            minArray.append(stepMin)
    return min(minArray)
 
for i in range(N):
    dp[i] = rec_dp(i,K,dp)
 
print(dp[N-1])

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

int main() {
    int A[3];
    std::cin >> A[0] >> A[1] >> A[2];
    std::sort(A, A + 3);

    std::cout << std::abs(A[1] - A[0]) + std::abs(A[1] - A[2]) << std::endl;

    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;

const int MAXN = 5e3+3; //AREGLAAAAAAAAR!!!!
int m[4][4];
int main(){
	FOR(i,0,3) FOR(j,0,3) ri(m[i][j]);
	FOR(i,0,1000001){
		int b1=m[0][0]-i,b2=m[0][1]-i,b3=m[0][2]-i;
		int a1=i,a2=m[1][0]-b1,a3=m[2][0]-b1;
		if(a1+b1==m[0][0] && a1+b2==m[0][1] && a1+b3==m[0][2] && a2+b1==m[1][0] && a2+b2==m[1][1] && a2+b3==m[1][2] &&
			a3+b1==m[2][0] && a3+b2==m[2][1] && a3+b3==m[2][2]){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;

}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

void func(long long N, std::vector<long long> a){

    lli sum = 0;
    REP(i,0,N)sum ^= a[i];

    REP(i,0,N){
        cout<<(sum^a[i])<<" ";
    }

    cout<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    func(N, std::move(a));
    return 0;
}


Measured memory_bytes: 4840
N=int(input())
H=list(map(int,input().split()))
memo=H[-1]
for i in range(N-1):
    h=H[N-2-i]
    if h<=memo:
        memo=h
    elif h==memo+1:
        pass
    else:
        print("No")
        exit()
print("Yes")
        

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

vector<int> to[2505];
vector<int> rto[2505];
bool reachableFrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
    if (reachableFrom1[v]) return;
    reachableFrom1[v] = true;
    for (int u : to[v]) {
        dfs(u);
    }
}

void rdfs(int v) {
    if (reachableToN[v]) return;
    reachableToN[v] = true;
    for (int u : rto[v]) {
        rdfs(u);
    }
}

int main() {
    int n, m, p; cin >> n >> m >> p;
    vector<tuple<int, int, int> > edges;
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        c -= p;
        c = -c;
        edges.emplace_back(a, b, c);
        to[a].push_back(b);
        rto[b].push_back(a);
    }
    dfs(0);
    rdfs(n-1);
    rep(i, n) ok[i] = reachableFrom1[i] & reachableToN[i];

    //bellman-ford
    vector<int> d(n, INF);
    d[0] = 0;
    bool upd = true;
    int step = 0;
    while (upd) {
        upd = false;
        rep(i, m) {
            int a, b, c;
            tie(a, b, c) = edges[i];
            if (!ok[a]) continue;
            if (!ok[b]) continue;
            int newD = d[a]+c;
            if (newD < d[b]) {
                upd = true;
                d[b] = newD;
            }
        }
        step++;
        if (step > n) {
            puts("-1");
            return 0;
        }
    }
    int ans = -d[n-1];
    chmax(ans, 0);
    cout << ans << endl;

}

Measured memory_bytes: 640
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int r;
	cin>>r;
	double x=r*2*3.14;
	cout<<fixed<<setprecision(7)<<x;
	return 0;
}


Measured memory_bytes: 3804
n,k = map(int,input().split())

t = list(map(int,input().split()))

kagu = []

for i in range(10):
    if i in t:
        continue
    kagu.append(str(i))

ans = 1000000000000

for i in kagu:
    if i == '0':
        continue
    if n<=int(i):
        print(i)
        exit()
    memo = [i]
    while int(memo[-1])< n:
        a = memo.pop(0)
        for j in kagu:
            goukei = a+j
            memo.append(goukei)
            if n<=int(goukei):
                ans = min(ans,int(goukei))
                break
print(ans)

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

#define ll long long
#define vi vector<int> 
#define pb push_back	

ll a, b;
 
int main(){
	cin >> a >> b;
	if(a > 0 && b > 0){
		cout << "Positive";
	}
	if(a < 0 && b >= 0){
		cout << "Zero";
	}
	if(a < 0 && b < 0){
		if(abs((a - b + 1)% 2 != 0)){
			cout << "Negative";
		}
		else {
			cout << "Positive";
		}
	}
	return 0;
}

Measured memory_bytes: 256
#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>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int s;
  cin >> s;
  set<int> S;
  S.insert(s);
  int before = s;
  for(int i = 2; i <= 1000001; ++i){
    if(before % 2) s = 3 * before + 1;
    else s = before / 2;
    auto it = S.find(s);
    if(it != S.end()) {
      cout << i << endl;
      return 0;
    }
    S.insert(s);
    before = s;
  }

}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App  {
  val sc = new Scanner(System.in)
  val iS = sc.next

  val s = iS.split("(?<=.)").map(_.toInt)
  val n = s.length

  val count01 = s.zipWithIndex.foldLeft(0){case (count, (c,i)) =>
      if(c == i % 2) count + 1 else count
  }

  val res = Math.min(count01, n - count01)

  println(res)



}


Measured memory_bytes: 50268
# -*- coding:utf-8 -*-
import sys


def merge(lst, left, mid, right):
    L = lst[left: mid]
    R = lst[mid: right]
    l_len = len(L)
    r_len = len(R)
    cnt = 0
    i = 0
    j = 0
    for k in range(left, right):
        cnt += 1
        if l_len <= i:
            lst[k] = R[j]
            j += 1
        elif r_len <= j:
            lst[k] = L[i]
            i += 1
        elif L[i] <= R[j]:
            lst[k] = L[i]
            i += 1
        else:
            lst[k] = R[j]
            j += 1
    return cnt


def mergeSort(lst, left, right):
    if left + 1 < right:
        mid = (left + right) >> 1
        cnt = mergeSort(lst, left, mid)
        cnt += mergeSort(lst, mid, right)
        return merge(lst, left, mid, right) + cnt
    else:
        return 0


if __name__ == "__main__":
    lst = [val.split() for val in sys.stdin.read().splitlines()]
    data = [int(n) for n in lst[1]]
    cnt = mergeSort(data, 0, int(lst[0][0]))
    print(" ".join([str(n) for n in data]))
    print(cnt)

Measured memory_bytes: 106216
# include <iostream>
# include <string>
# include <algorithm>
using namespace std;
string s[200005];
int main()
{
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        cin >> s[i];
    }
    sort(s + 1 , s + 1 + n);
    int cnt = 1;
    for(int i = 2;i <= n;i++)
    {
        if(s[i] != s[i-1])
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 9888
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#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 <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
//#define int long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2005;
int a[N], n, k, q;
bool check(int l , int r){
	l = max(1 , l);
	int cnt = 0 , len = 0;
	int res = 0;
	rep(i , 1 , n + 1){
		if(a[i] < l){
			res += min(cnt , max(len - k + 1 , 0 ));
			len = 0 , cnt = 0;
		}
		else{
			len++;
			if(a[i] <= r)cnt++;
		}
	}


	return res >= q;
}
main(){
	scanf("%d%d%d" , &n , &k , &q);
	rep(i , 1, n)
		scanf("%d" , a + i);
	a[n + 1] = -1;
	int l = 0 , r = 1e9 , res = 1e9;

	while(l <= r){
		int m = (l + r) >> 1;
		bool ok = 0;
		rep(i , 1 , n){
			ok |= check(a[i] - m , a[i]);
		}
		if(ok)res = m , r = m - 1;
		else l = m + 1;
	}
	ret(res);
}

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

int main()
{
    int N, M, C;
    
    cin >> N >> M >> C;
    int B[M], A[N][M];
    
    for(int i = 0; i < M; i++){
        cin >> B[i];
    }
  
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }

    int ans = 0;

    for(int i = 0; i < N; i++){
        int sum = C;
        for(int j = 0; j < M; j++){
            sum += A[i][j] * B[j];
        }
        if(sum > 0){
            ans++;
        }
    }
  
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256