akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 50000 + 10;
const double pi = acos(-1.0);
const double inf = 1e100;
const double eps = 1e-12;

typedef struct point vec;  //向量vec
struct point {    //点的基本数据结构
    double x, y;
    point(double _x=0, double _y=0):
    x(_x),y(_y)
    {
    }
    point operator*(const point& i_T) const
    {
        return point(x * i_T.x, y * i_T.y);
    }
    point operator*(double u) const
    {
        return point(x * u, y * u);
    }
    bool operator==(const point& i_T) const
    {
        return x == i_T.x && y == i_T.y;
    }
    point operator/(double u) const
    {
        return point(x / u, y / u);
    }
    point operator+(const point& i_T)
    {
        return point(x + i_T.x, y + i_T.y);
    }
    point operator-(const point& i_T)
    {
        return point(x - i_T.x, y - i_T.y);
    }
    friend bool operator<(point a, point b)
    {
        return a.y == b.y ? a.x < b.x : a.y < b.y;
    }
    friend ostream& operator<<(ostream& out, point& a)
    {
        //cout << a.x << ' ' << a.y;
        printf("%.8f %.8f", a.x+eps, a.y+eps);
        return out;
    }
    friend istream& operator>>(istream& in, point& a)
    {
        in >> a.x >> a.y;
        return in;
    }
};
struct cirles {
    vec o;
    double r;
    friend istream& operator>>(istream& in, cirles& a)
    {
        in >> a.o >> a.r;
        return in;
    }
    friend ostream& operator<<(ostream& out, cirles& a)
    {
        out << a.o << ' ' << a.r;
        return out;
    }
};
double changdu(vec a) //向量长度
{
    return sqrt(a.x * a.x + a.y * a.y);
}
vec xiangliang_xuanzhuan(vec a,double pi) //将向量按照起点旋转逆时针pi,
{
    double x,y;
    x=cos(pi)*a.x-sin(pi)*a.y; 
    y=sin(pi)*a.x+cos(pi)*a.y;
    return vec(x,y);
}
pair<point,point>guodian_yuan_qiedian(cirles a,point p)
{
    double l=changdu(a.o-p);
    double t=asin(a.r/l);
    double lb=l*cos(t);
    vec x=a.o-p;
    x=x/l*lb;
    return make_pair(p+xiangliang_xuanzhuan(x,t),p+xiangliang_xuanzhuan(x,-t));
}
int dayu_dengyu(double x, double y)
{
    if (fabs(x - y) < eps || x > y)
        return 1;
    return 0;
}
int main()
{
    //freopen("txt.txt", "w", stdout);
    cirles a;
    point p;
    cin>>p>>a;
    pair<point,point>q=guodian_yuan_qiedian(a,p);
    if (fabs(q.first.x - q.second.x) < eps) {
        if (dayu_dengyu(q.first.y, q.second.y))
            cout << q.second << '\n' << q.first << endl;
        else
            cout << q.first << '\n' << q.second << endl;
    } else if (dayu_dengyu(q.first.x, q.second.x))
        cout << q.second << '\n' << q.first << endl;
    else
        cout << q.first << '\n' << q.second << endl;
    return 0;
}


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

int main(){
  int H,W,K;
  cin >> H >> W >> K;
  vector<vector<int>> V(H+1,vector<int>(W+1,0));
  for(int i=1;i<=H;i++){
    string S;
    cin >> S;
    for(int j=1;j<=W;j++){
      if(S[j-1]=='1') V[i][j]++;
      V[i][j] += V[i][j-1];
    }
  }
  
  int ans = H+W;
  for(int tmp=0;tmp<(1<<(H-1)); tmp++) {
    bitset<9> B(tmp);
    int N=B.count(), lastcut=0;
    for(int i=1;i<=W;i++){
      int white=0;
      for(int j=1;j<=H;j++){
        white += V[j][i] - V[j][lastcut];
        if(white>K){
          if(lastcut==i-1) N += 10000;
          N++;
          lastcut = i-1;
          i--;
          break;
        }
        if(j!=H) if(B.test(j-1)) white = 0;
      }
      if(N>ans) break;
    }
    ans = min(ans,N);
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def p_c():
    n, k = map(int, input().split())
    H = [int(input()) for _ in range(n)]
    H.sort()
    ans = 10 ** 9 + 1
    for i in range(n - k + 1):
        ans = min(ans, H[i + k - 1] - H[i])
    print(ans)
    
p_c()

Measured memory_bytes: 50264
n, y = gets.split.map &:to_i

(0..n).each do |a|
  (0..n-a).each do |b|
    c = n - a - b
    if a * 10000 + b * 5000 + c * 1000 == y
      puts "#{a} #{b} #{c}"
      exit
    end
  end
end
puts "-1 -1 -1"

Measured memory_bytes: 14356
#include <iostream>
#include <vector>

int main() {
  const uint32_t MAX = 100'000;
  std::vector<bool> prime(MAX + 1, true);
  prime[0] = false, prime[1] = false;
  for (uint32_t i = 2; i < prime.size(); i++) {
    if (!prime[i]) continue;
    for (uint32_t j = i * 2; j < prime.size(); j += i) prime[j] = false;
  }

  std::vector<uint32_t> like(MAX + 1, 0);
  uint32_t sum = 0;
  for (size_t i = 1; i < like.size(); i += 2) {
    if (prime[i] && prime[(i + 1) / 2]) sum++;
    like[i] = sum, like[i+1] = sum;
  }

  uint32_t Q = 0;
  std::cin >> Q;
  for (size_t i = 0; i < Q; i++) {
    uint32_t l = 0, r = 0;
    std::cin >> l >> r;
    std::cout << like[r] - like[l - 1] << std::endl;
  }

  return 0;
}

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

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

	int cnt = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i])
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll n;
    cin>>n;
    ll ans[10010]={};
    rep2(i,1,101){
        rep2(j,1,101){
            rep2(k,1,101){
                ll c=i*i+j*j+k*k+i*j+j*k+k*i;
                if(c<=n) ans[c]++;
            }
        }
    }
    rep2(i,1,n+1){
        cout<<ans[i]<<endl;
    }



}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    solve(); 


    return 0;
}


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int x=0;
  int ans=0;
  for(int i=0; i<N; i++){
    if(S.at(i)=='I') x++;
    else x--;
    ans = max(ans, x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int N, flag = 1, temp, sw = 0;
	cin >> N;
	int A[N];
	for(int i = 0; i < N; i++)
		cin >> A[i] ;

	while(flag){
		flag = 0;
		for(int j = N - 1; j > 0 ; j--){
			if(A[j] < A[j - 1]){
				temp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = temp;
				flag = 1;
				sw++;
			}
		}
	}

	for(int i = 0; i < N; i++){
		if(i > 0)
			cout << " ";
		cout << A[i];
	}
	cout << endl << sw << endl;
	return 0;
}

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

#define NAME "S - Digit Sum"
#define show(x) cout << (#x) << " is " << (x) << endl
#define ll long long
#define ms(arr,val) memset(arr,val,sizeof(arr))
#define len length()

const int mod = 1e9 + 7;

void addmod(ll &x, ll val){
    x+=val;
    if (x>mod) x-=mod;
    if (x<0) x+=mod;
}
int main(){
    //ifstream cin(NAME".inp");
    //ofstream cout(NAME".out");

    string  x;
    int d;
    cin>>x;
    cin>>d;
    ll cur = 0;
    vector<ll> tmp(d,0);
    vector<ll> dp(d,0);
    for(int i=0;i<x.len;i++){

        for(int j = 0;j<d;j++)
            for(int k=0;k<=9;k++) addmod(tmp[ (j+k)%d  ], dp[j]);

        for(int j = 0;j<x[i]-'0';j++) addmod( tmp[(cur + j)%d],1LL);
        dp = tmp;
        fill(tmp.begin(),tmp.end(),0);
        //addmod(cur,0LL+x[i]-'0');
        cur = (cur + x[i]-'0')%d;
    }
    //show(dp[0]);
    //show(cur);
    cout<<dp[0] + (cur==0) - 1<<endl;

}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define d1(x) cout<<#x<<" "<<x<<endl;
#define d2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define d2i(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
#define all(v) v.begin(),v.end()
#define pm(v,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<v[i][j]<<" ";cout<<endl;}
///////////////////////////////////////////
/// choose such no such that every 5 sum of nu mber is divisible by 5

void solve(){
  ll n,m;
  cin>>n>>m;
  ll ans=1;
  for(ll i=1;i*i<=m;i++){

     if(m%i==0){
       if(m/i>=n)
       ans=max(ans,i);
       
       if(i>=n){
         ans=max(ans,m/i);
       }
     }
  }
  cout<<ans;
}




int main(){
    ll t=1;
  //cin>>t;
    while(t--){
        solve();
        cout<<endl;
    
    }
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

#define use   0
#define broken 1

void Swap(int *x, int i, int j);
void QSort(int *x, int left, int right);

int main(void){
  int N,H;

  scanf("%d %d",&N, &H);

  int loop = 0;
  char useable[N];
  int a[N],b[N];
  int enemy_HP = H;
  int count=0;
  int base_atk_cnt=0;
  int ans;
  int base_attack;
  int throw_cnt = 1;
  int sub[N];

  base_attack = 0;
  
  while( loop != N ){
    scanf("%d %d", &a[loop],&b[loop]);
    loop++;
    if( base_attack < a[loop-1] ){
      base_attack = a[loop-1];
    }
    
  }

  base_atk_cnt = enemy_HP/base_attack;
  if( enemy_HP%base_attack > 0 ){
    base_atk_cnt++;
  }
  ans = base_atk_cnt;

  QSort( b, 0, N-1 );

  loop = 1;
  sub[0] = b[N - 1];
  while( loop != N ){
    sub[loop] = sub [loop-1] + b[N - 1 -loop];
    loop++;
  }
  
  throw_cnt = 1;
  while( throw_cnt <= N ){
    count = throw_cnt;
    enemy_HP = H;

    enemy_HP = enemy_HP - sub[count-1];
    
    if( enemy_HP > 0 ){
      count = count + (enemy_HP/base_attack);
    }
    else{
      if( ans > count ){
	ans = count;
      }
      break;
    }
      
    if( enemy_HP%base_attack > 0 ){
      count++;
    }
        
    if( ans > count ){
      ans = count;
    }
    
    throw_cnt++;
  }
  
  printf("%d\n",ans);
  
  return 0;
}

void QSort(int* x, int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      
    j = right;                     

    pivot = x[(left + right) / 2]; 

    while (1) {                    

        while (x[i] < pivot)       
            i++;                   

        while (pivot < x[j])       
            j--;                   
        if (i >= j)                
            break;                 

        Swap(x, i, j);             
        i++;                       
        j--;
    }              

    if (left < i - 1)              
        QSort(x, left, i - 1);     
    if (j + 1 <  right)            
        QSort(x, j + 1, right);    
}

void Swap(int* x, int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}



Measured memory_bytes: 1280
#include<stdio.h>

int main(void){

 int W,H,x,y,r;

 scanf("%d",&W);

scanf("%d",&H);


scanf("%d",&x);


scanf("%d",&y);


scanf("%d",&r);


 if(W>=x+r && H>=y+r && 0<=x-r && 0<=y-r){


printf("Yes\n");


}


else{


printf("No\n");


}


return 0;

}

Measured memory_bytes: 584
from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r


def solve():
    s=input()
    n=len(s)
    a=s[:(n-1)//2]
    b=a[::-1]
    c=s[(n+3)//2 -1 :]
    d=c[::-1]
   
    if s==s[::-1] and a==b and c==d:
        print("Yes")
    else:
        print("No")


for _ in range(1):
    solve()
    


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

ll A, B, K;

int main() {
  cin >> A >> B >> K;

  ll d = min(A, K);
  A -= d;
  K -= d;
  B -= min(B, K);
  cout << A << " " << B << endl;
  return 0;
}


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

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

int main() {
	int n; cin >> n;

	int r, a, b, ma , cnt;
	REP( i, n ) {
		cin >> r;
		cnt = 0;
		
		if( r < 10 ) cnt = 0;
		else {

			int j;
			ma = 0;
			
			while( 1 ) {
				j = 10;
				while( 1 ) {
					a = r % j;
					b = r / j;
					
					if( a == r ) break;
					
					ma = max( a * b, ma );
					j *= 10;
				}
				cnt++;
				r = ma;
				ma = 0;
				if( r < 10 ) break;
			}
		}

		cout << cnt << endl;
	}
}


Measured memory_bytes: 3080
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

n = inp[0]
t = inp
m = inp[0]
sum = sum(t)
d = []
m.times{d<<inp}
max = 0
m.times  do |i|
  p sum - t[d[i][0]-1] + d[i][1]
end

Measured memory_bytes: 3964
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

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

	int x;
	cin >> x;
	cout << 6.28 * x << endl;
}

Measured memory_bytes: 3756
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
ld powe(ll y){
	ld s=1,x=0.5;
	while(y){
		if(y%2) s*=x;
		y/=2;x*=x;
	}return s;
}
int main(){
	ld s=0;ll i,n,k,f,c;cin>>n>>k;
	for(i=1;i<=n;i++){
		f=i;c=0;while(f<k) c++,f*=2;
		s+=powe(c);
	}s/=(n*1.0);printf("%.10Lf\n",s);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
int main(){
    int n,t,a;
    cin>>n>>t>>a;
    int h,ans=-1;
    double san=100000;
    rep(i,0,n){
        cin>>h;
        double tem=abs(t-h*0.006-a);
        if(san>tem){
            san=tem;
            ans=i;
        }
    }
    cout<<ans+1<<endl;
}

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

int main(){
    ll n;
    cin >> n;
    ll a[n] = {};
    rep(i,0,n){
        cin >> a[i];
        cout << a[i];
        if(i != n-1) cout << " ";
        else cout << endl;
    }

    rep(i,1,n){
        ll v = a[i],j = i - 1;

        while(j >= 0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        rep(k,0,n){
            cout << a[k];
            if(k != n-1) cout << " ";
            else cout << endl;
        }
    }
    return 0;
}



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

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

    int ans = 0;
    for (int i = 1; i < n; i++) {
        vector<pair<bool, bool>> check(26, make_pair(false, false));
        string x = s.substr(0,i);
        string y = s.substr(i);
        for (int j = 0; j < x.length(); j++) {
            check[x[j]-'a'].first = true;
        }
        for (int j = 0; j < y.length(); j++) {
            check[y[j]-'a'].second = true;
        }
        int count = 0;
        for (int i = 0; i < 26; i++) {
            if (check[i].first && check[i].second)
                count ++;
        }
        ans = max(ans,count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
# 2019/02/09
# Minnano Procon 2019 - B

# Input
cnt = [0, 0, 0, 0]
for i in range(3):
    a, b = list(map(int,input().split()))
    cnt[a-1] += 1
    cnt[b-1] += 1
    
# Check cnt
cnt_1 = 0
cnt_2 = 0

for i in range(3):
    if cnt[i] == 1:
        cnt_1 += 1
    elif cnt[i] == 2:
        cnt_2 += 1

if cnt_1 == 1 and cnt_2 == 2:
    ans = "YES"
else:
    ans = "NO"

# Output
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  string s;
  cin>>s;
  string ans=" ";
  ans+=s[0];
  for(int i=1;i<s.size();i++) {
    if(ans[ans.size()-1]=='T'||ans[ans.size()-1]==' '){
      ans+=s[i];
      continue;
    }
    if(s[i]=='S'){
      ans+=s[i];
      continue;
    }
    ans.erase(ans.end()-1);
  } 
  //cout<<ans<<endl;
  cout<<ans.size()-1;
}

Measured memory_bytes: 776
N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0
for i in range(N):
  if A[i] >= 2:
    ans += A[i]//2
    A[i] -= (A[i]//2)*2
  if i < N-1:
    m = min(A[i],A[i+1])
    ans += m
    A[i] -= m
    A[i+1] -= m
  #print(i,ans,A)
print(ans)


Measured memory_bytes: 50648
#include<iostream>
#include<stdio.h>

using namespace std;

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;

double DP[3000][3000];

int main(){
    int N;
    cin >> N;
    vector<double> P(N);
    REP(i,N){
        double p;
        cin >> p;
        P[i] = p;
    }

    DP[0][0] = 1;
    REP(i,N){
        double p = P[i];
        REP(j,N){
            DP[i+1][j+1] += DP[i][j] * p;
            DP[i+1][j] += DP[i][j] * (1-p);
        }
    }

    //REP(i,N+1)

    double ans = 0;
    REPi(i,N/2+1, N+1){
        ans += DP[N][i];
    }

    printf("%.15lf\n", ans);
    return 0;
}


Measured memory_bytes: 70528
from collections import deque

N,M=map(int,input().split())
G=[[] for i in range(N)]
for i in range(M):
    L,R,D=map(int,input().split())
    L,R=L-1,R-1
    G[L].append((D,R))
    G[R].append((-D,L))
ok=True
dist=[None]*N
que=deque()
for i in range(N):
    if dist[i]!=None:
        continue
    que.append(i)
    dist[i]=0
    while que:
        v=que.popleft()
        for cost,nv in G[v]:
            if dist[nv]!=None:
                if dist[nv]!=dist[v]+cost:
                    print('No')
                    exit()
            else:
                dist[nv]=dist[v]+cost
                que.append(nv)

print('Yes')

Measured memory_bytes: 81056
import java.util.Scanner;
public class Main {
	void cinr(){
		int w,h,x,y,r;
		Scanner s = new Scanner(System.in);
		w = s.nextInt();
		h = s.nextInt();
		x = s.nextInt();
		y = s.nextInt();
		r = s.nextInt();
		if(x-r<0||y-r<0||x+r>w||y+r>h){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}


	}
	public static void main(String args[]){
		Main m = new Main();
		m.cinr();
	}
}

Measured memory_bytes: 26196
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
typedef vector<int> vi;
typedef vector < pair<int, int > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
int n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
	int n, m;
	int ans[100];
	REP(i,100)
	{
		ans[i] = 0;
	}
	cin >> n >> m;
	REP(i,2*m)
	{
		int a;
		cin >> a;
		a--;
		ans[a]++;
	}
	REP(i,n)
	{
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 256
//  [amitdu6ey]
// g++ -std=c++11 -o2 -Wall filename.cpp -o filename
#include <bits/stdc++.h>
#define hell 1000000009
#define bug1(x) cout<<"$ "<<x<<" $"<<endl
#define bug2(x) cout<<"% "<<x<<" %"<<endl
#define bug3(x) cout<<"# "<<x<<" #"<<endl
#define ll long long
#define pb push_back
#define mp make_pair
#define tr(z) for(auto it=z.begin(); it!=z.end(); it++)
#define rloop(i,a,b) for(long long i=a; i>=b;i--)
#define loop(i,a,b) for(long long i=a; i<b; i++)
#define vbool vector< bool >
#define vvbool  vector< vector<bool> >
#define vchar vector<char>
#define vi vector<int>
#define vvi vector< vector<int> >
#define pll pair<long long, long long>
#define vll vector<long long>
#define vvl vector< vector<long long> >
#define ninf numeric_limits<long long>::min()
#define pinf numeric_limits<long long>::max()
#define comp(a,b) (abs(a-b)<1e-9) // to compare doubles
using namespace std;

void solve(){
    ll N, W;
    cin>>N>>W;
    vll wt(N+1,0);
    vll val(N+1,0);
    loop(i,1,N+1) cin>>wt[i]>>val[i];
    vector< vector<ll> > dp(N+1, vector<ll>(W+1,0));
    loop(i,1,N+1){
        loop(j,1,W+1){
            if(j-wt[i] >= 0)
                dp[i][j] = max(dp[i-1][j], val[i] + dp[i-1][j-wt[i]]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    // loop(i,0,N+1){
    //     loop(j,0,W+1){
    //             cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    cout<<dp[N][W]<<endl;
    return;
}

int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int test_cases=1;
    //cin>>test_cases;
    while(test_cases--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 83172
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main(void)
{
	int n;
	scanf("%d",&n);
	ll ans = 0;
	int lst = 0;
	for(int i=1; i<=n; ++i)
	{
		int a;
		scanf("%d",&a);
		if(a < lst) ans += lst - a;
		lst = max(lst, a);
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int main() {

	int n, q;
	cin >> n >> q;

	vector<list<int>> ll(n,list<int>());

	for (int i = 0; i < q; i++) {

		int a, b, c;
		cin >> a >> b;

		if (a == 0) {
			cin >> c;
			ll[b].push_back(c);
		}
		else if (a == 1) {
			if (!ll[b].empty()) {
				cout << *ll[b].begin();
				if (ll[b].size() != 1) {
					for (auto itr = ll[b].begin(); itr != ll[b].end(); itr++) {
						if (itr == ll[b].begin()) { itr++; }
						cout << " " << *itr;
					}
				}
				cout << endl;
			}
			else {
				cout << endl;
			}
		}
		else if (a == 2) {
			cin >> c;
			ll[c].splice(ll[c].end(),move(ll[b]));
		}

	}



}


Measured memory_bytes: 18664
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 200002;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()



int32_t main()
{ 
   IOS
  

  int n;
  cin >> n;
  vector<pair<int,int>> ed;
  for(int i = 1;i<=n-1;i++){
    int u,v;
    cin >> u >> v;
    ed.push_back({u,v});
  }
  int ans =0;
  for(int i = 1;i<=n;i++){
    ans += i*(n-i+1);
  }
  for(int i = 1;i<n;i++){
    int u,v;
    tie(u,v) = ed[i-1];
    if(u>v)
      swap(u,v);
    int p = (u)*(n-v+1);
    ans -=  p;
  }
  cout<<ans<<endl;

  

  


  

  



  
  

 
}

Measured memory_bytes: 7372
N,K=map(int,input().split())
S=input()
l=[]
count=0
if S[0]=="0":
    now=0
    l+=[0]
    a=0
else:
    now=1
    a=1
for i in range(len(S)):
    if int(S[i])==now:
        count+=1
    else:
        l+=[count]
        count=1
        now=int(S[i])
l+=[count]
l+=[0]

ans=sum(l[:2*K+1])
s=sum(l[:2*K+1])
if len(l)-2*K>0:
    for i in range(2*K+2,len(l),2):
        s+=l[i]+l[i-1]-l[i-2*K-1]-l[i-2*K-2]
        ans=max(ans,s)
else:
    ans=sum(l)



if len(l)==1 and a==1:
    print(l[0])
else:
    print(ans)



Measured memory_bytes: 4596
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(pos,mp) for(ll pos=mp.begin();pos!=mp.end();pos -++)
#define ALL(a) (a).begin(),(a).end()

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

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll n, t;
    cin >> n >> t;

    vector<ll> a(n), b(n);
    rep(i, n)cin >> a[i] >> b[i];

    vector<ll> ord(n);
    iota(ALL(ord), 0);
    sort(ALL(ord), [&](ll x, ll y){
        return a[x] < a[y];
    });

    // dp[i][j] : i個までで，j秒での満足度
    ll dp[n+1][t] = {};

    ll ans = 0;
    rep(i, n)rep(j, t){
        ll pos = ord[i];

        dp[i+1][j] = dp[i][j];
        // dp[i][j]とi+1
        ans = max(ans, dp[i+1][j] + b[pos]);
    
        ll order = j - a[pos];
        if(order >= 0){
            dp[i+1][j] = max(dp[i+1][j], dp[i][order] + b[pos]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 74040
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	char b;
	cin >> b;
	int s = 1;
	vector<int> S;
	for (int i = 1; i < N; i++) {
		char c;
		cin >> c;
		if (c == b) s++;
		else {
			S.push_back(s);
			s = 1;
			b = c;
		}
	}
	S.push_back(s);

	int MAX = 0;
	int sum = 0;
	int max_r = 0;
	for (int i = 0; i < (int)S.size(); i++) {
		sum += S[i];
		if (i >= 2 * K + 1) sum -= S[i - 2 * K - 1];
		if (MAX < sum) {
			max_r = i;
			MAX = sum;
		}
	}

	int ans = 0;
	for (int i = 0; i < (int)S.size(); i++) if (i <= max_r - 2 * K - 1 || i > max_r) ans += S[i] - 1;
	ans += MAX - 1;
	cout << ans << endl;

}


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

int main() {
  int A, B, C; cin >> A >> B >> C;
  string ans = "Yes";
  if (A == B && A == C) ans = "No";
  if (A != B && A != C && B != C) ans = "No";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <deque>
using namespace std;
int main(){
deque <char>s;
char swaped_char,input;
int len;
string S,t,message,instedOfdeque;
cin >> S >> t;
len =S.length();
for (int x=0;x<len;x++){
        for (int i=0;i<len;i++){
        if (i==len-1){
          s.push_front(S[i]);break;
    }
     else {
        s.push_back(S[i]);}

  }for(int a=0;a<len;a++){
  S[a]=s[a];}
if (S==t){message ="Yes";break;}
    else {message ="No";}s.clear();
}
    cout << message;

return 0;}


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

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

  vector<int> A(N);
  long long ans = 0;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(i > 0 && A[i - 1] > 0 && A[i] > 0){
      ans += 1;
      A[i] -= 1;
    }
    ans += A[i] / 2;
    A[i] %= 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
 


int main() {
ll n;
  cin>>n;
  ll a[n+1];
  for(int i=1;i<=n;i++){
    cin>>a[i];}
  
  ll id[1000008];
    ll no[1000008];
  for(int i=1;i<=1000007;i++){
    id[i]=0;
  no[i]=0;}
  


  
  for(int tt=1;tt<=n;tt++){
    ll now=a[tt];
  
    
  vector <ll> vec{};
  vector <ll> vec2{};
while (now >= 2) {
	bool so = true;
	for (ll i = 2; i*i <= now; i++) {
   
		if (now%i == 0) {
			vec.push_back(i);
          vec2.push_back(i);
			now /= i;
			so = false;
			break;
		}
	}
	if (so) {
		vec.push_back(now);
      vec2.push_back(now);
		break;
	}
}
  
    
    for(int i=0;i<vec.size();i++){
      no[vec[i]]++;}
    for(int i=0;i<vec.size();i++){
          id[vec[i]]=max(id[vec[i]], no[vec[i]]);
        no[vec[i]]=0;}
    
    }
    

  
  ll seki=1;
  for(int i=1;i<=1000007;i++){
    if(id[i]){
      for(int j=1;j<=id[i];j++){
        seki*=i;
        seki%=MOD;}
    }
  }
  
  
    ll aa[n+1];
  for(int i=1;i<=n;i++){
   aa[i]= seki*modinv(a[i], MOD);
    aa[i]%=MOD;
  }
  
  ll ans=0;
  for(int i=1;i<=n;i++){
    ans+=aa[i];
    ans%=MOD;}
  
  cout<<ans<<endl;
    
    
  
  

}

Measured memory_bytes: 16000
import numpy as np
import sys

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n = int(input())
    wsv = LLI(n)
    wsv.sort(key=lambda x: x[0] + x[1])
    m = wsv[-1][0] + wsv[-1][1] + 1
    dp = np.zeros(m, dtype="i8")
    for w, s, v in wsv:
        np.maximum(dp[s + w:w - 1:-1], dp[s::-1] + v, out=dp[s + w:w - 1:-1])
    print(np.max(dp))

main()


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

int main(){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  s1[0]+=('A'-'a');
  s2[0]+=('A'-'a');
  s3[0]+=('A'-'a');
  cout << s1[0] << s2[0] << s3[0] << endl;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <utility>

using namespace std;

int main() {

	int N, W;
	scanf("%d %d", &N, &W);
	pair<int, int> items[N + 1];
	for (int i = 1; i <= N; ++i) {
		int v, w;
		scanf("%d %d", &v, &w);
		items[i] = make_pair(v, w);
	}

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

	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= W; ++j) {
			if (items[i].second <= j) {
				V[i][j] = max(V[i - 1][j], V[i - 1][j - items[i].second] + items[i].first);
			} else {
				V[i][j] = V[i - 1][j];
			}
		}
	}
	int maxV = 0;
	for (int i = 1; i <= W; ++i) {
		maxV = max(maxV, V[N][i]);
	}
	cout << maxV << endl;

	return 0;
}

Measured memory_bytes: 7176
import __pypy__
import sys

B, W = map(int, sys.stdin.readline().split())
MOD = 10**9 + 7

L = B+W
fact = [1]*(L+1)
rfact = [1]*(L+1)
for i in range(L):
    fact[i+1] = r = fact[i] * (i+1) % MOD
    rfact[i+1] = pow(r, MOD-2, MOD)

rev2 = pow(2, MOD-2, MOD)

p = q = 0
base = 1
bl = __pypy__.builders.StringBuilder(B+W)
bl.append("%d\n" % rev2)
for i in range(1, B+W):
    base = rev2 * base % MOD
    if i-B >= 0:
        p = (p + ((fact[i-1]*rfact[B-1] % MOD)*rfact[i-B] % MOD)*base % MOD) % MOD
    if i-W >= 0:
        q = (q + ((fact[i-1]*rfact[W-1] % MOD)*rfact[i-W] % MOD)*base % MOD) % MOD
    bl.append("%d\n" % ((1-p+q)*rev2 % MOD))
sys.stdout.write(bl.build())

Measured memory_bytes: 70876
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	a, b, c, d, e, f = IN()
	mm=f
	ww_list=[0]*(mm+1)
	ww_list[0]=1
	for i, is_ok in enumerate(ww_list):
		if is_ok == 1:
			if i+(a*100) <= mm:
				ww_list[i+(a*100)]=1
			if i+(b*100) <= mm:
				ww_list[i+(b*100)]=1
				
	max_noudo=0
	ret_sw=a*100
	ret_suger=0
	for wv, is_ok_w in enumerate(ww_list):
		if is_ok_w == 0:
			continue
		suger_limit=e*(wv//100)
		ok_s=[0]*(suger_limit + 1)
		ok_s[0]=1
		max_suger=0
		for i, is_ok in enumerate(ok_s):
			if is_ok == 1:
				if i + c <= suger_limit and (wv+i+c) <= f:
					ok_s[i+c]=1
					max_suger=max(max_suger, i+c)
				if i+d <= suger_limit and (wv+i+d) <= f:
					ok_s[i+d]=1
					max_suger = max(max_suger, i+d)
		if wv == 0:
				continue
			
		suger_noudo=((100*max_suger)/(wv+max_suger))
		if max_noudo < suger_noudo:
			max_noudo=suger_noudo
			ret_sw = wv+max_suger
			ret_suger = max_suger
	print(ret_sw, ret_suger)
	return 
				
		
	
	

	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 39860
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)
 
 
#define MAX_V 110
 
struct edge{int to,cap,rev;};
 
vector<edge> G[MAX_V];  //???°???????????????
int level[MAX_V];       //??§???????????????????¢
int iter[MAX_V];        //????????????§????????????
 
// from??????to?????????????????????cap????????????°?????????????????????
void add_edge(int from,int to,int cap){
    G[from].push_back(  (edge){ to  ,cap,(int)G[to  ].size()   }  );
    G[to  ].push_back(  (edge){ from,0  ,(int)G[from].size()-1 }  );
}
 
// s?????????????????????¢???BFS???§??¨??????????
void bfs(int s){
    rep(i,MAX_V)level[i]=-1;
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
        int v=que.front();que.pop();
         
        rep(i,G[v].size()){
            edge &e=G[v][i];
            if(e.cap>0 && level[e.to]<0){
                level[e.to]=level[v]+1;
                que.push(e.to);
            }
        }
    }
}
 
//??¢?????????????DFS???§???¢???
int dfs(int v,int t,int f){
    if(v==t)return f;
    for(int &i=iter[v];i<G[v].size();i++){
        edge &e=G[v][i];
        if(e.cap>0&&level[v]<level[e.to]){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
 
// s??????t????????????§????????±???????
int max_flow(int s,int t){
    if(s==t)return INF;
    int flow=0;
    for(;;){
        bfs(s);
        if(level[t]<0)return flow;
        memset(iter,0,sizeof(iter));
        int f;
        while((f=dfs(s,t,INF))>0){
            flow+=f;
        }
    }
}
 
void isUsedDfs(int s,int t,bool used[MAX_V]){
    if(s==t)return ;
    for(auto &e:G[s]){
        if(!used[e.to]&&e.cap>0){
            used[e.to]=true;
            isUsedDfs(e.to,t,used);
        }
    }
}
 
 
int main(){
    int k,n,m;
    cin>>k>>n>>m;
    int s = 1+k+n;
    int t = 0;
    int v = s+1;
     
    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        add_edge(a,b,c);
        add_edge(b,a,c);
    }
     
    rep(i,k)add_edge(s,i+1,INF);
     
    int res = max_flow(s,t);
    vector<edge> Greg[MAX_V];
    rep(i,v)Greg[i] = G[i];
     
     
    bool used[MAX_V]={};
    used[s]=true;
    isUsedDfs(s,t,used);
     
    int ans = 0;
    vector<int> sflow(v,-1),tflow(v,-1);
    rep(i,v){
        for(auto e:Greg[i]){
            if(used[i]&&!used[e.to]){
                rep(i,v)G[i] = Greg[i];
                if(sflow[i]==-1) sflow[i] = max_flow(s,i);
                if(tflow[e.to]==-1)tflow[e.to] = max_flow(e.to,t);
                ans = max( ans , res + min(sflow[i],tflow[e.to]) );
            }
        }
    }
    if(ans>=INF)cout<<"overfuro"<<endl;
    else cout<<ans<<endl;
     
}

Measured memory_bytes: 3592
//#pragma GCC oplmize(2)
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define sc(x) scanf("%lld",&x)
#define scs(x) scanf("%s",x+1)
#define pr(x) printf("%lld\n",x)
#define prs(x) printf("%s\n",x)
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
const double pi=acos(-1.0);
const double eps = 1e-8;
ll n,k,ma=-0x3f3f3f3f,ww,cc,ans[5005],s;
struct node{
    ll nex,val;
}a[5005];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    sc(n),sc(k);
    for(int i=1;i<=n;i++) sc(a[i].nex);
    for(int i=1;i<=n;i++) sc(a[i].val);
    for(int i=1;i<=n;i++){
        cc=0;
        ww=a[i].nex;
        memset(ans,0,sizeof(ans));
        while(ww!=i && cc<k){
            cc++;
            ans[cc]=ans[cc-1]+a[ww].val;
            ma=max(ma,ans[cc]);
            ww=a[ww].nex;
        }
        if(cc<k) {
            cc++;
            ans[cc]=ans[cc-1]+a[ww].val;
            ma=max(ma,ans[cc]);
        }
        if(ans[cc]>0 && k>cc){
            s=k/cc*ans[cc];
            ma=max(ma,s);
            for(int i=1;i<=k%cc;i++){
                s+=ans[i]-ans[i-1];
                ma=max(ma,s);
            }
            s=(k/cc-1)*ans[cc];
            for(int i=1;i<=cc;i++){
                s+=ans[i]-ans[i-1];
                ma=max(ma,s);
            }
        }
    }
    pr(ma);
    return 0;
}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int ct_g = 0, ct_p = 0;
  int ans = 0;
  REPx(x, s)
  {
    if (x == 'g')
    {
      if (ct_p+1 <= ct_g)
      {
        ans++;
        ct_p++;
      }
      else ct_g++;
    }
    else
    {
      if (ct_p+1 <= ct_g) ct_p++;
      else
      {
        ans--;
        ct_g++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int fibonacci(int);

int F[45];

int main()
{

    int n;

    scanf("%d", &n);
    printf("%d\n", fibonacci(n));

    return 0;
}

int fibonacci(int n)
{

    if (n == 0 || n == 1)
        return F[n] = 1;

    if (F[n] != 0)
        return F[n];

    return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
}



Measured memory_bytes: 2112
#include<stdio.h>
int main(void){
	
	int spade[13]={0},heart[13]={0},club[13]={0},diamond[13]={0},i,k,num,n;
	char m;
	
	scanf("%d",&num);
	
	for(i=0;i<num;i++){
		scanf("%s %d",&m,&n);
		if(m=='S'){
			spade[n-1]=1;
		}else if(m=='H'){
			heart[n-1]=1;
		}else if(m=='C'){
			club[n-1]=1;
		}else{
			diamond[n-1]=1;
		}
	}
	
	for(i=0;i<4;i++){
		for(k=0;k<13;k++){
			if(i==0){
				if(spade[k]==0){
					printf("S %d\n",k+1);
				}
			}else if(i==1){
				if(heart[k]==0){
					printf("H %d\n",k+1);
				}
			}else if(i==2){
				if(club[k]==0){
					printf("C %d\n",k+1);
				}
			}else{
				if(diamond[k]==0){
					printf("D %d\n",k+1);
				}
			}
		}
	}
	return 0;
}

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

ll count1,count2,count4;

int main(){
    ll h,w;
    cin >> h >> w;
    vector<ll> memo(26,0);
    char a[h][w];
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            cin >> a[i][j];
            memo[a[i][j]-'a']++;
        }
    }
    if(h%2==0&&w%2==0) count4=(h/2)*(w/2);
    else if(h%2==1&&w%2==1){
        count1=1;
        count2=h/2+w/2;
        count4=(h/2)*(w/2);
    }
    else if(h%2==1&&w%2==0){
        count2=w/2;
        count4=(h/2)*(w/2);
    }
    else if(h%2==0&&w%2==1){
        count2=h/2;
        count4=(h/2)*(w/2);
    }
    for(ll i=0;i<count1;i++){
        for(ll j=0;j<26;j++){
            if(memo[j]%4==1||memo[j]%4==3){
                memo[j]--;
                break;
            }
        }
    }
    for(ll i=0;i<count4;i++){
        for(ll j=0;j<26;j++){
            if((memo[j]%4==0&&memo[j]>0)||(memo[j]%4==2&&memo[j]>4)){
                memo[j]-=4;
                break;
            }
        }
    }
    for(ll i=0;i<count2;i++){
        for(ll j=0;j<26;j++){
            if(memo[j]%4==2||(memo[j]%4==0&&memo[j]>0)){
                memo[j]-=2;
                break;
            }
        }
    }
    bool flag=true;
    for(ll i=0;i<26;i++){
        if(memo[i]!=0) flag=false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}  


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define md 1000000007
#define ll long long 
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fastmap mp.reserve(1024);mp.max_load_factor(0.25);
#define fastset st.reserve(1024);st.max_load_factor(0.25);
ll int mpw(ll int a,ll int b,ll int m)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans=(ans*a)%m;
		}
		a=(a*a)%m;
		b>>=1;
	}
	return ans;
}

ll int pw(ll int a,ll int b)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans*=a;
		}
		a*=a;
		b>>=1;
	}
	return ans;
}

ll int mn(ll int a,ll int b)
{
	if(a<=b)
	{
		return a;
	}
	return b;
}

ll int mx(ll int a,ll int b)
{
	if(a>=b)
	{
		return a;
	}
	return b;
}
vector<vector<ll int>>D;
int main()
{
	fio
	int n;
	cin>>n;
	vector<pair<pair<int,int>,int>>nm(n);
	for(int i=0;i<n;++i)
	{
		cin>>nm[i].first.first>>nm[i].first.second>>nm[i].second;
	}
	vector<pair<pair<int,int>,int>>D(n,{{0,0},0});
	D[0]=nm[0];
	for(int i=1;i<n;++i)
	{
		D[i].first.first=max(D[i-1].first.second,D[i-1].second)+nm[i].first.first;
		D[i].first.second=max(D[i-1].first.first,D[i-1].second)+nm[i].first.second;
		D[i].second=max(D[i-1].first.first,D[i-1].first.second)+nm[i].second;
	}
	cout<<max(D[n-1].first.first,max(D[n-1].first.second,D[n-1].second))<<"\n";
	return 0;
}

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

int n,m,q,res=0,a[55],b[55],c[55],d[55];

void dfs(vector<int> v,int cnt){
    if(cnt==n){
        int k=0;
        for(int i=0;i<q;i++){
            if(v[b[i]-1]-v[a[i]-1]==c[i])k+=d[i];
        }
        res=max(res,k);
    }
    else{
        for(int i=v[cnt];i<=m;i++){
            vector<int> vv=v;
            vv.push_back(i);
            dfs(vv,cnt+1);
        }
    }
}

signed main(){
    cin>>n>>m>>q;
    for(int i=0;i<q;i++)cin>>a[i]>>b[i]>>c[i]>>d[i];
    vector<int> v={1};
    dfs(v,0);
    cout<<res<<endl;
}

Measured memory_bytes: 3632