akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=50;
struct State{
    LL S;
    int cur,val;
    State (LL _S=0,int _cur=0,int _val=0):S(_S),cur(_cur),val(_val){}
    bool operator < (const State &rh)const{
        return val>rh.val;
    }
};
map<LL,int>Dist[maxn]; // Dist[cur][state]
int n,m;
int V[maxn];
LL G[maxn];
vector<int>E[maxn];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>V[i];
    for(int i=1;i<=m;i++)
    {
        int u,v;
        cin>>u>>v;
        G[u]|=1LL<<v;E[u].push_back(v);
        G[v]|=1LL<<u;E[v].push_back(u);
    }
    int Init=0;
    for(int i=1;i<=n;i++)
    {
        G[i]|=1LL<<i;
        if(G[1]&(1LL<<i))Init+=V[i];
    }
    priority_queue<State>Q;
    Q.push(State(G[1],1,Init));
    Dist[1][G[1]]=Init;
    while(!Q.empty())
    {
        State now=Q.top();Q.pop();
        int u=now.cur;
        if(u==n)
        {
            cout<<now.val<<endl;
            break;
        }
        for(int i=0;i<(int)E[u].size();i++)
        {
            int v=E[u][i];
            LL newS=now.S|G[v];
            int newVal=0;
            for(int j=1;j<=n;j++)
                if(newS & (1LL<<j))
                    newVal+=V[j];
            if(Dist[v].find(newS)==Dist[v].end() || Dist[v][newS]>newVal)
            {
                Dist[v][newS]=newVal;
                Q.push(State(newS,v,newVal));
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4560
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    double ans=0;
    for(int n=0; n<N; n++) {
        double x;
        string u;
        cin >> x >> u;
        if(u=="JPY") {
            ans += x;
        } else {
            ans += x*380000;
        }
    }
    
    cout << ans << endl;



    return 0;
    
}

Measured memory_bytes: 256
s = input()
x = s[0:3]
if(x.count('S')==3):
    D = 0
elif(x.count('S')==2):
    D = 1
elif(x.count('S')==1):
    if(x[1]=='S'):
        D = 1
    else:
        D = 2
elif(x.count('S')==0):
    D = 3
print(D)


Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin>>s;
  int n=s.length();
  vector<int> l(n, -1);
  vector<int> r(n, -1);
int t=n-1;
  for(int i=n-2;i>=0; i--){
  if(s[i]=='L'){
  t=i;
  }
    else{
    l[i]=t;
      //l[i]-=i;
    }
  }
  t=0;
  for(int i=1;i<n; i++){
  if(s[i]=='R'){
  t=i;
  }
    else{
    r[i]=t;
      //r[i]=i-r[i];
    }
  }
  vector<int> ans(n,0);
  for(int i=0; i<n; i++){
  if(l[i]!=-1){
  int ind=l[i];
    if((l[i]-i)%2==0){
    ans[l[i]]++;
    }
    else{
    ans[l[i]-1]++;
    }
  }
     if(r[i]!=-1){
  int ind=l[i];
    if((i-r[i])%2==0){
    ans[r[i]]++;
    }
    else{
    ans[r[i]+1]++;
    }
  }
  
  }
  for(int i=0;i<n; i++){
  cout<<ans[i]<<" ";
  }
  return 0;
}

Measured memory_bytes: 1792
#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);

    long long n;
    cin >> n;
    vector<long long> A(n);
    REP(i, n){
        cin >> A[i];
        A[i] -= (i + 1);
    }
    
    sort(A.begin(), A.end());
    
    int mid;
    if(n % 2){
        mid = A[n / 2];
    }else{
        mid = (A[n / 2] + A[n / 2 - 1]) / 2;
    }

    long long ans = 0;
    REP(i, n){
        ans += abs(A[i] - mid);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <numeric>
#include <bitset>
#include <cstdint>
using namespace std;

#ifdef DEBUG
#include <cassert>
#else
#define assert(x)
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
using ll = long long;

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // 浮動小数の表示の精度
    cout << setprecision(15);

    vector<char> v(3);
    rep(i, 3) { cin >> v[i]; }
    if (v[0] == v[1] && v[1] == v[2])
    {
        cout << "No\n";
    }
    else
    {
        cout << "Yes\n";
    }

    return 0;
}


Measured memory_bytes: 3608
package main
import (
	"fmt"
)

func main(){
	var k,a,b int16
	fmt.Scan(&k)
	fmt.Scan(&a)
	fmt.Scan(&b)

	l := a/k
	
	if l*k == a{
		fmt.Println("OK")
	} else if l*k + k <= b {
		fmt.Println("OK")
	} else {
		fmt.Println("NG")
	}

}

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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 100005
#define MOD 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846
#define Q ll _; cin >> _; while(_--)
#define endl "\n"
#define flush fflush(stdout);

int main(){

    fast

    ll i,j,n;
    cin >> n;
    ll dp[2001];
    for(i=0;i<=n;i++){
        dp[i] = 0;
    }
    dp[0] = 1;
    dp[1] = 0;
    dp[2] = 0;
    dp[3] = 1;
    dp[4] = 1;
    dp[5] = 1;

    for(i=6;i<=n;i++){
        for(j=0;j<=i-3;j++){
            dp[i] = (dp[j]%MOD)+ (dp[i]%MOD);
            dp[i] = dp[i]%MOD;
        }
    }
    ll ans = dp[n]%MOD;
    cout << ans%MOD << endl;
}


//    cout << fixed << setprecision(12);


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define ps(s)     for(auto i:s){cout<<i<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll a,b;
	cin>>a>>b;
	if((b-a)>=2019){cout<<0;}
	else{
		int ans=2019;
		for(int i=a;i<b;i++){
			for(int j=i+1;j<=b;j++){
				ans=min(ans,(i*j)%2019);
			}
		}
		cout<<ans;
	}
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case "<<k<<": ";
		solve();
		//e;
	}
}

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

int main(){
	int a[5000];
	int n, m, sum;

	for (;;){
		cin >> n;
		if (n == 0) break;
		m = 0;
		for (int i = 0; i < n; i++){
			cin >> a[i];
		}
		m = a[0];
		for (int i = 0; i < n; i++){
			sum = 0;
			for (int j = i; j < n; j++){
				sum += a[j];
				m = max(sum, m);
			}
		}

		cout << m << endl;
	}

	return 0;
}

Measured memory_bytes: 1176
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int x = sc.nextInt();

        if (2<=x && x<=2*N-1-1) {
            System.out.println("Yes");
            ArrayList<Integer> before = new ArrayList<Integer>();
            ArrayList<Integer> after = new ArrayList<Integer>();
            int cnt = 0;
            for (int i=1;i<=2*N-1;i++) {
                if (i==x-1 || i==x || i==x+1) continue;
                cnt++;
                if (cnt<=N-2) {
                    before.add(i);
                } else {
                    after.add(i);
                }
            }
            for (int i=0;i<N-2;i++) {
                System.out.println(before.get(i));
            }
            System.out.println(x-1);
            System.out.println(x);
            System.out.println(x+1);
            for (int i=0;i<N-2;i++) {
                System.out.println(after.get(i));
            }
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 56796
N=int(input())
m1=[0,0]
m2=[0,0]
for i in range(N):
    a=int(input())
    if a>=m1[0]:
        m2=m1[:]
        m1=[a,i]
    elif a>=m2[0]:
        m2=[a,i]
        
for i in range(N):
    if i==m1[1]:
        print(m2[0])
    else:
        print(m1[0])

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

typedef long long ll;

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

    string S;
    cin >> S;

    int c0 = 0;
    int c1 = 0;

    for(int i = 0; i < S.length(); i++) {
        if(S[i] == '0') {
            c0++;
        } else {
            c1++;
        }
    }

    if(c0 < c1) {
        cout << c0 * 2 << endl;
    } else {
        cout << c1 * 2 << endl;
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <string>

#define endl '\n'
using namespace std;

string s;

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

	cin >> s;

	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::string s;
	std::cin >> s;
	std::string l,r;
	l=s.substr(0,n);
	r=s.substr(n,n);
	std::reverse(all(r));
	int count=0;
	std::map<std::pair<std::string,std::string>, int> map;
	rep(ss,1<<n) {
		std::string x,y;
		rep(i,n) {
			if(ss>>i&1) x+=l[i];
			else y+=l[i];
		}
		map[std::make_pair(x,y)]++;
	}
	rep(ss,1<<n) {
		std::string x,y;
		rep(i,n) {
			if(ss>>i&1) x+=r[i];
			else y+=r[i];
		}
		count+=map[std::make_pair(x,y)];
	}
	print(count);
	return 0;
}


Measured memory_bytes: 91904
from collections import defaultdict
from operator import itemgetter

n, m = map(int, input().split())

d = defaultdict(list)
for query_idx in range(m):
    pref_idx, year = map(int, input().split())
    d[pref_idx].append((year, query_idx))

ans = [None] * m
for pref_idx in d.keys():
    d[pref_idx].sort(key=itemgetter(0))
    # 県別誕生年昇順ソート
    for city_idx, (year, query_idx) in enumerate(d[pref_idx], 1):
        ans[query_idx] = '{:0>6}{:0>6}'.format(pref_idx, city_idx)
print(*ans, sep='\n')


Measured memory_bytes: 46384
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	string a, b, c;
	cin >> a >> b >> c;
	int diff = 'A' - 'a';
	cout << (char)(a[0] + diff) << (char)(b[0] + diff) << (char)(c[0] + diff) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
  string s;
  cin>>n>>s;
  int sum = 0, mx = 0;
  rep(i, n){
    if(s[i]=='I')sum++;
    else sum--;
    chmax(mx, sum);
  }
  cout<<mx<<endl;
	return 0;
}


Measured memory_bytes: 256
loop do
  n, m, a, d = 4.times.map{ gets.to_i }
  break if n == 0
  bar = d.times.map{ gets.chomp.split('').map(&:to_i) }
  goal = Array.new(n){|i| i}
  can = n.times.map{ [false]*n }
  (d-1).downto(0) do |i|
    (n-1).times do |j|
      if bar[i][j] == 1
        goal[j], goal[j+1] = goal[j+1], goal[j]
      else
        if (bar[i][j-1] == 0 || j == 0) && (bar[i][j+1] == 0 || j == n-2)
          can[goal[j]][goal[j+1]] = can[goal[j+1]][goal[j]] = [i, j]
        end
      end
    end
  end
  if goal[m-1] == a-1 then p 0
  else
    if ret = can[a-1][goal[m-1]]
      puts "#{ret[0]+1} #{ret[1]+1}"
    else p 1
    end
  end
end

Measured memory_bytes: 9020
import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {

    var str = StdIn.readLine()

    for(_ <- 1 to StdIn.readInt()){

      val line = StdIn.readLine().split(" ")
      val a = line(1).toInt
      val b = line(2).toInt

      line(0) match {
        case "replace" => {
          str = str.take(a) + line(3) + str.takeRight(str.length - b - 1)
        }
        case "reverse" => {
          str = str.take(a) + str.slice(a,b + 1).reverse + str.takeRight(str.length - b - 1)
        }
        case "print"   => println(str.slice(a,b + 1))
      }
    }
  }
}

Measured memory_bytes: 44824
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }


int main() {
    int a, b; scanf("%d%d", &a, &b);
    if (a > 0) {
        puts("Positive");
        return 0;
    }
    if (a <= 0 && 0 <= b) {
        puts("Zero");
        return 0;
    }

    if ((b - a) & 1) {
        puts("Positive");
    } else {
        puts("Negative");
    }

    return 0;
}


Measured memory_bytes: 256
def distance(i,j,x,y):
    return min(j-i,abs(x-i)+abs(y-j)+1,abs(y-i)+abs(x-j)+1)


n,x,y=map(int,input().split())

ans=[0]*n
for i in range(1,n+1):
    for j in range(i,n+1):
            ans[distance(i,j,x,y)-1]+=1
for i in range(n-1):
    print(ans[i])

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

int main()
{
	int k, s, count{};
	scanf("%d%d", &k, &s);
	for (int x = 0; x <= k; x++)
	{
		if (x > s) continue;
		for (int y = 0; y <= k; y++)
		{
			if (x + y > s || x + y + k < s) continue;
			count++;
		}
	}
	printf("%d\n", count);

	return 0;
}

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

int main() {
	int N,M,c=0;
	cin >> N >> M;
	vector<int> x(N,2);
	vector<int> y(M,1);

	rep(i,M)
		x.push_back(y.at(i));

	rep(i,N+M)
		for(int j=i+1; j<N+M; ++j)
			if((x.at(i)+x.at(j))%2 == 0)
				++c;
	cout << c << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int tmp;
		int[] values = new int[w];
		for(int i = 0; i < values.length; i++){
			values[i] = i + 1;
		}
		for(int i = 0; i < n; i++){
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) -1;
			int b = Integer.parseInt(ab[1]) -1;
			tmp = values[a];
			values[a] = values[b];
			values[b] = tmp;
		}
		for(int i = 0; i < w; i++){
			System.out.println(values[i]);
		}
	}
}

Measured memory_bytes: 26232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll MOD = 1e9 + 7;
const ll dx[4] = { -1,1,0,0 };
const ll dy[4] = { 0,0,-1,1 };
const ll MAX = 4e5 + 50 ;
const ll oo = 1e16;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
long long gcd(long long  a, long long  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll n , m  , a , b , k , Q  , ind  , x , y, ans , p , T , G; string s , t;

 void check(int st){

    for(int i = 0 ; i < n ; ++i)
        if(s[i] != t[(i + st)%n])
            return;
    cout << "Yes" << '\n';
    exit(0);
}
int main(){

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



    cin >> s >> t ;
    n = (int)s.length();
    for(int i = 0 ; i < n ; ++i)
        if(s[0] == t[i])
            check(i);

    cout << "No" << '\n';

     return 0;
}


Measured memory_bytes: 256
var h, dp: array[-1000..100010] of longint;
    findmin: array[1..1000] of longint;
    n, i, j, k: longint;
begin
    readln(n, k);
    for i:=1 to n do
        read(h[i]);
    for i:=1 to k do
    begin
        dp[1-i]:=0;
        h[1-i]:=h[1];
    end;
    for i:=2 to n do
    begin
        for j:=1 to k do
        begin
            findmin[j]:=dp[i-j]+abs(h[i]-h[i-j]);
            if j=1 then
                dp[i]:=findmin[j]
            else
            begin
                if findmin[j]<dp[i] then
                    dp[i]:=findmin[j];
            end;
        end;
    end;
    writeln(dp[n]);
end.

Measured memory_bytes: 896
import java.util.Scanner;

class Main {

	int W = 0,H = 0,I = 0,F = 0,A = 0,Z = 0;

	public void pr() {

		Scanner sc = new Scanner(System.in);

		H = sc.nextInt();

		W = sc.nextInt();

		while(H != 0 || W != 0) {

			for(I = 0;I < H; I++) {

				for(F = 0;F < W; F++) {

					if(I == 0||I == H - 1||F == W - 1) {

						System.out.print("#");

					} else {

						if(F == 0) {

							Z = 0;

						}

						if(Z == 0) {

							System.out.print("#");

							Z++;

						}

						for(A = W - 3;A < W-2&&F != 0;A++) {

							System.out.print(".");

						}

					}

					if(F == W - 1) {

						System.out.println();

					}

				}

			}

				System.out.println();

			H = sc.nextInt();

			W = sc.nextInt();

		}

	}

	public static void main(String[] args) {

		new Main().pr();

	}

}

Measured memory_bytes: 36720
import java.util.Arrays;
import java.util.Scanner;

/**
 * Gluttony
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            long K = sc.nextLong();

            long[] A = new long[N];
            long[] F = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextLong();
            }
            for (int i = 0; i < N; i++) {
                F[i] = sc.nextLong();
            }

            //long sum = Arrays.stream(A).sum();
            long sum = 0;
            for (long a : A) {
                sum += a;
            }

            if (sum <= K) {
                System.out.println(0);
                return;
            }

            Arrays.sort(A);
            Arrays.sort(F);

            long min = 0;
            long max = 0;
            for (int i = 0; i < N; i++) {
                max = Math.max(max, A[i] * F[N - 1 - i]);
            }

            while (max - min > 1) {
                long mid = (min + max) / 2;

                long need = 0;
                for (int i = 0; i < N; i++) {
                    need += Math.max(0, A[i] - mid / F[N - 1 - i]);
                }

                if (need > K) {
                    min = mid;
                } else {
                    max = mid;
                }
            }

            System.out.println(max);
        }

    }

}


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

int main() {
    int n;
    cin >> n;
    double xmin = ceil(n / 1.08);
    double xmax = (n + 1) / 1.08;
    
    if(xmax - ceil(xmin) > 0) cout << ceil(xmin) << endl;
    else                      cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
	//	 static int mod =  (int) (Math.pow(10,9)+7);
		 static int mod =  2019;
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        
	        long N = sc.nextLong();
	        
			LinkedList<Integer> q = new LinkedList<Integer>();

	        long ans=0;
			q.add(0);
			q.add(0);
			while(!q.isEmpty()) {
				int now = q.poll();
				int keta = q.poll();
				long tmp = (long) (now+3*Math.pow(10, keta));
				if(tmp<=N) {
					q.add((int)tmp);
					q.add(keta+1);
				}
				tmp = (long) (now+5*Math.pow(10, keta));
				if(tmp<=N) {
					q.add((int)tmp);
					q.add(keta+1);
				}
				tmp = (long) (now+7*Math.pow(10, keta));
				if(tmp<=N) {
					q.add((int)tmp);
					q.add(keta+1);
				}
				boolean flg3=false;
				boolean flg5=false;
				boolean flg7=false;				
				while(now>0) {
					int t = now%10;
					if(t==3) {
						flg3=true;
					} else if(t==5) {
						flg5=true;
					} else if(t==7) {
						flg7=true;
					}
					now= now/10;
				}
				if(flg3==true&&flg5==true&&flg7==true)ans++;
			}
	        
	        
	    	System.out.println(ans);
	    	
	        		
	    }
	    

	}

Measured memory_bytes: 26628
#include<stdio.h>

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else if(a==b){
		printf("a == b\n");
	}
	
	return 0;
}

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

int main() {

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

  sort(a.begin(), a.end(), greater<int>());
  int diff(0);
  for(int i = 0; i + 1< a.size(); i += 2)
  {
   	 diff += a.at(i) - a.at(i + 1);
  }
  if( a.size() % 2 != 0 )
  {
   	diff += a.at(a.size() - 1); 
  }
  cout << diff << endl;
}


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

int n, t;
int a[3001], b[3001];
int dp1[3001][3001], dp2[3001][3001];

int main() {
    cin >> n >> t;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }

    for (int i = 0; i < a[0]; ++i) dp1[0][i] = 0;
    for (int i = a[0]; i < t; ++i) dp1[0][i] = b[0];
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < t; ++j) {
            dp1[i][j] = dp1[i-1][j];
            if (j - a[i] >= 0) dp1[i][j] = max(dp1[i][j], dp1[i-1][j-a[i]] + b[i]);
        }
    }

    for (int i = 0; i < a[n-1]; ++i) dp2[n-1][i] = 0;
    for (int i = a[n-1]; i < t; ++i) dp2[n-1][i] = b[n-1];
    for (int i = n - 2; i >= 0; --i) {
        for (int j = 0; j < t; ++j) {
            dp2[i][j] = dp2[i+1][j];
            if (j - a[i] >= 0) dp2[i][j] = max(dp2[i][j], dp2[i+1][j-a[i]] + b[i]);
        }
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < t; ++j) {
            int s1 = (i - 1 >= 0) ? dp1[i-1][j] : 0;
            int s2 = (i + 1 < n) ? dp2[i+1][t-j-1] : 0;
            ans = max(ans, s1 + s2 + b[i]);
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 70656
# -*- coding: utf-8 -*-
def main():
    N,K,Q = map(int,input().split())
    A=[int(input()) for i in range(Q)]
    Ns=[0 for i in range(N)]
    for i in A:
        Ns[i-1] += 1
    SUM = sum(Ns)
    for j in range(N):
        if K<=SUM-Ns[j]:
            print('No')
        else:
            print('Yes')
if __name__ == '__main__':
    main()

Measured memory_bytes: 8624
import java.io.*;
import java.util.Arrays;

class Main {
	public static void main(String args[]) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String s;
			int count = 0, i, b[] = new int [1000001], j;
			Arrays.fill(b, 1);
			while((s = reader.readLine()) != null) {
				int n = Integer.parseInt(s);
				for(i = 2;i*i <= n;i++) {
					if(b[i] == 0)
						continue;
					for(j = i+i;j <= n;j+=i) {
						b[j] = 0;
					}
				}
				for(int k = 2;k <= n;k++) {
					if(b[k] == 1)
						count++;
				}
				System.out.println(count);
				count = 0;
			}
		}
		catch(IOException e) {
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 24584
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define lol long long
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c;
bool an[10];
bool o[10][10];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol d=0,e=0,f=0;
  string s;
  cin >>a>>b>>c>>d;
  if(a!=c) cout <<"1\n";
  else cout <<"0\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        boolean c = false;
        int ci = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == 'C') {
                c = true;
                ci = i;
                break;
            }
        }
        boolean f = false;
        int fi = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (s.charAt(i) == 'F') {
                f = true;
                fi = i;
                break;
            }
        }
        if (!(c && f)) {
            System.out.println("No");
            return;
        }
        if (ci > fi) {
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 21972
#include <stdio.h>
#include <math.h>

int primecheck(int m){
    int i;
    
    if(m==1)return 0;
    for(i=2;i<=sqrt(m);i++){
        if(m%i==0)return 0;
    }
    return 1;
}

int main(void){
    int i,n;
    
    while(scanf("%d",&n) != EOF){
        for(i=n-1;;i--){
            if(primecheck(i)){
                printf("%d ",i);
                break;
            }
        }
        
        for(i=n+1;;i++){
            if(primecheck(i)){
                printf("%d\n",i);
                break;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
const ll MOD = 1e9 + 7;
const ll INF = (ll)1e18;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}

int main() {
#ifdef HIRO
  string quiz(QUIZ);
  ifstream cin("input/" + quiz + ".txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  
  int arr[n];
  while(n--) cin>>arr[n];

  for(int i: arr) {
    if(i%2)continue;
    if(i%3&&i%5){
      cout <<"DENIED";
      return 0;
    }
  }
  cout <<"APPROVED";
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000

//aのb乗
int beki(int a,int b){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=mod(x*a);
		}
		a=mod(a*a);
		b>>=1;
	}
	return x;
}

//aの逆元
int gyakugen(int a){
	return beki(a,modulo-2);
}

struct combi{
	deque<int> kaijou;
	deque<int> kaijou_;
	
	combi(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(mod(kaijou[i-1]*i));
		}
		
		int b=gyakugen(kaijou[n]);
		
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(mod(kaijou_[0]*k));
		}
	}
	
	int combination(int n,int r){
		if(r>n)return 0;
		int a = mod(kaijou[n]*kaijou_[r]);
		a=mod(a*kaijou_[n-r]);
		return a;
	}
	
	int junretsu(int a,int b){
		int x = mod(kaijou_[a]*kaijou_[b]);
		x=mod(x*kaijou[a+b]);
		return x;
	}
	
};

int main(){
	
	int N,K;
	cin>>N>>K;
	
	vector<int> A(N);
	
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	
	combi C(200000);
	
	sort(A.begin(),A.end());
	
	int ans = 0;
	
	for(int i=0;i<N;i++){
		int x = C.combination(i,K-1);
		int y = mod(A[i]);
		int z = mod(x*y);
		ans = mod(ans + z);
	}
	
	reverse(A.begin(),A.end());
	
	for(int i=0;i<N;i++){
		int x = C.combination(i,K-1);
		int y = mod(A[i]);
		int z = mod(x*y);
		ans = mod(ans - z);
	}
	
	cout<<ans<<endl;
	
	
	
    return 0;
}


Measured memory_bytes: 2304
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int query(int pos) {
  printf("%d\n", pos);
  fflush(stdout);
  static char response[64];
  scanf(" %s", response);
  if (response[0] == 'V') exit(0);
  return response[0] == 'M';
}

void solve(int a, int b, int a_value, int b_value) {
  const int mid = a + (b - a) / 2;
  int mid_value = query(mid);
  if ((mid - a) % 2 != (mid_value - a_value + 2) % 2)
    solve(a, mid, a_value, mid_value);
  else
    solve(mid, b, mid_value, b_value);
}

int main() {
  int n;
  scanf("%d", &n);
  int first = query(0), last = query(n - 1);
  solve(0, n - 1, first, last);
  return 0;
}


Measured memory_bytes: 852
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        List<Pair> list = new ArrayList<>();
        HashMap<Integer, Pair> map = new HashMap<>();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
            if (!map.containsKey(A[i])) {
                Pair p = new Pair();
                p.x = A[i];
                p.count = 1;
                map.put(A[i],p);
                list.add(p);
            } else {
                Pair p = map.get(A[i]);
                p.count += 1;
            }
        }
        if (map.size() <= K) {
            System.out.println(0);
            return;
        }
        list.sort(new PairComparator());
        int remain = map.size() - K;
        long answer = 0;
        for (int i = 0; i < remain; i++) {
            answer += list.get(i).count;
        }
        System.out.println(answer);
    }
    class Pair {
        int x;
        int count;
    }
    class PairComparator implements Comparator<Pair> {
        @Override
        public int compare(Pair o1, Pair o2) {
            if (o1.count == o2.count) {
                return Integer.compare(o1.x, o2.x);
            }
            return Integer.compare(o1.count, o2.count);
        }
    }
}


Measured memory_bytes: 109728
n, k = map(int, input().split())
a = list(map(int, input().split()))

dp = [False]*(k+1)
for i in range(1, k+1):
    flag = False
    for ai in a:
        if i-ai >= 0 and  not dp[i-ai]:
            flag = True
            break
    dp[i] = flag

if dp[-1]:
    print("First")
else:
    print("Second")

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ll long long
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define pii pair<ll, ll>
#define ls rt << 1
#define rs rt << 1 | 1
#define sz(x) (int)(x).size()
#define ALL(x) (x).insgin(), (x).end()
#define vi vector<int>
#define EPS 1e-8
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}

int n, K;
char s[310];
int f[305][305][305];

int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	K = read();
	rep(k, 0, K)
		rrep(i, n, 1)
		{
			f[i][i][k] = 1;
			rep(j, i + 1, n)
			{
				f[i][j][k] = max(f[i + 1][j][k], f[i][j - 1][k]);
				if(s[i] == s[j]) f[i][j][k] = max(f[i][j][k], f[i + 1][j - 1][k] + 2);
				if(k) f[i][j][k] = max(f[i][j][k], f[i + 1][j - 1][k - 1] + 2);
			}
		}
	cout << f[1][n][K];
	return 0;
}


Measured memory_bytes: 110464
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    while True:
        n, w, d = LI()
        if n==0 and w==0 and d==0:
            break

        cake = []
        cake.append([w, d])
        for _ in range(n):
            ps = LI()
            p = ps[0]-1
            s = ps[1]
            # ケーキカット
            cake_w = cake[p][0]
            cake_d = cake[p][1]
            s %= (cake_w+cake_d)*2
            if s<cake_w:
                new_cake_s = [min(s, cake_w-s), cake_d]
                new_cake_l = [max(s, cake_w-s), cake_d]
            elif cake_w<s<cake_w+cake_d:
                new_cake_s = [cake_w, min(s-cake_w, cake_w+cake_d-s)]
                new_cake_l = [cake_w, max(s-cake_w, cake_w+cake_d-s)]
            elif cake_w+cake_d<s<cake_w+cake_d+cake_w:
                new_cake_s = [min(s-(cake_w+cake_d), cake_w+cake_d+cake_w-s), cake_d]
                new_cake_l = [max(s-(cake_w+cake_d), cake_w+cake_d+cake_w-s), cake_d]
            else:
                new_cake_s = [cake_w, min(s-(cake_w+cake_d+cake_w), cake_w+cake_d+cake_w+cake_d-s)]
                new_cake_l = [cake_w, max(s-(cake_w+cake_d+cake_w), cake_w+cake_d+cake_w+cake_d-s)]

            # id付け替え
            del cake[p]
            # 新ケーキ追加 
            cake.append(new_cake_s)
            cake.append(new_cake_l)

        print(*sorted([i[0]*i[1] for i in cake]))

if __name__ == '__main__':
    resolve()


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

#define  quick  ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define s(x) sort(x.begin(),x.end())
#define sr(x) sort(x.begin(),x.end(),greater<ll>())
#define v1 vector<ll>
#define p1 pair<ll,ll>
#define m1 map<ll,ll>
#define ff first
#define ss second
#define ee '\n';
#define pb push_back
#define all(v) v.begin(),v.end()
#define f(i,x,y) for(i=x;i<y;i++)
#define mp make_pair
#define yes cout<<"YES"<<endl
#define no  cout<<"NO"<<endl

const int N = 1e5 + 5;

bool sortsec(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return (a.first > b.first);
}


void solve()
{  
       string s,t;
       cin>>s>>t;
       ll j,i,n = s.size(),x=t.size();
       if(s==t)
       {
              cout<<"0"<<ee; 
       }
       else
       {
                v1 v;
                for(i=0;i<n-x+1;i++)
                {
                         ll cnt = 0,k=0;
                         for(j=i;j<i+x;j++)
                         {
                                     if(s[j]!=t[k])
                                     {
                                             cnt++;
                                     }
                                     k++;
                         }
                       
                         v.pb(cnt);
                }
                ll ans  = *min_element(all(v));
                cout<<ans<<ee;
       }
}

 int32_t main()
 {
    quick;
    ll t=1;
    //cin>>t;
    while(t--)
    {
       solve();
    }
    return 0;
 }

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,ans=0;
  cin>>a>>b;
  for(int i=0;i<=a;i++){
    for(int n=0;n<=a;n++){
      int m=b-i-n;
        if(0<=m&&m<=a) ans+=1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

mod = 1000000007
fmax =0
smax =0
tmax =0

result = 1
for i in a:
    if i == fmax and i == smax and i == tmax:
        result = result * 3 % mod
        fmax += 1
    elif i == fmax and i == smax and i != tmax:
        result = result * 2 % mod
        fmax += 1
    elif i == fmax and i != smax and i == tmax:
        result = result * 2 % mod
        fmax += 1
    elif i != fmax and i == smax and i == tmax:
        result = result * 2 % mod
        smax += 1
    elif i == fmax and i != smax and i != tmax:
        fmax += 1
    elif i != fmax and i == smax and i != tmax:
        smax += 1
    elif i != fmax and i != smax and i == tmax:
        tmax += 1
    else:
        print(0)
        exit()
print(result)


Measured memory_bytes: 52952
from sys import stdin
#input = stdin.readlines
import math

def main():
    N = int(input())
    p = [list(map(int, input().split())) for _ in range(N)]
    s = 0.0
    for i in range(N - 1):
        for j in range(i + 1, N):
            s += math.sqrt((p[i][0] - p[j][0])**2 + (p[i][1] - p[j][1])**2)
    print(s*2/N)

if __name__ == '__main__':
    main()

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



int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    unordered_map<char,int> mp;
    string str;
    cin>>str;
    int i;
    unordered_map<char,int>::iterator iter;
    for(i=0;i<str.length();i++){
        iter = mp.find(str[i]);
        if(iter==mp.end()){
            mp.emplace(str[i],1);
        }
        else{
            iter->second++;
        }
    }
    if(mp.size()!=2){
        cout<<"No\n";
    }
    else{
        iter = mp.begin();
        if(iter->second==2){
            cout<<"Yes\n";
        }
        else
        {
            cout<<"No\n";
        }
        
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int n,a[20];

int solve(int p,int key){
  if(key < 0 || p > n){
    return 0;
  }

  if(!key){
    return 1;
  }

  if(solve(p+1,key)){
    return 1;
  }

  if(p < n && solve(p+1,key-a[p])){
    return 1;
  }

  return 0;
}

int main(){
  int i,q,key;
  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d" ,a + i);
  }

  scanf("%d" ,&q);
  while(q--){
    scanf("%d" ,&key);
    if(solve(0,key)){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }

  return 0;
}

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

main()
{
	int x,y;
	scanf("%d %d",&x,&y);
	if(x==0)
	{
		if(y>=0)
		printf("%d",y);
		else
		printf("%d",-y+1);
	}
	else if(y==0)
	{
		if(x<=0)
			printf("%d",-x);
		else
			printf("%d",x+1);
	}
	else if((x>=0&&y>=0)||(x<=0&&y<=0))
	{
		if(x<=y)
			printf("%d",y-x);
		else
			printf("%d",x-y+2);
	}
	else
	{
		y=-y;
		if(x<=y)
			printf("%d",y-x+1);
		else
			printf("%d",x-y+1);
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{

    int H,W;
    cin >> H >> W;
    int N;
    cin >> N;

    int ans[101][101];
    int x=1,y=1;
    int t;
    for(int i=1;i<=N;++i)
    {
        cin >> t;
        while(t)
        {
            t--;
            ans[y][x]=i;


            if(y%2==0&&x==1)
                ++y;
            else if(x==W&&y%2)
                ++y;
            else if(y%2)
                ++x;
            else
                --x;
        }
    }


    for(int i=1;i<=H;++i)
        for(int j=1;j<=W;++j)
        {
            cout << ans[i][j] ;
            if(j==W)
                cout << endl;
            else
                cout << ' ';
        }


	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<stack>
#include<algorithm>
using namespace std;

#define MAX_N 92

int x[MAX_N][MAX_N];
bool z[MAX_N][MAX_N][4];
bool y[MAX_N][MAX_N];
bool t[MAX_N][MAX_N][4];

stack<int>S;

int main() {
	int n, m, c, d, p, q;
	int MAX = 0;
	while (true) {
		MAX=0;
		memset(z, false, sizeof(z));
		memset(x,0,sizeof(x));
		cin >> n;
		cin >> m;
		if(n==0 && m==0){
			break;
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				cin >> x[i][j];
			}
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (x[i][j] == 1) {
					if (x[i - 1][j] == 1) {
						z[i][j][0] = true;
					}
					if (x[i][j - 1] == 1) {
						z[i][j][1] = true;
					}
					if (x[i + 1][j] == 1) {
						z[i][j][2] = true;
					}
					if (x[i][j + 1] == 1) {
						z[i][j][3] = true;
					}
				}
			}
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				S.push(i * 100 + j);
				memset(y, false, sizeof(y));
				memset(t,false,sizeof(t));
				y[i][j]=true;
				while (!S.empty()) {
					p = 0;
					c = S.top() / 100;
					d = S.top() % 100;
					if ((z[c][d][0] == true && y[c - 1][d] == false) && t[c][d][0]==false) {
						S.push((c - 1) * 100 + d);
						y[c - 1][d] = true;
						t[c][d][0]=true;
						t[c-1][d][2]=true;
						p++;
					}
					else if ((z[c][d][1] == true && y[c][d - 1] == false) && t[c][d][1]==false) {
						S.push(c * 100 + (d - 1));
						y[c][d - 1] = true;
						t[c][d][1]=true;
						t[c][d-1][3]=true;
						p++;
					}
					else if ((z[c][d][2] == true && y[c + 1][d] == false)  && t[c][d][2]==false){
						S.push((c + 1) * 100 + d);
						y[c + 1][d] = true;
						t[c][d][2]=true;
						t[c+1][d][0]=true;
						p++;
					}
					else if ((z[c][d][3] == true && y[c][d + 1] == false) && t[c][d][3]==false) {
						S.push(c * 100 + (d + 1));
						y[c][d + 1] = true;
						t[c][d][3]=true;
						t[c][d+1][1]=true;
						p++;
					}
					if (p == 0) {
						if(y[c-1][d]==false){
							t[c][d][0]=false;
							t[c-1][d][2]=false;
						}
						if(y[c][d-1]==false){
							t[c][d][1]=false;
							t[c][d-1][3]=false;
						}
						if(y[c+1][d]==false){
							t[c][d][2]=false;
							t[c+1][d][0]=false;
						}
						if(y[c][d+1]==false){
							t[c][d][3]=false;
							t[c][d+1][1]=false;
						}
						S.pop();
						y[c][d]=false;
					}
					q = S.size();
					MAX = max(MAX, q);
				}
			}
		}
		cout << MAX << endl;
	}
	return 0;
}

Measured memory_bytes: 1312
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>

using namespace std;

int main()
{
  int A, B;
  cin >> A >> B;
  int ans = 0;
  for (int i = 0; i < 2; ++i) {
    if (A >= B) {
      ans += A;
      --A;
    }
    else {
      ans += B;
      --B;
    }      
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int d[n];
  for(int i=0; i<n; i++) cin >> d[i];

  sort(d,d+n);

  int count=0;
  for(int i=0; i<n; i++) if(d[i]!=d[i-1]) count++;
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	char a, b;
	cin >> a >> b;

	if (a == 'H') {
		if (b == 'H')print('H');
		else print('D');

	}
	else {
		if (b == 'H')print('D');
		else print('H');

	}






	return 0;
}

Measured memory_bytes: 256
#include<iostream>


int main() {
	int n, m;
	bool num[30];
	bool temp[30];
	for (int i = 0; i < 30; i++)num[i] = true, temp[i] = false;
	std::cin >> n >> m;

	for (int i = 0; i < n; i++) {
		int k;
		std::cin >> k;
		for (int j = 0; j <  30;j++)temp[j] = false;
		for (int j = 0; j < k; j++) {
			int a;
			std::cin >> a;
			a--;
			temp[a] = true;
		}

		/*for (auto i : temp) {
			printf("%d", i);
		}
		printf("\n");
		*/
		for (int j = 0; j < 30; j++) {
			num[j] &= temp[j];
		}
	}

	int ans = 0;
	for (int i = 0; i < 30; i++) {
		ans += num[i];

	}

	
	printf("%d", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#define LLMAX 9223372036854775807

using namespace std;
using ll = long long;

int main() {
	ll argN;
	string argS;
	cin >> argN >> argS;

	ll ret = LLMAX;
	ll rightE = count(argS.begin(), argS.end(), 'E');
	ll rightW = argS.size() - rightE;
	ll leftE = 0;
	ll leftW = 0;
	for (ll i = 0; i < argN; ++i) {
		if (argS.at(i) == 'E') {
			rightE -= 1;
		}
		else {
			rightW -= 1;
		}

		ret = min(rightE + leftW, ret);

		if (argS.at(i) == 'E') {
			leftE += 1;
		}
		else {
			leftW += 1;
		}
	}

	cout << ret << endl;
}

Measured memory_bytes: 832