akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc161/tasks/abc161_f

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

VPL factorize(ll n) {
  VPL res;

  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;

    auto r = PL(i, 0);

    while (n % i == 0) {
      n /= i;
      r.second++;
    }

    res.push_back(r);
  }

  // sqrt(n) 以上の素因数は高々一つ
  if (n != 1) res.emplace_back(n, 1);

  return res;
}

void solve() {
  ll N;
  cin >> N;

  auto fact = factorize(N);

  ll res = 0;

  // N
  {
    VL facts(0);

    for (ll fact = 1; fact * fact <= N; ++fact) {
      unless(N % fact == 0) continue;

      if (fact != 1) facts.push_back(fact);
      if (fact != N / fact) facts.push_back(N / fact);
    }

    for (auto fact : facts) {
      ll num = N;
      while (num % fact == 0) num /= fact;
      if (num % fact == 1) ++res;
    }
  }

  // N-1
  {
    ll M = N - 1;

    for (ll fact = 1; fact * fact <= M; ++fact) {
      unless(M % fact == 0) continue;

      if (fact != 1) ++res;
      if (fact != M / fact) ++res;
    }
  }

  cout << res << "\n";
}

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
constexpr int Mbit= 49;
using path= bitset<Mbit>;
using Graph= vector<vector<int>>;
using edge= pair<int, int>;

void dfs(const Graph& gph, const map<edge, int>& ids_edge, int s, int g, int parent, int child, path* path_dfs, vector<path>* paths){
  if(g==child){
    paths->emplace_back(*path_dfs);
    return;
  }
  else{
    for(auto neighbor:gph.at(child)){
      if(neighbor != parent){
        int id_e= ids_edge.at(make_pair(child, neighbor));
        path_dfs->set(id_e);
        dfs(gph, ids_edge, s, g, child, neighbor, path_dfs, paths);
        path_dfs->reset(id_e);
      }
    }
  }
}

int main(){
  constexpr int Cmax= 20;

  int N;
  cin >> N;
  const int M= N-1;
  Graph gph(N);
  map<edge, int> ids_edge;

  int v1,v2;
  for(int j=0; j<M; j++){
    cin >> v1 >> v2;
    v1--; v2--; // 1-indexed -> 0-indexed
    gph.at(v1).emplace_back(v2);
    gph.at(v2).emplace_back(v1);
    ids_edge[make_pair(v1,v2)]= j;
    ids_edge[make_pair(v2,v1)]= j;
  }

  int C;
  cin >> C;
  vector<path> paths;
  for(int c=0; c<C; c++){
    cin >> v1 >> v2;
    v1--; v2--; // 1-indexed -> 0-indexed

    path path_empty;
    dfs(gph, ids_edge, v1, v2, -1, v1, &path_empty, &paths);
  }

  int64_t ng= 0;
  for(int tmp=1; tmp<(1<<C); tmp++){
    bitset<Cmax> activesets(tmp);

    path activeedges;
    for(int c=0; c<C; c++){
      if(activesets.test(c)){
        activeedges |= paths.at(c);
      }
    }
    int Mfree= M- activeedges.count();

    if(activesets.count()% 2== 1){ ng+= 1LL<< Mfree; }
    else                         { ng-= 1LL<< Mfree; }
  }
  int64_t ans= (1LL<< M)- ng;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=a-1;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.14159265358979323
#define sz(a) (int)((a).size())
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)


void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("in.txt","r",stdin);
   freopen("out.txt","w",stdout); 
   #endif
} 

int main(){
   Fast_IO();
   ll a,v,b,w,t;
   cin>>a>>v>>b>>w>>t;
      if((v-w)<=0) cout<<"NO";
      else{
         ll ans;
         if(abs(a-b)>=(v-w)) {
            if(abs(a-b)%(v-w)==0)ans = abs(a-b)/(v-w);
            else ans =  abs(a-b)/(v-w) +1;
         }
         else{
            ans=1;
         }
         //cout<<ans;
         if(ans<=t) cout<<"YES";
         else cout<<"NO";
      } 

}




Measured memory_bytes: 3688
# -*- coding: utf-8 -*-
#ARC081C
import copy
import sys
import math

n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

hoge.sort()

count=0
h=0
w=0
i=0
while(1):
#for i in range(0,n-1):
	if(i<n-1):
		if(hoge[n-1-i]==hoge[n-2-i]):
			if(count==0):
				h=hoge[n-1-i]
				count+=1
				i+=1
			else:
				w=hoge[n-1-i]
				break
		i+=1
	else:
		break
print(w*h)

#print(hoge)


Measured memory_bytes: 15148
n = int(input())
dic = [[x for x in input().split()] for i in range(n)]

for i in range(n):
    dic[i][1] = int(dic[i][1])
    dic[i].append(i + 1)

dic.sort(key= lambda x: x[1], reverse= True)
dic.sort(key= lambda x: x[0])

for i in range(n):
    print(dic[i][2])

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

vector<vector<pair<int, int>>> G;
vector<int> ans;

void dfs(int now, int pre, int color) {
  ans.at(now) = color;
  for (auto g : G.at(now)) if (g.first != pre) dfs(g.first, now, color ^ (g.second & 1));
}

int main() {
  int N;
  cin >> N;
  G.resize(N), ans.resize(N);
  for (int u, v, w; cin >> u >> v >> w;) G.at(--u).push_back({--v, w}), G.at(v).push_back({u, w});
  dfs(0, -1, 0);
  for (auto a : ans) cout << a << "\n";
}

Measured memory_bytes: 8192
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
const int maxn=1e5+7;
const ll modn=1e9+7;
const int inf=2e9+7;
const double PI = acos(-1.0);
const double eps=1e-8;
inline int lowbit(int x){return x&-x;}
inline ll lowbit(ll x) {return x&-x;}
inline int CountOneBinary(ll num){int ans=0;while(num){if(num&1) ans+=1;num>>=1;}return ans;}
inline void read(int &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline void read(ll &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline ll qpow(ll x,ll y){ll ans=1;while(y){if(y&1) ans=ans*x%modn;x=x*x%modn;y>>=1;}return ans;}
inline double qpow(double x,ll y){double ans=1;while(y){if(y&1) ans=ans*x;x=x*x;y>>=1;}return ans;}
char s[maxn];
int main()
{
    while(scanf("%s",s)!=EOF)
    {
        int n=strlen(s);
        bool flag=0;
        if(s[n-1]=='1'||s[0]=='0')
        {
            puts("-1");
            continue;
        }
        for(int i=0;i<n-1;i++)
        {
            int j=n-2-i;
            if(s[i]!=s[j])
            {
                flag=1;
                break;
            }
        }
        if(flag)
        {
            puts("-1");
            continue;
        }
        int from=1,to=2;
        for(int i=0;i<n-1;i++,to++)
        {
            printf("%d %d\n",from,to);
            if(s[i]=='1') from=to;
        }
    }
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0]) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <numeric>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <tuple>

using namespace std;

//#define int long long

#define rep(i,n) for(int i = 0; i<n ; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)
#define REPSTR(i,s) for(int i=0; (s)[i]; i++)
#define REPITR(i,s) for(auto i=(s).begin(); i!=(s).end();i++)

#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))

#define pb push_back
#define mp make_pair

#define ALL(a) begin(a), end(a)

#define EXIST(s,x) ((s).find(x)!=(s).end())

#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))

#ifdef _DEBUG
#define DEBUG(x) cerr<<#x<<":"<<x<<endl
#else
#define DEBUG(x)
#endif

#define PRINTJOIN(x,n) rep(i,n){if(i)cout<<" ";cout<<x[i];}cout<<endl 
#ifdef int
#define INF 1001001001001001001LL
#else
#define INF 1001001001
#endif

typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef stringstream SS;

#define PQ priority_queue

#define FST first
#define SEC second

int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

template <typename T>
struct Point {
    T x;
    T y;
    Point(){}
    Point(T x, T y): x(x), y(y){}
    T operator ^ (Point const& p) {
        return this->x*p.y-this->y*p.x; 
    }
    Point operator + (Point const& p) {
        return Point(this->x+p.x, this->y+p.y);
    }
    Point operator - (Point const& p) {
        return Point(this->x-p.x, this->y-p.y);
    }
    friend istream & operator >> (istream & stream, Point<T>& p) {
        return stream >> p.x >> p.y;
    }
};



const double eps = 1e-10;
signed main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n; cin>>n;
    rep(i,n){
    Point<double> p1, p2, p3, p4;
    cin>>p1>>p2>>p3>>p4;
    cout<<(abs((p2-p1)^(p4-p3))<eps? "YES":"NO")<<endl;
    }

	return 0;
}


Measured memory_bytes: 3232
n = gets.to_i
s = gets.chomp
count_arr = []

n.times do |i|
  count = 0
  x_new = ''
  x = s[0..i].squeeze
  y = s[i+1..n-1].squeeze
  x.length.times do |j|
    next if x_new.include?(x[j])
    if y.include?(x[j])
      count += 1
    end
    x_new += x[j]
  end
  count_arr << count
end

puts count_arr.max

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int H,W,N;
int x,y;
string S,T;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>H>>W>>N;
    cin>>x>>y;
    x--; y--;
    cin>>S>>T;
    int r=W-y,l=y+1, u=x+1, d=H-x;
    bool t=false;
    int res=0;
    rep(i,0,N){
        if(S[i]=='R'){
            res++;
            if(res==r){
                t=true;
                break;
            }
        }
        if(T[i]=='L'){
            res--;
            if(res==-l) res++;
        }
    }
    res=0;
    rep(i,0,N){
        if(S[i]=='L'){
            res++;
            if(res==l){
                t=true;
                break;
            }
        }
        if(T[i]=='R'){
            res--;
            if(res==-r) res++;
        }
    }
    res=0;
    rep(i,0,N){
        if(S[i]=='U'){
            res++;
            if(res==u){
                t=true;
                break;
            }
        }
        if(T[i]=='D'){
            res--;
            if(res==-d) res++;
        }
    }
    res=0;
    rep(i,0,N){
        if(S[i]=='D'){
            res++;
            if(res==d){
                t=true;
                break;
            }
        }
        if(T[i]=='U'){
            res--;
            if(res==-u) res++;
        }
    }
    cout << (t?"NO":"YES")<<"\n";
}

Measured memory_bytes: 920
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }


int main() {
	string s;
	cin >> s;
	int cnt = 0;
	REP(i, 15) {
		if (s[i] == 'x')cnt++;
	}
	if (cnt <= 7) {
		put("YES");
	}
	else {
		put("NO");
	}
	return 0;
}



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

#define printl(s) cout << s << endl;
#define print(s) cout << s << endl; return 0;
#define yes cout << "Yes" << endl; return 0;
#define no cout << "No" << endl; return 0;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n)+1; ++i)
using ll = long long;

const ll modseed = pow(10,9) + 7;

template <typename T>
vector<T> getValues(ll num){
    vector<T> values(num);
    for(ll i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

string S;
int A,B,C,K,N, cnt;

int main(){
  cin >> A >> B >> K;
  stack<int> s;
  rep2(i,min(A,B)){
    if(A%i==0 && B%i==0){
      s.push(i);
    }
  }
  rep(i,K-1){
    s.pop();
  }
  print(s.top());
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int a,b;
    cin >> a >> b;
    if((a+b)%2==1 ){cout<<"IMPOSSIBLE"<<endl; return 0;}
    cout << (a+b)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
ll A, B, C, X, Y;

//解法
void solve() {

	C *= 2;

	ll ans1 = max(X, Y)*C;
	ll ans2 = X*A + Y*B;

	ll ans3=min(X,Y)*C;
	if (X > Y) {
		ans3 += (X - Y)*A;
	}
	else {
		ans3 += (Y - X)*B;
	}

	cout << min(min(ans1, ans2), ans3);

	return;
}

int main() {
	//入力
	cin >> A >> B >> C >> X >> Y;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    int a[n];
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]%2==0)   cnt++;
    }
    int res = pow(3,n);
    if(cnt==0)  cout<<res-1<<endl;
    else{
        int all_odd = pow(2,cnt);
        cout<<res-all_odd<<endl;
    }

    return 0;
}



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

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

using namespace std;

typedef long long ll;

int n;
vector<string> s;

ll dfs(int x,int y) {
  if( '0' <= s[y][x] && s[y][x] <= '9' ) {
    return (ll)(s[y][x]-'0');
  }
  assert( s[y][x] == '*' || s[y][x] == '+' );
  char op = s[y][x];
  ll ret = ( (op=='*') ? 1 : 0 );
  ++y, ++x;
  while( y < n && x < (int)s[y].size() ) {
    if( '0' <= s[y][x] && s[y][x] <= '9' ) {
      if( op == '*' ) ret *= (ll)(s[y][x]-'0');
      else            ret += (ll)(s[y][x]-'0');
      ++y;
    } else {
      if( op == '*' ) ret *= dfs(x,y);
      else            ret += dfs(x,y);
      ++y;
      while( y < n && x < (int)s[y].size() && s[y][x] == '.' ) ++y;
    }
  }
  return ret;
}

int main() {
  while( cin >> n,n ) {
    s.clear();
    s.resize(n);
    rep(i,n) cin >> s[i];
    cout << dfs(0,0) << endl;
  }
  return 0;
}

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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;

  // 1の個数-0の個数-1の個数-...-0の個数 的な配列が欲しい
  vector<int> Nums;
  int now = 1;
  int cnt = 0;
  for (int i=0; i<N; i++) {
    if(S[i]==(char)('0'+now)) cnt++;
    else {
      Nums.push_back(cnt); //cntをNumsの末尾に追加
      now = 1 - now; // 1と0の切り替え
      cnt = 1;
    }
  }
  if (cnt != 0) Nums.push_back(cnt); //最後もpush back
  if (Nums.size() % 2 == 0) Nums.push_back(0); // 偶数個で終わらせる
  
  // 累積和
  vector<int> sum(Nums.size()+1);
  for (int i=0; i<Nums.size(); i++) {
    sum[i+1] = sum[i] + Nums[i];
  }
  
  int Add = 2 * K + 1; //何個足したら答えになるか
  int ans = 0;
  // 偶数番目だけ見る
  for (int i=0; i<Nums.size(); i += 2) {
    // [left, right)
    int left = i;
    int right = min(i+Add, (int)Nums.size());
    int tmp = sum[right] - sum[left];
    
    ans = max(tmp, ans);
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 1272
import Data.List(sort)

main :: IO ()
main = myPrint . map (sort . map read . words) . lines =<< getContents

myPrint :: [[Int]] -> IO ()
myPrint [[0, 0]] = return ()
myPrint [] = return ()
myPrint (x:xs) = do
    putStrLn . unwords . map show $ x
    myPrint xs

Measured memory_bytes: 4520
#include<stdio.h>

int main (void){

  int b1,b2,b3,ans;
  
  scanf("%d",&b1);
  scanf("%d",&b2);
  scanf("%d",&b3);
  
  ans = b1*1+b2*10+b3*100;
  if(ans > 10){
  printf("Open\n");
}else{
  printf("Close\n");
}
  return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;


    vector<vector<int>> G(n);
    vector<int> deg(n, 0);
    for (int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        deg[v] += 1;
    }

    queue<int> q;
    for (int i = 0; i < n; i++){
        if (deg[i] == 0)
            q.push(i);
    }
    
    vector<int> dp(n, 0);
    while (!q.empty()){
        auto u = q.front(); q.pop();
        for (auto v: G[u]){
            deg[v] -= 1;
            dp[v] = max(dp[v], dp[u] + 1);

            if (deg[v] == 0)
                q.push(v);
        }
    }

    cout << *max_element(dp.begin(), dp.end()) << '\n';

    return 0;
}


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


/**
 * @brief Union Find class.
 * 
 * @details "Path compression" and "Union by rank" are used.
 * @see <https://en.wikipedia.org/wiki/Disjoint-set_data_structure>
 */
class UnionFind {
    public:
        /**
         * @brief Construct a new Union Find object.
         * 
         * @param N Number of node.
         */
        UnionFind(int N) {
            _N = N;
            _make_set();
        }

        int find(int x) {
            if (_parent[x] != x) {
                _parent[x] = find(_parent[x]);
            }
            return _parent[x];
        }

        void unite(int x, int y) {
            int x_root = find(x);
            int y_root = find(y);

            if (x_root == y_root) return;

            int x_rank = _rank[x_root];
            int y_rank = _rank[y_root];
            if (x_rank > y_rank) {
                _parent[y_root] = x_root;
                _size[x_root] += _size[y_root];
            } else if (x_rank < y_rank) {
                _parent[x_root] = y_root;
                _size[y_root] += _size[x_root];
            } else {
                _parent[y_root] = x_root;
                _rank[x_root] += 1;
                _size[x_root] += _size[y_root];
            }
        }

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

        int size(int x) { return _size[find(x)]; }


    private:
        int _N;
        vector<int> _parent, _rank, _size;

        void _make_set() {
            _parent = vector<int>(_N + 1);
            iota(_parent.begin(), _parent.end(), 0);
            _rank = vector<int>(_N + 1, 0);
            _size = vector<int>(_N + 1, 1);
        }

};


int main() {
    int N, M;
    cin >> N >> M;

    auto uf = UnionFind(N);

    int A, B;

    rep(_, M) {
        cin >> A >> B;
        uf.unite(A, B);
    }

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5628
#include <iostream>
using namespace std;
//関数の定義　戻り値の型　関数(引数リスト){}
bool f(int x){
  int keta =0;
  while(x != 0){ //int xが0じゃない間は行われるということ
    keta++;
    x /= 10;
  }
  return keta%2 ==1; //ketaの2で割った余りが1なら真として戻り値1を返す
}

int main(){
  int N;
  cin >> N;
  int ans = 0;
  //答えをカウントするans
  for(int i=1;i<=N;i++){
    if(f(i)){ //f(i)が真(1)の間はans++でカウントするということ
      ans++;
      //桁数が奇数かどうかの関数を作り、そうならカウントする
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
using namespace std;
struct po{
  int job,kai;
};
vector <po> ls[10001];
int cost[101][10001];
int main() {

  int n,m;
  cin >> n >> m;

  while(1) {
    int s,t,e;
    cin >> s >> t >> e;
    if(s == 0 && t == 0 && e == 0) break;
    po tmp;
    tmp.job = t;
    tmp.kai = e;
    ls[s].push_back(tmp);
  }

  int L;
  cin >> L;

  for(int i=1;i<=L;i++) 
    for(int j=1;j<=m;j++)
      cin >> cost[i][j];

  for(int i=1;i<=L;i++) {
    for(int j=1;j<=n;j++) {
      int a = 0;
      for(int k=0;k<ls[j].size();k++){
	//	cout <<a << "+"<< ls[j][k].kai <<"*"<<cost[i][ls[j][k].job] << endl;
	a = a + ls[j][k].kai*cost[i][ls[j][k].job];
      }
      cout << a ;
      if(j != n) cout << " ";
    }
    cout << endl;
  }

  return 0;

}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define vc vector<int>
#define um unordered_map<int,int>
#define ll long long 
#define rep(i,a,b) for(__typeof(a) i=a; i<b; i++)
#define si(a) a.size()
#define all(a) a.begin(),a.end()
#define ss(a) a.second
#define ff(a) a.first
#define M 1000000
#define pb push_back
#define repit(i,a) for(auto i=a.begin(); i!=a.end(); i++)
#define take(arr,n) for(int i=0;i<n;i++)cin>>arr[i]
#define out(arr,n) for(int i=0;i<n;i++)cout<<arr[i]<<' '
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define reprev(i,b,a) for(__typeof(b) i=b; i>=a; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define doublearray vector<vector<int>>
using namespace std;
ll max(ll a, ll b){ return a>b?a:b; }
ll min(ll a, ll b){ return a<b?a:b; }
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
int main(){
    int n; cin>>n;
    string s; cin>>s;
    int r = count(all(s),'R'), w = count(all(s),'W'), ans=0;
    rep(i,0,r){
        if(s[i]=='W') ans++;
    }
    cout<<ans<<endl;
}






Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
struct EDGE
{
	int x,y,data;
}edge[2*100000+10];
struct node
{
	int x,y,id;
}arr[100000+10];
int fa[100500];
int find(int x)
{
	if(x==fa[x]) return fa[x];
	return fa[x] = find(fa[x]);
}
bool cmp1(node a,node b)
{
	return a.x<b.x;
}
bool cmp2(node a,node b)
{
	return a.y<b.y;
}
bool cmp(EDGE a,EDGE b)
{
	return a.data<b.data;
}
int cnt = 0;
void built(int x,int y,int data)
{
	edge[++cnt].x=x;
	edge[cnt].y=y;
	edge[cnt].data=data;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		fa[i]=i;
		scanf("%d%d",&arr[i].x,&arr[i].y);
		arr[i].id = i;
	}
	sort(arr+1,arr+1+n,cmp1);
	for(int i=2;i<=n;i++)
	built(arr[i-1].id,arr[i].id,arr[i].x-arr[i-1].x);
	sort(arr+1,arr+1+n,cmp2);
	for(int i=2;i<=n;i++)
	built(arr[i-1].id,arr[i].id,arr[i].y-arr[i-1].y);
	long long res = 0;
	sort(edge+1,edge+1+cnt,cmp);
	for(int i=1;i<=cnt;i++)
	if(find(edge[i].x)!=find(edge[i].y))
	{
		res += edge[i].data;
		fa[fa[edge[i].x]] = fa[edge[i].y];
	}
	printf("%d\n",res);
	return 0;
}


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

using namespace std;

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

char cells[100][100];
int visited[100][100][4];
int visitt[100][100][4];
int visitbef[100][100][2];
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
char d[4]={'N','E','S','W'};

int main(){
  while(1){
    int posx,posy,befx,befy,dir;
    int h,w,walk=0,flag=0;
    long long l;
    cin >> h >> w >> l;
    if (h==0)break;
    rep(i,h){
      string s;
      cin >> s;
      rep(j,w){
        cells[i][j] = s[j];
        if (s[j]!='.'&&s[j]!='#'){
          posx = i;
          posy = j;
          if (s[j]=='N'){
            dir = 0;
          } else if (s[j]=='E'){
            dir = 1;
          } else if (s[j]=='S'){
            dir = 2;
          } else {
            dir = 3;
          }
        }
      }
    }
    rep(i,h)rep(j,w)rep(k,4){visited[i][j][k]=0;visitt[i][j][k]=-1;}
    visited[posx][posy][dir]=1;
    visitt[posx][posy][dir]=0;
    while(l>0){
      if (posx+dx[dir]>=0&&posx+dx[dir]<h&&posy+dy[dir]>=0&&posy+dy[dir]<w){
        if (cells[posx+dx[dir]][posy+dy[dir]]!='#'){
          befx = posx;
          befy = posy;
          posx += dx[dir];
          posy += dy[dir];
          cells[posx][posy]='@';
          if (visited[posx][posy][dir]==0){
            l--;
            walk++;
            visited[posx][posy][dir]=1;
            visitt[posx][posy][dir]=walk;
            visitbef[posx][posy][0] = befx;
            visitbef[posx][posy][1] = befy;
          } else if (flag==0&&visitbef[posx][posy][0]==befx&&visitbef[posx][posy][1]==befy){
            l = l%(walk-visitt[posx][posy][dir]+1)-1+(walk-visitt[posx][posy][dir]+1);
            flag=1;
          } else if (flag==0){
            l--;
            walk++;
            visitt[posx][posy][dir]=walk;
          } else {
            l--;
          }
        } else {
          dir++;
          if (dir==4)dir=0;
          if (visited[posx][posy][dir]==0){
            visited[posx][posy][dir]=1;
            visitt[posx][posy][dir]=walk;
          } else if(flag==0&&visitbef[posx][posy][0]==befx&&visitbef[posx][posy][1]==befy&&cells[posx+dx[dir-1]][posy+dy[dir-1]]!='#'&&posx+dx[dir-1]>=0&&posx+dx[dir-1]<h&&posy+dy[dir-1]>=0&&posy+dy[dir-1]<w){
            l = l%(walk-visitt[posx][posy][dir]);
            flag = 1;
          }
        }
      } else {
        dir++;
        if (dir==4)dir=0;
        if (visited[posx][posy][dir]==0){
          visited[posx][posy][dir]=1;
          visitt[posx][posy][dir]=walk;
        } else if (flag==0&&visitbef[posx][posy][0]==befx&&visitbef[posx][posy][1]==befy&&cells[posx+dx[dir-1]][posy+dy[dir-1]]!='#'&&posx+dx[dir-1]>=0&&posx+dx[dir-1]<h&&posy+dy[dir-1]>=0&&posy+dy[dir-1]<w) {
          l = l%(walk-visitt[posx][posy][dir])+(walk-visitt[posx][posy][dir]);
          flag = 1;
        }
      }
    }
    cout << posx+1 << " " << posy+1 << " " << d[dir]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3472
H, W = map(int, input().split())
field = [input() for _ in range(H)]

# Left
Left = [[0] * W for _ in range(H)]
for h in range(H):
    cnt = 0
    for w in range(W):
        if field[h][w] == '#':
            cnt = 0
        else:
            cnt += 1
        Left[h][w] = cnt

# Right
Right = [[0] * W for _ in range(H)]
for h in range(H):
    cnt = 0
    for w in range(W-1, -1, -1):
        if field[h][w] == '#':
            cnt = 0
        else:
            cnt += 1
        Right[h][w] = cnt

# Up
Up = [[0] * W for _ in range(H)]
for w in range(W):
    cnt = 0
    for h in range(H):
        if field[h][w] == '#':
            cnt = 0
        else:
            cnt += 1
        Up[h][w] = cnt

# Down
Down = [[0] * W for _ in range(H)]
for w in range(W):
    cnt = 0
    for h in range(H-1, -1, -1):
        if field[h][w] == '#':
            cnt = 0
        else:
            cnt += 1
        Down[h][w] = cnt

# 集計
ans = -1
for h in range(H):
    for w in range(W):
        ans = max(ans, Left[h][w] + Right[h][w] + Up[h][w] + Down[h][w] - 3)
print(ans)



Measured memory_bytes: 179076
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val left = s.indexOf("C")
    val right = s.lastIndexOf("F")
    if (left != -1 && right != -1 && left < right) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 29484
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int tmp = a + b+c;
        int max = Math.max(a, Math.max(b,c));
        if ((tmp % 2 == 0 && max % 2 == 0) || (tmp % 2 != 0 && max % 2 != 0) ) {
            System.out.println((3 * max - tmp) / 2);
        } else  {
            int diff = (3 * (max+1) - tmp)/2;
            System.out.println(diff);
        }
    }
}


Measured memory_bytes: 35624
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef double f32;
typedef long long i64;
const int N = 1e5+5;
int n, k, p[N], a[N], b[N]; i64 S, T, A, B; pii v[N];
int main()
{
    scanf("%d", &n), A = B = 1; for(int i = 1; i <= n; ++i) scanf("%d%d", a+i, b+i), S += a[i], v[i] = pii(max(a[i], b[i]), b[i]);
    sort(v+1, v+n+1, greater<pii>());
    for(k = 1; k <= n; ++k) if((T += v[k].fi) >= S) break;
    for(int i = 1; i <= n; ++i)
    {
        i64 R = S-(T-v[min(i, k)].fi);
        if(R <= v[i].se&&(f32)R/v[i].se < (f32)A/B) A = R, B = v[i].se;
    }
    A = B-A+(n-k)*B, B *= n, printf("%lld %lld\n", A/__gcd(A, B), B/__gcd(A, B));
    return 0;
}

Measured memory_bytes: 5384
#include <stdio.h>

int main()
{ int n,i;
    scanf("%d",&n);
    char name[n];

    scanf("%s", name);
    int count=0;
    if(n%2==0)
    {
    for(i=0; i<n/2;i++){
        if(name[i]!=name[n/2+i]){
            count++;
        }
    }
    if(count==0)
        printf("Yes");
    else
        printf("No");
    }
    else printf("No");
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func max(a, b int64) int64 {
	if a > b {
		return a
	} else {
		return b
	}
}

var n int
var d int
var b [20][200001] /*height*/ int64
var h [200000] /*k, i*/ int
var a [200000] /*i*/ int64

func updateBeauty(i int, bb int64) {
	for k := 0; k <= d; k++ {
		b[k][i] = max(b[k][i], bb)
		i >>= 1
	}
}

// func maxBeauty2(i, k, s, e int) int64 {
// 	if i < s {
// 		// fmt.Printf("maxBeauty2(%d, %d, %d, %d) => %d\n", i, k, s, e, 0)
// 		return 0
// 	} else {
// 		if k == 0 {
// 			// fmt.Printf("maxBeauty2(%d, %d, %d, %d) => %d\n", i, k, s, e, b[0][s])
// 			return b[0][s]
// 		} else {
// 			if i >= e {
// 				// fmt.Printf("maxBeauty2(%d, %d, %d, %d) => %d\n", i, k, s, e, b[k][s>>uint(k)])
// 				return b[k][s>>uint(k)]
// 			} else {
// 				return max(maxBeauty2(i, k-1, s, (s+e)/2), maxBeauty2(i, k-1, (s+e)/2, e))
// 			}
// 		}
// 	}
// }

// func maxBeauty(i int) int64 {
// 	return maxBeauty2(i, d, 0, 1<<uint(d))
// }

func maxBeauty(i int) int64 {
	result := int64(0)
	mask := 1 << uint(d)
	base := 0
	for k := d; k >= 0; k-- {
		if i&mask > 0 {
			result = max(result, b[k][base])
			base++
		}
		base <<= 1
		mask >>= 1
	}
	return result
}

func parseInt(s string) int64 {
	x, _ := strconv.ParseInt(s, 10, 64)
	return x
}

func readLine(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	return strings.TrimSuffix(s, "\n")
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	n = int(parseInt(readLine(reader)))
	for i, token := range strings.Fields(readLine(reader)) {
		h[i] = int(parseInt(token))
	}
	for i, token := range strings.Fields(readLine(reader)) {
		a[i] = parseInt(token)
	}
	for d = 1; 1<<uint(d) <= n; d++ {
	}

	for i := 0; i < n; i++ {
		bb := maxBeauty(h[i])
		// fmt.Printf("maxBeauty(%d) => %d\n", h[i], bb)
		updateBeauty(h[i], bb+a[i])

		for j := 0; j <= d; j++ {
			// fmt.Println(b[j][:1<<uint(d-j)])
		}
	}

	fmt.Println(b[d][0])
}


Measured memory_bytes: 43776
def f(n):
    # 縦線n本で構成できる横線の組み合わせ
    if n <= 1: return 1
    return f(n - 1) + f(n - 2)


MOD = 10 ** 9 + 7

H, W, K = map(int, input().split())
K -= 1
# 0-indexed

dp = [[0 for _ in range(W)] for _ in range(H + 1)]
dp[0][0] = 1
# dp[h][k]
# h段のあみだくじで横線kに到達する本数

for h in range(H):
    # h: 移動前の高さ
    for i in range(W):
        # i: 移動前の縦線
        if i >= 1:
            dp[h + 1][i - 1] += dp[h][i] * f(i - 1) * f(W - 1 - i)
            dp[h + 1][i - 1] %= MOD
        dp[h + 1][i] += dp[h][i] * f(i) * f(W - 1 - i)
        dp[h + 1][i] %= MOD
        if i < W - 1:
            dp[h + 1][i + 1] += dp[h][i] * f(i) * f(W - 2 - i)
            dp[h + 1][i + 1] %= MOD

print(dp[H][K])


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

char conv[40] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

string solve(int n, int m, int q,
             vector<string>& vs,
             vector<string>& vb) {
    string s = "";

    for (int i = 0; i < m; ++i) {
        vector<int> cand;
        for (int j = 0; j < n; ++j) {
            bool flg = (vs[0][j] == vb[0][i]);
            for (int k = 1; flg && k < q; ++k) {
                if(vs[k][j] == '1' && (vb[k][i] == vb[k - 1][i])) {
                    flg = false;
                }
                if(vs[k][j] == '0' && (vb[k][i] != vb[k - 1][i])) {
                    flg = false;
                }
            }

            if (flg) {
                cand.push_back(j);
            }
        }

        s += (cand.size() == 1 ? conv[cand[0]] : '?');
    }
    
    return s;
}

int main() {
    int n, m, q;
    vector<string> vs;
    vector<string> vb;
    while (true) {
        cin >> n >> m >> q;
        if(n == 0 && m == 0 && q == 0) {
            break;
        }
        vs.resize(q);
        vb.resize(q);
        for (int j = 0; j < q; ++j) {
            cin >> vs[j] >> vb[j];
        }
        cout << solve(n, m, q, vs, vb) << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef int ii;
//typedef vector<ll> vi;

#define INF 1000000007

#define pi 3.141592654

#define T while(t--)
#define for2(i,a,b) for(i=a;i>=b;i--)
#define for3(i,a,b) for(i=a;i<=b;i=i+2)
#define for1(i,a,b) for(i=a;i<=b;i++)
#define pb push_back
#define mp make_pair

#include<sstream>

#define si set<ll>
#define se multiset<ll>

typedef long double ld;

typedef vector<ll> vi;

#define bb(arr,nn,xx) upper_bound(arr,arr+nn,xx)-arr
#define aa(arra,nna,xxa) lower_bound(arra,arra+nna,xxa)-arra

#define all(v) sort(v.begin(),v.end())
 
#define all1(v) sort(v.rbegin(),v.rend())

ii main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);

    string s; cin>>s;
    
    ll p=s.length();
    
    if(s[p-1]=='s') s=s+"es";
    
    else s=s+"s";
    
    cout<<s<<"\n";
    
}


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

int main() {
  FAST;
  uint64_t N, K, S;
  cin >> N >> K >> S;
  vector<uint64_t> A(N);
  uint64_t maxS = pow(10, 9);
  if (S < maxS) {
    for (uint64_t i = 0; i < K; i++) {
      A.at(i) = S;
    }
    for (uint64_t i = K; i < N; i++) {
      A.at(i) = S + 1;
    }
  }
  else {
    for (uint64_t i = 0; i < K; i++) {
      A.at(i) = maxS;
    }
    for (uint64_t i = K; i < N; i++) {
      A.at(i) = 1;
    }
  }
  for (uint64_t i = 0; i < N - 1; i++) {
    cout << A.at(i) << " ";
  }
  cout << A.at(N - 1) << endl;
}

Measured memory_bytes: 2176
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1e+10
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0; i<n; i++)

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vii;
typedef pair<int,ll> pii;

int main() {
  int n;
  while (1) {
    cin >> n;
    if (n == 0) {
      break;
    }
    vi data(n);
    rep(i, n) {
      cin >> data[i];
    }
    sort(data.begin(), data.end());
    ll closest = INF;
    rep(i, n-1) {
      closest = min(closest, data[i+1] - data[i]);
    }
    cout << closest << endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

//ただし、左端のマスには必ず R、右端のマスには必ず L が書かれています。
string s;
int main() {
    cin>>s;
    vi ans(s.size());
    fill(ALL(ans),0);

    int lastl = 0;
    REP(i,s.size()-1){
        if(s.substr(i,2)=="RL"){
            int j = i; 
            int cnt = 0;
            while(j >= 0){
                if(s[j]=='L') break;

                if(cnt%2==0)
                    ans[i]++;
                else
                    ans[i+1]++;
                
                cnt++;
                j--;
            }

            j=i+1;
            cnt=0;
            
            while(j < s.size()){
                if(s[j]=='R') break;

                if(cnt%2==0)
                    ans[i+1]++;
                else
                    ans[i]++;
                
                cnt++;
                j++;
            }

            i = j-1;
        }
    }

    REP(i,ans.size()-1)
        cout << ans[i] << " ";

    cout << ans[ans.size()-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
long long a,b,uf;
inline long long gcd(long long a,long long b)
{
	if(a==0)return b;
	else return gcd(b%a,a);
}
inline long long solve(long long p){return p-(p/a+p/b-p/uf);}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    long long l,r;
    scanf("%lld%lld%lld%lld",&l,&r,&a,&b);uf=a/gcd(a,b)*b;
    printf("%lld\n",solve(r)-solve(l-1));
   	return 0;
}

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

int main(void){
	int a;
	int b;
	int c;
	scanf("%d %d %d", &a, &b, &c);
	if( a < b && a < c){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll t[1003] = {}, a[1003] = {};
    cin >> n;
    for (int i = 0; i < n; i++) cin >> t[i] >> a[i];
    for (int i = 1; i < n; i++) {
        ll b = max((t[i - 1] - 1) / t[i], (a[i - 1] - 1) / a[i]) + 1;
        t[i] *= b; a[i] *= b;
    }
    cout << t[n - 1] + a[n - 1];
}


Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	int n,k;
	cin>>n>>k;
	int a[k];

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

	sort(a,a+k);
	std::vector<int> v;
	for(int i=1;i<k;i++){
		v.push_back(a[i]-a[i-1]);
	}
	sort(v.begin(),v.end());
	ll sum = 0;
	for(int i=(v.size() - n);i>=0;i--){
		//cout<<v[i]<<" ";
		sum += (ll)v[i];
	}//cout<<endl;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 4308
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {  
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		//O.pln(Math.log(1000000000));
		int N = I.nextInt();
		int K = I.nextInt();
		long[] a = new long[N+1];
		for (int i = 1; i <= N; i++) a[i] = I.nextLong();
		for (int i = K+1; i <= N; i++) {
			O.pln(a[i]>a[i-K]?"Yes":"No");
		}
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "YES";
const string NO = "NO";

int main(){
    int n, m;
    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];
    cin >> m;
    vi t(m);
    rep(i, m) cin >> t[i];
    map<int, int> cntd, cntt;
    rep(i, n) cntd[d[i]]++;
    rep(i, m) cntt[t[i]]++;
    bool ans = true;
    for (auto p : cntt) {
        int f = p.first, s = p.second;
        if (cntd[f] < s) ans = false;
    }
    if (ans) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


Measured memory_bytes: 23500
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int ans=(b+c)-a;
	if(ans<0)
		ans=0;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,k;
  double ans=0;
  
  int N;
  scanf("%d",&N);
  double A[N];
  char B[N][10];
  for(i=0;i<N;i++){
    scanf("%lf %s",&A[i],B[i]);
    if(B[i][0] == 'J'){
      ans += A[i];
    }
    else
      ans += A[i] *380000;
    
  }
  
  printf("%f\n",ans);
  return 0;
}
  

Measured memory_bytes: 128
def ini(): return int(input())
def inli(): return list(map(int, input().split()))
def inf(): return float(input())
def inlf(): return list(map(float, input().split()))
def inl(): return list(input())
def pli(): return "".join(list(map(str, ans)))

n = ini()
ans= 0
for i in range(n+1):
    ans = ans +i
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;


int main() {
    ll N, sum = 0, ans = 0;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++){
        cin >> A.at(i);
        sum += A.at(i);
    }
    for (int i = 0; i < N; i++){
        sum -= A.at(i);
        ans += (sum % 1000000007) * A.at(i);
        ans %= 1000000007;
    }
    cout << ans << endl;
}

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

class Main {
	
	public static void main(String[] args) throws IOException {

		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));

		ArrayList<String> ans = new ArrayList<String>();
		
		String[] msg = {"light fly","fly","bantam","feather","light","light welter",
						"welter","light middle","middle","light heavy"};
		double[] w = {48,51,54,57,60,64,69,75,81,91};
		
		while (true) {
			
			String s = br.readLine();
			if (s == null) break;
			
			double weight = Double.parseDouble(s);
			for (int i = 0; i < w.length; i++) {
				if (weight <= w[i]) {
					ans.add(msg[i]);
					break;
				}
				if (i == w.length - 1) {
					ans.add("heavy");
				}
			}
			
		}
		
		for (String a : ans)
			System.out.println(a);

	}

}

Measured memory_bytes: 9104