akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

long long N, K, X, Y;

int main() {
	cin >> N >> K >> X >> Y;
	if (N <= K)cout << X * N << endl;
	else cout << X * K + (N-K) * Y << endl;
	return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:100000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
#define debug puts
#define setp cout << fixed << setprecision(15)
#define fst ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
const int N=1e5+5;
const int MOD=998244353;
int a[N],b[N],n,m;

int main(void){
    fst;
    ll a,b;
    cin >>a >>b ;
    cout << max(a+b,max(a-b,a*b))<<endl;

    return 0;
}
void bef0re_submit(){
    debug("Make sure the algorithm is right!");
    debug("LONG LONG!!!");
    debug("n==0?1?2?3?");
    debug("Make sure output format is right/// Yes??YES  (%.20LF)???");
    debug("if all meet,run with special situation!!!");
    debug("I confirm that I have done all above");

    debug("If u know brute,consider fast,binary(log) or tree?");
}


/*********

*********/


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

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

    int a, b;
    cin >> a >> b;
    if(a <= b) cout << a << endl;
    else cout << a - 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007, mod998 = 998244353;

int N, A, t;
ll res;

int main() {
	cin >> N;
	cin >> res;
	--N;
	--res;
	t = 2;
	while (N--) {
		cin >> A;
		res += (A - 1) / t;
		if (A == t)++t;
	}
	cout << res << endl;
	return 0;
}

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

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

  int N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end());

  int res = 0;
  vector<int> q(1 << 20);
  for (int j = 0; j < N; ++j) {
    int a = A[j];
    if (q[a]) continue;
    if (j + 1 == N || A[j + 1] != a) ++res;
    for (int i = a; i < 1 << 20; i += a) {
      q[i] = 1;
    }
  }

  cout << res << endl;

  return 0;
}



Measured memory_bytes: 8268
package main

import (
	"fmt"
)

// +=での文字列連結はパフォーマンス的にあまりよろしくないらしい
// https://qiita.com/ruiu/items/2bb83b29baeae2433a79
// https://qiita.com/ono_matope/items/d5e70d8a9ff2b54d5c37
// https://drken1215.hatenablog.com/entry/2020/03/08/144800
// いくつか別解があるらしい
// けんちょんさんの解法2を素直に実装するとTLE
func main() {
	var S string
	var Q, rev int
	var t, l []rune
	fmt.Scan(&S, &Q)
	Srune := []rune(S)
	for i := 0; i < Q; i++ {
		var T int
		fmt.Scan(&T)
		switch T {
		case 1:
			// 0と1を反転させる
			rev = 1 - rev
		case 2:
			var F int
			var C string
			fmt.Scan(&F, &C)
			Crune := []rune(C)
			F--
			if rev == 1 {
				F = 1 - F
			}
			if F == 0 {
				// https://blog.sarabande.jp/post/89635855383
				t = append(t, Crune...)
			} else {
				l = append(l, Crune...)
			}
		}
	}
	t = Reverserune(t)
	ans := append(t, Srune...)
	ans = append(ans, l...)
	if rev == 1 {
		ans = Reverserune(ans)
	}
	fmt.Println(string(ans))
}

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func Reverserune(s []rune) []rune {
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
	return s
}


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

using namespace std;

struct Dice
{
    int s[7];
    void roll(char c)
    {
        int tmp;
        if (c == 'E')
        {
            tmp = s[1];
            s[1] = s[4];
            s[4] = s[6];
            s[6] = s[3];
            s[3] = tmp;
        }
        if (c == 'W')
        {
            tmp = s[1];
            s[1] = s[3];
            s[3] = s[6];
            s[6] = s[4];
            s[4] = tmp;
        }
        if (c == 'N')
        {
            tmp = s[1];
            s[1] = s[2];
            s[2] = s[6];
            s[6] = s[5];
            s[5] = tmp;
        }
        if (c == 'S')
        {
            tmp = s[1];
            s[1] = s[5];
            s[5] = s[6];
            s[6] = s[2];
            s[2] = tmp;
        }
    }
    int top(){
        return s[1];
    }
};
int main()
{
    Dice d;
    char s1[110];
    for(int i = 1;i<7;i++){
        scanf("%d",&d.s[i]);
    }
    cin >> s1;
    for(int i = 0;s1[i]!='\0';i++){
        d.roll(s1[i]);
    }
    cout << d.top() << endl;

}


Measured memory_bytes: 3220
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <tuple>

using namespace std;

class Solver {
};
int main() {
	while (true) {
		int w, h;
		cin >> w >> h;
		if (w == 0)break;

		vector<vector<char>>grid(h, vector<char>(w));
		for (int i = 0; i < h; i++) {
			string s;
			cin >> s;
			for (int j = 0; j < w; j++) {
				grid[i][j] = s[j];
			}
		}

		vector <vector<vector<string>>>grid_vals(h,
			vector<vector<string>>(w));

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				string s = "";
				for (int k = 0; k < 80; k++) {
					s += '0';
				}
				grid_vals[i][j].emplace_back(s);
			}
		}

		string res = "";
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (grid[i][j] < '0' || '9' < grid[i][j])continue;

				sort(grid_vals[i][j].begin(), grid_vals[i][j].end());
				string next
					= grid_vals[i][j][grid_vals[i][j].size() - 1].substr(1);
				next += grid[i][j];
				res = max(res, next);
				if (i + 1 < h)grid_vals[i + 1][j].emplace_back(next);
				if (j + 1 < w)grid_vals[i][j + 1].emplace_back(next);
			}
		}

		bool val = false;
		int cnt = 0;
		for (int i = 0; i < res.size(); i++) {
			if ('1' <= res[i] && res[i] <= '9')val = true;
			if (!val)continue;
			cout << res[i];
			cnt++;
		}
		if (cnt == 0)cout << 0;
		cout <<  endl;
	}
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x;
  int a=0,b=0;
  for(int i=0;i<3;++i){
    cin>>x;
    if(x==5){
      a++;
    }
    else if(x==7){
      b++;
    }
  }
  if(a==2 && b==1){
    cout<<"YES";
    return 0;
  }
  else{
    cout<<"NO";
    return 0;
  }
}


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

int main() {
  	int n, m;
	cin>>n>>m;
  	if ( n > m ) {
      for ( int i=0; i<n; i++ ){
      	printf("%d", m);
      }
    }
  	else {
      for ( int i=0; i<m; i++ ){
        printf("%d", n);
      }
    }
}

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

int solve();

int main()
{
	printf("%d\n", solve());

	return 0;
}

int solve()
{
	int X;
	scanf("%d", &X);
	for (int i{1}; i * 100 <= X; i++)
	{
		int rest{X - i * 100};
		int need{rest / 5};
		if (rest % 5 != 0)
			need++;
		if (need <= i) return 1;
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll h,w;
  cin>>h>>w;
  if(h==1||w==1){
    cout<<1;
    exit(0);
  }
  cout<<(h*w+1)/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, 0, n) {
        cin >> a[i];
    }
    ll sum = a[0];
    rep(i, 1, n) sum ^= a[i];
    rep(i, 0, n) {
        ll ans = sum ^ a[i];
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair < int, int > ii;

const int N = 1e5 + 5;
const int mod = 1e9 + 7;

inline int add(int x, int y) {
  return x + y >= mod ? x + y - mod : x + y;
}

inline int mul(int x, int y) {
  return (ll) x * y % mod;
}

inline int fe(int x, int k) {
  int res = 1;
  while(k) {
    if(k & 1)
      res = mul(res, x);
    x = mul(x, x);
    k >>= 1;
  }
  return res;
}

inline int dv(int x, int k) {
  return mul(x, fe(k, mod - 2));
}

int n;
char a[N];
int dp[N][2];

int main() {
  scanf("%s", a + 1);
  n = strlen(a + 1);
  dp[n + 1][0] = 1;
  dp[n + 1][1] = 1;
  for(int i = n; i >= 1; i--) {
    dp[i][1] = mul(dp[i + 1][1], 3);
    dp[i][0] = dp[i + 1]['0' < a[i]];
    if(a[i] == '1')
      dp[i][0] = add(dp[i][0], mul(2, dp[i + 1][0]));
    // printf("i = %d d0 = %d d1 = %d\n", i, dp[i][0], dp[i][1]);
  }
  printf("%d\n", dp[1][0]);
  return 0;
}

Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main d = new Main();
        long[] answer = d.solve();
        int M = answer.length;
        for (int i = 0; i < M; i++) {
            System.out.println(answer[M - 1 - i]);
        }
    }

    public long[] solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        int[] A = new int[M];
        int[] B = new int[M];
        List<String> edge_list = new ArrayList<>();
        for (int i = 0; i < M; i++) {
            A[i] = scan.nextInt() - 1;
            B[i] = scan.nextInt() - 1;
        }
        UnionFind union_find = new UnionFind(N);
        long[] answer = new long[M];
        //long current_answer = new BigInteger(Integer.toString(N)).multiply(new BigInteger(Integer.toString(N - 1))).divide(new BigInteger("2")).longValue();
        long current_answer = ((long) N) * ((long) N - 1) / 2;
        int i = 0;
        do {
            answer[i] = current_answer;
            int a_parent = union_find.find(A[M - 1 - i]);
            int b_parent = union_find.find(B[M - 1 - i]);
            if (a_parent != b_parent) {
                current_answer = current_answer - union_find.size(a_parent) * union_find.size(b_parent);
            }
            union_find.unite(A[M - 1 - i], B[M - 1 - i]);
            i += 1;
        } while (i < M);
        return answer;
    }

    class UnionFind {
        private int[] parent = null;
        private int[] rank = null;
        private int[] size = null;
        public UnionFind(int N) {
            int[] parent = new int[N];
            for (int i = 0; i < N; i++) {
                parent[i] = -1;
            }
            this.parent = parent;
        }

        public int size(int x) {
            int parent = this.find(x);
            return -this.parent[parent];
        }
        public void unite(int x, int y) {
            x = this.find(x);
            y = this.find(y);
            if (x == y) {
                return;
            }
            if (this.parent[x] < this.parent[y]) {
                this.parent[x] += this.parent[y];
                this.parent[y] = x;
                return;
            }
            this.parent[y] += this.parent[x];
            this.parent[x] = y;
        }

        public int find(int x) {
            if (this.parent[x] < 0) {
                return x;
            }
            return this.parent[x] = find(this.parent[x]);
        }

        public boolean same(int x, int y) {
            return find(x) == find(y);
        }
    }
}


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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

ll n;
string s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	n++;
	s = to_string(n);
	cout << (s[0] - '0') + (s.size() - 1) * 9 - 1 << endl;
	return 0;
}


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


def read():
    A, B, C = map(int, input().strip().split())
    return A, B, C


def solve(A, B, C):
    if A % 2 != 0 or B % 2 != 0 or C % 2 != 0:
        return 0
    if A == B and B == C:
        return -1
    n = 0
    while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        a = B // 2 + C // 2
        b = C // 2 + A // 2
        c = A // 2 + B // 2
        A = a
        B = b
        C = c
        n += 1
    return n


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


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
#define per(i,a,b) for (int i=(a); i>=(b); i--)
using namespace std;

const int maxn = 2005;
const int mod = 1000000007;
int fac[maxn*maxn], rev[maxn*maxn], f[maxn<<1][maxn];
int n, K, ans;

inline int power(int x, int p) {
	int res = 1;
	while (p) {
		if (p & 1) res = 1ll * res * x % mod;
		x = 1ll * x * x % mod; p >>= 1;
	}
	return res;
}

inline int C(int n, int m) {
	return 1ll * fac[n] * rev[m] % mod * rev[n-m] % mod;
}

int main() {
	scanf("%d%d", &n, &K);
	if (K == 1) return puts("1"), 0;
	fac[0] = rev[0] = 1;
	rep (i, 1, maxn*maxn-1) {
		fac[i] = 1ll * fac[i-1] * i % mod;
		rev[i] = power(fac[i], mod - 2);
	}
	f[0][0] = 1;
	rep (i, 1, n*2) rep (j, 0, n)
		if (f[i-1][j]) {
			if (j*2 > i-1) 
				f[i][j] = (f[i][j] + f[i-1][j]) % mod;
			f[i][j+1] = (f[i][j+1] + 1ll * f[i-1][j] * C(K * (i-1-j) + (K-1) * (2*j-i+1) + K-2, K-2)) % mod;
		}
	ans = 1ll * f[n*2][n] * fac[n] % mod;
	printf("%d\n", ans);
	return 0;
}

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

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

answer = 'Yes'
for x,y in ['EW','NS','WE','SN']:
    if x in S and y not in S:
        answer = 'No'

print(answer)

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n,m,k; cin >> n >> m >> k; vl num(m*n+1,0);
  
  for(ll i=0; i <= n; i++){
    for(ll j=0; j <= m; j++){
      num[i*j+(n-i)*(m-j)] = 1;
    }
  }
  
  if(num[k] == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
}
      

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+20;
//题意:给出一个括号序列,问最少添加多少个字符使得序列合法并且字典序尽量小(左括号<右括号).输出方案.
//如果右括号不匹配 字典序最小 添加左括号到最前面即可 
int n;
string a;
stack<char> s;
int main()
{ 
	while(cin>>n>>a)
	{
		int cnt=0;
		for(int i=0;a[i];i++)
		{
			if(a[i]=='(')
				s.push(a[i]);
			else
			{
				if(s.empty())
					cnt++;
				else
					s.pop();//弹出左括号 
			}	
		}
		for(int i=0;i<cnt;i++)
			cout<<'(';
		for(int i=0;a[i];i++)//合法的都打印出来 
			cout<<a[i];
		cnt=0;
		//若还有左扩号,则右括号尽量放后面 
		while(!s.empty())
			s.pop(),cnt++;
		for(int i=0;i<cnt;i++)
			cout<<')';
		cout<<endl; 
	}
	return 0;
} 

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad

change :: Int -> Int -> Int
change m t
  | m >= 500  = change (m `mod` 500) (t + (m `div` 500))
  | m >= 100  = change (m `mod` 100) (t + (m `div` 100))
  | m >= 50   = change (m `mod` 50) (t + (m `div` 50))
  | m >= 10   = change (m `mod` 10) (t + (m `div` 10))
  | m >= 5    = change (m `mod` 5) (t + (m `div` 5))
  | m >= 1    = t + m
  | otherwise = t

main :: IO()
main = do
  line <- (read :: String -> Int) <$> getLine
  unless (line == 0) $
    do print $ change (1000 - line) 0
       main

Measured memory_bytes: 3612
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
long long int a[333],b[333],c[333],d[333];

int n, m;
void dfs(int a);
 
int main(void) {
    ll n, m, k=0;
    double A, B, ans=0;
    cin >> n >> m;
    
    A=100*(n-m)+1900*m;
    B=pow(2, m);
    
    cout << A*B << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    int ans =0;
    int cnt = 1;
    if( b != 1){
        while(cnt<b){
            cnt--;
            cnt+=a;
            ans++;
        }
    }
    cout << ans;


    return 0;
}


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

struct P {
  int n;
  int x;
  int y;
  bool b;

  P() {
    P(0,0,0,false);
  }

  P(int n, int x, int y, bool b): n(n),x(x),y(y),b(b) {}

  bool operator<(const P &obj) const {
    return n > obj.n;
  }
};

char a[102][102];
bool u[102][102];
int w, h;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

int solve() {
  P p;
  priority_queue<P> q;
  q.push(P(0,0,0, false));
  int xx, yy, n;
  for (int i=0; i<=h+1; i++) {
    for (int j=0; j<=w+1; j++) {
      u[i][j] = false;
    }
  }
  while (!q.empty()) {
    p = q.top();
    q.pop();
    u[p.y][p.x] = true;
    if (a[p.y][p.x] == -1) {
      return p.n;
    }
    for (int i=0; i<4; i++) {
      xx = p.x + dx[i];
      yy = p.y + dy[i];
      if (xx < 0 || xx > w+1 || yy < 0 || yy > h+1 || u[yy][xx]) continue;
      if (!p.b && a[yy][xx]==1) {
        n = p.n+1;
      } else {
        n = p.n;
      }
      q.push(P(n, xx, yy, a[yy][xx]==1));
    }
  }
  return -1;
}

int main() {
  char buf[105];
  while (1) {
    scanf("%d %d\n", &w, &h);
    if (!w && !h) break;
    for (int i=0; i<=h+1; i++) {
      for (int j=0; j<=w+1; j++) {
        a[i][j] = false;
      }
    }
    for (int i=0; i<h; i++) {
      fgets(buf, sizeof(buf), stdin);
      for (int j=0; j<w; j++) {
        if (buf[j] == '#') {
          a[i+1][j+1] = 1;
        } else if (buf[j] == '.') {
          a[i+1][j+1] = 0;
        } else {
          a[i+1][j+1] = -1;
        }
      }
    }

    printf("%d\n", solve());
  }

  return 0;
}

Measured memory_bytes: 1312
N = int(input())
s = [input().strip() for i in range(N)]

dic = {}
for moji in s:
    if moji in dic.keys():
        dic[moji] += 1 
    else: dic[moji] = 1
max_dic = max(dic.values())
ans_list= [k for k, v in dic.items() if v == max_dic]  
ans_list = sorted(ans_list)
for al in ans_list:
    print(al)

Measured memory_bytes: 35220
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>

#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 998244353

using namespace std;


void solve()
{
    int a, b, c, k;

    cin >> a >> b >> c >> k;

    if (k <= a)
    {
        cout << k << endl;
        return;
    }

    if (k <= a + b)
    {
        cout << a << endl;
        return;
    }

    cout << a - (k - a - b) << endl;

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

    int T = 1;
    // cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}



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

typedef long long ll;

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

    if(s.compare(u) == 0) {
        cout << a-1 << " " << b;
    }else if(t.compare(u) == 0){
        cout << a << " " << b - 1;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

vector<string> split(const string &str, char delim) {
	vector<string> res;
	size_t current = 0, found;
	while((found = str.find_first_of(delim, current)) != string::npos) {
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}

int formula(string& s, int& i) {
	if(s[i] == '(') {
		i++;
		int val = formula(s, i);

		char op = s[i];
		if(s[i] == '-' && s[i+1] == '>') {
			i++;
			op = s[i];
		}

		i++;
		int val2 = formula(s, i);

		int ret = 0;
		if(op == '+') {
			if(val || val2) ret = 1;
			else ret = 0;
		} else if(op == '*') {
			if(val && val2) ret = 1;
			else ret = 0;
		} else if(op == '>') {
			if(!val) ret = 1;
			else if(val2) ret = 1;
			else ret = 0;
		}

		i++;
		return ret;
	} else if(isdigit(s[i])) {
		int ret = s[i] - '0';
		i++;
		return ret;
	} else if(s[i] == '-') {
		i++;
		int ret = formula(s, i);

		if(ret == 0) return 1;
		else return 0;
	}
}

bool used[30];

int main() {
	string s;

	while(cin >> s) {
		if(s == "#") break;

		vector<string> ret = split(s, '=');
		string s1 = ret[0];
		string s2 = ret[1];

		bool flag = true;

		rep(i, 1<<11) {
			memset(used, 0, sizeof(used));
			rep(j, 11) {
				if(i & (1<<j)) used[j] = true;
			}

			string t1 = s1, t2 = s2;
			rep(j, t1.size()) {
				if('a' <= t1[j] && t1[j] <= 'k') {
					if(used[t1[j] - 'a']) t1[j] = 'T';
					else t1[j] = 'F';
				}

				if(t1[j] == 'T') t1[j] = '1';
				if(t1[j] == 'F') t1[j] = '0';
			}

			rep(j, t2.size()) {
				if('a' <= t2[j] && t2[j] <= 'k') {
					if(used[t2[j] - 'a']) t2[j] = 'T';
					else t2[j] = 'F';
				}

				if(t2[j] == 'T') t2[j] = '1';
				if(t2[j] == 'F') t2[j] = '0';
			}

			int j = 0, k = 0;
			int f1 = formula(t1, j);
			int f2 = formula(t2, k);

			if(f1 == f2) continue;

			flag = false;
			break;
		}

		if(flag) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;
}

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

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

n = int(input())
h = [int(i) for i in readline().split()]
#lr = [[int(i)-1 for i in readline().split()] for _ in range(q)]


res = [0]
for i in range(n-2,-1,-1):
    if h[i] >= h[i+1]:
        res.append(res[-1]+1)
    else:
        res.append(0)


print(max(res))

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>

i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

i64 cup(i64 xxx, i64 yyy) {//切り上げ
	return (xxx + yyy - 1) / yyy;
}

//メモリ置き場
int n, r;

//inputします
void input() {
	cin >> n >> r;
}

//ライブラリ置き場


//main
int main() {
	input();
	if (n > 9) {
		cout << r;
	}
	else {
		cout << r + (10 - n) * 100;
	}
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
void rd(long long &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
long long N, P;
long long doit(long long i){
  int Lj4PdHRW, k=0;
  long long res=1;
  while(P%i==0){
    k++;
    P /= i;
  }
  k /= N;
  for(Lj4PdHRW=0;Lj4PdHRW<k;Lj4PdHRW++){
    res *= i;
  }
  return res;
}
int main(){
  long long i, j, res=1;
  rd(N);
  rd(P);
  for(i=2;i*i<=P;i++){
    if(P%i==0){
      res *= doit(i);
    }
  }
  if(P > 1){
    res *= doit(P);
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20180730-1

// --- original code ---
// ll N, P;
// 
// ll doit(ll i){
//   int k = 0;
//   ll res = 1;
//   while(P%i==0){
//     k++;
//     P /= i;
//   }
//   k /= N;
//   rep(k) res *= i;
//   return res;
// }
// 
// {
//   ll i, j;
//   ll res = 1;
//   rd(N,P);
// 
//   for(i=2;i*i<=P;i++){
//     if(P%i==0) res *= doit(i);
//   }
//   if(P > 1) res *= doit(P);
// 
//   wt(res);
// }


Measured memory_bytes: 256
A=input()
l=["A","a","B","b","C","c","D","d","E","e","F","f","G","g","H","h","I","i","J","j","K",
   "k","L","l","M","m","N","n","O","o","P","p","Q","q","R","r","S","s","T","t","U","u",
   "V","v","W","w","X","x","Y","y","Z","z"]
for i in range(len(l)):
    if A==l[i]:
        if i%2==0:
            print("A")
        else:
            print("a")
        break

Measured memory_bytes: 9140
#include<iostream>
using namespace std;
int main(){
  long long a;
  long long answer=0;
  cin>>a;
  for(long long i=1;i<=a;i++){
    if((i%5==0||i%3==0)){
      
    }else if(i%5==0&&i%3==0){
    }else{
      answer+=i;
    }
  }
  cout<<answer<<endl; 
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <map>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  map<int, string> S;

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

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      int count = 0;
      if(S[i][j] == '.'){
        count = 0;
        for(int diffH = -1; diffH <= 1; diffH++){
          if(diffH + i < 0 || diffH + i >= H) continue;
          for(int diffW = -1; diffW <= 1; diffW++){
            if(diffW + j < 0 || diffW + j >= W) continue;
            if(S[diffH + i][diffW + j] == '#') count++;
          }
        }
        S[i][j] = to_string(count)[0];
      }
    }
    cout << S[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
#define pi 3.141592653589
using namespace std;
signed main() {
	ll n;
	string s, t;
	cin >> n >> s >> t;
		for (int i = 0; i < n; i++) {
			if (s.substr(i, n - i) == t.substr(0, n - i)) {
				cout << n + i << endl;
				return 0;
			}
		}
		cout << 2 * n << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256
/// In The Name Of God
/// I wish, that I could leave it all behind me / Go to my own world where no one can find me
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define pii pair <int , int>
#define ld long double
#define for2(a,b,c) for(int (a) = (b); (a) < (c); (a)++)
#define setp cout << fixed << setprecision(15)
#define endl "\n"
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define error(x) cerr << #x << " = " << (x) << endl;
#define all(x) (x).begin() , (x).end()


int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k; cin >> n >> k;
    int ans = 0;
    int cnt = 0;
    int l,r;
    for2(i,0,n){
        int x; cin >> x;
        if(x == 1){
            l = cnt;
            cnt = -1;

        }
        cnt++;
    }
    r = cnt;
    bool b = 0;
    for2(j,1,k){
        if(l%(k-1) != 0) l --,b=1;
        else if(r%(k-1) != 0) r--,b=1;
    }

    cout << (l+k-2)/(k-1) + (r+k-2)/(k-1) + b << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String l = sc.next();
		char []a = l.toCharArray();
		int count= 0;
		
		for(int i = 1; i <=3; i++) {
			if(a[i] == a[i-1]) {
				count++;
			}			
		}
		if(count == 0) {
			System.out.println("Good");
		}
		if(count != 0) {
			System.out.println("Bad");
		}

	}

}


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

int main(){
    int n,a;
    int odd=0;
    cin >> n;

    for(int i=0; i<n; i++){
        cin >> a;
        if(a%2 == 1){
            odd++;
        }
    }
    if(odd%2 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bitset<2000002> b;
int sum,k;
int main() {
	int n,V;
	scanf("%d",&n);
	b[0]=1;
	while(n--) { 
		int v;
		scanf("%d",&v);
		b|=b<<v;
		sum+=v;
	}
	int i=(sum)/2+1;
	while(i--)  if(b[i]) {k=sum-i;break;}
	printf("%lld",k);
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll n,x,y; cin>>n>>x>>y;
    vector<ll>ans(n-1);
    Graph G(n);
    rep(i,n-1){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[x-1].push_back(y-1);
    G[y-1].push_back(x-1);
    rep(i,n){
        vector<ll>dist(n,-1);
        dist[i]=0;
        queue<ll>q;
        q.push(i);
        while(!q.empty()){
            ll b=q.front();
            q.pop();
        for(auto p:G[b]){
            if(dist[p]!=-1)continue;
            dist[p]=dist[b]+1;
            ans[dist[p]-1]++;
            q.push(p);
        }
    }
    }
    rep(i,n-1)cout<<ans[i]/2<<endl;
}



















































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

using namespace std;
typedef long long ll;

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

  bool is_prime[100010];
  int cum[100010] = {};
  fill(is_prime, is_prime + 100010, true);
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= 100000; i++) {
    cum[i] += cum[i - 1];
    if (!is_prime[i]) continue;
    cum[i] += i & 1 && is_prime[(i + 1) / 2];
    for (int j = 2 * i; j <= 100000; j += i) {
      is_prime[j] = false;
    }
  }
  
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    cout << cum[r] - cum[l - 1] << endl;
  }

  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int N, M;
    int a[110000];
    int sum[110000];
    int delta = 110000;
    int roop;
    int i,j;
    int ans = 0;

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

    for(i=0; i<=N; i++){
        sum[i] = 1;
    }

    for(i=0; i<M; i++){
        scanf("%d", &a[i]);
        sum[a[i]] = 0;
    }

    if(M>1){
        for(i=1; i<M; i++){
            if(delta > (a[i]-a[i-1])){
                delta = a[i] - a[i-1];
            }
        }
    }

    for(i=2; i<=N; i++){
        if(sum[i] != 0){
            sum[i] = (sum[i-1]+sum[i-2])%1000000007;
        }

    }

    if(delta == 1){
        printf("0");
    }else{
        printf("%d", sum[N]);
    }

    return 0;

}

Measured memory_bytes: 896
import sys
from collections import defaultdict
from itertools import accumulate

input = sys.stdin.readline

N, K = map(int, input().split())
sushi = defaultdict(list)
for i in range(N):
    t, d = map(int, input().split())
    sushi[t].append(d)

X, Y = [], []
for v in sushi.values():
    v = sorted(v, reverse=True)
    X.append(v[0])
    if len(v) > 1:
        Y += v[1:]
X = sorted(X, reverse=True)
Y = sorted(Y, reverse=True)

X = [0] + [x for x in accumulate(X)]
Y = [0] + [x for x in accumulate(Y)]

ans = 0
for i in range(1, min(len(X), K + 1)):
    j = K - i
    if j < len(Y):
        ans = max(ans, X[i] + Y[j] + i * i)
print(ans)


Measured memory_bytes: 33952
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

int main() {
    int n = 0, t = 0;
    cin >> n >> t;
    vector<pair<ll, ll>> dish(n);
    for (int i=0; i<n; i++) {
        cin >> dish.at(i).first >> dish.at(i).second;
    }

    auto cmp = [](pair<ll, ll> i, pair<ll, ll> j) {
        return i.first < j.first;
    };

    sort(dish.begin(), dish.end(), cmp);

    vector<vector<ll>> dp(n+1, vector<ll>(t+1));
    for (int i=1; i<n+1; i++) {
        ll time = dish.at(i-1).first, good = dish.at(i-1).second;
        for (int j=1; j<t+1; j++) {
            if (j - time >= 0) {
                dp.at(i).at(j) = max(dp.at(i-1).at(j), dp.at(i-1).at(j-time) + good);
            } else {
                dp.at(i).at(j) = dp.at(i-1).at(j);
            }
        }
    }

    ll ans = 0;
    for (int i=0; i<n; i++) {
        ans = max(ans, dish.at(i).second + dp.at(i).at(t-1));
    }
    cout << ans << endl;
    return 0;
}
 

Measured memory_bytes: 70784
//最大流問題
//辺の構造体を持つ隣接リストで表現
//いつものadjlistじゃあダメかなぁ
//実装大変そう
//蟻本実装
//アルゴリズムは理解した　正当性はようわからん

#include<bits/stdc++.h>
using namespace std;
#define MAX_V 1000000
#define INF 1e9

//辺を表す構造体　(行先、容量、逆辺の場所)
struct edge{
    int to, cap, rev;
};

vector<vector<edge> > G(MAX_V);       //グラフの隣接リスト表現
bool used[MAX_V];                    //DFSですでに調べたかのグラフ


// from から to へ向かう容量 cap の辺をグラフに張る
void add_edge(int from, int to, int cap){

    edge F;
    edge T;
    F.to = to;
    F.cap = cap;
    F.rev = G[to].size();
    G[from].push_back(F);

    T.to = from;
    T.cap = 0;
    T.rev = G[from].size() - 1;
    G[to].push_back(T);    
}

//増加パスをDFSで探す
int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        edge &e = G[v][i];                          //すごい
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;            //もっとすごい
                return d;
            }
        }
    }
    return 0;
}

//s から t への最大流を求める
int max_flow(int s, int t){
    int flow = 0;
    while(1){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}

int main(){

    //入力
    int v, e, s, g; cin >> v >> e;              //v := 頂点数　e := 辺数 s := スタート g := ゴール
    s = 0;
    g = v - 1;

    for(int i = 0; i < e; i++){
        int from, to, cap; cin >> from >> to >> cap;
        add_edge(from, to, cap);
    }

    
    cout << max_flow(s, g) << endl;
    return 0;
}





Measured memory_bytes: 27408
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;

int n, a, b, c, d, q, ans;

int main() {
	INIT
	cin >> a >> b >> c;
	ans = c / a * b;
	cout << ans;

	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;
int N;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	N=S.size();
	
	cout<<min(count(ALL(S),'0'),count(ALL(S),'1'))*2<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


#define MOD ((lli)(1000000007))
lli mop(lli p,lli q){
	lli res=1,bp=p,b=1;
	while(q){
		if(q&b){
			res=(res*bp)%MOD;
			q-=b;
		}
		bp=(bp*bp)%MOD;
		b*=2;
	}
	return res;
}

lli inv(lli p){
	return mop(p,MOD-2);
}

lli fact(int p){
	lli res=1;
	reg(i,1,p)res=(res*i)%MOD;
	return res;
}


lli fdat[300005];

lli ifdat[300005];

void init(){
	{
		fdat[0]=fdat[1]=1;
		lli r=1;
		reg(i,1,300004){
			r=(r*i)%MOD;
			fdat[i] = r;
		}
	}

	{
		ifdat[0]=ifdat[1]=1;
		lli r=1;
		reg(i,1,300004){
			r=(r*inv(i))%MOD;
			ifdat[i] = r;
		}
	}
}


lli comb(lli p,lli q){
	lli res=(((fdat[p]*ifdat[q])%MOD)*ifdat[p-q])%MOD;
	return res;
}



int h,w,a,b;
int main(void){
	scanf("%d%d%d%d",&h,&w,&a,&b);
	init();
	lli ans=comb(h+w-2,w-1);
	while(a>=1 && b>=1){
		ans=(ans+MOD-(comb(b-1+h-a,b-1)*comb(a-1+w-b,a-1))%MOD)%MOD;
		a--; b--;
	}
	printf("%lld\n",ans);
	return 0;
}




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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N;
    cin >> N;
    vector<vector<ll>> V(N, vector<ll>(N));
    vector<unordered_set<int> > G(N, unordered_set<int>());
    REP(i, N) {
        REP(j, N) {
            cin >> V[i][j];
        }
    }
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> PQ;
    REP(s, N) {
        vector<ll> dist(N, LLONG_MAX);
        VI parent(N);
        PQ.push({0, s});
        dist[s] = 0;
        while (!PQ.empty()) {
            auto top = PQ.top();
            PQ.pop();
            int v = top.second;
            if (top.first > dist[v]) continue;
            REP(i, N) {
                if (i == v) continue;
                ll d = top.first + V[v][i];
                if (d < dist[i]) {
                    PQ.push({d, i});
                    dist[i] = d;
                    parent[i] = v;
                } else if (d == dist[i]) {
                    parent[i] = v;
                }
            }
        }
        REP(i, N) {
            if (i == s) continue;
            if (dist[i] != V[s][i]) {
                cout << -1 << '\n';
                return 0;
            }
            G[parent[i]].insert(i);
            G[i].insert(parent[i]);
        }
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int v : G[i]) {
            ans += V[v][i];
        }
    }
    cout << ans / 2  << '\n';
}

Measured memory_bytes: 1152
from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))


def main():
    n = input()
    a = readLine_int_list()

    c = []
    _c = [] 

    for i in a:
        rank = i//400
        if rank > 7:
           _c.append(rank) 
        else:    
            c.append(rank)
    
    
    p = len(set(c))
    print(max(1,p), p+len(_c))

        
if __name__ == "__main__":
    main()



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x;
  cin>>x;
  if(x>=400 && x<=599)
    cout<<"8"<<endl;
  
  else if(x>=600 && x<=799)
    cout<<"7"<<endl;
  
  else if(x>=800 && x<=999)
    cout<<"6"<<endl;
  
  else if(x>=1000 && x<=1199)
    cout<<"5"<<endl;
  
  else if(x>=1200 && x<=1399)
    cout<<"4"<<endl;
  
  else if(x>=1400 && x<=1599)
    cout<<"3"<<endl;
  
  else if(x>=1600 && x<=1799)
    cout<<"2"<<endl;
  
  else 
    cout<<"1"<<endl;
}

Measured memory_bytes: 3636
//#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;

using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<ll, ll> pii;
typedef long double ld;
#define double long double
typedef pair<ld, ld> pld;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

typedef vector<ll> vi;
typedef vector<pii> vpii;
namespace IO {
    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> &a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> &a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> &a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define int ll

void solve() {
    int a;
    cin >> a;
    ld b;
    cin >> b;
    put((int)(a*b));
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;
    while (q--) solve();
}



Measured memory_bytes: 3748
i,m,n,x;
main(a){
  for(;1;)
    {
      scanf("%d",&i);
      if(!i)exit(0);
      for(a=1,x=0;a<13;a++)
        {
          scanf("%d%d",&m,&n);
          i-=(m-n);
          if(i<1&&!x)x=a;
        }
      if(x)
        printf("%d\n",x);
      else
        puts("NA");
    }
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define mov(x) (1ll<<(x))

using namespace std;

template <typename T> void read(T& x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

typedef long long ll;

bool calc(ll x, int b)
{
	ll rem = (x+1) % mov(b+1);
	bool flg = 0;
	if(b == 0) flg = (((x+1)/2)&1);
	if(rem <= mov(b)) return flg;
	else return (((rem-mov(b))&1)^flg);
}

int main()
{
	ll a, b, c = 0;
	read(a); read(b);
	if(a == 0)
	{
		for(int i=0; i<60; i++)
			if(calc(b, i))
				c |= mov(i);
		printf("%lld\n", c);
	}
	else
	{
		a--;
		for(int i=0; i<60; i++)
			if(calc(a, i) ^ calc(b, i))
				c |= mov(i);
		printf("%lld\n", c);
	}
	return 0;
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define MSG(msg1,msg2,flag) cout<<((flag)? msg1:msg2);

#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
template <class T> map<T,int> 
count_same_elements(const vector<T>& v){map<T,int>cmap; for_each(v.begin(),v.end(),[&cmap](auto x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}

string s;
void input(){
    cin>>s;
}
void src(){
    int max=0;
    repi(i,1,s.size()){
        rep(j,s.size()-i+1){
            string s2 = s.substr(j,i);
            if(all_of(s2.begin(),s2.end(),[](char x){return (x=='A' or x=='T' or x=='C' or x=='G');})){
                chmax(max,(int)i);
            }
        }
    }
    cout<<max;
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256