akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    long long sum = 0;
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    
    sort(A.rbegin(), A.rend());
//    cout << A[M-1] << " " << sum / 4/M << endl;
    if( A[M-1] * 4 * M < sum ) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
# C-Traveling
N = int(input())
t = [0]*N
x = [0]*N
y = [0]*N

for i in range(N):
    t[i], x[i], y[i] = map(int, input().split())
flg = 1
for i in range(N):
    if i == 0:
        deltax = x[i]
        deltay = y[i]
        deltat = t[i]
    else:
        deltax = abs(x[i] - x[i-1])
        deltay = abs(y[i] - y[i-1])
        deltat = t[i] - t[i-1]
    trip_len = deltax + deltay
    if (((deltat - trip_len)%2) != 0) or (deltat < trip_len) :
        flg = 0
if flg == 1:
    print('Yes')
else:
    print('No')

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



int main(){
	int n,W;
	cin>>n>>W;
	vector<int> w(n),v(n);
	int value=0;
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
		value+=v[i];
	}
	vector<long long int > dp(value+1,(1e18L+5));
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=value;j>=0;j--){
			if(j>=v[i])
				dp[j]=min(dp[j],w[i]+dp[j-v[i]]);
		}
	}
	int ans=0;
	for(int i=0;i<=value;i++){
		if(dp[i]<=W){
			ans=max(ans,i);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
# 2019/05/10
# AtCoder Beginner Contest 107 - C

# Input
n, k = map(int, input().split())
x = list(map(int, input().split()))

# Init
acdist = list()
#acdist.append(0) # Distance from x[0]
for i in range(n):
    wx = x[i] - min(x[0], 0)
    acdist.append(wx)

mindist = 10 ** 10
eflg = False

if x[0] >= 0:
    mindist = x[k-1]
    eflg = True
elif x[n-1] <= 0:
    mindist = abs(x[n-k])
    eflg = True

for i in range(n-k+1):
    if eflg == True:
        break
    sidx = i
    eidx = i + k - 1
    if (x[eidx] < 0 and eidx < n-1) or (x[sidx] > 0 and sidx > 0):
        continue
    else:
        # 折り返してゴールまで
        dist = acdist[eidx] - acdist[sidx]
        # 0からSidxまでの距離とEidxまでの距離の小さい方を足す
        dist += min(0-x[sidx], x[eidx]-0)
        if dist < mindist:
            mindist = dist

# Output
print(mindist)


Measured memory_bytes: 14660
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

using mint = modint998244353;
const mint inv9 = mint(1)/9;

struct S {
    mint x, w;
    S(mint x=0, mint w=1):x(x),w(w) {}
};

S op(S a, S b) {
    return S(a.x*b.w + b.x, a.w*b.w);
}

S e() { return S();}

S mapping(int f, S a) {
    if (f == 0) return a;
    return S((a.w-1)*inv9*f, a.w);
}

int composition(int f, int g) {
    if (f == 0) return g;
    return f;
}

int id() { return 0;}

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

    lazy_segtree<S,op,e,int,mapping,composition,id> t(n);
    rep(i,n) t.set(i, S(1,10));
    rep(qi,q) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        t.apply(l,r,d);
        S ans = t.prod(0,n);
        cout << ans.x.val() << endl;
    }
    return 0;
}

Measured memory_bytes: 9856
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# だいたい転倒数。Wから見て左のBを数える

S = read().rstrip().decode('utf-8')

B = 0
answer = 0
for x in S:
    if x == 'B':
        B += 1
    else:
        answer += B

print(answer)

Measured memory_bytes: 3444
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
	FIO
	
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0; i < 3; i++){
		if(s[i] == 'o')ans += 100;
	}
	cout << 700 + ans << '\n';
	return 0; 
}


Measured memory_bytes: 256
#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 A, B, M;
	cin >> A >> B >> M;
	int a[100010], b[100010], c[100010];
	int x[100010], y[100010];
	rep(i,A) cin >> a[i];
	rep(i,B) cin >> b[i];
	rep(i,M){
		cin >> x[i] >> y[i] >> c[i];
		x[i]--;
		y[i]--;
	}
	int sum=1000000;
	rep(i,M) sum=min(sum,a[x[i]]+b[y[i]]-c[i]);
	sort(a,a+A);
	sort(b,b+B);
	cout << min(a[0]+b[0],sum) << endl;

	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>
#include <iomanip>

#define BIG 1000000007
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)
#define long long long

using namespace std;

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

    cout << ((s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) ? "Bad" : "Good") << endl;
}




Measured memory_bytes: 760
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n[]={0,1,2,1,3,1,3,1,1,3,1,3,1};
main(){
	int a,b,c;
	cin>>a>>b;
	if((a+b)%3==0||a%3==0||b%3==0)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
	int N, k, l, i;
	scanf("%d", &N);
	if(N == 3){
		printf("2 5 63\n");
		return 0;
	}
	if(N <= 15002){
		k = N - 2;
		l = 2;
	}
	else{
		if(N % 2 == 1){
			k = 14999;
			l = N - k;
		}
		else{
			k = 15000;
			l = N - k;
		}
	}
	if(k % 3 == 1){
		for(i = 1; i <= (k / 3) * 3; i++){
			printf("%d ", 2 * i);
		}
		printf("%d ", 2 * (k / 3 + 1) * 3);
	}
	else{
		for(i = 1; i <= k; i++){
			printf("%d ", 2 * i);
		}
	}
	for(i = 1; i <= l; i++){
		printf("%d ", 6 * i - 3);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
# ABC075B - Minesweeper
h, w = list(map(int, input().rstrip().split()))
lst = [list(input().rstrip()) for _ in range(h)]
emp_lst = ["."] * (w + 2)

for i in lst:
    i.append(".")
    i.insert(0, ".")

lst.append(emp_lst)
lst.insert(0, emp_lst)

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if lst[i][j] == ".":
            count = 0
            if lst[i - 1][j - 1] == "#":
                count += 1
            if lst[i - 1][j] == "#":
                count += 1
            if lst[i - 1][j + 1] == "#":
                count += 1
            if lst[i][j - 1] == "#":
                count += 1
            if lst[i][j + 1] == "#":
                count += 1
            if lst[i + 1][j - 1] == "#":
                count += 1
            if lst[i + 1][j] == "#":
                count += 1
            if lst[i + 1][j + 1] == "#":
                count += 1
            lst[i][j] = count

for i in range(1, h + 1):
    for j in range(1, w + 1):
        print(lst[i][j], end="")
    print()

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int n; cin >> n;
	bool is_four = false;
	rep(i,n){
		char c; cin >> c;
		if (c == 'Y') is_four = true;
	} 
	cout << (is_four ? "Four" : "Three") << endl;
}

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

int main(void) {
	int A, B, C;
	int ans;

	cin >> A >> B >> C;
	if (B == C)
		ans = A;
	else if (A == C)
		ans = B;
	else
		ans = C;

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();

    vl v1(26);  // v1[i] : sに含まれるi番目のアルファベットの個数
    vl v2(26);  // v2[i] : tに含まれるi番目のアルファベットの個数
    rep(i, n) {
        for(char c = 'a'; c <= 'z'; c++) {
            if(s[i] == c) {
                v1[c - 'a']++;
            }
            if(t[i] == c) {
                v2[c - 'a']++;
            }
        }
    }
    sort(all(v1));
    sort(all(v2));

    rep(i, 26) {
        if(v1[i] != v2[i]) {
            out("No");
            re0;
        }
    }

    out("Yes");
    re0;
}

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

int main(void){
  int a[5] = {0};
  for(int i = 0;i<5;i++) cin >> a[i];
  sort(a,a+5, [](const int& a, const int& b){
    return a > b;
  });
  for(int i = 0;i<5;i++){
    if(i != 0) cout << " ";
    cout << a[i];
    if(i == 4) cout << endl;
  }
}

Measured memory_bytes: 3160
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
B = [list(map(int, input().split())) for _ in range(N)]

edge = { -1: {}, 2*N: {} }
for i, a in enumerate(A):
  edge[i] = {}
  edge[-1][i] = 1
  for j, b in enumerate(B):
    j += N
    if j not in edge:
      edge[j] = {}
    edge[j][2*N] = 1
    if a[0] < b[0] and a[1] < b[1]:
      edge[i][j] = 1

# Ford-Fulkerson (impl: DFS)
visited = [False] * (2*N+2)
def find_route(start, goal, bottleneck):
  global visited
  visited[start] = True
  if start == goal:
    return bottleneck
  for to in edge[start]:
    if visited[to] or edge[start][to] <= 0:
      continue
    flow = find_route(to, goal, min(bottleneck, edge[start][to]))
    if flow > 0:
      edge[start][to] = edge[start].get(to, 0) - flow
      edge[to][start] = edge[to].get(start, 0) + flow
      return flow
  return 0

ans = 0
while True:
  visited = [False] * (2*N+2)
  flow = find_route(-1, 2*N, float("inf"))
  if flow == 0:
    break
  ans += flow
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define REP(n) for(int i = 0; i < n; i++)
#define all(p) p.begin(), p.end()
#define count_1(p) __builtin_popcountll(p)
#define count_0(p) __builtin_ctzll(p)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
template<class X=int>inline X min(X a,X b,X c){return min(min(a,b),c);}
template<class X=int>inline X min(X a,X b,X c,X d){return min(min(a,b,c),d);}
template<class X=int> inline X max(X a,X b,X c){return max(max(a,b),c);}
template<class X=int> inline X max(X a,X b,X c,X d){return max(max(a,b,c),d);}
template<class X=int> inline X mid(X s,X e){return (s+(e-s)/2);}
template<class X=int> inline X len(X s,X e){return (e-s+1);}
const int MOD = 1e9 + 7;
const int INF = 987654321;
const bool TESTCASES = 0;
const bool CODEJAM = 0;

void solve() {
	int n;
	cin >> n;
	vector<double> A(n);
	REP(n) cin >> A[i];
	vector<vector<double>> dp(n + 1, vector<double>(n + 1));
	dp[0][0] = 1.0;
	for(int i = 1; i <= n; i++) {
		dp[i][0] = (1 - A[i - 1])*dp[i - 1][0];
		for(int j = 1; j <= i; j++) {
			dp[i][j] = dp[i - 1][j - 1]*A[i - 1] + dp[i - 1][j]*(1 - A[i - 1]);
		}
	}
	double ans = 0;
	for(int j = (n + 1)/2; j <= n; j++) ans += dp[n][j];
	cout << setprecision(10) << fixed << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int T = 1;
	if(TESTCASES) cin >> T;
	for(int t = 1; t <= T; t++) {
		if(CODEJAM) cout << "Case #" << t << ": ";
		solve();
	}
	return 0;
}


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

int main() {
  
  string s;
  
  cin >> s;
  
  int count=0;
  
  for(int i=0; i<3; i++) {
    
    if(s.at(i) =='o') {
      
      count++;
      
    }
    
  }
  
  int sum = 700+(count*100);
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 int main()
 {int n;
 cin>>n;
  int flag=0;
  for(int i=1;i<=9;i++)
  {if(n%i==0 and n/i<=9)
  {flag=1;
   break;
  }
  }
  if(flag==0)
    cout<<"No";
  else
    cout<<"Yes";
  return 0;
 }



Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 200005
  #define INF 1000000000000
  #define eps 1e-6
  int arr[26];

  set<int> pos[26];

int32_t main()
{

    IOS

  
    string s,t;
    cin >> s >> t;


    for(int i = 0; i < s.length(); i++)
    {
      arr[s[i]-'a']++;
    }

    for(int i = 0; i < t.length(); i++)
    {
      if(arr[t[i] - 'a'] == 0)
      {
        cout << -1;
        return 0;
      }
    }


    for(int i = 0;i < s.length(); i++)
    {
      pos[s[i]-'a'].insert(i);
    }

    int prev = -1;

    int ans = 0;


    for(int i = 0; i < t.length(); i++)
    {
        auto it = pos[t[i]-'a'].upper_bound(prev);
        if(it == pos[t[i]-'a'].end())

        {
          it = pos[t[i]-'a'].begin();
          ans+= (s.length() - prev + *it );
          //trace1(s.length() - prev + *it);

        }
        else
        {
            ans += (*it- prev);
            //trace2(*it,prev);
        }
        prev = *it;
    }
    cout << ans  << endl;


	return 0;
}

Measured memory_bytes: 5200
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}



int main(){
	int n, l;
	cin >> n >> l;
	vector<int> a(n);
	rep(i, n) a[i] = l + (i + 1) - 1;
	int s = 0;
	int d = inf;
	rep(i, n){
		d = abs(a[i]) < abs(d) ? a[i] : d;
		s += a[i];
	}
	cout << s - d << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int n_r = 0, n_b = 0;
    rep(i,n) {
        if (s[i] == 'R') n_r++;
        if (s[i] == 'B') n_b++;
    }
    if (n_b < n_r) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const double PI = 3.1415926535;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

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


int n, m;
vector<vector<int>> G;
int memo[100100];
int dfs(int x){
    if(memo[x] != -1) return memo[x];

    int res = 0;
    for(auto i : G[x]){
        chmax(res, dfs(i) + 1);
    }
    return memo[x] = res;
}

signed main(void){
    cin >> n >> m;
    G.assign(n, vector<int>());
    REP(i, m){
        int x, y; cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
    }

    REP(i, n) memo[i] = -1;
    int ans = 0;
    REP(i, n) chmax(ans, dfs(i));

    cout << ans << endl;
}

Measured memory_bytes: 8576
import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int ar[]=new int[n];
		
		int ans=0;
		int pre=0;
		int cur;
		
		for(int i=0;i<n;i++)
		{
			int curr=scan.nextInt();
			if(pre>curr)
			{
				ans+=pre-curr;
			}
			pre=curr;
		}
		ans+=pre;
		System.out.println(ans);
	}
}


Measured memory_bytes: 22484
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int sum = 0;
    vector<int> S(n,0);
    REP(i, n) cin >> S[i], sum+=S[i];
    sort(ALL(S));

    if(sum%10==0){
        REP(i, n){
            if(S[i]%10!=0){
                sum-=S[i];
                break;
            } 
        }
        if(sum%10==0) cout << 0 << endl;
        else cout << sum << endl;
    }
    else cout << sum << endl;

   return 0;
}

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

using namespace std;

int a[110],n;
int main(){
	
	while(cin>>n){
		for(int i=0; i<n; ++i)cin>>a[i];
		sort(a,a+n);
		int m = unique(a,a+n)-a;
		cout<<m;
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

const int mod = (int) 1e9 + 7;

int mul(int a, int b) {
  return (long long) a * b % mod;
}

void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

const int maxn = 4005;
int c[maxn][maxn];
int c1[maxn][maxn];
int p2[maxn];

void precalc() {
  for (int i = 0; i < maxn; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      c[i][j] = c[i - 1][j - 1];
      add(c[i][j], c[i - 1][j]);
    }
  }
  for (int i = 0; i < maxn; i++) {
    c1[i][0] = 0;
    for (int j = 0; j + 1 < maxn; j++) {
      c1[i][j + 1] = c[i][j];
      add(c1[i][j + 1], c1[i][j]);
    }
  }
  p2[0] = 1;
  for (int i = 1; i < maxn; i++) {
    p2[i] = mul(p2[i - 1], 2);
  }
}

int a, b;

int read() {
  if (scanf("%d%d", &a, &b) < 2) {
    return false;
  }
  return true;
}

int dp[maxn][maxn];

void solve() {
  memset(dp, 0, sizeof(dp));
  int res = 1;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j < b; j++) {
      int s = i + j;
      int fst = a - s;
      if (fst < 0 || fst >= a) {
        continue;
      }
      int dx = a - fst - i, dy = b - 1 - j;
      dp[i][j] = c[dx + dy][dx];
      add(res, dp[i][j]);
    }
  }
  for (int i = a; i > 0; i--) {
    for (int j = b; j > 0; j--) {
      auto &cur = dp[i][j];
      add(cur, dp[i + 1][j]);
      int x = i, y = j - 1;
      if (y <= x) {
        add(res, mul(cur, p2[y]));
      } else {
        int tomul = c1[y][x + 1];
        add(tomul, mod - c1[y][0]);
        add(res, mul(cur, tomul));
      }
    }
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 188288
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,k;
    ci(n>>k);
  vll A(k);
  FOR(i,0,k){
    A[i]++;
    n--;
  }
  A[k-1]+=n;
  co(A[k-1]-A[0])
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
#define rep(i, n) for(int i = 0; i < n; i++)
#define ll long long
using namespace std;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  double a, b, c, d, e, f;
  while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
    double y = (c * d- f * a) / (b * d- a * e);
    double x = (c - b * y) / a;
    printf("%0.3f %0.3f\n", x, y);
  }
  return 0;
}



Measured memory_bytes: 3228
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n,a[100005],sum=1,ans=0;
	cin>>n;
	for(register int i=0; i<n; i++) {
		cin>>a[i];
	}
	sort(a,a+n);
	if(n==1) {
		cout<<1<<endl;
		return 0;
	}
	for(int i=1; i<n; i++) {
		if(a[i]==a[i-1]) {
			sum++;
		} else {
			ans+=(sum%2);
			sum=1;
		}
	}
	if(sum%2){
		ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
H, W = map(int, input().split())
g = [list(input()) for _ in range(H)]
mod = int(1e9) + 7
dp = [[0 for i in range(W)] for j in range(H)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if g[i][j] == "#":
            continue
        if i + 1 < H:
            dp[i+1][j] += dp[i][j] % mod
        if j + 1 < W:
            dp[i][j+1] += dp[i][j] % mod
print(dp[H-1][W-1] % mod)

Measured memory_bytes: 122672
N = input()
N = N.split()


def main():
    if (N[0] == N[1]) and (N[1] == N[2]) and N[2] == N[0]:
        return 'No'

    if (N[0] != N[1]) and (N[1] != N[2]) and (N[0] != N[2]):
        return 'No'

    return 'Yes'


print(main())

Measured memory_bytes: 3060
import java.util.*;

public class Main {

    static class Pair {
        int h, w, cnt;

        public Pair(int h, int w, int cnt) {
            this.h = h;
            this.w = w;
            this.cnt = cnt;
        }
    }

    static int bfs() {
        visited = new boolean[H][W];
        visited[0][0] = true;
        prev = new Pair[H][W];
        prev[0][0] = new Pair(-1, -1, -1);

        Deque<Pair> que = new ArrayDeque<>();
        que.offer(new Pair(0, 0, 0));

        while (!que.isEmpty()) {
            Pair pair = que.poll();
            if (pair.h == H-1 && pair.w == W-1) return pair.cnt;

            for (int dir = 0; dir < 4; ++dir) {
                int nh = pair.h + dy[dir];
                int nw = pair.w + dx[dir];

                if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
                if (visited[nh][nw]) continue;
                if (grid[nh][nw] == '#') continue;

                prev[nh][nw] = pair;
                visited[nh][nw] = true;
                que.offer(new Pair(nh, nw, pair.cnt + 1));
            }
        }

        return 0;
    }

    static int H;
    static int W;
    static boolean[][] visited;
    static char[][] grid;
    static Pair[][] prev;
    static int[] dx = {-1, 1, 0, 0};
    static int[] dy = {0, 0, -1, 1};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        H = Integer.parseInt(sc.next());
        W = Integer.parseInt(sc.next());
        grid = new char[H][W];
        for (int i = 0; i < H; ++i) grid[i] = sc.next().toCharArray();
        int black = 0;
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                if (grid[i][j] == '#') ++black;
            }
        }

        int cnt = bfs();

        if (cnt != 0)
            System.out.println(H * W - black - cnt - 1);
        else
            System.out.println(-1);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    ll N, T;
    cin >> N >> T;
    vector<ll> t(N);
    REP(i, N) { cin >> t[i]; }
    if(N == 1) {
        cout << T << endl;
        return 0;
    }
    vector<ll> d(N - 1);
    REP(i, N - 1) { d[i] = t[i + 1] - t[i]; }
    ll ans = 0;
    REP(i, N - 1) { ans += min(d[i], T); }
    cout << ans + T << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

ll modpow(ll r,ll n,ll m=MOD){
  ll re=1,d=r%m;
  if(n<0)(n%=m-1)+=m-1;
  for(;n;n/=2){
    if(n&1)(re*=d)%=m;
    (d*=d)%=m;
  }
  return re;
}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  ll n,t;
  cin>>n>>t;
  ll re=0;
  vector<int> fs;
  for(int i=1;i*i<=n;++i){
    if(n%i) continue;
    fs.pb(i);
    fs.pb(n/i);
  }
  sort(all(fs));
  UNIQUE(fs);
  //cout<<fs;
  const int m=fs.size();
  vector<ll> dec(m);
  rep(i,m){
    const int x=fs[i];
    ll p=modpow(t,(x+1)/2);
    (p+=MOD-dec[i])%=MOD;
    reps(j,i+1,m) if(fs[j]%x==0) (dec[j]+=p)%=MOD;
    (re+=p*(x%2?x:x/2)%MOD)%=MOD;
  }
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int Map[1100];

int main() {
	int a, b;
	int sub, ans;
	Map[0] = 0;
	for (int i = 1; i <= 1000; i++) {
		Map[i] = Map[i - 1] + i;
	}


	scanf("%d %d", &a, &b);
	sub = b - a;
	ans = Map[sub-1] - a;
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>


#define N 10000
#define Q 500

int main(){

  int n,q,i,j,c=0,temp=N;
  int S[N],T[Q];

  scanf("%d", &n);

  for(i=0 ; i<n ; i++){
    scanf("%d", &S[i]);
  }

   scanf("%d", &q);

  for(i=0 ; i<q ; i++){
    scanf("%d", &T[i]);
  }

  for(i=0 ; i<q ; i++){
    for(j=0 ; j<n ; j++){
      if(T[i]==S[j]) {
	if(temp!=T[i]){
	c++;
	temp=T[i];
	}
      }
    }
  }

  printf("%d\n",c);

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "No" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
const int MAXX=1010;
const int MAXY=1010;
bool map2d[MAXX][MAXY];
int depth[MAXX][MAXY];
int dx[4]={1,0,0,-1};
int dy[4]={0,1,-1,0};

vector<ll> X;
vector<ll> Y;

ll bfs(ll sx, ll sy) {
    if(map2d[sx][sy]==0 or depth[sx][sy]!=0) return 0;
    deque<P> dq;
    rep(i,X.size()) dq.emplace_back(X[i],Y[i]);
    rep(i,X.size()) depth[X[i]][Y[i]]=1; // departure: depth=1
    ll ct=0;
    while(!dq.empty()) {
        ll vx = dq.front().first;
        ll vy = dq.front().second;
        ++ct;
        dq.pop_front();
        rep(i,4){
            ll x=vx+dx[i]; ll y=vy+dy[i];
            if(x<0 or x>=MAXX or y<0 or y>=MAXY) continue;
            if(map2d[x][y]==0) continue;
            if(depth[x][y]!=0) continue;
            depth[x][y]=depth[vx][vy]+1;
            dq.emplace_back(x,y);
        }
    }
    return ct;
}

//--MAIN-----------------------------------
void Main() {
    ll H,W; cin>>H>>W;
    rep(i,H){
        rep(j,W){
            map2d[i][j]=1;
            char c; cin>>c;
            if(c=='#') X.emplace_back(i),Y.emplace_back(j);
        }
    }
    bfs(X[0],Y[0]);

    ll ans=0;
    rep(i,H){
        rep(j,W){
            maxi(ans,(ll)depth[i][j]);
        }
    }
    cout<< ans-1 <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 37204
#include<bits/stdc++.h>
using namespace std;
map<int,int> mp,flag;

int main()
{
    int n;
    cin>>n;
    int a[n+2],ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    for(int i=0;i<n;i++)
    {
        if(flag[a[i]]) continue;
        if(mp[a[i]]<a[i]) ans+=mp[a[i]];
        else ans+=(mp[a[i]]-a[i]);
        flag[a[i]]=1;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    int n, a, b;
    string s;
    cin >> n >> a >> b;
    cin >> s;
    int sum = 0, sumb = 1;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'a' && sum < a + b){
            cout << "Yes" << endl;
            sum++;
        }else if(s[i] == 'b' && sum < a + b && sumb <= b){
            cout << "Yes" << endl;
            sum++; sumb++;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int pch(ll H) {
	ll i = 2;
	while (i * i <= H) {
		if (H % i == 0) {
			return -1;
		}
		i++;
	}
	return H;
}



int main() {
	ll X,s=0;
	cin >> X;
	vector<ll> A(X);
	vector<ll> S(X);
	rep(i, X) {
		cin >> A.at(i);
		s += A.at(i);
		S.at(i) = s;
	}
	ll an = s;
	rep(i, X) {
		an = min(an, abs(2 * S.at(i) - s));
	}
	cout << an << endl;
	
}





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

int main()
{
  int m,f,r;
  cin >> m >> f >> r;
  int sum;
  char x[100]={};
  int i=0;
  while(!(m==-1&&f==-1&&r==-1))
    {
      sum=m+f;
      if(m==-1||f==-1)x[i]='F';
      else{
	if(sum>=80)x[i]='A';
	else if(sum>=65)x[i]='B';
	else if(sum>=50)x[i]='C';
      else if(sum>=30)
	{if(r>=50)x[i]='C';
	  else x[i]='D';}
      else x[i]='F';
      }
      cin >> m >> f >> r;
      i++;
    }

  for(int j=0;j<i;j++)
    {
      cout << x[j] << endl;
    }


  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<string.h>
#include<cstring>
#include<math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<cctype>
#include<utility>
#include<set>
#include<map>
#include<sstream>
#include<iterator>
#include<limits>
#include<map>
#include<deque>
using namespace std;
#define pb push_back
#define F(i,a,b) for(int i=a;i<b;++i)
#define Fl(i,a,b) for(long long i=a;i<b;++i)
#define all(v) v.begin(), v.end() 
#define X first
#define Y second
#define mp make_pair
typedef long long ll;
typedef std::vector<int> vec;
typedef std::vector<long long> vecl;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef std::pair<int,int> pii;
typedef pair<ll,ll> pll; 
const int MOD = 1000000007;
#define pie 3.141592653589793238462643383279


int main() {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    

 	int t{},T{};
 	//cin>>t;T=t;
    t=1;
 	while(t--){
        //cout<<"------------- #"<<T-t<<endl;
        ll n{},m{},ans{},k{},a{},b{},c{},x{},y{},f{1};
        cin>>n>>m>>k;
        map<pll,int> mm;
        vecl row(n+1,0),col(m+1,0);
        Fl(i,0,k){
            cin>>a>>b;
            mm[mp(a,b)]=1;
            row[a]++;
            col[b]++;
        }
        if(n*m==1){
            if(k==1){
                cout<<1<<endl;
            }else{
                cout<<0<<endl;
            }
            return 0;
        }
        a=max_element(all(row))-row.begin();//++a;
        b=max_element(all(col))-col.begin();//++b;
        //cout<<a<<"---"<<b<<endl;
        if(row[a]>col[b]){
            F(j,1,m+1){
                if(mm[mp(a,j)]==1){
                    ans=max(ans,col[j]-1);
                }else{
                    ans=max(ans,col[j]);
                }
            }
            ans+=row[a];
            //cout<<"=";
        }else if(row[a]<col[b]){
            F(i,1,n+1){
                if(mm[mp(i,b)]==1){
                    ans=max(ans,row[i]-1);
                }else{
                    ans=max(ans,row[i]);
                }
            }
            ans+=col[b];
        }else{
            F(j,1,m+1){
                if(mm[mp(a,j)]==1){
                    x=max(x,col[j]-1);
                }else{
                    x=max(x,col[j]);
                }
            }
            x+=row[a];
            
            F(i,1,n+1){
                if(mm[mp(i,b)]==1){
                    y=max(y,row[i]-1);
                }else{
                    y=max(y,row[i]);
                }
            }
            y+=col[b];
            ans=max(x,y);
        }
        cout<<ans<<endl;
        
        
    }
    
    
	return 0;
}

Measured memory_bytes: 64140
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    S = input()[:-1]
    if S == "ABC":
        print("ARC")
    else:
        print("ABC")
        


if __name__ == '__main__':
    main()

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

ss = []
mins = 'a'*100
for _ in range(n):
  s = str(''.join(sorted(input())))
  ss.append(s)
  if len(mins) > len(s):
    mins = s
  
ans = ''
for w in mins:
  ok = True
  for i, s in enumerate(ss[:]):
    if w in s:
      wi = s.find(w)
      ss[i] = s[:wi] + s[wi+1:]
    else:
      ok = False
  if ok:
    ans += w
print(ans)

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

int main(){
  int H, W;
  cin >> H >> W;

  vector<vector<char>> v(H, vector<char>(W));
  vector<vector<int>> L(H, vector<int>(W));
  vector<vector<int>> R(H, vector<int>(W));
  vector<vector<int>> D(H, vector<int>(W));
  vector<vector<int>> U(H, vector<int>(W));
  vector<vector<int>> Light(H, vector<int>(W));

  int lmax = 0;

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> v[i][j];
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(v[i][j] == '#'){
        L[i][j] = 0;
      }
      else if(j == 0){
        L[i][j] = 1;
      }
      else{
        L[i][j] = L[i][j-1] + 1;
      }

      if(v[i][W-j-1] == '#'){
        R[i][W-j-1] = 0;
      }
      else if(j == 0){
        R[i][W-j-1] = 1;
      }
      else{
        R[i][W-j-1] = R[i][W-j] + 1;
      }

      if(v[i][j] == '#'){
        U[i][j] = 0;
      }
      else if(i == 0){
        U[i][j] = 1;
      }
      else{
        U[i][j] = U[i-1][j] + 1;
      }

      if(v[H-i-1][j] == '#'){
        D[H-i-1][j] = 0;
      }
      else if(i == 0){
        D[H-i-1][j] = 1;
      }
      else{
        D[H-i-1][j] = D[H-i][j] + 1;
      }
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      //cout << i << " " << j << endl;
      Light[i][j] = L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3;
      lmax = max(lmax, Light[i][j]);
      //cout << "L" << L[i][j] << " R" << R[i][j] << " D" << D[i][j] << " U" << U[i][j] << " Light" << Light[i][j] << endl << endl;
    }
  }

  cout << lmax << endl;

  return 0;
}


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

const int MAX = 1000000;

int dp[MAX], dp_odd[MAX];

int main()
{
  vector<int> tetra;

  for (int i = 1; ; ++i) {
    int d = i * (i + 1) * (i + 2) / 6;
    if (d >= MAX)
      break;
    tetra.push_back(d);
  }

  dp[0] = dp_odd[0] = 0;
  for (int i = 1; i < MAX; ++i) {
    dp[i] = dp_odd[i] = i;
    for (int j = 0; j < tetra.size(); ++j) {
      if (tetra[j] > i)
	break;
      dp[i] = min(dp[i], dp[i-tetra[j]]+1);
      if (tetra[j] % 2 == 1)
	dp_odd[i] = min(dp_odd[i], dp_odd[i-tetra[j]]+1);
    }
  }

  int in;
  for ( ; ; ) {
    cin >> in;
    if (in == 0)
      break;
    cout << dp[in] << " " << dp_odd[in] << endl;
  }
  return 0;
}

Measured memory_bytes: 8584
<?php
$s=trim(fgets(STDIN));
$c=strlen($s);
$i=0;
while($i<$c){
  if($i%2==0 && $s[$i]=='L'){
    echo 'No';
    exit;
  }
  if($i%2==1 && $s[$i]=='R'){
    echo 'No';
    exit;
  }
  ++$i;
}
echo 'Yes';

Measured memory_bytes: 4728
#include <iostream>
using namespace std;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int check_sharp(string *S, 
                const int h,
                const int w,
                const int i, 
                const int j, 
                int &d){
  if(d==4) return 1;
  const int ni = i + dy[d];
  const int nj = j + dx[d];
  if(ni<0 or h<=ni){
    ++d;
    return check_sharp(S, h, w, i, j, d);
  }else if(nj<0 or w<=nj){
    ++d;
    return check_sharp(S, h, w, i, j, d);
  }
  
  if(S[ni][nj]=='#'){
    return 0;
  }else{
    ++d;
    return check_sharp(S, h, w, i, j, d);
  }
}

int main(){
  int h, w;
  cin >> h >> w;
  
  string s[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] =='#'){
        int d = 0;
        int ans;
        ans = check_sharp(s, h, w, i, j, d);
        if(ans==1){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

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 x;
	cin >> x;
	while(!IsPrime(x)){
		x++;
	}
	cout << x << endl;
}


Measured memory_bytes: 256
#include <cstdio>

typedef struct vertex_{
    int found;
    int d;
    int f;
}vertex;

int search(vertex *array, int (*A)[101], int id, int n, int time){
    if(array[id].found)return time;
    array[id].found=1;
    array[id].d=++time;
    for(int i=1;i<=n;i++){
        if(A[id][i])time=search(array,A,i,n,time);
    }
    array[id].f=++time;
    return time;
}

int searchAll(vertex *array, int (*A)[101], int n){
    int time = 0;
    for(int id=1;id<=n;id++)if(!array[id].found)time=search(array,A,id,n,time);
    return time;
}

int main(){
    int i, j, n, u, k, v;
    scanf("%d",&n);
    vertex array[n+1];
    for(i=1;i<=n;i++)array[i].found=0;
    int A[101][101];
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            A[i][j]=0;
        }
    }
    for(i=1;i<=n;i++){
        scanf("%d %d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d",&v);
            A[u][v]=1;
        }
    }
    int time = searchAll(array, A, n);
    for(i=1;i<=n;i++)printf("%d %d %d\n",i,array[i].d,array[i].f);
    return 0;
}



Measured memory_bytes: 2700
# -*- coding: utf-8 -*-

import sys
import os
import math

N = int(input())
n = 4

for i in range(N):
    print("Case {}:".format(i+1))
    d = int(input())

    for j in range(10):
        square = d * d
        s = str(square).zfill(n*2)
        d = int(s[2:-2])
        print(d)

Measured memory_bytes: 7604
use std::collections::HashMap;

fn main() {
    let table: HashMap<_, _> = vec![("Sunny", "Cloudy"), ("Cloudy", "Rainy"), ("Rainy", "Sunny")].into_iter().collect();

    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    println!("{}", table.get(s.trim()).unwrap());
}


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

int main() {
	int N; cin >> N;
	vector<int> vec(N);
	for (int i = 0; i < N; i++){
    	cin >> vec.at(i);
    }
  	sort(vec.begin(), vec.end());
  	reverse(vec.begin(), vec.end());
  	int x = vec.at(0), counter = 1;
  	for(int i = 0; i < N; i++){
    	if(x > vec.at(i)){
        	x = vec.at(i);
        	counter+=1;
        }
    }
  	cout << counter << endl;
}

Measured memory_bytes: 3580
N = int(input())
C = [0] * (N - 1)
S = [0] * (N - 1)
F = [0] * (N - 1)
for i in range(N-1):
    c, s, f = map(int, input().split())
    C[i] = c
    S[i] = s
    F[i] = f
for i in range(N-1):
    ttl = 0
    for j in range(i, N-1):
        if ttl < S[j]:
            ttl = C[j] + S[j]
        elif ttl % F[j] == 0:
            ttl += C[j]
        else:
            ttl += F[j] - (ttl % F[j]) + C[j]
    print(ttl)
print(0)

Measured memory_bytes: 9060
# coding: utf-8
# Your code here!

l = list(map(int,input().split()))
l.sort()
a = l[0]
b = l[1]
c = l[2]

s = c - a
t = c - b

if s % 2 == t % 2:
    ans = (s + t) // 2
else:
    ans = (s + 1 + t + 1 + 1) // 2

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;
 
int main() {
    ll N, W;
    cin >> N >> W;
 
    vec<vec<ll>> v(4,vec<ll>(1));
    ll w0;
    cin >> w0 >> v[0][0];
    rep(i, N-1){
        ll w,val;
        cin >> w >> val;
        v[w-w0].push_back(val);
    }
 
    rep(i,4){
        sort(all(v[i]),greater<ll>());
        v[i].insert(v[i].begin(),0);
        for(int j=1;j<v[i].size();++j){
            v[i][j] = v[i][j]+v[i][j-1];
        }
    }
 
    ll ans = 0;
    rep(i,v[0].size())rep(j,v[1].size())rep(k,v[2].size())rep(l,v[3].size()){
        ll count = w0*(i+j+k+l)+j+2*k+3*l;
        if(count > W) break;
        ans = max(ans,v[0][i]+v[1][j]+v[2][k]+v[3][l]);
    }
 
    cout << ans;
    return 0;
}

Measured memory_bytes: 3624