akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void preorder(Node *u) {
	if (u == NIL)return;

	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}

void inorder(Node *u) {
	if (u == NIL)return;

	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left=z;
		}
		else {
			y->right=z;
		}
	}
}

Node *find(Node *x, int k) {
	while (x != NIL && k != x->key) {
		if (k < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	return x;
}

int main() {
	int n, i, x;
	string com;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		cin >> com;
		if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (com[0]=='f') {
			scanf("%d", &x);
			Node *t = find(root, x);
			if (t != NIL)printf("yes\n");
			else printf("no\n");
		}
	}
	return 0;
}


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

#define int long long

using namespace std;

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

        if (s.size() == 1)
                return cout << k / 2, 0;

        int first = -1, last, sz = 0, ans = 0;
        for (int i = 0; i < s.size(); i++) {
                int cur = 1;
                while (i + 1 < s.size() && s[i + 1] == s[i])
                        ++i, ++cur;
                if (!~first)
                        first = cur;
                last = cur;
                ans += cur / 2;
                ++sz;
        }
        if (k == 1)
                return cout << ans, 0;
        if (sz == 1)
                return cout << (int)s.size() * k / 2, 0;
        if (s.front() == s.back()) {
                if ((first & 1) && (last & 1))
                        return cout << ans * k + k - 1, 0;
        }

        cout << ans * k;

        return 0;
}


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

int color[101010], sz[101010];
vector<int> f[101010], b[101010];

void dfs(int x, int c){
    color[x] = c;
    sz[c]++;
    for(auto to : f[x]){
        if(color[to] == -1)dfs(to, c);
    }
}


int main(){
    int n, m, k;
    cin >> n >> m >> k;
    for(int i=0;i<m;i++){
        int x, y;
        cin >> x >> y;
        --x; --y;
        f[x].push_back(y);
        f[y].push_back(x);
    }
    for(int i=0;i<k;i++){
        int x, y;
        cin >> x >> y;
        --x; --y;
        b[x].push_back(y);
        b[y].push_back(x);
    }

    for(int i=0;i<n;i++)color[i] = -1;

    for(int i=0;i<n;i++){
        if(color[i] == -1)dfs(i, i);
    }
    vector<int> ans(n);
    for(int i=0;i<n;i++){
        ans[i] = sz[color[i]] - 1;
        for(auto to : f[i]){
            if(color[i] == color[to])--ans[i];
        }
        for(auto to : b[i]){
            if(color[i] == color[to])--ans[i];
        }
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<" \n"[i+1==n];
    }
    return 0;
}


Measured memory_bytes: 13056
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    int p,q,r;
    cin>>p>>q>>r;

    int a=p+q;
    int b=q+r;
    int c=r+p;

    cout<<min(a,min(b,c))<<endl;
}



Measured memory_bytes: 3640
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
n = int(input())
dic = {}
for i in range(2, n+1):
    l = factorization(i)
    for j in range(len(l)):
        if l[j][0] not in dic.keys():
            dic[l[j][0]] = 1
        else:
            dic[l[j][0]] += l[j][1]
ans = 1
for i in dic.keys():
    ans *= dic[i]+1
MOD = 10**9+7
print(ans%MOD)

Measured memory_bytes: 42328
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    string s, t;
    cin >> s >> t;
    REP(i, 26) {
        string z = s + char('a' + i);
        if (z == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

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

long long lcm(long long a, long long b){
    return a*b/gcd(a,b);
}

int main(){
    
    ll a,b;
    while(cin>>a>>b){
        cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
    }
    
    return 0;
}

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

void solve()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n)
    {
        int x;
        cin >> x;
        x--;
        a[x]++;
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int ans = 0;
    for (int i = k; i < n; i++)
    {
        ans += a[i];
    }
    cout << ans << endl;
}

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

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

int main(){

    long long N,A,B; cin >> N >> A >> B;
    long long ans = 0;

    ans += A*(N/(A+B));
    if(N%(A+B) >= A){ans += A;}
    else{ans += N%(A+B);}

    cout << ans << endl;
}

Measured memory_bytes: 256
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N = in.nextLong

  val divs = 0 +: (1 to 10).flatMap(i => Array.fill(i + 1)(i))

  def div(n: Long, p: Long, c: Int): Int = {
    if (n == 1L) c
    else if (p * p > n) c + 1
    else {
      def divCount(n0: Long, c0: Int): (Long, Int) = if (n0 % p == 0) divCount(n0 / p, c0 + 1) else (n0, c0)
      val (n0, c0) = divCount(n, 0)
      div(n0, p + 1, c + divs(c0))
    }
  }

  println(div(N, 2L, 0))
}

Measured memory_bytes: 56984
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
//--------------------
#define MOD 1000000007 
using namespace std;
//--------------------
int main(){

	string res = "Odd";
	int A , B ; cin >> A >> B;

	if (A * B % 2 == 0) res = "Even";

	cout << res << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	char a, b;
	cin >> a >> b;
	if (a - 'A' > b - 'A') {
		cout << ">" << endl;
	}
	else if (a - 'A' == b - 'A') {
		cout << "=" << endl;
	}
	else {
		cout << "<" << endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i > ll(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size()) // sizeをsize_tからllに直しておく

#define INF 1000000000000 // 10^12:極めて大きい値,∞
const int MOD = 1000000007;
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define Umap unordered_map
#define Uset unordered_set
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000

void add(long long &a, long long b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}
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;
}

int main() {

    int n, m;
    cin >> n >> m;
    int field_cnt = 0;
    if (n % 2 == 1) {
        for (int l = 1, r = n - 1; l < r; l++, r--) {
            cout << l << " " << r << endl;
            field_cnt++;
            if (field_cnt == m) {
                break;
            }
        }

    } else {
        bool already_pushed = false;
        for (int l = 1, r = n - 1; l < r; l++, r--) {
            if (!already_pushed && (r - l) * 2 <= n) {
                r--;
                already_pushed = true;
            }
            cout << l << " " << r << endl;
            field_cnt++;
            if (field_cnt == m) {
                break;
            }
        }
    }
}


Measured memory_bytes: 3640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int N;
string S[16];
vector<string>C;
int T[16][16];
string dp[1<<15][16];

string mini(string a,string b)
{
	string res=a;
	if(a.length()==0)res= b;
	else if(a.length()==b.length()&&a>b)res=b;
	else if(a.length()>b.length())res=b;
	return res;
}

string solve()
{
	bool flg[16];
	memset(flg,1,sizeof(flg));
	for(int i=0;i<(1<<11);i++)
		for(int j=0;j<11;j++)
			dp[i][j]="";
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			if(i!=j&&flg[j]&&S[j].find(S[i])!=string::npos)
				flg[i]=0;
	C.clear();
	for(int i=0;i<N;i++)
		if(flg[i])
			C.push_back(S[i]);
	N=C.size();
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			if(i!=j)
			{
				int n=C[i].size(),m=C[j].size();
				for(int k=min(n,m);k>=0;k--)
					if(C[i].substr(n-k,k)==C[j].substr(0,k))
					{
						T[i][j]=m-k;
						break;
					}
			}
	//memset(dp,-1,sizeof(dp));
	for(int i=0;i<N;i++)
		dp[1<<i][i]=C[i];
	for(int S=0;S<1<<N;S++)
		for(int u=0;u<N;u++)
			if(S&(1<<u))
				for(int v=0;v<N;v++)
					if(!(S&(1<<v)))
						dp[S|(1<<v)][v]=mini(dp[S|(1<<v)][v],dp[S][u]+C[v].substr(C[v].length()-T[u][v]));
	string res="";
	for(int i=0;i<N;i++)
		res=mini(res,dp[(1<<N)-1][i]);
	return res;
}

int main()
{
	for(;scanf("%d",&N),N;)
	{
		for(int i=0;i<N;i++)
			cin>>S[i];
		cout<<solve()<<endl;
	}
}

Measured memory_bytes: 5836
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int N = 1e5 + 10;
int n, ans;
char s[N];
int main()
{
	scanf("%d%s", &n, s);
	for (int i = 0; i < n; i++)
		if (!i || s[i] != s[i - 1])
			++ans;
	printf("%d", ans);	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<utility>
#include<map>

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

bool cs(pair<int,int> a,pair<int,int> b){
  if(a.second!=b.second)return a.second<b.second;
  else return a.first<b.first;
}
signed main(){
  int n;cin>>n;
  int ans=0;
  vector<int> a(3*n);
  vector<pair<int,int>> af(n*2);
  vector<pair<int,int>> ar(n);
  priority_queue<int> f,r;
  rep(i,3*n){
    cin>>a[i];
    if(i<2*n){
      af[i].second=a[i];
      af[i].first=i;
    }
    else{
      ar[i-2*n].second=a[i];
      ar[i-2*n].first=i;
    }
  }
  sort(af.begin(),af.end(),cs);
  sort(ar.begin(),ar.end(),cs);
  reverse(af.begin(),af.end());
  rep(i,n){
    f.push(af[i].first);
    r.push(ar[i].second);
    ans+=af[i].second-ar[i].second;
  }
  int af_next=n;
  int buf=ans;
  int front=f.top();
  int end=r.top();
  f.pop();r.pop();

  rep(i,n){
    //cout<<"buf="<<buf<<endl;
    int now=2*n-1-i;
    int now_v=a[now];
    //cout<<"a[now]="<<a[now]<<endl;
    //cout<<"end="<<end<<endl;
    if(end>now_v){
      buf+=end-now_v;
      r.push(now_v);
      end=r.top();
      r.pop();
    }
    //cout<<"front="<<front<<endl;
    if(front==now){
      buf-=a[front];
      while(af[af_next].first>now){
        af_next++;
        if(af_next==2*n)goto FINE;
      }
      f.push(af[af_next].first);
      front=f.top();
      f.pop();
      buf+=a[af[af_next].first];
      af_next++;
    }
    if(ans<buf)ans=buf;
  }
  FINE:
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 9076
x=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(x[int(input())-1])

Measured memory_bytes: 3060
# python3
# -*- coding: utf-8 -*-
import sys
import math
#from math import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
sys.setrecursionlimit(1000000000)


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


# main
S, T = input().split()
A, B = mis()
U = input()

if U == S:
    print(str(A-1) + " " + str(B))
else:
    print(str(A) + " " + str(B-1))


Measured memory_bytes: 3808
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	for(int i; cin >> i; printf("3C%02d\n", i)) i = (i - 1) % 39 + 1;
}

Measured memory_bytes: 0
//coded b vishal mourya - the legendary coder
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define f(a,b) for(ll i = a ; i < b ; i++ )
#define fj(a,b) for(ll j = a ; j < b ; j++ )
#define fk(a,b) for(ll k = a ; k < b ; k++ )
#define fasthoja ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(void){
    fasthoja;
    
    ll n; cin >> n;
    
    ll a[10][10] = {0};
    
    for( ll i = 1 ; i <= n ; i++ ) {
        
        ll ld = i % 10;
        ll fd = 0;
        ll t1 = i;
        while( t1 > 0 ) {
            fd = t1 % 10;
            t1 /= 10;
        }
        // ll fd 
        
        a[fd][ld]++;
    }
    
    ll ans = 0;
    for( ll i = 0 ; i < 10 ; i++ ) {
        for( ll j = 0 ; j < 10 ; j++ ) {
            ans += ( a[i][j] * a[j][i] );
        }
    }
    cout << ans << "\n";
 return 0;
}


Measured memory_bytes: 3632
a, b, c, x, y = map(int, input().split())

if a + b <= c * 2:
  ans = a * x + b * y
else:
  common = min(x, y)
  value = a if x >= y else b
  value = min(value, c * 2)
  ans = c * (common * 2) + (max(x, y) - common) * value
print(ans)

Measured memory_bytes: 3060
def greatest_common_divisor(x, y):
    if x < y:
        x, y = y, x

    if y == 0:
        return x
    else:
        return greatest_common_divisor(y, x % y)

if __name__ == '__main__':
    x, y = [int(x) for x in input().split()]
    print(greatest_common_divisor(x, y))

Measured memory_bytes: 5600
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var x = sc.ReadInt();
        if (x < 1200)
        {
            Console.WriteLine("ABC");
        }
        else
        {
            Console.WriteLine("ARC");
        }
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

   class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	if(a+b < 24) {
    		System.out.println(a+b);
    		System.exit(0);
    	}
    	else {
    		System.out.println(a+b-24);
    		System.exit(0);
    	}
    }
}

Measured memory_bytes: 21972
#   ABC129　D問題
H, W = map(int, input().split())    #   1 <= H, W <= 2000
S_arr = []
for _ in range(H):
    S_arr.append(list(input()))

point_arr = [[0]*W for _ in range(H)]

start = 0
stop = W
for y in range(H):
    start = 0
    stop = W
    for x in range(W):
        if S_arr[y][x] == "#":
            stop = x
            for i in range(start, stop):
                point_arr[y][i] += stop - start
            start = stop + 1
    for i in range(start, W):
        point_arr[y][i] += W - start


for x in range(W):  #   コードのコピペ禁止の原則に違反してるけど、改善方法が思いつかない問題
    start = 0
    stop = H
    for y in range(H):
        if S_arr[y][x] == "#":
            stop = y
            for i in range(start, stop):
                point_arr[i][x] += stop - start
            start = stop + 1
    for i in range(start, H):
        point_arr[i][x] += H - start

ans = 0
for i in range(H):
    for j in range(W):
        if ans < point_arr[i][j]:
            ans = point_arr[i][j]
ans -= 1
print(ans)
#   O(H*W)程度の計算量で十分高速だと思ってたのに、そうでもない問題
#   2019/06/10 現在未解決　PyPy使ったらどうなるのかやってみた。Numpy含まれてるからランタイムエラーになるのだろうか？


Measured memory_bytes: 217608
/* https://atcoder.jp/contests/dp/tasks/dp_k */

#include<bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
	ll N, K;
	cin>>N>>K;
	vector<ll> a(N);
	ll x;
	for (auto& x : a) {
		cin>>x;
	}

	vector<bool> dp(K+1);
	for (int i = 0;i <= K;++i) {
		for (int j = 0;j < a.size();++j) {
			if (i - a[j] >= 0 && !dp[i-a[j]]) {
				dp[i] = true;
			}
		}
	}

	/*
	for (auto const& x : dp) {
		cout<<x<<" ";
	}
	*/

	printf("%s\n", dp[K]  ? "First" : "Second");
	
	return 0;
}


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

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

  string strList[N];
  long long m=0, a=0, r=0, c=0, h=0;

  for(int i=0; i<N; ++i){
      cin >> strList[i];

      if (strList[i][0] == 'M') ++m;
      else if (strList[i][0] == 'A') ++a;
      else if (strList[i][0] == 'R') ++r;
      else if (strList[i][0] == 'C') ++c;
      else if (strList[i][0] == 'H') ++h;
  }

  long long combi=0;

  combi = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;

cout << combi;

  return 0;
}


Measured memory_bytes: 6144
n, m = map(int, input().split())
list_num_road = [0 for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  list_num_road[a-1] += 1
  list_num_road[b-1] += 1
for one_city in list_num_road:
  print(one_city)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll l = 100000000000;
    ll r = 999999999999;
    while(l<r){
        ll m = (l + r) / 2;
        cout << "? " << m << endl;
        fflush(stdout);
        char s; cin >> s;
        if(s == 'Y'){
            r = m;
        }else{
            l = m + 1;
        }
    }

    int ans[20] = {};
    while(r % 10 == 0)r /= 10;
    int keta = 0;
    rep(i,20){
        if(r > 0)keta++;
        ans[i] = r % 10;
        r /= 10;
    }

    int nine = 1;
    rep(i,keta){
        if(ans[i] != 9)nine = 0;
    }

    if(nine == 1){
        ll ten = 100000000000000;
        int flag = 0;
        drep(i,15){
            if(i == 0)break;
            cout << "? " << ten << endl;
            ten /= 10;
            fflush(stdout);
            char s; cin >> s;
            if(s == 'Y'){
                flag = i;
                break;
            }
        }
        cout << "! ";
        if(flag == 0){
            rep(i,keta){
                cout << '9';
            }
        }else{
            rep(i,flag+1){
                cout << ans[i];
            }
        }
        cout << endl;
        fflush(stdout);
        return 0;
    }

    int flag = 0;
    ll ten = 100000000000000;
    drep(i,15){
        if(i == 0)break;
        cout << "? " << ten - 1 << endl;
        ten /= 10;
        fflush(stdout);
        char s; cin >> s;
        if(s == 'N'){
            flag = i;
            break;
        }
    }

    cout << "! ";
    rep(i,flag+1){
        if(keta - 1 - i < 0){
            cout << '0';
        }else{
            cout << ans[keta - 1 - i];
        }
        
    }
    cout << endl;
    fflush(stdout);
    return 0;
}
 
 


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

int main(){
    int a, b;
    cin >> a >> b;
    if(a > b) cout << "a > b" << endl;
    if(a < b) cout << "a < b" << endl;
    if(a == b) cout << "a == b" << endl;
    return 0;
}



Measured memory_bytes: 3096
s=input()
y=int(s[:4])
m=int(s[5:7])
d=int(s[8:])

if y<2018:
  ans='Heisei'
elif y==2019 and m<4:
  ans='Heisei'
elif y==2019 and m==4 and d<=30:
  ans='Heisei'
else:
  ans='TBD'
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define re register
int a[300100],n;
int main()
{
	scanf("%d",&n);
	for(re int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);if((a[i]&1)!=(i&1)){puts("No");return 0;}
	}
	for(re int i=n-2;i;i--)if(a[i+2]<a[i+1]&&a[i+1]<a[i])std::swap(a[i],a[i+2]);
	for(re int i=2;i<n;i++)if(a[i-1]>a[i+1]&&(a[i-1]<a[i]||a[i]<a[i+1])){puts("No");return 0;}
	puts("Yes");
}

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1E9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;

int main() {

    ll n, a, b;
    cin >> n >> a >> b;

    ll dist = abs(a - b);
    if ( dist == 1 ) {
        cout << min(max(n - a, n - b), max(a - 1, b - 1)) << endl;
    } else if ( dist & 1 ) {
        ll menor = INFLL;
        ll aux;

        aux = min(n - a, n - b) + 1 + (dist - 1) / 2;
        menor = min(aux, menor);
        aux = min(a - 1, b - 1) + 1 + (dist - 1) / 2;
        menor = min(aux, menor);

        cout << menor << endl;
    }else {
        cout << abs(a - b) / 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, r;
  cin >> n >> r;
  if (n >= 10) {
    cout << r << endl;
  } else {
    cout << r + 100 * (10 - n) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
    cin >> a[i];
  vector<int> L(n), R(n);
  L[0] = a[0];
  R[n-1] = a[n-1];
  for(int i = 1; i < n; i++)
    L[i] = __gcd(a[i], L[i-1]);
  for(int i = n-2; i >= 0; i--)
    R[i] = __gcd(R[i+1], a[i]);
  int ans = L[n-1];
  for(int i = 0; i < n; i++){
    int tmp = -1;
    if(i > 0)
      tmp = L[i-1];
    if(i < n-1){
      if(tmp == -1)
        tmp = R[i+1];
      else
        tmp = __gcd(tmp, R[i+1]);
    }
    if(tmp == -1)
      continue;
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
import java.util.*;

/**
 * B
 */
public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a<b) {
            int tmp = a;
            a = b;
            b = tmp;
        }

        while(b != 0) {
            
            int c = a%b;
            a = b;
            b = c;

        }

        System.out.println(a);

    }
}


Measured memory_bytes: 26216
#include<iostream>
 using namespace std;
int main()
{
    int N,D,man,remainder;
    cin>>N;
    cin>>D;
    man = N / (2*D + 1);
    remainder=N%(2*D+1);
    if(!remainder)
        cout<<man<<endl;
    else
        cout<<man+1<<endl;
 
    return 0;
}

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

int main() {
    int n;
    int flag = 0;
    string s;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> s;
        if (s == "Y") {
            flag = 1;
            break;
        }
    }
    if (flag) {
        cout << "Four" << endl;
    }
    else {
        cout << "Three" << endl;
    }
}


Measured memory_bytes: 3544
package main

import (
  "bufio"
  "fmt"
  "strings"
  "os"
  "strconv"
  "math"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
  sc.Scan()
  return sc.Text()
}


func main()  {
  line := nextLine()
  s := strings.Split(line, " ")
  n  := []float64{}
  for _, v := range s {
    a, _ := strconv.ParseFloat(v, 64)
    n = append(n, a)
  }
  fmt.Println(int(math.Max(0, math.Abs(n[2]-n[1])-n[0])))
}


Measured memory_bytes: 640
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-13 06:59:53
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int64 x; cin >> x;

  int64 t = 1;

  while (t * (t + 1) / 2 < x) {
    ++t;
  }

  debug(t);

  cout << t << endl;

  return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while (cin >> n, n) {
		int flag = 0;
		vi v(1000, INF), ans(1000, 0);
		int t = 0;
		REP(i, n) {
			int M, D, h, m, p;
			char c;
			cin >> M >> c >> D >> h >> c >> m >> c >> p;
			if (c == 'I') {
				v[p] = h * 60 + m;
				if (p == 0) flag = 1;
			}
			else {
				if (flag) {
					if (p == 0) {
						FOR(i, 1, 1000) {
							ans[i] += max(0, h * 60 + m - max(v[i], v[0]));
						}
						flag = 0;
					}
					else ans[p] += max(0, h * 60 + m - max(v[p], v[0]));
				}
				v[p] = INF;

			}
		}
		int p, cmax = -1;
		FOR(i, 1, 1000) {
			if (ans[i] > cmax) {
				p = i;
				cmax = ans[i];
			}
		}
		cout << cmax << endl;
	}
}

Measured memory_bytes: 3088
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
using namespace std;

int main(){
  ll N,K,Q;
  cin>>N>>K>>Q;

vector<ll> p(N,K-Q);
//vector<ll> a(Q);
ll tmp;
for(ll i=0;i<Q;i++){
cin>>tmp;
p[--tmp]++;
}
for(ll i=0;i<N;i++){
  if(p[i]>0){
    cout<<"Yes"<<endl;
  }
  else
  {
        cout<<"No"<<endl;

  }
  
}


}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9

int main(){
    int n; 
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ma, ma2;
    vector<int> sa(n);
    rep(i, n) sa[i] = a[i];
    sort(sa.begin(), sa.end());

    ma = sa[n-1];
    ma2 = sa[n -2];

    rep(i, n) {
        if(a[i] == ma) cout << ma2 << endl;
        else cout << ma << endl;
    }

    return 0;
}



Measured memory_bytes: 4728
import sys
  
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
  
  
table = [0]*26
  
letters = "abcdefghijklmnopqrstuvwxyz"
input_str = sys.stdin.read()
  
for A in input_str:
    index = 0
    for B in letters:
        if A == B or A == B.upper():
            table[index] += 1
            break
        index += 1
  
for i in range(len(letters)):
    print("%s : %d"%(letters[i],table[i]))


Measured memory_bytes: 5576
#include<iostream>
#include<string>
//#include<cmath>
#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>
//#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI N, M, L = 0, R = 1e9,a,b;
	cin >> N >> M;
	for (int i = 0; i < M;i++) {
		cin >> a >> b;
		if (a > L) {
			L = a;
		}
		if (b < R) {
			R = b;
		}
	}
	if (R - L + 1 < 0) {
		cout << 0 << endl;
	}
	else {
		cout << R - L + 1 << endl;
	}
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
#include <cstring>
#include <math.h>

int main(){
	int a, b;
	std::cin >> a >> b;
	int p = a + b, q = a - b, r = a * b;
	std::cout << std::max({ p,q,r }) << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N=100005;
int f[N],Next[N<<1],c[N],s[N],to[N<<1],last[N],fa[N],x,y,n,m,xx,yy,sum,edge,s2[N],a[N],cnt;
int find(int x){
	if (f[x]==x) return x;
	f[x]=find(f[x]);
	return f[x];
}
void dfs(int x,int fa){
	f[x]=fa;
	s[x]=c[x];
	for (int i=last[x];i;i=Next[i])
		if(to[i]!=fa){
			c[to[i]]=0-c[x];
			dfs(to[i],x);
			s[x]=s[x]+s[to[i]];
		}
}
void add(int x,int y){
	to[++edge]=y;
	Next[edge]=last[x];
	last[x]=edge;
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) f[i]=i;
	if (n==m)
	for (int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		int fx=find(x),fy=find(y);
		if (fx==fy) xx=x,yy=y;
		else{
			add(x,y),add(y,x);
			f[fx]=fy;
		} 
	} 
	else
	for (int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		add(x,y),add(y,x);
	}
	memset(f,0,sizeof(f));
	c[1]=1;
	dfs(1,0);
	if (m<n){
		if (s[1]) puts("-1");
		else{
			for (int i=1;i<=n;i++) sum=sum+abs(s[i]);
			printf("%d",sum);
		}
	}else if (c[xx]==c[yy]){
		if (s[1]&1){
			puts("-1");
			return 0;
		}
		int t=-s[1]/2;
		for (;xx;xx=f[xx]) s[xx]+=t;
		for (;yy;yy=f[yy]) s[yy]+=t;
		for (int i=1;i<=n;i++) sum=sum+abs(s[i]);
		printf("%d",sum+abs(t));
	}else{
		if (s[1]){
			puts("-1");
			return 0;
		}
		for (;xx;xx=f[xx]) s2[xx]+=1;
		for (;yy;yy=f[yy]) s2[yy]-=1;
		for (int i=1;i<=n;i++) 
			if (s2[i]==1) a[++cnt]=s[i];
			else if (s2[i]==2) a[++cnt]=s[i],a[++cnt]=s[i];
			else if (s2[i]==-1) a[++cnt]=-s[i];
			else if (s2[i]==-2) a[++cnt]=-s[i],a[++cnt]=-s[i];
		std::sort(a+1,a+cnt+1);
		int t=-a[cnt/2+1];
		for (int i=1;i<=n;i++) sum=sum+abs(s2[i]*t+s[i]);
		printf("%d\n",sum+abs(t));
	}
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll& a, ll b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
bool chmax(ll& a, ll b) {
    if (b > a) {
        a = b;
        return 1;
    }
    return 0;
}
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> x;
    vector<vl> A(11);
    rep(i, 9) A[0].push_back(i + 1);

    rep(i, 10) {
        rep(j, A[i].size()) {
            t = A[i][j] % 10;
            if (t != 0) A[i + 1].push_back(A[i][j] * 10 + t - 1);
            A[i + 1].push_back(A[i][j] * 10 + t);
            if (t != 9) A[i + 1].push_back(A[i][j] * 10 + t + 1);
        }
    }

    a = 0;
  

    while(x){
        ans = A[a][min(ll(A[a].size()), x) - 1];
        x -= min(ll(A[a].size()), x);
        a++;
    }

    cout << ans << endl;
}

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

int main(){
      int N,K;
      string S;
      cin >> N >> K;
      cin >> S;
      for(int i = 0; i <= N;i++){
            if(i == K){
                  if(S[i-1] == 'A'){
                        S[i-1] = 'a';
                  }else if(S[i-1] == 'B'){
                        S[i-1] = 'b';
                  }else{
                        S[i-1] = 'c';
                  }
            }

      }
      cout << S << endl;
}


Measured memory_bytes: 256
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

K, S = map(int, readline().split())
ans = 0
for i in range(K + 1):
    for j in range(K + 1):
        if 0 <= S - i - j <= K:
            ans += 1
print(ans)


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

int main(){
long long int n;
cin >> n;
 vector<int> v(n);
 long long sum=0;
 for(long long int i=0;i<n;i++)
 	 cin >> v[i];
 for(long long int i=0;i<n;i++){
 	for(long long int j=i+1;j<n;j++){
 		sum+= v[i]*v[j];
 		
 	}
 	
 }	
  cout << sum;	
}

Measured memory_bytes: 256
N = int(input())
cnt_s = {}
for _ in range(N):
  s = input()
  if s in cnt_s:
    cnt_s[s] += 1
  else:
    cnt_s[s] = 1
  
max_cnt = max(cnt_s.values())

ans = []
for key, value in cnt_s.items():
  if value == max_cnt:
    ans.append(key)
  
[print(s) for s in sorted(ans)]


Measured memory_bytes: 34012
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)
#define ll long long

int n;
vector<ll> a;

int main(){
    cin >> n;
    REP(i, n){
        ll ai;
        cin >> ai;
        a.push_back(ai);
    }
    sort(a.begin(), a.end());

    ll tmp = -1;
    ll c;
    ll output = 0;
    REP(i, a.size()){
        if(a[i] == tmp){
            c += 1;
        } else {
            if(c%2==1) output += 1;
            tmp = a[i];
            c = 1;
        }
    }
    if(c%2==1) output += 1;
    cout << output << endl;
}


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

int main() {
  int h, w;
  cin >> h >> w;

  vector<string> grid(h+2);
  string frame(w+2, '-');
  grid.at(0) = frame;
  grid.at(h+1) = frame;

  for (int i = 1; i < h+1; i++) {
    string row;
    cin >> row;
    row = "-" + row + "-";
    grid.at(i) = row;
  }
  
  for (int i = 1; i < h+1; i++) {
    for (int j = 1; j < w+1; j++) {
      if (grid.at(i).at(j) == '#') {
        cout << '#';
      } else {
        int cnt = 0;
        for (int y = -1; y <= 1; y++) {
          for (int x = -1; x <= 1; x++) {
            if (grid.at(i + y).at(j + x) == '#') cnt++;
          }
        }
        cout << cnt;
      }
      if (j == w) cout << endl;
    }
  }
}


Measured memory_bytes: 256
S = input()
rain = False
count = 0
maxC = 0
for i in range(len(S)):
    if (S[i] == 'R'):
        count += 1
        rain = True
    else:
        rain = False
        if maxC < count:
            maxC = count
        count = 0
if maxC < count:
    maxC = count


print(maxC)


Measured memory_bytes: 61612
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {

        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int numa = inpt[0] * inpt[1];
        int numb = inpt[2];

        int ans = Math.Min(numa, numb);
        Console.WriteLine(ans);
    
    }



    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"





7 17 120


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
#define int long long

signed main(){
    string S;
    cin >> S;
    
    if(S[0] == '9' || S[1] == '9'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n, v, a[25][2], r; bool f[25];
void p1(int u) { if(u == -1) return; cout << ' ' << u, p1(a[u][0]), p1(a[u][1]); }
void p2(int u) { if(u == -1) return; p2(a[u][0]), cout << ' ' << u, p2(a[u][1]); }
void p3(int u) { if(u == -1) return; p3(a[u][0]), p3(a[u][1]), cout << ' ' << u; }
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) cin >> v, cin >> a[v][0] >> a[v][1], f[a[v][0]] = f[a[v][1]] = true;
	for(int i = 0; i < n; i++) if(!f[i]) r = i;
	cout << "Preorder" << endl; p1(r); cout << endl;
	cout << "Inorder" << endl; p2(r); cout << endl;
	cout << "Postorder" << endl; p3(r); cout << endl;
}

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

int box[100005];
int main()
{
    int n,x;
    scanf("%d%d",&n,&x);
    
        for (int i=1;i<=n;i++)
            scanf("%d",&box[i]);
        long long all=0;
        if (box[1]>x)
        {
            all+=box[1]-x;
            box[1]=x;
        }
        for (int i=2;i<=n;i++)
        {
            int k = box[i]+box[i-1]-x;
            if (k>0)
            {
                all+=k;
                box[i]-=k;
            }
        }
        cout<<all;
    
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;


int main(){
    long N, M, K;
    cin >> N >> M >> K;
    map<long, int> A;
    vector<long> B;
    long asum=0;
    A[0]=0;
    for(int i=0;i<N;i++){
        long a;
        cin >> a;
        asum += a;
        A[asum]=i+1;
    }
    long bsum=0;
    B.push_back(0);
    for(int i=0;i<M;i++){
        long b;
        cin >> b;
        bsum += b;
        B.push_back(bsum);
    }
    auto ta = A.upper_bound(K);
    ta--;
    int mx=0;
    for(int i=0;i<=M;i++){
        if(K-B[i] < 0){break;}
        auto iter = A.upper_bound(K-B[i]);
        iter--;
        int ans = iter->second;
        mx = max(mx, ans + i);
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 17784
#include<bits/stdc++.h>
using namespace std;
#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(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

  bool f=0;
  REP(i,s.size()){
    if(f){
      if(s[i]=='F'){
        cout<<"Yes"<<endl;
        return 0;
      }
    }else{
      if(s[i]=='C') f=1;
    }
  }
  cout<<"No"<<endl;
  
  return 0;
}

Measured memory_bytes: 256