akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;

    ll A[N];
    REP(i, N) cin >> A[i];

    ll ans = A[0];
    FOR(i, 1, N) {
        ans = gcd(ans, A[i]);
    }

    cout << ans << endl;


}

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> pic(2 * H);
  for(int i = 0; i < H; i++){
      string s;
      cin >> s;
      pic.at(2 * i + 1) = s;
      pic.at(2 * i) = s;
    }
  for(int i = 0; i < 2 * H; i++){
    cout << pic.at(i) <<endl;
  }
}

Measured memory_bytes: 256
#define FASTIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//#define BZ
//#define PBDS
//#define POINT

#ifndef BZ
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("no-stack-protector")
#pragma GCC target ("tune=native")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize ("conserve-stack")
//#pragma GCC optimize ("no-stack-limit")
#endif

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using str = string;
using pll = pair<ll, ll>;

#ifdef POINT
using point = complex<ll>;
#define x real
#define y imag
#endif

#ifdef PBDS
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//using namespace __gnu_pbds::detail;
template <class T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#endif

#define INF 0x7fffffffffffffffLL
#define BASE 1000000007LL // 3 * 10**9 + 19 // 998244353 - rev == pow(n + m, BASE - 2)
#define MAX(type) std::numeric_limits<type>::max()
#define MIN(type) std::numeric_limits<type>::min()

#define LOG(v) cout << #v << " " << v << "\n";

#define pb push_back
#define eb emplace_back
//#define all(c) c.begin(), c.end()
//#define rall(c) c.rbegin(), c.rend()
#define F first
#define S second
#define forEach(c) for (auto &it : c)
#define loop while (true)
#define mp make_pair
#define mt make_tuple

template<class T>
void chMax(T &a, T b) {
	if (a < b) a = b;
}

template<class T>
void chMin(T &a, T b) {
	if (b < a) a = b;
}

inline ll divUp(ll a, ll b) {
	return (a + b - 1)/b;
}

void solve() {
	ll n;
	cin >> n;
	string s;
	for (ll i = 0; i < n / 2; i++) {
		char c;
		cin >> c;
		s.pb(c);
	}
	string t;
	cin >> t;
	if (s == t) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

//#define LOCAL

int main() {
	FASTIO
#ifdef LOCAL
	auto start = std::chrono::system_clock::now();
#endif
	solve();
#ifdef LOCAL
	auto end = std::chrono::system_clock::now();
	std::chrono::duration<ld> elapsed_seconds = end - start;
	cerr << "\ntime: " << elapsed_seconds.count() << " s\n";
#endif
	return 0;
}


Measured memory_bytes: 256
"""
n = int(sys.stdin.readline())
a, b = map(int, sys.stdin.readline().split())
c = list(map(int, sys.stdin.readline().split()))
s = [list(map(int,list(sys.stdin.readline()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

a = 100
b = 0.987654321
print('{0:06d}-{1:6f}'.format(a,b))  # 0埋め, 小数点出力桁指定時のときの出力
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)


mod = 1000000007

if __name__ == "__main__":
    target = list("ACGT")
    s = sys.stdin.readline()
    l = 0
    ml = 0
    for w in s:
        if w in target:
            l += 1
        else:
            if ml < l:
                ml = l
            l = 0
    print(ml)

Measured memory_bytes: 5072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

template <typename T>
struct Graph {
    int V, E;
    struct Edge {
        int from, to;
        T cost;
    };
    vector<vector<Edge>> edge;
    vector<ll> a;
    vector<Edge> es;

    Graph(int V, int E) : V(V), E(E) {
        edge.assign(V, vector<Edge>(0));
        a.resize(V);
    }

    void input(bool is_direct, bool inputc, bool index0 = false) {
        int a, b;
        T c = 0;
        for (int i = 0; i < E; i++) {
            cin >> a >> b;
            if (inputc) cin >> c;
            if (!index0) a--, b--;
            edge[a].push_back((Edge){a, b, c});
            es.push_back((Edge){a, b, c});
            if (!is_direct) {
                edge[b].push_back((Edge){b, a, c});
                es.push_back((Edge){b, a, c});
            }
        }
        if (!is_direct) E *= 2;
    }

    void add_edge(int from, int to, T cost, bool is_direct) {
        edge[from].push_back({from, to, cost});
        es.push_back({from, to, cost});
        if (!is_direct) {
            edge[to].push_back({to, from, cost});
            es.push_back({to, from, cost});
            E++;
        }
        E++;
    }

    vector<int> ans;
    vector<ll> dp;

    void dfs(int v, int from, int i) {
        if (from == -1) ans.assign(V, 1);
        for (const auto& e : edge[v]) {
            int to = e.to;
            if (to == from) continue;

            int change_point = lower_bound(dp.begin(), dp.begin() + i + 1, a[to]) - dp.begin();
            ll t1 = dp[change_point];

            dp[change_point] = a[to];
            ans[to] = lower_bound(dp.begin(), dp.begin() + i + 1, INF) - dp.begin();

            dfs(to, v, i + 1);
            dp[change_point] = t1;
        }
    }
};

int main() {
    int N;
    cin >> N;
    Graph<int> g(N, N - 1);
    for (int i = 0; i < N; i++) cin >> g.a[i];
    g.input(false, false);
    g.dp.assign(N + 10, INF);
    g.dp[0] = g.a[0];
    g.dfs(0, -1, 1);
    for (int i = 0; i < N; i++) cout << g.ans[i] << endl;
    return 0;
}

Measured memory_bytes: 39824
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define mod (int)1000000007
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 5;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = DBL_EPSILON;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline int gcd(int a, int b) {
	while (b) {
		int c = a;
		a = b; b = c % b;
	}
	return a;
}
inline int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
bool isprime(int n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
int mypow(int a, int b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
int modpow(int a, int b, int m = mod) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	int memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
string s;
int dp[1000010][2];
signed main() {
	cin >> s;
	reverse(all(s));
	rep(i, s.size() + 1) {
		rep(j, 2)dp[i][j] = INF;
	}
	dp[0][0] = 0;
	rep(i, s.size()) {
		rep(j, 2) {
			if (j == 1 && s[i] == '9') {
				chmin(dp[i + 1][1], dp[i][j]);
			}
			int d = s[i] - '0';
			d += j;
			chmin(dp[i + 1][0], dp[i][j] + d);
			chmin(dp[i + 1][1], dp[i][j] + (10 - d));
		}
	}
	cout << min(dp[s.size()][0], dp[s.size()][1] + 1) << endl;
	return 0;
}

Measured memory_bytes: 17028
<?php
fscanf(STDIN, "%s", $hinaArareNum);
$HinaArares = trim(fgets(STDIN));
$oneHinaArare = explode(" ", $HinaArares);
$result = array_unique($oneHinaArare);

if(count($result)==3){
    echo 'Three';
}else{
    echo 'Four';
}

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long a, b, c, k;

int main() {
    cin >> a >> b >> c >> k;
    long long sum = 0;
    if(k > a) {
        sum += a;
        k -= a;
    }else {
        cout << k << endl;
        return 0;
    }

    if(k > b) {
        k -= b;
    }else {
        cout << sum << endl;
        return 0;
    }

    if(k > 0) {
        cout << sum - k << endl;
        return 0;
    }else {
        cout << sum << endl;
        return 0;
    }
}

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

int main(){
    ll r,g,b,n,ans=0;
    cin>>r>>g>>b>>n;
    for(ll i=0; i<=n; i++) {
        for(ll j=0; j<=n; j++) {
            ll k = n - r*i - g*j;
            if(n >= r*i + g*j && k % b == 0) ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
//AtCoder ABC066 A - ringring
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    vector<ll> t(3,0);
    cin>>t[0]>>t[1]>>t[2];
    sort(t.begin(),t.end());
    cout<<t[0]+t[1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef     long long               ll;
typedef     vector<ll>              vll;
#define     meme(s)                 memset(s,0,sizeof(s))
#define     rall(s)                 s.rbegin(),s.rend()
#define     i(x)                    scanf("%lld",&(x))
typedef     unordered_map<ll,ll>    mll;
#define     pb                      push_back
#define     in2(x,y)                i(x),i(y)
#define     EL                      cout<<'\n'
#define     fio                     ios_base::sync_with_stdio(false),cin.tie(NULL)
#define     all(s)                  s.begin(),s.end()
typedef     unordered_map<ll,vll>   circuit;
typedef     unordered_map<ll,bool>  is;
const ll    MOD=                    1e9+7;
#define     no                      cout<<"NO\n"
#define     yes                     cout<<"YES\n"
#define     fr(n,x)                 for(int n=0;n<x;n++)
#define     pf(x)                   printf("%lld\n",(x))
const ll    mx=                     2e7;
#define     segtree                 ll L=2*node,R=L+1,mid=(l+r)/2
#define     cs(n)                   printf("Case %lld: ",(n))
typedef     pair<ll,ll>             pll;
typedef     set<ll>                 sll;
#define     X                       first
#define     Y                       second
vector<bool>                        pr(mx,1);
void sv()                           {pr[1]=0;for(ll n=2;n*n<=mx;n++){if(pr[n]){for(ll k=2*n;k<mx;k+=n)pr[k]=0;}}}
ll bit[mx];
void up( ll ind,ll vl)            {while (ind<mx){bit[ind]+=vl;ind+=ind&(-ind);}} //BIT update
ll qr( ll ind)              {ll res=0;while(ind){res+=bit[ind];ind-=ind&(-ind);}return res;} //BIT query
#define T(j) ll t;i(t);for(ll j=1;j<=t;j++)



void solve()
{
    
    long double a,b;
    cin >>a >>b;
    a*=b;
    ll ans = a;
    cout <<ans<<endl;

}

int main() {
    //T(n)
    //cs(n),
    solve();

}


Measured memory_bytes: 5404
using System;

class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int Anum = int.Parse(input[0]);
    int N = int.Parse(input[1]);
    int C = int.Parse(input[2]);
	string[] B = Console.ReadLine().Split(' ');
    string[] A = new string[Anum];
    int Count = 0;
    int Sum = 0;
    
    for(int i = 0; i < Anum; i++)
    { 
      A = Console.ReadLine().Split(' ');
      for(int j = 0; j < N; j++)
      {
        Sum += int.Parse(A[j]) * int.Parse(B[j]);
      }
      if(Sum + C > 0) Count++;
      Sum = 0;
    }
    Console.WriteLine(Count);
  }
}

Measured memory_bytes: 13140
import java.util.Scanner;
import java.util.InputMismatchException;

class Main {
   public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] hset = new int[n];
      int i,j;
      int sum = 1;
      int count = 0;
      for (i = 0; i < n; i++) {
         hset[i] = sc.nextInt();
      }
      for (i=1; i < n; i++) {
         for (j=0; j<i; j++) {
            if (hset[j] <= hset[i]) {
               count = count + 1;
            }
         }
         if (count == i) {
            sum = sum + 1;
         }
         count = 0;
      }
      System.out.println(sum);
   }
}

Measured memory_bytes: 23764
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string str, s;
  map<char, int> cnt;
  while (cin >> str) {
    s += str;
  }
  rep(i, s.size()) {
    if (isupper(s[i]))
      s[i] = tolower(s[i]);
    cnt[s[i]]++;
  }

  rep(i, 26) cout << char('a' + i) << " : " << cnt['a' + i] << endl;

  return 0;
}


Measured memory_bytes: 3208
import bisect
n=int(input())
L=sorted(list(map(int,input().split())))
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    k=bisect.bisect_left(L,L[i]+L[j],j+1)-1
    ans+=k-j
print(ans)

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define endl "\n"
#define mod 1000000007
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
int main()
{
    int n;
    cin>>n;
    map<string,int>mp;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
        

    }
    int count=0;
    for(auto x:mp)
    {
       count++;
    }
   cout<<count;



}

Measured memory_bytes: 19176
package main

import "fmt"

type pair struct {
	x int
	y int
}

func top(n int) int {
	for i := 0; ; i++ {
		if n/10 == 0 {
			return n
		}
		n /= 10
	}
}

func main() {
	var n int
	fmt.Scan(&n)

	m := map[pair]int{}
	for i := 1; i <= n; i++ {
		t := top(i)
		b := i % 10
		m[pair{t, b}]++
	}

	ans := 0
	for j := 0; j < 10; j++ {
		for k := 0; k < 10; k++ {
			ans += m[pair{j, k}] * m[pair{k, j}]
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
N = int(input())
A = list(map(int,input().split()))

cap = 1000
stock = 0
for i in range(N-1):
  if A[i] < A[i+1]:
    stock += cap // A[i]
    cap %= A[i]    
  else:
    cap += stock * A[i]
    stock = 0
    
print(cap + stock * A[N-1])
    
    
  


Measured memory_bytes: 8916
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main{

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

	void run() {
		
		Scanner sc=new Scanner(System.in);
		
		int N=sc.nextInt();
		int W=sc.nextInt();
		
		int[] value=new int[N];
		int[] weight=new int[N];
		
		for(int i=0;i<N;i++) {
			value[i]=sc.nextInt();
			weight[i]=sc.nextInt();
		}
		
		//dp[i][w]=i番目までのアイテムと重さwのリュックを使った時の価値の最大値
		//dp[0][0]=0;
		
		int[][] dp= new int[N+1][W+1];//0オリジンだから、要素の数はN+1,W+1
		
		//N=3 0,1,2,3
		
		
		//アイテムを一つも使わなければ、価値は0
		for(int w=0;w<W+1;w++) {
			dp[0][w]=0;
		}
		
		
		for(int i=0;i<N;i++) {
			
			for(int w=0;w<W+1;w++) {
				
				//そもそも入る余地があるのかどうか
				if(w>=weight[i]) {
					dp[i+1][w]=Math.max(dp[i][w-weight[i]]+value[i],dp[i][w]);
				}else {
					dp[i+1][w]=dp[i][w];
				}
				
			}
			
		}
		
		System.out.println(dp[N][W]);
		
		sc.close();
		
		
	}
}






Measured memory_bytes: 30988
#include<stdio.h>
int main(void)
{ 
	int a,b,c,i,sum;
	scanf("%d %d %d",&a,&b,&c);
	sum=0;
	if(a==b&&b==c) printf("1\n");
	else if(a!=b&&b==c) printf("2\n");
	else if(a==b&&b!=c) printf("2\n");
	else if(a==c&&b!=c) printf("2\n");
	else printf("3\n");
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int w;
		while(a > b || b > c){
			if(a > b){
				w = a;
				a = b;
				b = w;
			}else if(b > c){
				w = b;
				b = c;
				c = w;
			}else if(a > b){
				w = a;
				a = b;
				b = w;
			}
		}
			System.out.println(a + " " + b + " " + c);
	}
}

Measured memory_bytes: 26092
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main() {
    string S;
    cin >> S;
    rep(i, S.size()) { S[i] = 'x'; }
    cout << S << endl;
    return 0;
}


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

int main(){
    int prev = -1, curr = 0, ret = 0;
    int n;
    cin >> n;

    for(int i = 0, x; i < n; ++i){
        cin >> x;

        if(x != prev){
            prev = x;
            ret += (curr / 2);
            curr = 1; }
        else ++curr; }

    ret += (curr / 2);
    cout << ret <<endl;
    return 0; }


Measured memory_bytes: 256
import math
t=0
X=int(input())
while True:
  if X==2:
    break
  t=0
  for i in range(2,math.ceil((X)**(1/2))+1):
    if X%i==0:
      break
    else:
      t+=1
  if t==math.ceil((X)**(1/2))-1:
    break
  X+=1
print(X)

Measured memory_bytes: 3060
#include <math.h>
#include <bits/stdc++.h>//一括で読み込み
typedef long long ll;
using namespace std;

struct flowEdge 
{
	ll to, cap, rev;
};

class Max_Flow
//最大流問題のDinic法。頂点数10^3,辺数10^4程度なら大体間に合う
//またはO(最大流*辺数)
{
public:
	vector<vector<flowEdge>> G;
	vector<ll>level, iter;

	void init(ll size_) 
  {
		G.resize(size_);
		level.resize(size_);
		iter.resize(size_);
	}

	void add_flowEdge(ll from, ll to, ll cap) 
  {
		G[from].push_back(flowEdge{to, cap, (ll)G[to].size()});
		G[to].push_back(flowEdge{from, 0, (ll)G[from].size()-1});
	}

	void bfs(ll s) 
  {
		for (ll i = 0; i < level.size(); i++) level[i] = -1;
		queue<ll> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty())
    {
			ll v = que.front(); que.pop();
			for (ll i = 0; i < G[v].size(); i++)
      {
				flowEdge &e = G[v][i];
				if (e.cap > 0 && level[e.to] < 0) 
        {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}

	ll dfs(ll v, ll t, ll f) 
  {
		if (v == t) return f;
		for (ll &i = iter[v]; i < G[v].size(); i++)
    {
			flowEdge &e = G[v][i];
			if (e.cap > 0 && level[v] < level[e.to])
      {
				ll 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;
	}

	ll max_flow(ll s, ll t)
  {
		ll flow = 0;
		for(;;)
    {
			bfs(s);
			if (level[t] < 0) return flow;
			for (int i = 0; i < iter.size(); i++) iter[i] = 0;
			ll f;
			while ((f = dfs(s, t, (1LL<<60))) > 0)
      {
				flow += f;
			}
		}
	}
};

ll n, a[100], answer;

vector<pair<ll, ll>> L;//最大流の頂点

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
  {
		cin >> a[i];
	}
  
  Max_Flow X;
  X.init(n+2);//頂点数で初期化
	for (int i = 0; i < n; i++) 
  {
    if(a[i] < 0) X.add_flowEdge(n, i, -a[i]);
    else
    {
      X.add_flowEdge(i, n+1, a[i]);
      answer += a[i];
    }
	}

  for(int i = 1; i <= n; i++)
  {
    int x = i*2;
    while(x <= n)
    {
      X.add_flowEdge(i-1, x-1, (1LL<<60));
      x += i;
    }
  }
  
	cout << (answer - X.max_flow(n, n+1)) << endl;//開始頂点から終了頂点までの最大流を求める
	return 0;
}

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

typedef long long ll;
const ll inf = 1e15;
ll mod = 1000000007;

ll modfact(ll a) {
    ll res = 1;
    while(a) {
        res = res * a % mod;
        a--;
    }
    return res;
}

int main() {
    ll n;
    scanf("%lld",&n);
    string s;
    cin>>s;
    string col(2*n,' ');
    col[0] = 'L';
    ll lnum = 1;
    ll rnum= 0;
    for (int i = 1; i < 2 * n; i++) {
        if (s[i] == s[i - 1]) {
            if (col[i - 1] == 'L') col[i] = 'R',rnum++;
            else col[i] = 'L',lnum++;
        } else {
            if (col[i - 1] == 'L') col[i] = 'L',lnum++;
            else col[i] = 'R',rnum++;
        }
    }

    if (lnum != rnum || s[0] == 'W' || s[2*n-1] == 'W') {
        printf("%d\n",0);
        return 0;
    }

    vector<ll> lnums(2 * n, 0);
    for (int i = 1; i < 2 * n; i++) {
        if (col[i - 1] == 'L') lnums[i] = lnums[i - 1] + 1;
        else lnums[i] = lnums[i - 1];
    }

    ll ans = 1;
    for (int i = 1; i < 2 * n; i++) {
        if (col[i] == 'R') ans = ans * (2 * lnums[i] - i) % mod;
    }
    ans = ans * modfact(n) % mod;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2308
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll H,W;
vector<string> S;


int drow[] = {-1,1};

bool onBoard(int row,int column){
    if(row>=0 && row<H && column>=0 && column<W){
        return true;
    }
    return false;
}

int UDP[2000][2000];
int DDP[2000][2000];
int DDfs(int row,int t){
    if(DDP[row][t] != -1){
        return DDP[row][t];
    }
    int retVal =1;
    int nt = t -1;
    if(onBoard(row,nt)){
        retVal += DDfs(row,nt);
    }
    DDP[row][t] = retVal;
    return retVal;
}
int UDfs(int row,int t){
    if(UDP[row][t] != -1){
        return UDP[row][t];
    }
    int retVal =1;
    int nt = t +1;
    if(onBoard(row,nt)){
        retVal += UDfs(row,nt);
    }
    UDP[row][t] = retVal;
    return retVal;
}
int LDP[2000][2000];
int RDP[2000][2000];
int LDfs(int t,int column){
    if(LDP[t][column] != -1){
        return LDP[t][column];
    }
    int retVal =1;
    int nt = t -1;
    if(onBoard(nt,column)){
        retVal += LDfs(nt,column);
    }
    LDP[t][column] = retVal;
    return retVal;
}
int RDfs(int t,int column){
    if(RDP[t][column] != -1){
        return RDP[t][column];
    }
    int retVal =1;
    int nt = t +1;
    if(onBoard(nt,column)){
        retVal += RDfs(nt,column);
    }
    RDP[t][column] = retVal;
    return retVal;
}

int main() {
    cin >> H >>W;
    S.resize(H);
    for(int i=0;i<H;i++){
        cin >> S[i];
    }
   
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(S[i][j] == '#'){
                UDP[i][j] = 0;
                DDP[i][j] =0;
                LDP[i][j] = 0;
                RDP[i][j] =0;
            }else{
               UDP[i][j] = -1;
                DDP[i][j] =-1;
                LDP[i][j] = -1;
                RDP[i][j] =-1;
            }
        }
    }
    int ans =0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(S[i][j] == '#'){
                continue;
            }
            ans = max(ans,UDfs(i,j)+ DDfs(i,j)+LDfs(i,j)+RDfs(i,j)-3);
            // cerr <<"i="<<i <<", j=" << j <<"val = "<<UDfs(i,j)+ DDfs(i,j)+LDfs(i,j)+RDfs(i,j)-3<<endl;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 66944
#include<stdio.h>
#include<string>
#include<iostream>

using namespace std;

int main(void){


int n,a,b;

cin >> n >> a >> b;

int k;

k = (b-a)%2;

if(k == 1){
  cout << "Borys" << endl;
}
else{
  cout << "Alice" << endl;
}
return 0;



}


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

int main() {
  int n , m;
  cin >> n >> m;
  int a[n];
  for(int i = 0; i < n; ++i)cin >> a[i];
  int sum = 0;
  for(int i = 0 ; i < n; ++i)sum += a[i];
  int u = 0;
  for(int i = 0; i < n; ++i){
      if(a[i]*4*m >= sum )++u;
  }
  if(u >= m)cout << "Yes" << endl;
  else cout << "No" << endl; 

}
  

  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
main() {int n,ans = 0,x[200000],y[200000];cin>>n;r(i,n) scanf("%d", &x[i]);r(i,n) scanf("%d", &y[i]);r(i,n)r(j,n)ans ^= x[i] + y[j];cout<<ans;}

Measured memory_bytes: 5168
def solve():
    N = int(input())
    F = []
    for _ in range(N):
        f = list(map(int,input().split()))
        F.append(f)
    
    P = []
    for _ in range(N):
        p = list(map(int,input().split()))
        P.append(p)
    
    ans = -float('inf')
    for i in range(1, 1 << 10):
        me = [0] * 10
        for j in range(10):
            if (i >> j) & 1:
                me[j] = 1

        c = []
        for j in range(N):
            cnt = 0
            for k in range(10):
                if F[j][k] == 1 and me[k] == 1:
                    cnt += 1
            
            c.append(cnt)
        
        now = 0
        for j in range(N):
            now += P[j][c[j]]
        
        ans = max(ans, now)
    
    print(ans)
    
if __name__ == '__main__':
    solve()


Measured memory_bytes: 74236
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    n = ni()
    l = na()

    ans = 0
    for i in range(n):
        for j in range(i + 1, n):
            for k in range(j + 1, n):
                f1 = l[i] + l[j] > l[k]
                f2 = l[j] + l[k] > l[i]
                f3 = l[k] + l[i] > l[j]
                f4 = l[i] != l[j] and l[j] != l[k] and l[k] != l[i]
                if f1 and f2 and f3 and f4:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9484
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

vector<int> a;

// nCkの偶奇
int parity(int n, int k) { return (n & k) == k; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    a.resize(n);
    for(int i = 0; i < n; i++) {
        a[i] = s[i] - '0';
        --a[i];
    }
    int oe = 0;
    for(int i = 0; i < n; i++) {
        oe ^= parity(n - 1, i) * a[i] % 2;
    }
    if(oe == 1) {
        cout << 1 << endl;
        return 0;
    }
    bool oneExist = false;
    for(int i = 0; i < n; i++) {
        if(a[i] == 1) {
            oneExist = true;
        }
    }
    if(oneExist) {
        cout << 0 << endl;
        return 0;
    }
    for(int i = 0; i < n; i++) {
        a[i] /= 2;
    }
    oe = 0;
    for(int i = 0; i < n; i++) {
        oe ^= parity(n - 1, i) * a[i] % 2;
    }
    cout << (oe ? 2 : 0) << endl;
}

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

int w,h;
string field[50];
int wb[2][50][50];

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

void dfs(int x,int y,int num){
	for(int i = 0;i < 4;i++){
		int nx = x + dx[i],ny = y + dy[i];
		if(nx >= 0 && nx < h && ny >= 0 && ny < w && field[nx][ny] == '.' && !wb[num][nx][ny]){
			wb[num][nx][ny] = 1;
			dfs(nx,ny,num);
		}
	}
}

int main(){
	while(cin >> w >> h,w){
		for(int i = 0;i < h;i++) cin >> field[i];
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				wb[0][i][j] = 0;
				wb[1][i][j] = 0;
			}
		}
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				if(field[i][j] == 'W') dfs(i,j,1);
				else if(field[i][j] == 'B') dfs(i,j,0);
			}
		}
		int a = 0,b = 0;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				if(wb[0][i][j] && !wb[1][i][j]) a++;
				else if(wb[1][i][j] && !wb[0][i][j]) b++;
			}
		}
		cout << a << " " << b << endl;
	}
}

Measured memory_bytes: 3184
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;



int main() {
	cout << fixed << setprecision(18);
	long long int n,r,p,c,x[120][120]={},mymin=INF,mymax=-INF,sum=0;
	cin>>n>>r;
	while(n!=0){
		mymin=INF;mymax=-INF,sum=0;
		for(int i=1;i<=n;i++){
			x[0][i]=n-i+1;
		}
		for(int i=1;i<=r;i++){
			cin>>p>>c;
			for(int j=1;j<=c;j++){
				x[i][j]=x[i-1][j+p-1];
			}
			for(int j=c+1;j<=c+p-1;j++){
				x[i][j]=x[i-1][j-c];
			}
			for(int j=c+p;j<=n;j++){
				x[i][j]=x[i-1][j];
			}
		}
		cout<<x[r][1]<<endl;
		cin>>n>>r;
	}
} 



Measured memory_bytes: 3164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

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

            int eatCount = Integer.parseInt(br.readLine());

            int sumFees = 0;
            for (int i = 1; i <= eatCount; i++) {
                if (i % 15 == 0) {
                    sumFees += 600;
                } else {
                    sumFees += 800;
                }
            }

            System.out.println(sumFees);

        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21204
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	a := make([]int, m)
	b := make([]int, m)
	set := make(map[int]struct{})
	for i := 0; i < m; i++ {
		fmt.Scan(&a[i], &b[i])
		if a[i] == 1 {
			set[b[i]] = struct{}{}
		}
	}
	f := false
	for i := 0; i < m; i++ {
		if _, ok := set[a[i]]; ok {
			if b[i] == n {
				f = true
				break
			}
		}
	}
	if f {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


Measured memory_bytes: 9600
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    res = 0
    for i in range(60):
        cnt = 0
        for a in A:
            cnt += (a >> i) & 1
        res += (cnt * (n - cnt)) % mod * (1 << i) % mod
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 50788
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	for(int i=a;i<=b;i++)
		if(i%n==0){
			cout<<"OK"<<endl;
			return 0;
		}
	cout<<"NG"<<endl;
	return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

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

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; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll n,q;
string s;
vector<char> t,d;

bool isOkL(ll mid){
  ll pos=mid;
  rep(i,q){
    if(s[pos]==t[i]){
      if(d[i]=='L'){
        pos--;
        if(pos<0) return true;
      }else{
        pos++;
        if(pos>=n) return false;
      }
    }
  }
  return false;
}

bool isOkR(ll mid){
  ll pos=mid;
  rep(i,q){
    if(s[pos]==t[i]){
      if(d[i]=='R'){
        pos++;
        if(pos>=n) return true;
      }else{
        pos--;
        if(pos<0) return false;
      }
    }
  }
  return false;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>q>>s;
  t.resize(q), d.resize(q);
  rep(i,q) cin>>t[i]>>d[i];
  
  ll ans=0;
  ll ok=-1, ng=n+1;
  while(abs(ok-ng)>1){
    ll m=(ok+ng)/2;
    if(isOkL(m)) ok=m;
    else ng=m;
  }
  ans=ok+1;
  
  ok=n, ng=-1;
  while(abs(ok-ng)>1){
    ll m=(ok+ng)/2;
    if(isOkR(m)) ok=m;
    else ng=m;
  }
  ans+=n-ok;
  ans=n-ans;
  chmin(ans,n);
  cout<<ans<<endl;
}


Measured memory_bytes: 976
# Ruined Square
X1,Y1,X2,Y2 = gets.chomp.split(" ").map(&:to_i)
result = []
result.push(X2-(Y2-Y1))
result.push(Y2+(X2-X1))
result.push(result[0]-(X2-X1))
result.push(result[1]-(Y2-Y1))
puts result.join(" ")

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

// const int maxn = 10020;
const int w[] = {0,2,5,5,4,5,6,3,7,6};

int n, m;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> m;
	vector<int> a(m);
	for (int i = 0; i < m; ++i)
		cin >> a[i];

	sort(a.begin(), a.end()); //// !!!!!!

	vector<string> f(n+1);
	vector<bool> ok(n+1);
	for (int i = 0; i < m; ++i)
		if (w[a[i]] <= n) {
			ok[w[a[i]]] = true;
			f[w[a[i]]] = to_string(a[i]);
		}

	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < m; ++j) {
			int cost = w[a[j]];
			if (i > cost && ok[i-cost] && f[i-cost].length()+1 >= f[i].length()) {
				string cur = to_string(a[j]) + f[i-cost];
				if (f[i].length() < cur.length() || (f[i].length() == cur.length() && f[i] < cur)) {
					ok[i] = true;
					f[i] = cur;
				}
			}
		}
		// printf("%d:%s\n", i, f[i].c_str());
	}
		
	cout << f[n] << endl;

	return 0;
}

Measured memory_bytes: 32512
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
using namespace std;

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

	int ans = 0;
	bool is_up = false;
	int cnt = 0;
	int prev = 0;
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		if (cnt == 0)
		{
			cnt++;
			prev = a;
		}
		else if (cnt == 1)
		{
			if (a != prev)
			{
				is_up = (a > prev);
				prev = a;
				cnt++;
			}
		}
		else
		{
			if (is_up)
			{
				if (a < prev)
				{
					ans++;
					cnt = 1;
					prev = a;
				}
				else
				{
					prev = a;
				}
			}
			else
			{
				if (a > prev)
				{
					ans++;
					cnt = 1;
					prev = a;
				}
				else
				{
					prev = a;
				}
			}
		}
	}

	cout << (ans + 1) << endl;
}


Measured memory_bytes: 764
#include <cstdio>
#include <cstdlib>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <map>
#include <cstring>

using namespace std;

int main(){
	long n;
	long long a[200000];
	long long b[200000];

	scanf("%ld",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}

	if(n%2==0){
		for(int i=0;i<=n/2;i++){
			b[i] = a[n-1-2*i];
		}
		for(int i=0;i<n/2;i++){
			b[n/2+i] = a[2*i];
		}
	}
	if(n%2==1){
		for(int i=0;i<(n+1)/2;i++){
			b[i] = a[n-1-2*i];
		}
		for(int i=1;i<(n+1)/2;i++){
			b[(n-1)/2+i] = a[2*i-1];
		}
	}

	for(int i=0;i<n;i++){
		printf("%lld ",b[i]);
	}
	printf("\n");

	return 0;
}


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

int main() {
	int n,a,b,sum,t[2001];
	
	for(int i=0;i<=1000;++i)t[i]=i+1;
	for(int i=1001;i<=2000;++i)t[i]=2001-i;
	
	while(cin>>n){
		sum=0;
		for(int i=0;i<=2000;++i){
			for(int j=0;j<=2000;++j){
				if(i+j==n)sum += t[i] * t[j];
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1168
#include <stdio.h>

int solve(int,int,int *,int);

int main()
{
  int i,n,A[20],q,m;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=1;i<=q;i++){
    scanf("%d",&m);
  if(solve(0,m,A,n))printf("yes\n");
  else printf("no\n");
  }
  return 0;
}

int solve(int i,int m,int A[],int n)
{
  int res;

  if(m == 0)return 1;
  if(i > n)return 0;

  res = solve(i + 1,m,A,n) || solve(i + 1,m - A[i],A,n);
  
  return res;
}

  



Measured memory_bytes: 2108
import std.stdio, std.string, std.conv, std.array, std.algorithm;
import std.uni, std.range, std.math, std.container, std.datetime;
import core.bitop;

immutable long MOD = 1_000_000_007;

void main(){
    char[] buf; readln(buf);
    auto input = buf.split.to!(int[]);
    auto N = input[0], K = input[1];
    readln(buf);
    auto D = buf.split;
    int ans = N;

    while(true){
        bool flag = true;
        foreach(d ; D){
            if(ans.to!string.canFind(d)){
                flag = false;
                break;
            }
        }

        if(flag){
            writeln(ans);
            return;
        }

        ++ans;
    }
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>> &pq) {return (ll)pq.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>, greater<T>> &pq) {return (ll)pq.size(); }
ll sz(string &s) {return (ll)s.size(); } 
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }
bool checkindex(ll i,ll n){ return (i < n && i >= 0); }

int main(){
    ll a,b,t;
    cin >> a >> b >> t;
    cout << t/a *b << endl;
    return 0;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
#define fop(i,m,n) for(int i=m; i<n; i++)
#define MOD 998244353
#define ios ios::sync_with_stdio(0), cin.tie(0)
 
using namespace std;

int main()
{
    ios;
    
    int n;
    cin >> n;
    int h[n][3];
    fop(i,0,n) cin >> h[i][0] >> h[i][1] >> h[i][2];
    
    int dp[n][3];
    fop(i,0,n){
        if(i == 0) fop(j,0,3) dp[i][j] = h[i][j];
        else{
            dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + h[i][0];
            dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + h[i][1];
            dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + h[i][2];
        }
    }
    
    int ans = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 5988
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#define int long long

using namespace std;

inline int read()
{
   int x=0,f=1;char ch=getchar();
   while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
   while (isdigit(ch)){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
   return x*f;
}

const int maxn = 2e5+1e2;

char s[maxn];
int n;
int a[maxn];
int ans;
int now;
signed main()
{
  scanf("%s",s+1);
  n=strlen(s+1);
  now=n;
  for (int i=n;i>=1;i--)
  {
  	 if (s[i]=='B')
  	 {
  	 	ans=ans+now-i;
  	 	now--;
  	 }
  }
  cout<<ans;
  return 0;
  
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
int GCD(int a, int b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
 
    int main(){
      int a,b,c,d;
      cin >> a >> b >> c >> d;
      bool flag=false;
      if(abs(a-c)<=d) flag=true;
      if(abs(a-b)<=d && abs(b-c)<=d) flag=true;
      if(flag) cout << "Yes" << endl;
      else cout << "No" << endl;
      return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
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 int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  string s; cin >> s;
  int ok = true;
  REP(i,s.size()) {
    if (s[i] == 'U' || s[i] == 'D') continue;
    if (i%2) {
      if (s[i] != 'L') ok = false;
    } else {
      if (s[i] != 'R') ok = false;
    }
  }

  Yes(ok);
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

signed main(){
    int n;
    cin >> n;
    vector<pii> v(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        v[i] = make_pair(b, a);
    }
    sort(all(v));
    int t = 0;
    rep(i, n) {
        // cout << t << " " << v[i].fi << " " << v[i].se << " " << t << endl;
        if(t + v[i].se > v[i].fi) {
            cout << "No" << endl;
            return 0;
        }
        t = t + v[i].se;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3328
import sys
input = sys.stdin.readline

N, C = (int(i) for i in input().split())

pp = [[0] * 100001 for i in range(C)]

for i in range(N):
    s, t, c = (int(i) for i in input().split())
    for j in range(s, t+1):
        pp[c-1][j] = 1

res = 0
for i in range(100001):
    cc = 0
    for j in range(C):
        if pp[j][i]:
            cc += 1
    res = max(res, cc)

print(res)


Measured memory_bytes: 65388
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> A >> B >> K;
  M=K;
  K=max((lli)0,K-A);
  if(K==0)cout << A-M << " " << B << endl;
  if(K!=0){
    M=K;
    K=max((lli)0,K-B);
    if(K==0)cout << 0 << " " << B-M << endl;
    else cout << 0 << " " << 0 << endl;
  }
}

Measured memory_bytes: 256
h,n=map(int,input().split())
a,b=[],[]
for i in range(n):
  aa,bb=map(int,input().split())
  a.append(aa)
  b.append(bb)
inf=float("inf")
dp=[[inf]*(h+1) for i in range(n+1)]
dp[0][0]=0
for i in range(n):
  for j in range(h+1):
    dp[i+1][j]=min(dp[i+1][j],dp[i][j])    
    dp[i+1][min(j+a[i],h)]=min(dp[i+1][j]+b[i],dp[i+1][min(j+a[i],h)])
print(dp[n][h])


Measured memory_bytes: 221196
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;

int main(){
  int N, K;
  cin >> N >> K;
  vector<double> p(N);
  rep(i,N) cin >> p[i];
  double s[200010];
  s[0]=0;
  rep(i,N) s[i+1]=s[i]+(p[i]+1)/2;
  double ans=0;
  rep(i,N-K+1) ans=max(ans,s[i+K]-s[i]);
  cout << setprecision(15) << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string s,t;

  cin >> s >> t ;

  sort(s.begin(),s.end());

  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());

   if (t>s) cout << "Yes" << endl;
   
   else cout << "No" << endl;
 
  return 0;
}

Measured memory_bytes: 256