akhauriyash/Code-Regression huggingface dataset:
var lines =[];

var N, A, B, C;
var l
var result = Infinity;

var readline = require("readline");
var rl = readline.createInterface({
  input:  process.stdin,
  output: process.stdout
});

rl.on('line',function(x){
  lines.push(x);
});

rl.on('close',function(){

  var tmp = lines.shift();
  N = Number(tmp.split(" ")[0]);
  A = Number(tmp.split(" ")[1]);
  B = Number(tmp.split(" ")[2]);
  C = Number(tmp.split(" ")[3]);

  l = Array(N);

  for(var i=0;i<N;i++){l[i]=Number(lines[i]);}

  dfs(0,[])
  console.log(result);
});

function dfs(n,bamboo){
    if(n === N){calc(bamboo);return(0);}

    for(var i=0;i<4;i++){
        bamboo[n]=i;
        dfs(n+1,bamboo);
    }
}

function calc(bamboo){
    var a = 0;
    var b = 0;
    var c = 0;  
    var counter_a = 0;
    var counter_b = 0;
    var counter_c = 0;
    
    for(var i=0;i<N;i++){
        // Aに利用
        if(bamboo[i]===0){if(l[i] !== 0){a = a + l[i];counter_a++;}}
        // Bに利用
        else if(bamboo[i]===1){if(l[i] !== 0){b = b + l[i];counter_b++;}}
        // Cに利用
        else if(bamboo[i]===2){if(l[i] !== 0){c = c + l[i];counter_c++;}}
        // 不要
        else{}
    }
    counter_a -1 < 0 ? counter_a = 0:counter_a = counter_a -1;
    counter_b -1 < 0 ? counter_b = 0:counter_b = counter_b -1;
    counter_c -1 < 0 ? counter_c = 0:counter_c = counter_c -1;

    if(a>0 && b>0 && c>0){
        if(result > Math.abs(A-a) + Math.abs(B-b) + Math.abs(C-c) + (counter_a + counter_b + counter_c)*10){
            result = Math.abs(A-a) + Math.abs(B-b) + Math.abs(C-c) + (counter_a + counter_b + counter_c)*10;
        }
    }
}

Measured memory_bytes: 7880
from collections import OrderedDict

n = input()
nums = list(map(int, input().split()))

number_hash = OrderedDict()

for i in sorted(nums):
    if i not in number_hash:
        number_hash[i] = 1
    else:
        number_hash[i] += 1

ans = 0
for i in number_hash:
    cnt = 0
    # 今とある定数をハッシュから引き出した
    # ハッシュの中から今取り出した数プラマイ１の数字が多い物を見つける
    i_d = i - 1
    i_u = i + 1
    if i_d in number_hash:
        cnt += number_hash[i_d]
    if i_u in number_hash:
        cnt += number_hash[i_u]
    cnt += number_hash[i]

    if ans < cnt:
        ans = cnt

print(ans)


Measured memory_bytes: 24476
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
    ll a,b;
    cin>>a>>b;
    if(a<=9 && b<=9)
    {
        cout<<a*b<<endl;
    }
    else
    {
        cout<<"-1"<<endl;
    }
}


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


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int k; cin >> k;
    long long sev = 7, ns = 1;
    if(!(k%2) or !(k%5)){
        cout << -1 << endl;
    }
    else {
        while(true){
            if(!(sev%k)){
                break;
            }
            sev%=k;
            if(ns == 1000001){
                break;
            }
            sev*=10; sev+=7; ns++;
        }
        if(ns == 1000001){
            cout << -1 << endl;
        }
        else{
            cout << ns << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j,k,l,t,a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a==4 || a==6 || a==9 || a==11){
        if(b==30)
            printf("1");
        else
            printf("0");
    }
   else if(a==2){
        if(b==28)
            printf("1");
        else
            printf("0");
    }
    else if(b==31)
        printf("1");
    else
        printf("0");
}


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

int main(){
    int N;
    string s;
    cin >> N >> s;
    int red=0, blue=0;
    for(int i=0; i<N; i++){
        if(s[i]=='R') red++;
        else blue++;
    }
    if(red>blue) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(){
    int a, b, c, d;
    cin >>a>>b>>c>>d;
    if(a*b>c*d)
        cout << a*b <<endl;
    else
        cout << c*d <<endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
  int M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  
  if(M1==M2){
    cout << 0 << endl;
  }
  else{
    cout << 1 << endl;
  }  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ans;
void dfs(long long num,int f){
	if (num > n)
		return ;
	if (f == 7)
		ans++;
	dfs(num * 10 + 3,f | 1);
	dfs(num * 10 + 5,f | 2);
	dfs(num * 10 + 7,f | 4);	
}
int main(){
	cin >> n;
	dfs(0,0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3548
W,H,N=map(int,input().split())
x_max=W
x_min=0
y_max=H
y_min=0
for i in range(N):
  li=list(map(int,input().split()))
  if li[2]==1 and li[0]>x_min:
    x_min=li[0]
  elif li[2]==2 and li[0]<x_max:
    x_max=li[0]
  elif li[2]==3 and li[1]>y_min:
    y_min=li[1]
  elif li[2]==4 and li[1]<y_max:
    y_max=li[1]
    
#print(x_max,x_min,y_max,y_min)
s=(x_max-x_min)*(y_max-y_min)
if s>0 and x_max-x_min>0 and y_max-y_min:
  print(s)
else:
  print(0)

Measured memory_bytes: 3064
<?php
while (true) {
  list($m, $f, $r) = explode(" ", trim(fgets(STDIN)));
  if ($m == -1 && $f == -1 && $r == -1) break;

  if ($m == -1 || $f == -1) echo "F\n";
  elseif ($m + $f >= 80) echo "A\n";
  elseif ($m + $f >= 65) echo "B\n";
  elseif ($m + $f >= 50 || $r >= 50) echo "C\n";
  elseif ($m + $f >= 30) echo "D\n";
  else echo "F\n";
}



Measured memory_bytes: 9216
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
using namespace std;
int n; 
map<int,int>ma;
int a[200005];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		ma[a[i]]++;
	}
	sort(a+1,a+1+n); int ans = 0;
	for(int i=n;i>=1;i--) {
		int x = a[i];
		if(ma[x]!=0) {
			for(int j=30;j>=1;j--) {
				int o = (1<<j);
				if(o<=x) break;
				if(ma[o-x]!=0) {
					if(o-x==x) {
						if(ma[x]>=2) {ma[x]-=2,ans++;break; }
					} else {
						ma[x]--; ma[o-x]--; ans++; break;
					}
				}
			}
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 29824
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    ans = 0

    for a in range(1, N):
        for b in range(1, N):
            x = a * b
            if x >= N:
                break
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67556
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
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;}
typedef pair<ll,ll> P;


int main(){
    ll n;
    cin >> n;
    vector<P> a;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            ll p=i;
            int cnt=0;
            while(true){
                if(n%i!=0) break;
                cnt++;
                n=n/i;
            }
            a.push_back(P(i,cnt));
        }
    }

    bool ok = true;
    rep(i,a.size()){
        if(a[i].first==n) {
            ok =false;
            a[i].second++;
            break;
        }
    }
    if(ok&&n!=1) a.push_back(P(n,1));
    int sum=0;

    // rep(i,a.size()){
    //     cout << a[i].first<<" "<<a[i].second<<endl;
    // }

    rep(i,a.size()){
        for(int k=1;;k++){
            if(a[i].second-k>=0){
                sum++;
                a[i].second-=k;
            }else break;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i) continue;
        res.push_back(i);
        if (i * i != n) res.push_back(n / i);
    }
    sort(res.begin(), res.end());
    return res;
}

void _main() {
    int X;
    cin >> X;
    for (int p : divisor(X)) {
        for (int A = -1000; A <= 1000; ++A) {
            int B = A - p;
            if (p * (A * A * A * A + A * A * A * B + A * A * B * B + A * B * B * B + B * B * B * B) == X) {
                cout << A << " " << B << endl;
                return;
            }
            B = A + p;
            if (-p * (A * A * A * A + A * A * A * B + A * A * B * B + A * B * B * B + B * B * B * B) == X) {
                cout << A << " " << B << endl;
                return;
            }
        }
    }

}

signed main(signed argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

const int MAX_N = 200050;
bool isnp[200050];

signed main() {
    int x;
    cin >> x;

    isnp[0] = true;
    isnp[1] = true;
    rep(i, MAX_N) {
        if(isnp[i]) continue;
        int temp = i;
        while(temp+i <= MAX_N) {
            isnp[temp+i] = true;
            temp += i;
        }
    }

    FOR(i, x, MAX_N+1) {
        if(!isnp[i]) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
 
int main() {
	int k;
	string s;
	cin >> k >>  s;
	int l;
	l=s.size();
 
	if(l>k){
		for(int i=0;i<k;i++){
			cout << s[i];
		}
		cout << "..." << endl;
	}
	else cout << s << endl;
 
	return 0;
}

Measured memory_bytes: 3624
arr = gets.chomp.split('')
cen = arr.count / 2
left = arr.slice(0...cen).reverse
right = arr.count % 2 == 0 ? arr.slice(cen, arr.count) : arr.slice(cen + 1, arr.count)
diff = 0
(0...cen).each do |i|
  diff += 1 if left[i] != right[i]
end
puts diff

Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
 
int main() {
	static long long N, M, A[100010] = {};
	map<long long, long long, greater<long long> > mp;
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A, A + N);
	for (int i = 0; i < M; i++) {
		long long B, C;
		cin >> B >> C;
		mp[C] += B;
	}
	static long long X[100010] = {};
	int Count = 0;
	for (auto i = mp.begin(); i != mp.end(); i++) {
		for (int j = 0; j < i->second; j++) {
			X[Count] = i->first;
			Count++;
			if (Count == N) goto NEXT;
		}
	}
  NEXT:;
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		ans += max(A[i], X[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 8064
def reconstruct preorder, inorder
  root = preorder.shift
  unless root_idx = inorder.index(root)
    reconstruct(preorder,inorder)
    return
  end

  reconstruct(preorder,inorder[0...root_idx]) unless root_idx==0
  reconstruct(preorder,inorder[root_idx+1..-1]) unless root_idx==inorder.size-1
  $postorder << root
end

gets
Pre=gets.split.map &:to_i
In=gets.split.map &:to_i
$postorder=[]
reconstruct(Pre,In)
puts $postorder.join " "

Measured memory_bytes: 6112
#include<bits/stdc++.h>
#define ll int
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll>

using namespace :: std;

const ll maxn=1e6+500;
const ll mod=1e9+7;
const ll inf=1e9+500;

vector<ll> ger[maxn];
ll k;
ll kafek;
ll saghk;

pii dfs(ll a,ll p,ll H){
    pii ans=mp(0,0);
    if(H>kafek)
        ans.S++;
    if(H>saghk)
        ans.F++;

    for(auto v:ger[a]){
        if(v!=p){
            pii y=dfs(v,a,H+1);
            ans.F+=y.F;
            ans.S+=y.S;
        }
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n>>k;
    kafek=k/2;
    saghk=(k+1)/2;

    for(ll i=1;i<n;i++){
        ll v,u;
        cin>>v>>u;
        ger[u].pb(v);
        ger[v].pb(u);
    }
    ll ans=n-1;
    for(ll v=1;v<=n;v++){
        vector<pii> vec;
        for(auto u:ger[v]){
            vec.pb(dfs(u,v,1));
        }
        if(k&1){
            ll res=0;
            for(ll i=0;i<vec.size();i++){
                res+=vec[i].S;
            }
            ll mx=0;
            for(ll i=0;i<vec.size();i++){
                mx=max(mx,vec[i].S-vec[i].F);
            }
            ans=min(ans,res-mx);

        }else{
            ll res=0;
            for(ll i=0;i<vec.size();i++){
                res+=vec[i].F;
            }
            ans=min(ans,res);
        }
    }
    cout<<ans;
}


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

const int MAXN = 200005;

int K, N, a[MAXN];

int main(){
	scanf("%d %d", &K, &N);
	for(int i = 0; i < N; i++)
		scanf("%d", &a[i]);
	
	int res = K;
	for(int i = 0; i < N; i++){
		if(i == N - 1){
			res = min(res, a[N - 1] - a[0]);
		}else{
			res = min(res, K - (a[i + 1] - a[i]));
		}
	}
	printf("%d\n", res);
	
	return 0;
}


Measured memory_bytes: 1024
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

ll n,x,xi[200010],rui[500010];
ll ret;

int main(){
    LL(n); LL(x); REP(i,n) LL(xi[n-1-i]);
    REP(i,n) rui[i+1] = rui[i] + xi[i];
    FOR(i,n,n+300000) rui[i+1] = rui[i];
    ll col_cost = x*n;
    ret = LLONG_MAX;
    
    FOR(j,1,n+1){
        ll temp = j*x;
        REP(k,n/j+1){
            temp += (rui[j*(k+1)] - rui[j*k]) * (k ? 2*k+3 : 5);
            //cerr << j << " " << k << " " << temp << endl;
            if (temp < 0) break;
        }
        if (temp > 0 && ret > temp) ret = temp;
    }
    cout << ret + col_cost << endl;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        char[] c = s.toCharArray();
        
        boolean is7 = (c[0]=='7') ||(c[1]=='7') ||(c[2]=='7');
        System.out.println(is7 ? "Yes" : "No");

    }

}


Measured memory_bytes: 35728
#include<bits/stdc++.h>
using namespace std;
#define MN 200005
#define LL long long
#define mp make_pair
#define fir first
#define sec second
#define pii pair<int,int>
inline void chkmax(int &a,int b){if(a<b)a=b;}
inline void chkmin(int &a,int b){if(a>b)a=b;}
inline int read(){
	   int a=0,fh=1;char c=getchar();
	   while(c>'9'||c<'0'){if(c=='-')fh=-1;c=getchar();}
	   while('0'<=c&&c<='9'){
		   a=a*10+c-48;
		   c=getchar();
	   }
	   return a*fh;
}
char ch[MN];
int main(){
	scanf("%s",ch);
	if(ch[0]=='7'||ch[1]=='7'||ch[2]=='7')puts("Yes");
	else puts("No");
	return 0;
}

















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

int main()
{
	int K, N, a[100] = {0};

	cin >> N >> K;

	for (int i = 0; N > 0; i++) {
		if (i == K)i = 0;
		a[i]++;
		N--;
	}

	cout << a[0] - a[K - 1] << endl;

	return 0;
}

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

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

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

    vector<int> jud(n,0);
    vector<int> was(n,0);

    ll ACs = 0,WAs = 0;

    //1->AC 0-> WA
    int p;
    string S;
    for(int i=0;i<m;i++){
        cin>>p>>S;
        if(jud.at(p-1)==0){
            if(S=="WA"){
                was.at(p-1) ++;
            }else{
                ACs ++;
                jud.at(p-1) = 1;
            }
        }
    }

    rep(i,n){
        if(jud.at(i)==1) {
            WAs += was.at(i);
        }
    }

    cout<<ACs<<' '<<WAs<<endl;




}



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

int N;
int H[20];

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }
    int ans = 0;
    int maxh = 0;
    for (int i = 0; i < N; ++i) {
        if (maxh <= H[i]) {
            ++ans;
            maxh = H[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

const uint64_t base = 26;

std::pair<uint64_t, uint64_t> get_digits(uint64_t N){
  uint32_t d = 1;
  uint64_t a = base;
  while (a <= N)
  {
    N -= a;
    a *= base;
    d++;
  }
  return {a, N};
}

int main() {
  uint64_t N = 0;
  std::cin >> N;
  N--;

  auto data = get_digits(N);
  uint64_t d = data.first, val = data.second;
  d /= base;

  for (; d >= base; d/=base)
  {
    std::cout << (char)('a' + (val/d));
    val %= d;
  }

  std::cout << (char)('a' + (val%base)) << std::endl;

  return 0;
}

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

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

/*
  map<int, int> m;
  for( int i = 0; i < N; i++ ){
    m[ A.at(i) ] = i;
  }
*/
  vector< int > B(N);
  for( int i = 0; i < N; i++ ){
    B.at( A.at(i) - 1 ) = i;
  }
  
  cout << B.at(0) + 1;
  for( int i = 1; i < N; i++ ){
    cout << " ";
    cout << B.at(i) + 1;
  }
  
  //printf("%.10f", ans);

//  cout  << "OK";
  return 0;
}
  
      


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

tf=True
res=0
while tf:
    for i in range(n):
        if a[i]%2==0:

            #a[i]=a[i]//2
            a[i]//=2 
            
        else:
            tf = False
            break

    else:
        res+=1

print(res)


Measured memory_bytes: 2940
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        List<Integer> list = new ArrayList<>();
        for (int i=0; i < N; i++) {
            list.add(scanner.nextInt());
        }

        int abs = Integer.MAX_VALUE;
        for (int T=2; T<= 100; T++) {
            if (T >= list.size()) {
                break;
            }
            List<Integer> s1list = list.subList(0, T);
            List<Integer> s2list = list.subList(T, list.size());
            int s1 = s1list.stream().mapToInt(v -> v).sum();
            int s2 = s2list.stream().mapToInt(v -> v).sum();
            abs = Math.min(abs, Math.abs(s1 - s2));
        }
        System.out.println(abs);
    }
}


Measured memory_bytes: 27732
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

const int MOD=2019;
int L,R;

int main(){
    cin>>L>>R;

    int k=R-L+1;
    if(k>=2019){
        cout<<0<<endl;
        return 0;
    }

    int ans=MOD-1;
    for(int i=L;i<=R-1;i++){
        for(int j=i+1;j<=R;j++){
            if((i%MOD)*(j%MOD)%MOD<ans) ans=(i%MOD)*(j%MOD)%MOD;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {

	int n;
	cin >> n;
	vector<string> u(n);
	rep(i, n) cin >> u[i];
	int m;
	cin >> m;
	bool open = 0;
	rep(i, m){
		string t;
		cin >> t;
		bool exist = false;
		rep(i, n) if(t == u[i]) exist = true;
		if(!exist) cout << "Unknown " << t << endl;
		else{
			if(open) cout << "Closed by " << t << endl;
			else cout << "Opened by " << t << endl;
			open = !open;
		}
		
	}
	
	
	return 0;
}

Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
string t[3]={"Sunny","Cloudy","Rainy"};
int main(){
    string s;
    cin>>s;
    if(s==t[0])
        cout<<t[1]<<endl;
    else if(s==t[1])
        cout<<t[2]<<endl;
    else cout<<t[0]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int H = in(),W = in();
    vector<string> S(H);
    REP(i,H)S[i] = in<string>();
    vector<vector<int>> Bi(H,vector<int>(W));
    Bi[0][0] = (S[0][0] == '#' ? 1 : 0);
    REP(i,H){
        REP(j,W){
            if(i == 0){
                if(j != 0){
                    Bi[i][j] = Bi[i][j-1] + (S[i][j] == S[i][j-1] ? 0 : 1);
                }
            }else if(j == 0){
                Bi[i][j] = Bi[i-1][j] + (S[i][j] == S[i-1][j] ? 0 : 1);
            }else{
                Bi[i][j] = min(Bi[i][j-1] + (S[i][j] == S[i][j-1] ? 0 : 1),Bi[i-1][j] + (S[i][j] == S[i-1][j] ? 0 : 1));
            }
        }
    }
    if(S[0][0] == '.' &&S[H-1][W-1] == '.'){
        cout << Bi[H-1][W-1]/2 << "\n";
    }else if(S[0][0] == '&' &&S[H-1][W-1] == '&'){
        cout << Bi[H-1][W-1]/2 + 1<< "\n";
    }else{
        cout << (Bi[H-1][W-1]+1)/2<< "\n";
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
	int N;
	string S;

	cin >> N;
	cin >> S;

	int i;
	int Black = 0;
	int White = 0;
	vector<int> cnts(S.length());
	for (i=0; i<S.length(); i++) {
		if (S[i] == '#') {
			Black++;
		}
		else
			White++;
		cnts[i] = Black;
	}
	if (S.length() == 1) {
		cout << 0 << endl;
		return 0;
	}
	int cand1 = min(Black,White);
	int cand2 = 2000000000;

	for (i=0; i<S.length()-1; i++) {
		cand2 = min(cand2,2*cnts[i]+ White - (i+1));
	}
	cout << min(cand1,cand2) << endl;
	return 0;
}


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

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------
#define bitrep(i, n)     for(ll i=0; i<(ll) (1<<n); i++)
#define bis(i, j)        i & (1<<j)

int main(void) {
  string s;
  cin >> s;
  uniqueall(s);
  prt(s.size()-1);
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int N;
    cin >> N;
    vector<tuple<string,int,int>> SPN;
    for(int i = 0; i < N; i++){
        string s;
        int point;
        int num;
        cin >> s >> point;
        point = -point;
        num = i + 1;
        SPN.emplace_back(s, point, num);
    }
    sort(all(SPN));
    for(auto x : SPN){
        cout << get<2>(x) << endl;
    }
}


Measured memory_bytes: 3612
// O(nk)
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#define l first
#define r second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=200010;
const ll mod=998244353;
int n,k;
ll dp[N],pre[N];
pii a[N];
int main()
{
    IO;
    int minpos=1e9;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
    	cin>>a[i].l>>a[i].r;
    	minpos=min(minpos,a[i].l);
	}
    dp[1]=1;
    pre[1]=1;
    for(int i=1+minpos;i<=n;i++){
        for(int j=1;j<=k;j++){
        	//前缀和优化，应该dp是从i-a[j].r加到i-a[j].l 
        	dp[i]=(dp[i]+(pre[max(0,i-a[j].l)]-pre[max(0,i-a[j].r-1)]))%mod;
		}
        pre[i]=(pre[i-1]+dp[i])%mod;
    }
    cout<<(dp[n]+mod)%mod<<'\n';
    return 0;
}



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

int N;
vector<int> adj[100010], U, V, W;
int B[100010], cnt[16];

vector<int> subset[1 << 16];
int Xor[1 << 16];

int cc[1 << 16];
int dp(int mask) {
    if(mask == 0) return 0;
    int &ret = cc[mask];
    if(ret != -1) return ret;

    ret = 0;
    for(int i = 0; i < subset[mask].size(); i++) {
        if(Xor[ subset[mask][i] ] == 0) {
            ret = max(ret, 1 + dp(mask ^ subset[mask][i]));
        }
    }
    return ret;
}

int main() {
    subset[0].push_back(0);
    for(int i = 1; i < (1 << 16); i++) {
        for(int j = 0; j < subset[ i - (i & -i) ].size(); j++) {
            subset[i].push_back(subset[ i - (i & -i) ][j]);
            subset[i].push_back(subset[ i - (i & -i) ][j] + (i & -i));
        }
    }

    scanf("%d", &N);

    for(int i = 0; i < N - 1; i++) {
        int u, v, w; scanf("%d %d %d", &u, &v, &w);

        adj[u].push_back(U.size());
        adj[v].push_back(U.size());
        U.push_back(u);
        V.push_back(v);
        W.push_back(w);
    }

    for(int b = 0; b < 4; b++) {
        for(int u = 0; u < N; u++) {
            int tmp = 0;
            for(int i = 0; i < adj[u].size(); i++) {
                int e = adj[u][i];

                if(W[e] & (1 << b)) tmp++;
            }
            if(tmp % 2) B[u] |= (1 << b);
        }
    }

    for(int i = 0; i < N; i++) cnt[ B[i] ]++;

    int ans = cnt[0];
    int mask = 0;
    for(int i = 1; i <= 15; i++) {
        ans += cnt[i] / 2;
        if(cnt[i] % 2) mask ^= (1 << i);
    }

    for(int i = 0; i < (1 << 16); i++) {
        Xor[i] = 0;
        for(int j = 0; j < 16; j++) {
            if(i & (1 << j)) Xor[i] ^= j;
        }
    }

    memset(cc, -1, sizeof(cc));
    ans += dp(mask);
    printf("%d", N - ans);
}


Measured memory_bytes: 178928
#include <iostream>

using namespace std;


int main() {
  int h, w;
  cin >> h >> w;
  int dx[4] = {-1, 1, 0, 0};
  int dy[4] = {0, 0, -1, 1};
  char s[h][w];

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

  for (int i=0;i<h;i++) {
    for (int j=0;j<w;j++) {
      if (s[i][j] == '.') {
        continue;
      }

      bool found = false;
      for (int k=0;k<4; k++) {
        int nexti = i + dx[k];
        int nextj = j + dy[k];

        if (nexti >=0 && nexti < h && nextj >= 0 && nextj < w) {
          if (s[nexti][nextj] == '#') {
            found = true;
          }
        }
      }

      if (found == false) {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using ll = long long;
using namespace std;

void solve() {
   int n, m, x, y;
   cin >> n >> m;
   vector <int> ans(n);
   for(int i = 0; i < m; i++) {
      cin >> x >> y;
      ans[x - 1]++;
      ans[y - 1]++;
   }

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

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main()
{
	int a;
	scanf("%d",&a);
	long long int ans = 0;
	for(int i=1;i<a;i++)
	{
		int s = 1;
		int t = (a-1)/i;
		ans += (t-s+1);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1736
#include <algorithm>
#include <iostream>
using namespace std;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }
    sort(A, A+SIZE_OF_ARRAY(A));
    string ans="YES";
    for (int i=0; i<N-1; i++) {
        if (A[i] == A[i+1]) {
            ans = "NO";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

const int maxn = 1e3 + 5;
const int maxh = 2e4 + 5;
int dp[maxh];
int a[maxn], b[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	int n, h; cin >> h >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];
	int tmp = *max_element(a, a + n);
	for (int j = 1; j <= h + tmp; j++){
		dp[j] = 0x3f3f3f3f;
		for (int i = 1; i <= n; i++)
			if (j >= a[i]) dp[j] = min(dp[j], dp[j - a[i]] + b[i]);
	}
	cout << *min_element(dp + h, dp + h + tmp + 1);
	return 0;
}

Measured memory_bytes: 384
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
// #define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
  void solve()
  {
int k;
cin>>k;
  	map<int,int>mp;
int st=7;
for1(i,k+2)
{
if(st%k==0)
{
	cout<<i;
	return ;
}
if(mp[st])
{
cout<<"-1";
return ;
}
else
{
	mp[st]++;
	st=st*10+7;
	st%=k;
}
}
  }
  
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
    #endif
int t=1;
while(t--)
{
  solve();
}

    return 0;
  }


Measured memory_bytes: 50444
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

def swap(s,pos):
    s[pos]-=1
    s[pos+1]+=1
    print(s)
    if pos == n-2: return s
    if s[pos+2] == 0: swap(s,pos+1)
    return s

pl = 'abcdefghijklmnopqrstuvwxyz'

#n = ip()                              #入力整数1つ
#h,w= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
l = [pl[i] for i in range(26)]
for i in range(len(a)):
    if a[i] in l:
        p  = l.index(a[i])
        l.pop(p)
if len(l)==0:
    print("None")
else :
    print(l[0])


Measured memory_bytes: 14508
import sys
 
for i in sys.stdin:
    i = i.split(" ")
    x, y = int(i[0]), int(i[1])
    if x == y == 0:
       break
    elif x <= y:
       print("{0} {1}".format(x, y))
    else:
       print("{0} {1}".format(y, x))

Measured memory_bytes: 7732
# Maximum Sum Sequence
n = int(input())
while not n == 0:
    cnd = []
    cs = 0
    for _ in range(n):
        if cs < 0 : cs = 0
        cs += int(input())
        cnd.append(cs)
    print(max(cnd))
    try: n = int(input())
    except EOFError: break


Measured memory_bytes: 7704
#include<iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a > b) {
		cout << "a > b" << endl;
	}
	else if (a < b) {
		cout << "a < b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}
	return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;
import java.util.stream.Stream;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int[] i = Stream.of(S).mapToInt(Integer::parseInt).toArray();
    String ans = "unsafe";
    
    if(i[0] > i[1]){
      ans = "safe";
    }
    
    System.out.println(ans);
  }
}
    

Measured memory_bytes: 32572
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	cout << "#";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}

Measured memory_bytes: 1152
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
signed main(){
	int N;
	cin>>N;
	vint A;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.pb(a);
	}
	ll ans=1;
	int cnt[3]={-1, -1, -1};
	for(int i=0;i<N;i++){
		int a=A[i];

		ll temp=0;
		for(int j=0;j<3;j++){
			if(cnt[j]==a-1){
				temp++;
			}
		}
		(ans*=temp)%=MOD;
		//cout<<temp<<" "<<ans<<endl;
		for(int j=0;j<3;j++){
			if(cnt[j]==a-1){
				cnt[j]=a;
				break;
			}
		}
	}
	int temp=0;
	for(int i=0;i<3;i++)
		if(cnt[i]==-1)
			temp++;
	cout<<ans<<endl;
	/*
	if(temp==0)
		cout<<(ans*6)%MOD<<endl;
	else if(temp==1)
		cout<<(ans*6)%MOD<<endl;
	else if(temp==2)
		cout<<(ans*3)%MOD<<endl;
		*/
	return 0;
}



Measured memory_bytes: 892
import itertools
n = input()
lst = list("357")
cnt = 0
for i in range(3, len(n) + 1):
    for j in itertools.product(lst, repeat=i):
        if int("".join(j)) <= int(n) and "3" in j and "5" in j and "7" in j:
            cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <algorithm>

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

using namespace std;

int n;
vector<int> g[100];
int t = 1;
int p[100];
int q[100];

void dfs(int i){
	p[i] = t++;
	rep(j, g[i].size()){
		int v = g[i][j];
		if(!p[v]){
			dfs(v);
		}
	}
	q[i] = t++;
}

int main(){
	scanf("%d", &n);
	rep(i, n){
		int u, k;
		scanf("%d%d", &u, &k);
		rep(j, k){
			int v;
			scanf("%d", &v);
			g[u - 1].push_back(v - 1);
		}
	}
	rep(i, n){
		if(!p[i]){
			dfs(i);
		}
	}
	rep(i, n){
		printf("%d %d %d\n", i + 1, p[i], q[i]);
	}
	return 0;
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int)
using namespace std;
int a,b;
int main(){
	scanf("%d%d",&a,&b);
	printf("%d",(a-1)*(b-1));
	return 0;
}

Measured memory_bytes: 256
n, tl = map(int, input().split())
c = [0 for i in range(n)]
t = [0 for i in range(n)]
for i in range(n):
    c[i], t[i] = map(int, input().split())
sols = []
for i in range(n):
    if t[i] <= tl:
        sols.append(c[i])
    else:
        continue
if len(sols) == 0:
    print("TLE")
else:
    print(min(sols))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    for(int i=0;i<5;i++){
        cin>>n;
        if(n==0) {
            cout<<i+1<<endl;
            return 0;   
        }
    }
    
    
}


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

x,n = map(int,input().split())
L=list(map(int,input().split()))
if n==0:
    print(x)
    sys.exit()
if x not in L:
    print(x)
    sys.exit()
else:
    L.sort()
    for i in range(1,2*x):
        if x-i not in L:
            print(x-i)
            break
        if x+i not in L:
            print(x+i)
            break


        



Measured memory_bytes: 9036
def main():
    while True:
        line = input()
        if line == ".": break
        line = line.split()

        k_list = []
        for item in line:
            for j in item:
                if j == "(" or j == ")" or j == "[" or j == "]":
                    k_list.append(j)

        while True:
            bef = k_list.copy()
            k_list = rem_mk(k_list)
            k_list = rem_kk(k_list)
            aft = k_list.copy()
            
            if bef == aft: break

        if k_list == []: print("yes")
        else: print("no")

    return

def rem_mk(a):
    for i in range(len(a) - 1):
        if a[i] == "(" and a[i + 1] == ")":
            del a[i + 1]
            del a[i]
            return a
    return a
def rem_kk(a):
    for i in range(len(a) - 1):
        if a[i] == "[" and a[i + 1] == "]":
            del a[i + 1]
            del a[i]
            return a
    return a
main()



Measured memory_bytes: 5600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp69 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            string D = Console.ReadLine();

            int now = 0;
            int max = 0;

            for (int i = 0; i < N; i++) {
                if (D[i] == 'I') {
                    now++;
                } else {
                    now--;
                }

                max = Math.Max(max, now);
            }


            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 13140
n, m=gets.chomp.split(" ").map(&:to_i)
result = Array.new(n,0)
for i in 0..m-1
  pp, s = gets.chomp.split(" ")
  p = pp.to_i - 1
  if result[p] <= 0
    result[p] -= 1
    if s == "AC"
      result[p] = result[p] * -1
    end
  end
end

score = 0
wrong = 0
for i in 0..n-1
  r = result[i]
  if  r > 0
    score += 1
    wrong += r-1
  end
end

puts "#{score} #{wrong}"

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

using namespace std;

typedef pair<int, int> P_ii;
typedef pair<string, int> P_si;
typedef long long int ll;

const int MOD = 1000000007;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    printf("%d\n", min(a+b, min(a+c, b+c)));
    return 0;
}


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

#define ran 101101

int n;
char s[ran];

int main() {
	scanf("%d", &n);
	scanf("%s", s);
	
	int ans = 1;
	char c = s[0];
	for(int i=1;i<n;i++)
		if(s[i]!=c) {
			ans++;
			c = s[i];
		}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

class UnionFind{
public:
  vector<int> par;
  vector<int> rank;
  vector<int> sz;
  vector<int> bla;
  vector<int> whi;
  int N;

  UnionFind(int n){N=n;}

  //初期化
  void init(){
    for(int i=0;i<N;i++){
      par.push_back(i);
      rank.push_back(0);
      sz.push_back(1);
      bla.push_back(0);
      whi.push_back(0);
    }
  }

  //木の根を求める
  int find(int x){
    if(par[x]==x) return x;
    else{
      par[x]=find(par[x]);
      return par[x];
    }
  }

  //xとyの集合の併合
  void unite(int x, int y){
    x=find(x);
    y=find(y);
    if(x == y) return;

    if(rank[x] < rank[y]){
      par[x] = y;
      sz[y] += sz[x];
      bla[y] += bla[x];
      whi[y] += whi[x];
    }else{
      par[y] = x;
      sz[x] += sz[y];
      bla[x] += bla[y];
      whi[x] += whi[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  //x,yが同じ集合にあるか
  bool same(int x, int y){
    return find(x) == find(y);
  }

  //xの木のサイズ
  int size(int x){
    return sz[find(x)];
  }

};

//=======================================================

int dx[2] = {0,1};
int dy[2] = {1,0};

int main(){
  int H,W;
  cin >> H >> W;
  char s[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> s[i][j];
    }
  }

  UnionFind uf = UnionFind(H * W);
  uf.init();
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(s[i][j] == '#') uf.bla[i*W+j] = 1;
      else uf.whi[i*W+j] = 1;
    }
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      for(int k=0;k<2;k++){
        int nx = i + dx[k];
        int ny = j + dy[k];
        if(0 <= nx && nx < H && 0 <= ny && ny < W){
          if(s[i][j] != s[nx][ny]){
            uf.unite(i * W + j, nx * W + ny);
           }
        }
      }
    }
  }


  /*for(int i=0;i<H*W;i++){
    cout << uf.size(i);
    cout << uf.brack(i) << endl;
  }*/

  ll ans = 0LL;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      int p = i * W + j;
      if(p == uf.par[p]) ans += (ll)uf.bla[p] * (ll)uf.whi[p];
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3852
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            bool[] V = new bool[n];

            int s = A[0], result = 0;

            Dictionary<int, int> T = new Dictionary<int, int>();
            var temp = A.OrderBy(a => a).ToArray();
            for (int i = 0; i < n; i++)
            {
                if (s > A[i]) s = A[i];
                T[temp[i]] = i;
            }
            
            for (int i = 0; i < n; i++)
            {
                if (V[i]) continue;

                int cur = i, sum = 0;
                int min = A[cur], an = 0;

                while (!V[cur])
                {
                    V[cur] = true;
                    an++;

                    if (min > A[cur]) min = A[cur];
                    sum += A[cur];
                    cur = T[A[cur]];
                }
                result += Math.Min(sum + (an - 2) * min, min + sum + (an + 1) * s);
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 10340
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = (1LL<<40);
using namespace std;
ll exp(ll a , ll b){
	if(b == 0)	return 1;
	int x = b % 2 == 0 ?   ((exp(a , b/2)%mod)*(exp(a , b / 2)%mod))%mod :  (a%mod*exp(a , b - 1) % mod)%mod;
	return x;
}

int main(int argc,char ** argv){
	dhoom;
	int a , b , k;
	cin >> a >> b >> k;
	for(int i = a ; i <= min(b , a + k - 1) ; i++){
		cout << i << endl;
	}
	//cout << k << " " << b - a + 1 << endl;
	if(k >= b - a + 1)
		return 0;
	for(int i = max(a + k , b - k + 1) ; i <= b ; i++)
	{
		cout << i << endl;
	}
	return 0;
}


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

const int maxn=2005;

int n,a[2*maxn],L[2][2*maxn][maxn],R[2][2*maxn][maxn],pos[2][maxn];
char clr[2*maxn];

void ReadChar(char &ch)
{
    ch=getchar();
    while (ch!='B' && ch!='W') ch=getchar();
}

int invnum(int i,int j,int c)
{
    int w=pos[c][(c==0) ?i+1 :j+1];
    return R[0][w+1][i] + R[1][w+1][j];
}

int f[maxn][maxn];
int main()
{
    scanf("%d",&n);
    fo(i,1,2*n)
    {
        ReadChar(clr[i]);
        scanf("%d",&a[i]);
        pos[(clr[i]=='B')][a[i]]=i;
    }

    fo(i,1,2*n)
    {
        int ty=(clr[i]=='B');
        memcpy(L[ty^1][i],L[ty^1][i-1],sizeof(L[ty^1][i]));
        memcpy(L[ty][i],L[ty][i-1],sizeof(L[ty][i]));
        fo(j,a[i],n) L[ty][i][j]++;
    }
    fd(i,2*n,1)
    {
        int ty=(clr[i]=='B');
        memcpy(R[ty^1][i],R[ty^1][i+1],sizeof(R[ty^1][i]));
        memcpy(R[ty][i],R[ty][i+1],sizeof(R[ty][i]));
        fo(j,a[i],n) R[ty][i][j]++;
    }

    f[0][0]=0;
    fo(i,0,n)
        fo(j,0,n) if (i || j)
        {
            f[i][j]=n*n*20;
            if (i) f[i][j]=min(f[i][j],f[i-1][j]+invnum(i-1,j,0));
            if (j) f[i][j]=min(f[i][j],f[i][j-1]+invnum(i,j-1,1));
        }
    
    printf("%d\n",f[n][n]);
}

Measured memory_bytes: 141568