akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>
#define REP(x,n) for(int x = 0;x < n;x++)

struct UnionFind {
    vector<ll> data;
    UnionFind(ll size) : data(size, -1) { }
    bool unionSet(ll x, ll y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(ll x, ll y) {
        return root(x) == root(y);
    }
    ll root(ll x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    ll size(ll x) {
        return -data[root(x)];
    }
};

int n;
ll a[100000];
ll b[100000];

ll p[100000];

map<int,int> m;

static const int l = 20010;

int main()
{
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        cin >> p[i];
        p[i]--;
        m[p[i]] = i;
    }
    {
        int ca = 0;
        for(int i = 0;i < l;i++)
        {
            ca++;
            if(m.find(i) != m.end())
            {
                ca += m[i];
            }
            a[i] = ca;
        }
    }
    {
        int cb = 0;
        for(int i = l-1;i >= 0;i--)
        {
            cb++;
            if(m.find(i) != m.end())
            {
                cb += m[i];
            }
            b[i] = cb;
        }
    }
    for(int i = 0;i < n;i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
    for(int i = 0;i < n;i++)
    {
        cout << b[i] << " ";
    }
    cout << endl;
    
}



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

int mat[800][800];
int n, m;

int checked[800];

pair<int, int> dfs(int u, int c)
{
    pair<int, int> ret = {1, 0};
    checked[u] = c;

    for (int i = 0; i < n; i++) {
        if (i != u && !mat[u][i]) {

            if (checked[i]) {
                if (checked[i] == c)
                    throw 0;
                else
                    continue;
            }
            
            auto res = dfs(i, 3 - c);
            ret.first += res.second;
            ret.second += res.first;
        }
    }
    return ret;
}

int dp[800][800] = {};

int main()
{
    ios::sync_with_stdio(false);

    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        mat[a][b] = mat[b][a] = 1;
    }

    vector<pair<int, int>> v;
    try {
        for (int i = 0; i < n; i++) {
            if (checked[i])continue;
            v.push_back(dfs(i, 1));
        }
    } catch(...) {
        printf("-1\n");
        return 0;
    }



    dp[0][0] = 1;

    for (int k = 0; k < (int)v.size(); k++) {
        for (int i = 0; i <= n; i++) {
            if (dp[k][i]) {
                dp[k + 1][i + v[k].first] = dp[k + 1][i + v[k].second] = 1;
            }
        }
    }

    int best = n * n;
    for (int i = 0; i <= n; i++)
        if(dp[v.size()][i])
            best = min(best, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);

    cout << best << '\n';

}


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

int main() {
  string str1, str2;
  cin >> str1;
  if (str1=="ABC"){
  str2 = "ARC";
  }
  else{
     str2 = "ABC";
  }
    
  

  cout << str2 << endl;
}


Measured memory_bytes: 3600
import java.util.Scanner;

class Main{
  private static int H,W;

  public static void main(String[] args){
    
    Scanner s= new Scanner(System.in);
   
   while(true){
   H=s.nextInt();
   W=s.nextInt();
   
   if(H==0&&W==0){
       break;
   }
   for(int i = 0;i<H;i++){
       for(int x=0;x<W;x++){
           System.out.print("#");
       }
       System.out.println("");
       
   }System.out.println("");
   
  }
  }   
      
  }


Measured memory_bytes: 32568
#include <bits/stdc++.h>
#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
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int M1,D1,M2,D2;
    cin>>M1>>D1>>M2>>D2;
    if(D2==1) cout<<1<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n,q;cin>>n>>q;
  string s;cin>>s;
  vpii v(n);
  rep(i,q){
    int l,r;cin>>l>>r;
    v[i]=mp(l,r);
  }
  vi counter(n,0);
  irep(i,1,n){
    counter[i]=counter[i-1];
    if(s.substr(i-1,2)=="AC"){
      counter[i]++;
    }
  }
  rep(i,q){
    int l=v[i].first-1;
    int r=v[i].second-1;
    // cout<<l<<" "<<r<<" "<<counter[l]<<" "<<counter[r]<<endl;
    cout<<(counter[r]-counter[l])<<endl;
  }
}

Measured memory_bytes: 2256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[25][25], all, n;
const ll N = 2111111, mod = 1e9 + 7;
ll dp[25][N];
ll f(int mask, int i){
	if(mask == all) return 1LL;
	if(i > n) return 0LL;
	ll &res = dp[i][mask];
	if(~res) return res;
	res = 0;
	for(int j=0;j<21;j++){
		if(!(mask&(1<<j)) && a[i][j + 1]) {
			res += f(mask|(1<<j), i+1);
			res %= mod;
		}
	}	
	return res;
}
int main() {
	cin >> n;
	for(int i=1;i<=n;i++ ){
		for(int j=1;j<=n;j++) cin >> a[i][j];
	}
	all = (1 << n) - 1;
	memset(dp, -1, sizeof dp);
	cout << f(0, 1) << '\n';
	return 0;
}

Measured memory_bytes: 412544
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>
#include<experimental/any>
#include<cstring>
#include<cctype>
#include<ctime>
#include<cstdbool>
#include<cstdint>
#include<cstddef>
#include<set>
#include<unordered_set>
#include<bitset>
 
using namespace std;
using experimental::any;
 
#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);
 
#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)
#define BitFOR(N) REP(Bit,1<<(N))
 
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define TFDEB(f) (f)? cout<<"true ":cout<<"false ";
#define FORDEB(n,X) for(int i=0;i<(n);i++)ARDEB(i,X)
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define ARDEB(i,X) {}
#define TFDEB(f) {}
#define FORDEB(n,X) {}
#define END {}
#endif
 
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};
struct P2{int x,y;};
#define BIT(Bit,n) bitset<n>(Bit)
#define Endl endl
 
const int MOD7=1000000007;
const int INF=100000000;
const int SET=1000;
 
int main(){
	int a,b;
	cin>>a>>b;
	if((a*b)%2==0){
		cout<<"Even"<<endl;
	}
	else{
		cout<<"Odd"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
//ProblemD

//#define USE_STDIO
//#define USE_LOG
//#define FILE_ERR

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#ifndef debug
#define debug(...)
#endif // !LOG

//include
#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>

using namespace std;

//for
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define forbe(i, begin, end) for(decltype(begin) i = (begin); i != (end); ++i)
#define forbes(i, begin, end, step) for(decltype(begin) i = (begin); i != (end); i += (step))

//int
using ll = long long;
using ull = unsigned long long;
using uint = unsigned;

//pair
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
#define fi first
#define se second

//vector
template <typename Value>
static inline void fillv(Value& x, const Value& val) { x = val; }
template <typename Vector, typename Value>
static inline void fillv(Vector& v, const Value& val) { for (auto& x : v) fillv(x, val); }

static inline void Solve();

int main(int argc, char* argv[]) {
#ifdef REDIRECT_STDIO
	REDIRECT_STDIO;
#endif // REDIRECT_STDIO

	Solve();
	return 0;
}

constexpr ll MAXS = ll(1e12 + 7);

struct Edge {
	int next;
	ll sum;
};

//ProblemD
void Solve() {
	int n, m;
	cin >> n >> m;
	vector<vector<Edge>> edges(n);

	for (int i = 0; i < m; i++) {
		int u, v;
		ll s;
		cin >> u >> v >> s;
		u--, v--;
		edges[u].push_back({ v, s });
		edges[v].push_back({ u, s });
	}

	vector<pll> val(n, pll{0, 0});
	queue<int> q;
	q.push(0);
	val[0] = { 1, 0 };
	ll x = MAXS;
	while (!q.empty()) {
		auto top = q.front();
		q.pop();

		for (auto& edge : edges[top]) {
			int ne = edge.next;
			ll su = edge.sum;
			pll nval = { -val[top].first, su - val[top].second };
			if (val[ne].first == 0) {
				val[ne] = nval;
				q.push(ne);
			}
			else if (val[ne].first == nval.first) {
				if (val[ne].second != nval.second) {
					cout << 0 << endl;
					return;
				}
			}
			else if (x == MAXS) {
				if ((val[ne].second - nval.second) % (val[ne].first - nval.first)) {
					cout << 0 << endl;
					return;
				}
				x = - (val[ne].second - nval.second) / (val[ne].first - nval.first);
				if (x <= 0) {
					cout << 0 << endl;
					return;
				}
			}
			else if (val[ne].first * x + val[ne].second != nval.first * x + nval.second) {
				cout << 0 << endl;
				return;
			}
		}
	}

	if (x != MAXS) {
		for (auto& v : val) {
			if (v.first * x + v.second <= 0) {
				cout << 0 << endl;
				return;
			}
		}
		cout << 1 << endl;
		return;
	}

	ll minv = 1;
	ll maxv = MAXS;

	for (auto& v : val) {
		if (v.first > 0) {
			minv = max(minv, 1 - v.second);
		}
		else {
			maxv = min(maxv, v.second - 1);
		}
	}

	if (minv > maxv) {
		cout << 0 << endl;
	}
	else {
		cout << maxv - minv + 1 << endl;
	}
}


Measured memory_bytes: 9600
# N
# t1 x1 y1
# t2 x2 y2
# ...
# tn xn yn

n = gets.chomp.to_i

as = n.times.map do |_|
  gets.chomp.split(" ").map(&:to_i)
end.unshift([0,0,0])

can = false

as.zip(as[1..-1]).each do |(t1, x1, y1), (t2, x2, y2)|
  break if t2.nil?

  diff_t = t2 - t1
  diff_x = (x2 - x1).abs
  diff_y = (y2 - y1).abs

  d = diff_t - diff_x - diff_y

  if d < 0
    can = false
    break
  else
    if d.even?
      can = true
    else
      can = false
      break
    end
  end
end

if can
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 11900
n = int(input())
hats = list(map(int, input().split()))
MOD = 1000000007
r = 0
g = 0
b = 0
ans = 1

for h in hats:
    if ans == 0:
        break
    poss = 0
    can_add = True
    if r == h:
        poss += 1
        if can_add:
            r += 1
            can_add = False
    if g == h:
        poss += 1
        if can_add:
            g += 1
            can_add = False
    if b == h:
        poss += 1
        if can_add:
            b += 1
            can_add = False        
    ans *= poss
    ans = ans % MOD
    
print(ans)


Measured memory_bytes: 53044
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,n,x;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	scanf("%d",&f);
	if(a<=b && a<=c && a<=d){
		n=b+c+d;
	}
	else if(b<=a && b<=c && b<=d){
		n=a+c+d;
	}
	else if(c<=a && c<=b && c<=d){
		n=a+b+d;
	}
	else{
		n=a+b+c;
	}
	if(f<=e){
		x=n+e;
		printf("%d\n",x);
	}
	else{
		x=n+f;
		printf("%d\n",x);
	}
	
		return 0;
}



Measured memory_bytes: 2720
import java.util.Scanner;

public class Main {

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

		int x = sc.nextInt();
		int y = sc.nextInt();

		int crane = 0;
		int turtle = x * 4;

		while (turtle >= 0) {
			if (crane + turtle == y) {
				System.out.println("Yes");
				System.exit(0);
			}
			turtle -= 4;
			crane += 2;
		}
		System.out.println("No");
	}

}


Measured memory_bytes: 35756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    string N;
    cin >>N;
    
    if(N[0]=='7' || N[1]=='7'||N[2]=='7'){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }


    return 0;
    

}

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

 using namespace std;

 int main() {
   int N, i, seat;

   cin >> N;

   vector<int> l(N + 1);
   vector<int> r(N + 1);

   for (i = 1; i <= N; i++) cin >> l.at(i) >> r.at(i);

   seat = 0;
   for (i = 1; i <= N; i++) {
     seat += r.at(i) - l.at(i) + 1;
   }

   cout << seat << endl;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 100002

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
ll dp[102][N];
vii v;
ll go(ll ind,ll wt)
{
	if(ind==v.size())
		return 0;
	//test2(ind,wt);
	if(dp[ind][wt]!=-1)
		return dp[ind][wt];
	ll ans=0;
	if(wt>=v[ind].ff)
		ans=v[ind].ss+go(ind+1,wt-v[ind].ff);
	ans=max(ans,go(ind+1,wt));

	//test3(ind,wt,ans);
	return dp[ind][wt]=ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
        
	ll n,w;cin>>n>>w;
	rep(i,1,n+1)
	{
		ll l,r;cin>>l>>r;
		v.pb({l,r});
	}
	memset(dp,-1,sizeof(dp));
	ll ans=go(0,w);
	cout<<ans<<endl;
}

Measured memory_bytes: 80000
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int N,M,F[2][305][305];
char A[305][305];
long long Ans;
inline int LU(int x,int y,int k){
	if (k<1) return 0;
	k+=min(0,min(x-k,y-k));
	return F[0][x][y]-F[0][x-k][y-k];
}
inline int RU(int x,int y,int k){
	if (k<1) return 0;
	k+=min(0,min(x-k,M-y-k+1));
	return F[1][x][y]-F[1][x-k][y+k];
}
inline int Calc(int x_1,int y_1,int x_2,int y_2){
	if (x_2<x_1) swap(x_1,x_2),swap(y_1,y_2);
	if (y_1<=y_2){
		int z=max(x_2-N,y_2-M);
		if (z>0) x_2-=z,y_2-=z;
		if (x_2<1||y_2<1) return 0;
		return LU(x_2,y_2,x_2-x_1+1);
	}
	if (y_1>=y_2){
		int z=max(x_2-N,1-y_2);
		if (z>0) x_2-=z,y_2+=z;
		if (x_2<1||y_2>M) return 0;
		return RU(x_2,y_2,x_2-x_1+1);
	}
}
int main(){
	scanf("%d%d",&N,&M);
	for (int i=1;i<=N;++i) scanf("%s",A[i]+1);
	for (int i=1;i<=N;++i)
		for (int j=1;j<=M;++j) F[0][i][j]=F[0][i-1][j-1]+(A[i][j]=='#'),F[1][i][j]=F[1][i-1][j+1]+(A[i][j]=='#');
	int KS=min(N,M);
	for (int i=1;i<=N;++i)
		for (int j=1;j<=M;++j)
			for (int k=KS;k;--k){
				if (i>k&&j>k&&A[i-k][j]=='#'&&A[i][j-k]=='#') Ans+=Calc(i-k,j-2*k,i-2*k+1,j-k-1);
				if (i+k<=N&&j+k<=M&&A[i+k][j]=='#'&&A[i][j+k]=='#') Ans+=Calc(i+k,j+2*k,i+2*k-1,j+k+1);
				if (i>k&&j+k<=M&&A[i-k][j]=='#'&&A[i][j+k]=='#') Ans+=Calc(i-2*k,j+k,i-k-1,j+2*k-1);
				if (i+k<=N&&j>k&&A[i+k][j]=='#'&&A[i][j-k]=='#') Ans+=Calc(i+2*k,j-k,i+k+1,j-2*k+1);
			}
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int main()
{
	int N, A, B;
	cin >> N >> A >> B;

	long long patterns = 0;

	if (B < A)
	{
		patterns = 0;
	}
	else if (B == A)
	{
		patterns = 1;
	}
	else
	{
		if (N == 1)
		{
			patterns = 0;
		}
		else
		{
			patterns = (long long) (N-2)*(B - A);
			patterns++;
		}
	}

	cout << patterns << endl;
}

Measured memory_bytes: 256
def solve():
  N = int(input())
  P = [int(i) for i in input().split()]
  ans = 0
  for i in range(N - 2):
    maxP = max(P[i], P[i + 2])
    minP = min(P[i], P[i + 2])
    if minP < P[i + 1] and P[i + 1] < maxP: ans += 1
  return ans

print(solve())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
 
#define pb push_back
#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod) x-=mod;if(x<0) x+=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))
#define Set(N,cur) N=(N|(1LL<<cur))
#define Reset(N,cur) N=(N&(~(1LL<<cur)))
#define Check(N,cur) (!((N&(1LL<<cur))==0))
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define dump(x) cerr<<"~ "<<#x<<" = "<<x<<endl
//Imran addition
#define rep(i,n) for(int i = 1; i <= n; i++)
#define mem CLR
#define pf printf
#define sc scanf
#define endl "\n"
#define gi(k) scanf("%d",&k)
#define gl(k) scanf("%lld",&k)
#define NMAX 2147483647
#define LMAX 9223372036854775807LL
 
using namespace std;
 
 
#define LL long long
#define LLU long long unsigned int
typedef long long vlong;
typedef unsigned long long uvlong;
typedef pair < int, int > pii;
typedef pair < vlong, vlong > pll;
typedef vector<int> vi;
typedef vector<vlong> vl;
typedef vector<pll> vll;
 
inline vlong gcd ( vlong a, vlong b ) {
    a = ABS ( a ); b = ABS ( b );
    while ( b ) { a = a % b; swap ( a, b ); } return a;
}
 
 
const vlong inf = 2147383647;
const vlong mod = 1000000007;
const double pi = 2 * acos ( 0.0 );
const double eps = 1e-9;
 
 
 
int main () {
 
 	#ifdef forthright48
    freopen ( "00_input.txt", "r", stdin ); //freopen ( "00_output.txt", "w", stdout );
 	#endif
 	
 	vlong k,a,b,x,cnt;
    
    cin >> k >> a >> b;
    
    if( b-a > 2) {
        
        x = min(a,k+1);
        k -= x-1;
        
        x += k % 2;
        k /= 2;
        
        while(k) {
            x += (b-a);
            k--;
        }
        
        cout << x << endl;
    }
    
    else {
        cout << k+1 << endl;
    }
	
	
 
    return 0;
}

















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define MOD 1000000007
//#define MOD 998244353
#define EPS (1 >> 30)
//#define INF (1 << 30)
#define INF (1LL << 60)
#define fs first
#define sc second
//#define int long long
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

using Graph = vector<vector<pair<int, int>>>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int joutai; // tate 0 yoko 1
    int n;
    string s,t;
    cin>>n>>s>>t;
    ll ans=0;
    if(s[0]==t[0]){ // tate 0
        joutai=0;
        ans=3;
        //cout<<ans<<endl;
    }
    else{ // yoko 1
        joutai=1;
        ans=6;

    }

    for(int i=0;i<n;i++){
        if(i==0){
            if(joutai==0){
                continue;
            }
            else{
                i++;
                continue;
            }
        }
        int mae=joutai;
        if(s[i]==t[i]){
            joutai=0;
        }
        else{
            joutai=1;
        }

        if(mae==0&&joutai==0){
            ans*=2;
            ans%=MOD;
        }
        else if(mae==0&&joutai==1){
            ans*=2;
            ans%=MOD;
            i++;
        }
        else if(mae==1&&joutai==0){
            ans*=1;
            ans%=MOD;
        }
        else if(mae==1&&joutai==1){
            ans*=3;
            ans%=MOD;
            i++;
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
S = input()
XX,YY= [ int(it) for it in input().split() ]


s = 0
li=[]
for v in S:
  if (v=='T'):
    li.append(s)
    s = 0
  else:
    s += 1
li.append(s)
    
liv = li[1:]
liy = liv[0::2]
lix = liv[1::2]

xset = set([li[0]])
for v in lix:
  tmp = set()
  for w in xset:
    tmp.add(+v+w)
    tmp.add(-v+w)
  xset = tmp

yset = set([0])
for v in liy:
  tmp = set()
  for w in yset:
    tmp.add(+v+w)
    tmp.add(-v+w)
  yset = tmp

if ( XX in xset and YY in yset ):
  print ("Yes")
else:
  print ("No")

Measured memory_bytes: 49116
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N,X,i,now=0;
  cin >> N >> X;
  vector<int> L(N);
  for(i=0;i<N;i++)cin >> L[i];
  for(i=0;i<N;i++){
    now += L[i];
    if(now > X) {
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << N+1 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  
  int n,d;
  cin>>n>>d;
  int result=1;
  int right=d+d+1;
  while(right<n){
    right+=d+d+1;
    result++;
  }
  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  int n,c,k;
  cin>>n>>c>>k;
  vector<int> t(n);
  REP(i,n)cin>>t[i];
  sort(ALL(t));
  int ans=0;
  REP(i,n){
    int cap=1;
    int tmp=t[i]+k;
    for(int j=i+1;;j++){
      if(tmp<t[j]||cap==c)break;
      if(tmp>=t[i]&&cap<c)cap++;
    }
    i+=cap-1;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"unicode/utf8"
	// "sort"
	//"regexp"
)

var s string

func main() {
	fmt.Scan(&s)
	solve(s)
}

func solve(s string) {
	length := utf8.RuneCountInString(s)
	s = s[0 : length-1]
	length = utf8.RuneCountInString(s)
	if s[0:length/2] == s[length/2:length] {
		fmt.Println(length)
		return
	}
	solve(s)
}


Measured memory_bytes: 1824
def main():
    n = int(input())
    a = list(map(int,input().split()))
    q = int(input())
    from collections import Counter
    cnt = Counter(a)
    res = sum(a)
    for i in range(q):
        b, c = map(int,input().split())
        bufb = cnt[b]
        bufc = cnt[c]
        cnt[b] = 0
        cnt[c] += bufb
        res += (-b+c)*bufb
        print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 88584
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = 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;
}
// End of template code!
int main() 
{
    buff();
    string s;
    cin >> s;
    for(auto& c : s) if( c == '?') c = 'D';
    cout << s << '\n';
    return 0;
}



Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
int main(){
    int n, k; sc(n), sc(k);
    string s; cin >> s;
    bool check = false;
    int ans = 0, cnt = 0, left = 0;
    for (int i = 0; i < n; i++){
        if (s[i] == '0'){
            if (!check) cnt += 1;
            while (cnt > k){
                left++;
                if (s[left]=='1' && s[left-1]=='0') cnt--;
            }
            check = true;
        }else check = false;
        ans = max(ans, i-left+1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
// #define rep(i, n) for(int i = 0; i < (int)(n); i++)
// #define all(a) (a).begin(),(a).end()
// #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
// int gcd(int a, int b){return b ? gcd(b, a%b) : a;}

#define int long long
#define SIZE 100000

using namespace std;

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

  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  // int n; cin >> n;

  int k; cin >> k;
  int a; cin >> a;
  int b; cin >> b;

  num = 1;
  int yen = 0;
  
  // if (a < b) {
  if (b - a > 2) {
    
    for (int i = 0; i < k; ++i) {

      if (yen > 0) {
        --yen;
        num += b;
      } else { // yen == 0 => true
        if (num < a) {
          ++num;
        } else {
          if (i == k - 1) {
            ++num;
          } else {
            ++yen;
            num -= a;
          }
        }
      }
      // cout << "num: " << num << " yen: " << yen << endl;
    }
    
  } else {
    num += k;
  }
  
  // array<int, SIZE> a;
  // for (auto it = a.begin(); it < a.begin() + n; ++it) cin >> *it;
  // for (auto it = a.begin(); it < a.begin() + n; ++it) num += *it;

  cout << num << endl;
  return 0;
}


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

int main() {
	int w,a,b;
	cin >> w >> a >> b;
	if(a+w<b){
		cout << b-a-w;
	}else if(b+w<a){
		cout << a-b-w;
	}else{
		cout << 0;
	}
	
}

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

int main(void){
  vector<int> ans;
  int n;

  while(cin>>n){
    ans.clear();

    for(int i=512; i>0; i/=2){
      if(n/i == 1){
        ans.push_back(i);
        n -= i;
      }
    }

    for(int i=ans.size()-1; i>=0; i--){
      cout << ans[i];
      (i==0)? cout << endl : cout << " ";
    }
  }

  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    vector<int> q(N);
    for(int i = 0; i < N; ++i){
        cin >> p[i];
        q[i] = p[i];
    }
    sort(q.begin(), q.end());
    int c = 0;
    for(int i = 0; i < N; ++i){
        if(p[i] != q[i]) c++;
    }
    if(c == 0 || c == 2) cout << "YES";
    else cout << "NO";
    return 0;
}

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

int main() {
  LL k, a, b;
  cin >> k >> a >> b;
  LL ans;
  if (b - a <= 2 || k < a - 1) {
    ans = k + 1;
  } else {
    ans = a;
    k -= a - 1;
    if (k % 2 == 1) {
      k --;
      ans ++;
    }
    ans += (b - a) * (k / 2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N = int(input())
    a = list(map(int, input().split()))
    dp = [[0]*N for _ in range(N)]
    if N%2 == 0:
        for l in range(N-1, -1, -1):
            for r in range(N):
                if l > r:
                    continue
                if l==r==N-1 or l==r==0:
                    dp[l][N-r-1] = -a[l]
                if l+1==N or N-r-1+1==N:
                    continue
                if (r-l+1)%2 == 0:
                    dp[l][N-r-1] = max(dp[l+1][N-r-1]+a[l], dp[l][N-r-1+1]+a[r])
                else:
                    dp[l][N-r-1] = min(dp[l+1][N-r-1]-a[l], dp[l][N-r-1+1]-a[r])
    else:
        for l in range(N-1, -1, -1):
            for r in range(N):
                if l > r:
                    continue
                if l==r==N-1 or l==r==0:
                    dp[l][N-r-1] = a[l]
                if l+1==N or N-r-1+1==N:
                    continue
                if (r-l+1)%2 == 0:
                    dp[l][N-r-1] = min(dp[l+1][N-r-1]-a[l], dp[l][N-r-1+1]-a[r])
                else:
                    dp[l][N-r-1] = max(dp[l+1][N-r-1]+a[l], dp[l][N-r-1+1]+a[r])
    print(dp[0][0])
    
if __name__ == '__main__':
    main()

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

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

struct mykey {
    char cnt[26];
    mykey() : cnt{} {}
    mykey(const string &str) : cnt{} {
        for (int i = 0; i < str.size(); ++i) {
            ++cnt[str[i] - 'a'];
        }
    }

    bool operator<(const mykey &rkey) const {
        for (int i = 0; i < 26; ++i) {
            if (cnt[i] < rkey.cnt[i])
                return true;
            if (cnt[i] > rkey.cnt[i])
                return false;
        }
        return false;
    }
};

int main() {
    int n;
    cin >> n;
    map<mykey, ll> mp;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        ++mp[mykey(s)];
    }

    ll ans = 0;
    for (const auto &kv : mp) {
        if (kv.second >= 2) {
            ans += kv.second * (kv.second - 1) / 2;
        }
    }

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


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

int main(){
  ll a, b;
  cin >> a >> b;
  
  // 最大公約数をとる
  ll g = __gcd(a, b);
  
  // 素因数分解
  map<ll, ll> factor;
  for(ll i = 2; i * i <= g; i++) while(g % i == 0){
    factor[i]++;
    g /= i;
  }
  if(g != 1) factor[g]++;
  
  // 素数全てと1を選べば良い
  cout << factor.size() + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
using namespace std;

int main(void)
{
    //string a,b;
    int a,b,c,d;
    int i=0;
    //char a,b='.';
    cin>>a>>b>>c;
    if(a+b<c) cout<<"No";
    else cout<<"Yes";
    return 0;
}



Measured memory_bytes: 888
n = int(input())
listA = list(map(int, input().split()))

flag =1
count=0
while flag:
    flag =0
    index=0
    while index < len(listA):
        if listA[index]%2==0:
            listA[index]/=2
            index+=1
        else:
            break
    if index== len(listA):
        count+=1
        flag=1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvll vector<vll>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define pii pair<int, int>
#define vpli vector<pair<long long, int>>
#define deb(x) cout << "deb " << #x << " " << x << endl
#define all(x) x.begin(), x.end()
#define endl "\n"
const int N = 2e5 + 3,MOD = 1e9+7;

int n;
vll a(N),b(N);

ll bpow(ll base,ll pow)
{
    if(pow == 0) return 1;
    ll ans = bpow(base,pow/2);
    ans = (ans*ans)%MOD;
    if(pow%2)
    {
        ans = (ans * base)%MOD;
    }
    return ans;
}

void solve()
{
    cin>>n;
    ll zeroc = 0;
    map<pair<ll,ll>,ll> mp;
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
        if((a[i]>=0 && b[i]<0) || (a[i]<0 && b[i]<=0))
        {
            a[i]*=-1;
            b[i]*=-1;
        }
        else if(a[i] == 0 && b[i] == 0)
        {
            zeroc++;
            continue;
        }
        ll g = __gcd(abs(a[i]),abs(b[i]));
        a[i] /= g;
        b[i] /= g;
        mp[{a[i],b[i]}]++;
    }
    /*
    for(auto x : mp)
    {
        cout<<x.first.first<<" "<<x.first.second<<" "<<x.second<<endl;
    }
    */
    ll res = 1;
    for(auto x : mp)
    {
        ll a1 = x.first.first;
        ll b1 = x.first.second;
        ll cnt1 = x.second;
        ll a2,b2=abs(a1);
        if(a1>0)
        {
            a2 = -b1;
        }
        else
        {
            a2 = b1;
        }
        ll cnt2 = mp[{a2,b2}];
        if(mp.find({a2,b2}) != mp.end())
        {
            mp.erase({a2,b2});
        }
        res = (res*((bpow(2,cnt1)+bpow(2,cnt2)-1+MOD)%MOD)+MOD)%MOD;
        /*
        vll deb = {a1,b1,a2,b2,cnt1,cnt2,res};
        cout<<"DEBUGGING\n";
        for(ll x : deb) cout<<x<<" ";
        */
    }
    cout<<(res-1+zeroc+MOD)%MOD<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //pre();
    int t = 1;
    //cin >> t;
    //cout<<__gcd(-5,0)<<endl;
    while (t--)
        solve();
    return 0;
}


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

#define pb push_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;

using namespace std;
const int MAXN = 1e6 + 5 * 1e2;

ll n, mn, mx;
ll a[MAXN];

int main(){
cin >> n;
for(int i=1;i<=n;i++){
    cin >> a[i];
}
mn = 2, mx = 2;

for(int i=n;i>=1;i--){
    if(mn % a[i] != 0) mn = a[i] * (mn / a[i] + 1);
    mx = a[i] * (mx / a[i] + 1) - 1;
}
if(mn > mx){
    cout << -1;
}
else cout << mn << ' ' << mx;

return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int a, b;
    cin >> a >> b;
    if (b % a == 0)
        cout << a + b << endl;
    else
        cout << b - a << endl;
    return 0;
}




Measured memory_bytes: 256
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			String packageName = new Main().getClass().getPackage().getName();
			System.setIn(new FileInputStream("src/" + packageName + "/input.txt"));
			// System.setOut(new PrintStream(new FileOutputStream("src/" + packageName + "/result.txt")));
		} catch (FileNotFoundException e) {
		} catch (NullPointerException e) {
		}
		new Main().run();
	}

	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc;
	void run() {
		sc = new Scanner(System.in);
		int T = sc.nextInt();
		while (T -- > 0) solve();
	}
	void solve() {
		int[] as = new int[9];
		int[] bs = new int[9];
		for (int i = 0; i < 9; i++) as[i] = sc.nextInt();
		for (int i = 0; i < 9; i++) bs[i] = sc.nextInt();
		sort(as);
		sort(bs);

		int awin = 0;
		int bwin = 0;
		int total = 0;
		do {
			int a = 0, b = 0;
			for (int i = 0; i < as.length; i++) {
				if (as[i] > bs[i]) {
					a += as[i] + bs[i];
				} else {
					b += as[i] + bs[i];
				}
			}
			if (a > b) awin++;
			if (a < b) bwin++;
			++total;
		} while (nextPermutation(as));
		System.out.println(1.0 * awin / total + " " + 1.0 * bwin / total);
	}

	boolean nextPermutation(int[] is) {
		int n = is.length;
		for (int i = n - 1; i > 0; i--) {
			if (is[i - 1] < is[i]) {
				int j = n;
				while (is[i - 1] >= is[--j])
					;
				swap(is, i - 1, j);
				rev(is, i, n);
				return true;
			}
		}
		rev(is, 0, n);
		return false;
	}

	void swap(int[] is, int i, int j) {
		int t = is[i]; is[i] = is[j]; is[j] = t;
	}

	void rev(int[] is, int s, int t) {
		while (s < --t) swap(is, s++, t);
	}
}

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	vector<string> v;
	string s;
	getline(cin, s);
	while(s.size() != 0){
		int n = 0;
		while(n < s.size() && s[n] != ' ') n++;
		string t = s.substr(0, n);
		bool b = false;
		if(t[t.size()-1] == ',' || t[t.size()-1] == '.') t = t.substr(0, t.size()-1);
		v.push_back(t);
		if(n == s.size()) break;
		s = s.substr(n+1);
	}
	bool b = false;
	for(int i=0; i < v.size(); i++) if(3 <= v[i].size() && v[i].size() <= 6){ cout << (b ? " " : "") << v[i]; b = true;}
	cout << endl;
}

Measured memory_bytes: 1184
import os
import sys
from functools import lru_cache

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353

# MOD = 998244353

def get_factorials(max, mod=None):
    """
    階乗 0!, 1!, 2!, ..., max!
    :param int max:
    :param int mod:
    """
    ret = [1]
    n = 1
    if mod:
        for i in range(1, max + 1):
            n *= i
            n %= mod
            ret.append(n)
    else:
        for i in range(1, max + 1):
            n *= i
            ret.append(n)
    return ret


def mod_invs(max, mod):
    """
    逆元 0, 1/1, 1/2, 1/3, ..., 1/max
    :param int max:
    :param int mod:
    """
    invs = [1] * (max + 1)
    invs[0] = 0
    for x in range(2, max + 1):
        invs[x] = (-(mod // x) * invs[mod % x]) % mod
    return invs


def factorial_invs(max, mod):
    """
    階乗 0!, 1!, 2!, ..., max! の逆元
    :param int max:
    :param int mod:
    """
    ret = [1]
    r = 1
    for inv in mod_invs(max, mod)[1:]:
        r = r * inv % mod
        ret.append(r)
    return ret


class Combination:
    def __init__(self, max, mod):
        """
        :param int max:
        :param int mod: 3 以上の素数であること
        """
        self._factorials = get_factorials(max, mod)
        self._finvs = factorial_invs(max, mod)
        self._mod = mod

    def ncr(self, n, r):
        """
        :param int n:
        :param int r:
        :rtype: int
        """
        if n < r:
            return 0
        return self._factorials[n] * self._finvs[r] % self._mod * self._finvs[n - r] % self._mod


N, K = list(map(int, sys.stdin.buffer.readline().split()))


@lru_cache(maxsize=None)
def solve(li, k):
    li = eval(li)
    if k == 0:
        return {','.join(map(str, li))}
    ret_s = set()
    for i in range(len(li)):
        if li[i] > 0:
            for j in range(len(li)):
                if i == j:
                    continue
                cp = li[:]
                cp[i] -= 1
                cp[j] += 1
                ret_s |= solve(str(cp), k - 1)
    return ret_s


# print(solve(str([0] * N), K))

comb = Combination(N * 2 + 100, MOD)
if K >= N - 1:
    ans = comb.ncr(N * 2 - 1, N - 1)
    print(ans)
    exit()


@lru_cache(maxsize=None)
def solve2(n, k, size):
    if size == 0:
        return 0
    if k >= n - 1:
        return comb.ncr(n * 2 - 1, n - 1)
    ret = 0
    for i in range(k + 1):
        ret += solve2(n - i, k, size - 1)
    return ret


# ゼロが何個あるか
# 最大 K こ
ans = 0
for zero_cnt in range(K + 1):
    # ゼロを置く場所を選ぶ
    a = comb.ncr(N, zero_cnt)
    # ゼロ以外の場所に全部1を置く
    r = N - zero_cnt
    # r から (N - r == zero_cnt) 個選ぶ重複組合せ
    b = comb.ncr(r + zero_cnt - 1, zero_cnt)
    ans += a * b % MOD
    ans %= MOD
print(ans)


Measured memory_bytes: 79724
#include <cmath>
#include <climits>
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  int minnum = INT_MAX;
  int minus = 0;
  bool iszero = false;
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    int num;
    cin >> num;
    if (num < 0) minus++;
    if (num == 0) iszero = true;
    if (num != 0) minnum = min(abs(num), minnum);
    sum += abs(num);
  }
  if ((minus % 2 == 1) && !iszero)
    cout << sum - minnum * 2 << endl;
  else
    cout << sum << endl;
  return 0;
}

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi; typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;  typedef pair<ll, pi> plp;
typedef pair<int, pi> pip; typedef tuple<int, int, int> ti;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 432, MOD = 1e9 + 7;

int N3, N, A[MAX_N], B[MAX_N], Aix[MAX_N], Bix[MAX_N];
int C[MAX_N][MAX_N], F[MAX_N], P[MAX_N][MAX_N];
int GDy[MAX_N/3][MAX_N];
int Cnt[MAX_N/3][MAX_N][MAX_N], Union[MAX_N][MAX_N];
void add(int &a, int b) {
	if((a+=b) >= MOD) a -= MOD;
	if(a < 0) a += MOD;
}
int Func(int i, int j, int t) {
	return max(N3 - 3 * (N - t) - Union[i][j], 0);
}
int main() {
	for(int i=0, j; i<MAX_N; i++) for(C[i][0]=1, j=1; j<=i; j++) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MOD;
	F[0] = 1; for(int i=1; i<MAX_N; i++) F[i] = 1ll * F[i-1] * i % MOD;
	for(int i=0; i<MAX_N; i++) for(int j=0; j<=i; j++) P[i][j] = 1ll * C[i][j] * F[j] % MOD;

	cin >> N3;
	N = N3 / 3;
	for(int i=1; i<=N3; i++) scanf("%d", &A[i]), Aix[A[i]] = i;
	for(int i=1; i<=N3; i++) scanf("%d", &B[i]), Bix[B[i]] = i;

	//G[N];
	GDy[0][0] = 1;
	for(int i=1; i<=N; i++) for(int j=0; j<=2*(i-1); j++) for(int k=0; k<=j+2; k++)
		add(GDy[i][j+2-k], 1ll * GDy[i-1][j] * P[j+2][k] % MOD);
	int mul = GDy[N][0];

	
	for(int i=0; i<=N3; i++) for(int j=0; j<=N3; j++) Cnt[0][i][j] = 1;
	for(int i=0; i<=N3; i++) for(int j=0; j<=N3; j++) {
		if(i == 0 || j == 0) Union[i][j] = i+j;
		else Union[i][j] = Union[i][j-1] + (Aix[B[j]] <= i ? 0 : 1);
	}
	for(int t=1; t<=N; t++) for(int i=1; i<=N3; i++) for(int j=1; j<=N3; j++) {
		if(Aix[B[j]] > i && Bix[A[i]] > j)
			add(Cnt[t][i][j], 1ll * Cnt[t-1][i-1][j-1] * Func(i, j, t) % MOD);
		add(Cnt[t][i][j], Cnt[t][i][j-1]);
		add(Cnt[t][i][j], Cnt[t][i-1][j]);
		add(Cnt[t][i][j], -Cnt[t][i-1][j-1]);
	}
	printf("%lld\n", 1ll * Cnt[N][N3][N3] * mul % MOD);
	return 0;
}


Measured memory_bytes: 103424
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

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

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());

	if (a < b) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#define alphanso                  \
	ios_base::sync_with_stdio(0); \
	cin.tie(NULL)
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
int main()
{
        alphanso;
	int n, i, ans = 0;
	cin >> n;
	int v[n], c[n];
	for (i = 0; i < n; i++)
		cin >> v[i];
	for (i = 0; i < n; i++)
		cin >> c[i];
	for (i = 0; i < n; i++)
	{
		if (v[i] >= c[i])
			ans += (v[i] - c[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define PI 3.14159263

int main() {
  double R;
  cin >> R;

  cout << std::fixed << std::setprecision(4) << 2 * R * PI << endl;

  return 0;
}


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

struct Link {
    int to, from;
    ll cost;
    Link(int from_, int to_, ll cost_) {
        to = to_;
        from = from_;
        cost = cost_;
    }
};

int n, m, p;
vector<Link> links;
vector<ll> d;

void input() {
    cin >> n >> m >> p;
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        Link l(--a, --b, c-p);
        links.push_back(l);
    }
}

ll vellman_ford() {
    d = vector<ll>(n, INF);
    d[0] = 0;
    rep(i, n-1) {
        for (Link l : links) {
            if (d[l.from] != INF) d[l.to] = max(d[l.to], d[l.from] + l.cost);
        }
    }
    rep(i, n) {
        for (Link l : links) {
            if ((d[l.from] != INF) && (d[l.to] < d[l.from] + l.cost)) {
                d[l.to] = -INF;
            }
        }
    }
    if (d[n-1] == -INF) return -1;
    return max(0LL, d[n-1]);
}

int main() {
    input();
    cout << vellman_ford() << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, s, n) for(int i = s; i < n; i++)
using namespace std;

int main(void) {
    int n, m, k;
    cin >> n >> m >> k;
    int l[m], r[m], p[k], q[k];
    rep(i, m) cin >> l[i] >> r[i];
    rep(i, k) cin >> p[i] >> q[i];

    int dp[n+2][n+2];
    rep(r, n+2) rep(c, n+2) dp[r][c] = 0;


    rep(i, m) {
        int& L=l[i], R=r[i];
        dp[L][R] ++;
    }

    rep(i, n+1) reps(j, 1, n+1) dp[i][j] += dp[i][j-1];
    for(int i = n; i >= 1; i--) {
        reps(j, 1, n+1) dp[i][j] += dp[i+1][j];
    }
    // rep(i, n+1) {rep(j, n+1) cout << dp[i][j] << " "; cout << endl;}

    rep(i, k) {
        cout << dp[p[i]][q[i]] << endl;
    }

}


Measured memory_bytes: 4224