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

using namespace std;

#define bug(x) cerr << #x << " = " << x << '\n'
#define ll     long long
#define maxn   500005
#define ar3    array<int, 3>

int n, k;
int block;

int a[maxn], ret[maxn], d[maxn];

ar3 b[maxn];

bool cmp (ar3 a, ar3 b) {
        if(a[0] / block != b[0] / block)
            return a[0] < b[0];
        return a[1] < b[1];
}

int main() {
        //freopen(".inp","r",stdin);
        //freopen(".out","w",stdout);

        ios_base::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);

        int cnt = 0;

        auto qpush =[&] (int x) {
                if(d[x] == 0) cnt ++;
                d[x] ++;
        };

        auto qpop =[&] (int x) {
                if(d[x] == 1) cnt --;
                d[x] --;
        };

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

        for(int i = 1; i <= n; ++ i)
            cin >> a[i];

        for(int i = 1; i <= q; ++ i)
            cin >> b[i][0] >> b[i][1], b[i][2] = i;

        block = sqrt(n);
        sort(b + 1, b + q + 1, cmp);

        int r = 0, l = 1;
        for(int i = 1; i <= q; ++ i)
        {
            while(r < b[i][1]) ++ r, qpush(a[r]);
            while(l > b[i][0]) -- l, qpush(a[l]);
            while(r > b[i][1]) qpop(a[r]), -- r;
            while(l < b[i][0]) qpop(a[l]), ++ l;
            ret[b[i][2]] = cnt;
        }

        for(int i = 1; i <= q; ++ i)
            cout << ret[i] << endl;
}


Measured memory_bytes: 15524
#include<iostream>
using namespace std;
int main() {
	int N, M, X;
	int A[101];
	int count[101];
	int sum0 = 0;
	int sumN = 0;
	cin >> N >> M >> X;
	for (int i = 0; i <= N; ++i) {
		count[i] = 0;
	}
	for (int i = 0; i < M; ++i) {
		cin >> A[i];
		if (A[i] < X) {
			sum0++;
		}
		else {
			sumN++;
		}
	}

	if (sum0 >= sumN) {
		cout << sumN;
	}
	else {
		cout << sum0;
	}
	return 0;
}


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

int main()
{
    string s;
    cin>>s;
    if( s[0] != 'A')
    {
        cout<<"WA";
        return 0;
    }
    int count =0;
    for(int i=2;i<=s.length() -2;i++)
    {
        if(s[i] =='C' )
            count++;

    }
    if( count != 1)
    {
        cout<<"WA";
        return 0;
    }
    for(int i=0;i<s.length();i++)
    {
        if( s[i] <96 && (s[i]!='A' && s[i] != 'C'))
        {
            cout<<"WA";
            return 0;
        }
    }
    cout<<"AC";
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;

//	データセットの終わりを処理したら0,
//	それ以外なら1を返す関数
//	問題を解く部分
int solve();

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

int solve() 
{
	int R0,W0,C,R;
	cin >> R0 >> W0 >> C >> R;
	
	//	データセットの終わり
	if(!(R0|W0|C|R)) { return 0; }
	
	//	(R0 + XR) / W0 >= C　にしたいから
	//	R0 + XR >= C*W0
	//	X*R >= C*W0 - R0
	//	X >= (C*W0 - R0) / R
	//	Xは
	//	[1] C*W0 - R0がRで割り切れるなら(C*W0 - R0) / R
	//	[2] C*W0 - R0がRで割り切れないなら[(C*W0 - R0) / R]の整数部分+1
	
	int ans;
	
	if( R0 >= W0 * C )
	{ 
		ans = 0;
	} else if( ( C * W0 - R0 ) % R == 0 ) 
	{
		ans = ( C * W0 - R0 ) / R;
	} else 
	{
		ans = ( C * W0 - R0 ) / R + 1;
	}
	
	cout << ans << endl;
	
	return 1;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    int answer = 1;
    for (int i = 0; i < N; ++i) {
        if (answer * 2 <= answer + K) {
            answer *= 2;
        } else {
            answer += K;
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef pair <ll, ll> pll ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

ll n, p, ans = 1ll ;
vector <pll> v ;

signed main() {
	cin >> n >> p ;
	for (int i = 2; i <= sqrt(p); i++)
	if (p % i == 0){
		pll x = mp(i, 0) ;
		while (p % i == 0) x.se++, p /= i ;
		v.pb(x) ;
	}
	if (p > 1) v.pb(mp(p, 1)) ;
	for (int i = 0; i < siz(v); i++)
	if (v[i].se / n >= 1)
	for (int j = 1; j <= v[i].se / n; j++) ans = ans * v[i].fi ;
	printf("%lld\n", ans) ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import Counter


def read():
    N, M = map(int, input().strip().split())
    XYZ = []
    for i in range(M):
        x, y, z = map(int, input().strip().split())
        XYZ.append((x, y, z))
    return N, M, XYZ


class UnionFind():
    """Union-Find木の実装
    """

    def __init__(self, n):
        self.n = n
        self.parent = [x for x in range(n)]

    def find(self, x):
        """要素xが所属するグループを返す
        """
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def union(self, x, y):
        """要素x, yがそれぞれ所属するグループを併合する
        """
        x = self.find(x)
        y = self.find(y)
        if x > y:
            x, y = y, x
        self.parent[y] = x

    def parents(self):
        return [self.find(x) for x in range(self.n)]


def solve(N, M, XYZ):
    uf = UnionFind(N)
    for x, y, z in XYZ:
        uf.union(x-1, y-1)
    C = Counter(uf.parents())
    return len(C)


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


Measured memory_bytes: 38408
#include "bits/stdc++.h"
using namespace std;

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

string s;
int n;

int main(){
  cin>>n>>s;
  LL ret = 0;
  int ri = n-1;
  REP(i,n){
    if(s[i] == 'W'){
      while(s[ri] != 'R' && i != ri){
        ri--;
      }
      if(i>=ri)break;
      ret++;
      ri--;
    }
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
#define INF 1<<21
using pii = std::pair<int,int>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    long long N, K;
    long long count = 0;
    std::cin >> N >> K;
    std::vector<pii> a(N+1);
    a[0].first = a[0].second = 0;
    for (int i = 1; i <= N; i++) {
        std::cin >> a[i].first >> a[i].second;
    }
    SORT(a);
    for (int i = 1; i <= N; i++) {
        
        int b = a[i].second;
        K -= b;
        if (K<=0) {
            std::cout << a[i].first << std::endl;
            return 0;
        }
    }
    return 0;
}

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

int n,s,ans = 0;

void dfs(int i,int sum,int num){
    
    if(num == n){
        
        if(sum == s){
            ans++;
        }
        return;
    }
    if(i == 10){
        return;
    }
    //not including i
    dfs(i+1,sum,num);
    //including i
    dfs(i+1,sum + i,num+1);
}

int main(){

    while(cin >> n >> s){
        if(n == 0 && s == 0){
            break;
        }
        dfs(0,0,0);
        cout << ans << endl;
        ans = 0;
    }

    return 0;
}

Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		String ans = "Three";

		for (int i = 0; i < n; i++) {
			String m = sc.next();
			if (m.equals("Y")) {
				ans = "Four";
			}
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 23252
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
//#define MOD 1000000007
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/

int n,k;
const int N=2e5+10;
int ar[N];
int vis[N];
int32_t main()
{
	MEMS(vis,-1);
	fastio();
	cin>>n>>k;
	
	for(int i=1;i<=n;i++)
	{
		cin>>ar[i];
	}
	int counter=0;
	int cur=1;
	while(vis[cur]==-1)
	{
		vis[cur]=counter++;
		cur=ar[cur];
	}
	if(k>=vis[cur])
	{
		tr(vis[cur],(k-vis[cur]),(counter-vis[cur]));
		k=vis[cur]+(k-vis[cur])%(counter-vis[cur]);
	}
	tr(k);
	cur=1;
	for(int i=0;i<k;i++)
	{
		cur=ar[cur];
	}
	cout<<cur<<endl;
}


Measured memory_bytes: 6788
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF=1001001001001001LL;
int N,M;
int A[200][200],B[200][200];
int dp[2][200];
signed main(){
    while(cin>>N>>M,N||M){
        fill_n(*A,200*200,INF);
        fill_n(*B,200*200,INF);
        for(int i=0;i<N;i++){
            A[i][i]=0;
            B[i][i]=0;
        }
        for(int i=0;i<M;i++){
            int a,b,c;
            char d;
            cin>>a>>b>>c>>d;
            a--;b--;
            if(d=='L')A[a][b]=A[b][a]=min(A[a][b],c);
            else B[a][b]=B[b][a]=min(B[a][b],c);
        }

        for(int k=0;k<N;k++){
            for(int i=0;i<N;i++){
                for(int j=0;j<N;j++){
                    A[i][j]=min(A[i][j],A[i][k]+A[k][j]);
                    B[i][j]=min(B[i][j],B[i][k]+B[k][j]);
                }
            }
        }

        int R;cin>>R;
        int prev;cin>>prev;prev--;
        fill_n(*dp,2*200,INF);
        dp[1][prev]=0;

        for(int i=1;i<R;i++){
            int cur;cin>>cur;cur--;
            for(int j=0;j<N;j++){
                for(int k=0;k<N;k++){
                    if(j!=k)dp[(i+1)&1][j]=min(dp[(i+1)&1][j],dp[i&1][k]+A[prev][k]+B[k][j]+A[j][cur]);
                    else dp[(i+1)&1][j]=min(dp[(i+1)&1][j],dp[i&1][j]+A[prev][cur]);
                }
            }
            for(int j=0;j<N;j++)dp[i&1][j]=INF;
            prev=cur;
        }

        int mi=INF;
        for(int i=0;i<N;i++)mi=min(mi,dp[R&1][i]);

        cout<<mi<<endl;
    }
    return 0;
}

Measured memory_bytes: 1788
N = int(input())
L = []
for x in range(N):
    L.append(input())
#print(L)
M = {}
for x in L:
    if((x in M) != True):
        M[x] = 1
    else:
       # print(M[x])
        M[x] = M[x] + 1
#print(M)
max_m = max(M.values())
##print(M)
ans = []
for x,y in M.items():
    if(max_m == y):
        ans.append(x)
#print(ans)
ans.sort()
for x in ans:
    print(x)

Measured memory_bytes: 35220
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

void solve(void)
{
  int H, N; cin >> H >> N;
  vector<int> A(N);
  for(auto& a : A) cin >> a;
  auto sum = boost::accumulate(A, 0);
  auto ans = sum >= H;
  cout << (ans ? "Yes" : "No") << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
using Graph = vector<vector<pair<int, int> > >;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	int N, M;
	cin >> N;
	map<string,int> s;
	for (int i = 0; i < N; i++) {
		string p; cin >> p;
		if (s[p])s[p]++;
		else s[p] = 1;
	}
	cin >> M;
	map<string, int> t;
	for (int i = 0; i < M; i++) {
		string q; cin >> q;
		if (t[q])t[q]++;
		else t[q] = 1;
	}
	int maxval = 0;
	for (map<string,int>::iterator i = s.begin(); i != s.end(); i++) {
		pair<string,int> cm = *i;
		if (t.find(cm.first) != t.end())cm.second -= t[cm.first];
		maxval = max(maxval, cm.second);
	}
	cout << maxval << endl;





	return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
names = [name for name in s if name[0] in 'MARCH']
counter = Counter([name[0] for name in names])

from itertools import combinations
ans=0
for x,y,z in combinations(counter.values(), 3):
    ans+=x*y*z
    
print(ans)

Measured memory_bytes: 11636
n = int(input())

edge = []
num_list = []

for i in range(n):
    a, b = map(int, input().split())
    edge.append([a, b])
    num_list.append(a)
    num_list.append(b)

num_list.sort()
K = num_list[n-1]

ab = []
ax = []
xb = []

for i in range(n):
    a, b = edge[i]
    if a <= K and b <= K:
        ab.append(edge[i])
    elif a <= K:
        ax.append(edge[i])
    elif b <= K:
        xb.append(edge[i])

if len(ab) > 0:
    ans = sum(num_list[:n])
elif len(ax) == n or len(xb) == n:
    ans = sum(num_list[:n])
else:
    yabai_edge = num_list[n-1:n+1]
    if edge.count(yabai_edge) + edge.count(yabai_edge[::-1]) == 0:
        diff = num_list[n] - num_list[n-1]
    elif len(ax) == 1 and edge.count(yabai_edge) == 1:
        diff = num_list[n] - num_list[n-1]
    elif len(xb) == 1 and edge.count(yabai_edge[::-1]) == 1:
        diff = num_list[n] - num_list[n-1]
    else:
        diff = min(num_list[n+1]-num_list[n-1], num_list[n]-num_list[n-2]) 
    ans = sum(num_list[:n]) + diff

print(ans)




Measured memory_bytes: 78424
import Data.IORef
import Control.Monad
 
main :: IO()
main = getLine >> getContents >>= solve.(map $! read).lines >>= print
 
solve :: [Int] -> IO Int
solve (x:y:xs) = do
                  a <- newIORef (y - x)
                  b <- newIORef (min x y)
                  forM_ xs $ \z -> do
                    a' <- readIORef a
                    b' <- readIORef b
                    when (z - b' > a') $ writeIORef a (z - b')
                    when (z < b')      $ writeIORef b z
                  readIORef a

Measured memory_bytes: 5548
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#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()
{
	int n, t;
	cin >> n;
	map<int, int> mp;
	ll sum = 0;
	rep(i, n) {
		cin >> t;
		mp[t]++;
		sum += t;
	}
	int q, b, c;
	cin >> q;
	rep(i, q) {
		cin >> b >> c;
		sum += (c - b)*mp[b];
		mp[c] += mp[b];
		mp[b] = 0;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 7928
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int n, m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2<< endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	int team[200][3] = {{0}};
	int a,b;
	int cnt = 0;
	for(int i= 1;scanf("%d,%d",&a,&b);i++){
	    if(a+b==0)break;
        team[i][0] = a,team[i][1] = b;
        cnt++;
	}
	for(int i = 1; i <= cnt; i++){
        for(int j = i; j <= cnt; j++){
            if(team[i][1] < team[j][1]){
                swap(team[i][0],team[j][0]);
                swap(team[i][1],team[j][1]);
            }
        }
	}
	team[1][2] = 1;
	int rank = 1;
	for(int i = 2; i <= cnt; i++){
        if(team[i-1][1] > team[i][1])rank++;
        team[i][2] = rank;
	}
	int n;
	while(cin >> n){
	    int ans = 0;
        for(int i = 1; i <= cnt; i++){
            if(team[i][0] == n){
                ans = team[i][2];
                break;
            }
        }
        cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> s(n);
    rep (i, n) cin >> s[i];
    vector<bool> dp(101 + n * 100);
    dp[0] = true;
    rep (i, n) {
        reprev (j, 1 + n * 100) {
            if (dp[j]) dp[j + s[i]] = true;
        }
    }
    int ans = 0;
    reprev(i, 101 + n * 100) {
        if (i % 10 && dp[i]) chmax(ans, i);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool ispalin(string s)
{
    ll n=s.length();
    bool fg=true;
	    for(int i=0;i<n/2;i++)
            if(s[i]!=s[n-i-1])
            fg=false;
            return fg;
}
int main()
{
	ll t;
	t=1;
	for(int x=1;x<=t;x++)
	{
	    ll n;
	    cin>>n;
	    ll arr[n];
	    map<ll,ll> mp;
	    set<ll> s;
	    for(int i=0;i<n;i++)
	    {
	        cin>>arr[i];
	        s.insert(arr[i]);
	        mp[arr[i]]++;
	    }
	    ll ans=0;
	    auto it=s.begin();
	    while(it!=s.end())
        {
            ll p=mp[(*it)];
            p=(p*(p-1))/2;
            ans+=p;
            it++;
        }
        for(int i=0;i<n;i++)
        {
            ll f=mp[arr[i]];
            ll aa=ans;
            aa=aa-(f*(f-1))/2;f--;
            aa=aa+(f*(f-1))/2;
            cout<<aa<<"\n";
        }
	}
}


Measured memory_bytes: 17024
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
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;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  string s;
  cin>>s;
  int sum=0;
  rep(i,3){
    sum+=s[i]-'a';
  }
  string ans="No";
  if(sum==3)ans="Yes";
  cout(ans);
  return 0;
}

Measured memory_bytes: 125568
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#define INF 0x3f3f3f3f
using namespace std;
vector <tuple<int,int,int>>relation;
set<int> pa;
set<int> pb;
int a;
int main(){
    scanf("%d",&a);
    a=a+a*a+a*a*a;
    printf("%d",a);
}

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

using namespace std;

int main(){
    int M, K;
    cin >> M >> K;
    if(K>=1<<M) cout << -1 << endl;
    else if(K==0){
        for(int i=0; i<(1<<M)-1; ++i){
            cout << i << " " << i << " ";
        }
        cout << (1<<M)-1 << " " << (1<<M)-1 << endl;
    }
    else if(M==1) cout << -1 << endl;
    else{
        for(int i=0; i<(1<<M); ++i){
            if(i!=K) cout << i << " ";
        }
        cout << K << " ";
        for(int i=(1<<M)-1; i>=0; --i){
            if(i!=K) cout << i << " ";
        }
        cout << K << endl;
    }
}


Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>

using namespace std;

int roop(int j)
{
	int ans=1;
	for(int i=0;i<j;i++)
	{
		ans*=10;
	}
	return ans;
}

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
	int date[8];
	long long int max=0,min=0;
		char c[10];
		scanf("%s",c);
		for(int j=0;j<8;j++)
		{
			date[j]=c[j]-'0';
		}
		sort(date,date+8);
		for(int i=0;i<8;i++)
		{
			min+=date[i]*roop(7-i);
			max+=date[7-i]*roop(7-i);
		}
		printf("%ld\n",max-min);
	}
	return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> void print(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void print(H head, T ...tail) { cout << head << " "; print(tail...); }

ll euclid(ll a, ll b, ll &x, ll &y) {
	if (b) { ll d = euclid(b, a % b, y, x);
		return y -= a/b * x, d; }
	return x = 1, y = 0, a;
}

const ll mod = 998244353; // change to something else
struct Mod {
	ll x;
	Mod() : x(0) {}
	Mod(ll xx) : x(xx) {}
	Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
	Mod operator-(Mod b) { return Mod((x - b.x + mod) % mod); }
	Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
	Mod operator/(Mod b) { return *this * invert(b); }
	Mod invert(Mod a) {
		ll x, y, g = euclid(a.x, mod, x, y);
		assert(g == 1); return Mod((x + mod) % mod);
	}
	Mod operator^(ll e) {
		if (!e) return Mod(1);
		Mod r = *this ^ (e / 2); r = r * r;
		return e&1 ? *this * r : r;
	}
};

Mod fact[200005], invfact[200005];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

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

	fact[0] = Mod(1), invfact[0] = Mod(1);
	rep(i, 1, 200005) {
		fact[i] = fact[i - 1] * i;
		invfact[i] = invfact[i - 1] / i;
	}

	if (m == 1) {
		if (k == n - 1) {
			cout << 1 << endl;
		} else {
			cout << 0 << endl;
		}
		return 0;
	}

	auto ncr = [&](const int n, const int r) -> Mod {
		return fact[n] / fact[r] / fact[n - r];
	};
	auto calc = [&](const int k) -> Mod {
		return ncr(n - 1, k) * Mod(m) * (Mod(m - 1) ^ (n - 1 - k));
	};

	// from here, m >= 2
	Mod ans;
	rep(i, 0, k + 1) ans = ans + calc(i);

	cout << ans.x << endl;
}


Measured memory_bytes: 6780
'''input
3 3
.#.
#..
.#.
'''
# A coding delight
from sys import stdin, stdout
import gc
gc.disable()
input = stdin.readline
from collections import deque


def mp(arr):
	arr = map(str, arr)
	return ' '.join(arr)


def bfs(source):
	myq = deque()
	myq.append(source)
	visited = dict()
	visited[mp(source)] = True
	dist = -1
	while len(myq) > 0:
		temp = deque()
		dist += 1
		while len(myq) > 0:
			x, y  = myq.popleft()
			if x - 1 >= 0:
				if maze[x - 1][y] != '#' and mp([x - 1, y]) not in visited:
					visited[mp([x -1, y])] = True
					temp.append([x - 1, y])
			if x + 1 < n:
				if maze[x + 1][y] != '#' and mp([x + 1, y]) not in visited:
					visited[mp([x + 1, y])] = True
					temp.append([x + 1, y])
			if y - 1 >= 0:
				if maze[x][y - 1] != '#' and mp([x, y - 1]) not in visited:
					visited[mp([x, y - 1])] = True
					temp.append([x, y - 1])
			if y + 1 < m:
				if maze[x][y + 1] != '#' and mp([x, y + 1]) not in visited:
					visited[mp([x, y + 1])] = True
					temp.append([x, y + 1])
		myq = temp
	return dist		


# main starts
n, m = list(map(int, input().split()))
maze = []
for _ in range(n):
	state = list(input().strip())
	maze.append(state)

# from random import randint
# for _ in range(1000):
# maze = []
# n = randint(1, 20)
# m = randint(1, 20)
# for i in range(n):
# 	temp = []
# 	for j in range(m):
# 		k = randint(1, 2)
# 		if k == 1:
# 			temp.append('.')
# 		else:
# 			temp.append('#')
# 	maze.append(temp)

ans = 0
for i in range(n):
	for j in range(m):
		if maze[i][j] != '#':
			first = [i, j]
			ans = max(ans, bfs(first))
print(ans)

Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> x(N), y(N);
    vector<Pll> P(N);
    rep(i,N){
        cin >> x[i] >> y[i];
        //P[i] = Pll(x[i],y[i]);
    }
    //sort(P.begin(), P.end());
    ll Md = -1;
    ll md = 1e18+1;
    rep(i,N){
        ll tmp = x[i] + y[i];
        cmax(Md, tmp);
        cmin(md, tmp);
    }
    ll ans = 0;
    cmax(ans, Md - md);
    Md = -1;
    md = 1e18+1;
    rep(i,N){
        ll tmp = 1e9+1 - x[i] + y[i];
        cmax(Md, tmp);
        cmin(md, tmp);
    }
    cmax(ans, Md - md);
    Md = -1;
    md = 1e18+1;
    rep(i,N){
        ll tmp = 1e9+1 - x[i] + 1e9+1 - y[i];
        cmax(Md, tmp);
        cmin(md, tmp);
    }
    cmax(ans, Md - md);
    Md = -1;
    md = 1e18+1;
    rep(i,N){
        ll tmp = x[i] + 1e9+1 - y[i];
        cmax(Md, tmp);
        cmin(md, tmp);
    }
    cmax(ans, Md - md);
    cout << ans << endl;
    //cout << Md - md << endl;
    /*ll L = 0;
    ll R = 1e9+1;
    rep(aaa,500){
        ll mid = (L+R)/2;

    }

    cout <<  << endl;*/
}

Measured memory_bytes: 9584
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => Convert.ToDouble(x)).ToArray();
            var sum = 0.0;
            foreach(var a in input)
            {
                sum += a;
            }
            Console.WriteLine(Math.Ceiling(sum / input.Length));
        }
    }
}


Measured memory_bytes: 13524
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        DJSet set = new DJSet(n);
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            set.union(a, b);
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int x = set.countElement(i);
            if(ans < x) ans = x;
        }
        System.out.println(ans);
        sc.close();

    }

}

class DJSet {
    /**
     * 各要素の親を保持する配列。
     * 自信が根である要素は負の数を持つ。
     * （負の数の場合、絶対値がその集合の要素数）
     */
    public int[] upper;

    /**
     * コンストラクタ。
     * @param n 対象となる要素数
     */
    public DJSet(int n) {
        upper = new int[n];
        Arrays.fill(upper, -1);
    }

    /**
     * 要素xが含まれる集合のrootを求める。
     * rootを求める過程で経路圧縮しrootが親になるようにする。
     * @param x 要素x
     * @return 要素xが含まれる集合のroot
     */
    public int root(int x) {
        return upper[x] < 0 ? x : (upper[x] = root(upper[x]));
    }

    /**
     * 要素xと要素yが同じ集合か判定する。
     * @param x 要素x
     * @param y 要素y
     * @return 要素xと要素yが同じ集合であればtrue、そうでなければfalseを返す。
     */
    public boolean same(int x, int y) {
        return root(x) == root(y);
    }

    /**
     * 要素xと要素yを含むそれぞれの集合を合併する。
     * 要素数の多い集合のrootを残し、少ないほうのrootをその下に合併する。
     * @param x 要素x
     * @param y 要素y
     * @return 要素xと要素yを含むそれぞれの集合を合併できたらtrue、もともと同じ集合で合併しなかったらfalseを返す。
     */
    public boolean union(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (upper[y] < upper[x]) {
                int t = x;
                x = y;
                y = t;
            }
            upper[x] += upper[y];
            upper[y] = x;
        }
        return x != y;
    }

    /**
     * 集合の数を数える。
     * @return 集合の数
     */
    public int countSet() {
        int c = 0;
        for (int u : upper) {
            if (u < 0)
                c++;
        }
        return c;
    }

    /**
     * 要素ｘが含まれる集合の要素数を数える。
     * @param x 要素ｘ
     * @return 要素ｘが含まれる集合の要素数
     */
    public int countElement(int x) {
        return upper[root(x)] * -1;
    }
}


Measured memory_bytes: 59904
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
 
#define SENTINEL (1000000001)
#define putChar(c) ; *p = (char)(c); ++p;
 
int c = 0;
int S[500000];
int L[250001];
int R[250001];
char str[5500010];
char *p = str;
 
int getNum(void) {
    int n = 0;
    while ((*p >= '0') && (*p <= '9')) {
        n = n * 10 + (int)(*p - '0');
        ++p;
    }
    ++p;
    return n;
}
 
void putNum(int n) {
    int d;
    if (n < 10) {
        putChar( '0' + n );
        return;
    }
    d = n / 10;
    if (d) putNum(d);
    putChar( '0' + (n % 10) );
}
 
void Merge(int A[], int left, int mid, int right) {
    int i = 0, j = 0, k = left;
    int n1 = mid - left;
    int n2 = right - mid;
    memcpy(L, A + left, n1 * sizeof(int));
    memcpy(R, A + mid, n2 * sizeof(int));
    L[n1] = R[n2] = SENTINEL;
    for (; k < right; ++k) {
        if (L[i] <= R[j]) {
            A[k] = L[i];
            ++i;
        } else {
            A[k] = R[j];
            ++j;
        }
    }
}
 
void MergeSort(int A[], int left, int right) {
    int mid;
    if (left + 1 < right) {
        mid = (left + right) >> 1;
        MergeSort(A, left, mid);
        MergeSort(A, mid, right);
        Merge(A, left, mid, right);
        c += right - left;
    }
}
 
int main(void) {
    register int i;
    int n;
     
    fread(str, 1, 5500000, stdin);
    n = getNum();
    for (i = 0; i < n; ++i) {
        S[i] = getNum();
    }
     
    MergeSort(S, 0, n);
     
    --n;
    p = str;
    for (i = 0; i < n; ++i) {
        putNum(S[i]);
        putChar( ' ' );
    }
    putNum(S[i]);
    putChar( '\n' );
     
    putNum(c);
    putChar( '\0' );
     
    puts(str);
 
    return 0;
}

Measured memory_bytes: 9212
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def find_negative_loop(s,n,w,es):
  # s: start
  # n: number of nodes
  # w: number of edges
  # es[i]: from, to, cost
  
  # d: shortest dist of s -> i
  inf = float('inf')
  d = [inf for _ in range(n)]
  d[s] = 0
  for i in range(2*n):
    for j in range(w):
      p, q, r = es[j]
      if d[p] != inf and (d[q] > d[p] + r):
        d[q] = d[p] + r
        if i >= n:
          d[q] = (-1)*inf
    if i == n-1:
      temp = d[-1]
  return temp, d[-1]
         

n, w, p = map(int, input().split())
es = []
for i in range(w):
  x, y, z = map(int, input().split())
  es.append([x-1, y-1, (z-p)*(-1)])
  
temp, d = find_negative_loop(0, n, w ,es)
if temp == d:
  print(min(0, d)*(-1))
else:
  print('-1')

Measured memory_bytes: 46172
#include<bits/stdc++.h>
using namespace std;
int n,x,cnt,M;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		cnt+=x;
		M=max(M,x);
	}
	cnt-=M;
	if(M>=cnt)
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int h,w; cin >> h >> w;
    vector<string> S(h);
    rep(i,h) cin >> S[i];

    const int x[8] = {-1,0,1,-1,1,-1,0,1};
    const int y[8] = {1,1,1,0,0,-1,-1,-1};

    rep(i,h){
        rep(j,w){
            if(S[i][j] == '#') continue;

            int cnt = 0;
            for(int k = 0; k < 8; k++){
                const int ni = i + x[k];
                const int nj = j + y[k];

                if(ni < 0 || h <= ni) continue;
                if(nj < 0 || w <= nj) continue;
                if(S[ni][nj] == '#') cnt++;
            }
            char c = cnt + '0';
            S[i][j] = c;
        }
    }

    rep(i,h) cout << S[i] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main() {
  int N;
  cin>>N;
  vector<pair<int,int>>A(N);
  for (int i(0);i<N;i++){
    int a;
    cin>>a;
    A[i]=make_pair(a,i+1);
  }
  sort(A.begin(),A.end());
  for (int i(0);i<N;i++){
    cout << A[i].second << " ";
  }
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <cstdlib>
#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() {
    int n, m;
    int sum = 0;
    cin >> n  >> m;
    rep(i, m) {
        int a;
        cin >> a;
        sum += a;
    }
    if (sum > n) {
        cout << "-1" << endl;
    } else {
        cout << n - sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std; 
int main(){
    string k;
    int d;
    cin>>k>>d;
    //dp[i][j][k] represents how many numbers with i digits have
    //their sum of digits modulo d equal to j and whether the 
    //bound on the ith digit is tight or not, if it's not tight
    //the current digit can take numbers from 0 to 9 else it 
    //can digits only from 0 to k[i]
    int dp[k.size()+1][d][2];  
    memset(dp,0,(k.size()+1)*d*sizeof(dp[0][0]));
    dp[0][0][0] = 1;
    dp[0][0][1] = 0;
    for(int i=1;i<=k.size();i++){
        for(int j=0;j<d;j++){
            for(int l=0;l<=9;l++){
                dp[i][(j+l)%d][1]=(dp[i][(j+l)%d][1]+dp[i-1][j][1])%mod;
                if(l<k[i-1]-'0')
                    dp[i][(j+l)%d][1]=(dp[i][(j+l)%d][1]+dp[i-1][j][0])%mod;
                
            }
            dp[i][(j+(k[i-1]-'0'))%d][0]=(dp[i][(j+(k[i-1]-'0'))%d][0]+dp[i-1][j][0])%mod;
        }
    }
    // cout<<dp[k.size()][0][0]<<" "<<dp[k.size()][0][1]<<"\n";
    int ans = (dp[k.size()][0][0]+dp[k.size()][0][1]-1+mod)%mod;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 8064
import sys
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall as f
def main():
  t=np.fromstring(sys.stdin.buffer.read(),int,sep=' ')
  n,m,l=t[:3]
  m=m*3+3
  print('\n'.join((f(f(csr_matrix((t[5:m:3],(t[3:m:3],t[4:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n).astype(int)%n-1).astype(str).tolist()))
main()

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

int main(void){
  int m, f, r;

  while(true){
    cin >> m >> f >> r;

    if(m == -1 && f == -1 && r == -1){
      break;
    }

    if(m == -1 || f == -1){
      cout << "F" << endl;
    }else if(m + f >= 80){
      cout << "A" << endl;
    }else if(m + f >= 65){
      cout << "B" << endl;
    }else if(m + f >= 50){
      cout << "C" << endl;
    }else if(m + f >= 30){
      if(r >= 50){
        cout << "C" << endl;
      }else{
        cout << "D" << endl;
      }
    }else{
      cout << "F" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	ll q,h,s,d,n;
	ll a,b,c;
	cin >> q >> h >> s >> d >> n;
	ll mini=min(q*4,min(h*2,s));
	if(mini*2<d) cout << mini*n << endl;
	else cout << (n/2)*d+(n%2)*mini << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
	int h,w;
	cin >> h >> w;
	vector<string> v(h);
	rep(i,h)cin>>v[i];
	vector<vector<int> > r(h,vector<int>(w)),l(h,vector<int>(w)),d(h,vector<int>(w)),u(h,vector<int>(w));
	rep(i,h)rep(j,w){
			if(v[i][j]=='#'){
				l[i][j] = 0;u[i][j] = 0;
			}else{
				if(j==0){
					l[i][j]=1;
				}else{
					l[i][j] = l[i][j-1]+1;
				}
				if(i==0){
					u[i][j]=1;
				}else{
					u[i][j] = u[i-1][j]+1;
				}
			}
	}
	for(int i = h-1; i >= 0; i--)for(int j = w-1; j >= 0; j--){
		if(v[i][j]=='#'){
			r[i][j] = 0;d[i][j] = 0;
		}else{
			if(j==w-1){
				r[i][j]=1;
			}else{
				r[i][j] = r[i][j+1]+1;
			}
			if(i==h-1){
				d[i][j]=1;
			}else{
				d[i][j] = d[i+1][j]+1;
			}
		}
	}
	int ans = 0;
	rep(i,h)rep(j,w){
		ans = max(ans,u[i][j]+r[i][j]+d[i][j]+l[i][j]-3);
	}
	cout << ans << endl;
}

Measured memory_bytes: 67200
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
#define cint(...) ll __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__);

int main() {
	cint(a, b, c, d);
	if (a + b < c + d)
		cout << "Right" << endl;
	else if (a + b > c + d)
		cout << "Left" << endl;
	else
		cout << "Balanced" << endl;
}

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

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> a = vector<int>(N, 0);

    for (int i = 0; i < N; i++)
    {
        cin >> a.at(i);
    }

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

    int big = 0;
    for (int i = 0; i < N; i = i + 2)
    {
        big += a.at(i);
    }
    int small = 0;
    for (int i = 1; i < N; i = i + 2)
    {
        small += a.at(i);
    }

    cout << big - small << endl;

    return 0;
}


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


int main(){

  ll x;
  cin>>x;
  ll p,q;
  q =x%500;
  q /=5;
  q *=5;
  p =x/500;
  p *= 1000;
  cout <<p+q<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
  int64_t x;
  cin >> x;
  int64_t ans = x/11;
  ans *= 2;
  int64_t r = x%11;
  if(r==0) cout << ans << endl;
  else if(r<=6) cout << ans+1 << endl;
  else cout << ans+2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 10000

int main(void)
{
  int i,n,a[N],b[N],S_a,S_b;

  while(1)
    {
      scanf("%d",&n);
      if(n==0) break;
      for(i=0;i<=n-1;i++)
	{
	  scanf("%d%d",&a[i],&b[i]);
	}
      S_a=0;
      S_b=0;
      for(i=0;i<=n-1;i++)
	{
	  if(a[i]>b[i]) S_a+=a[i]+b[i];
	  else if(a[i]<b[i]) S_b+=a[i]+b[i];
	  else
	    {
	      S_a+=a[i];
	      S_b+=b[i];
	    }
	}
      printf("%d %d\n",S_a,S_b);
    }
  return 0;
}

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

int main() {
  int W, A, B;
  cin >> W >> A >> B;

  int ans = 0;

  if (A + W < B) ans = B - (A + W);
  else if (B + W < A) ans = A - (B + W);

  cout << ans << endl;
}

Measured memory_bytes: 256
w,h,n=map(int,input().split())
x0 = y0 = 0

for i in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    x0=max(x0,x)
  elif a==2:
    w=min(w,x)
  elif a==3:
    y0=max(y0,y)
  elif a==4:
    h=min(h,y)
    
print(max(w-x0,0)*max(h-y0,0))

Measured memory_bytes: 3064
// In the name of God
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <bitset>
#define sqr(a) (a)*(a)
#define all(a) (a).begin(), (a).end()
using namespace std;
  
template <typename T>
T next_int() {
    T x = 0, p = 1;
    char ch;
    do { ch = getchar(); } while(ch <= ' ');
    if(ch == '-') {
        p = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9') {
        x = x * 10 + (ch - '0');
        ch = getchar();
    }
    return p * x;
}
  
string next_token() {
    char ch;
    string ans = "";
    do { ch = getchar(); } while(ch <= ' ');
    while(ch > ' ') {
        ans += ch;
        ch = getchar();
    }
    return ans;
}
     
const long long INF = (long long)1e18;
const int INFINT = (int)1e9 + 227 + 1;
const int MAXN = (int)1e6 + 227 + 1;    
const int MOD = (int)1e9 + 7;
const long double EPS = 1e-9;

long long bin_pow(long long a, long long b, int MOD) {
    if(!b) return 1;
    long long ans = bin_pow(a, b / 2, MOD);
    ans = ans * ans % MOD;
    if(b % 2) ans = ans * a % MOD;
    return ans;
}

int main() {
    // freopen(".in", "r", stdin);

    int n = next_int<int>();
    int q = next_int<int>();
    int w = next_int<int>();

    int e = 0;
    int k = 0;

    string a; cin >> a;

    for(int i = 0; i < a.size(); i++) {
        if(a[i] == 'c') {
            puts("No");
        } else 
        if(a[i] == 'b') {
            if(e < w && k < q + w) {
                puts("Yes");
                e++, k++;
            } else {
                puts("No");
            }
        } else {
            if(k < q + w) {
                puts("Yes");
                k++;
            } else {
                puts("No");
            }
        }
    }
}

Measured memory_bytes: 1024
n,a,b,c=map(int,input().split())
l=[int(input()) for _ in range(n)]
ans=10**18
for i in range(4**n):
  la,lb,lc,ca,cb,cc=0,0,0,0,0,0
  for j in range(n):
    if (i>>2*j)&1 and not (i>>2*j+1)&1:
      ca+=1
      la+=l[j]
    if not (i>>2*j)&1 and (i>>2*j+1)&1:
      cb+=1
      lb+=l[j]
    if (i>>2*j)&1 and (i>>2*j+1)&1:
      cc+=1
      lc+=l[j]
  if ca*cb*cc:ans=min((ca+cb+cc-3)*10+abs(la-a)+abs(lb-b)+abs(lc-c),ans)
print(ans)

Measured memory_bytes: 68604