akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 21 10:40:39 2018
ABC078C
@author: maezawa
"""
import math
n, m = list(map(int, input().split()))

t = 100*(n-m)+1900*m
p = (1/2)**m
np = 1-p
pt = p*t

ex = 1
x = 1
i = 1
while True:
    x *= (i+1)/i * np
    ex += x
   #print(x,ex)
    if pt*x < 0.01:
        break
    i += 1
ans = math.ceil(pt*ex)
print(ans)

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

int x;

int main(){
    scanf("%d", &x);
    int ans = 0, p = 0;
    while(p < x){
        p += ++ans;
        if(p > x) p -= p-x;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   char c;
   cin >> c;
   if (c >= 'A' && c <= 'Z')
      cout << 'A' << endl;
   else
      cout << 'a' << endl;
   return 0;
}

Measured memory_bytes: 3648
rectArray = []

h, w = input().split()
h = int(h)
w = int(w)

while h != 0 and w != 0:
    rectArray.append([h, w])
    h, w = input().split()
    h = int(h)
    w = int(w)

for x in rectArray:
    for i in range(x[0]):
        for j in range(x[1]):
            if i == 0 or j == 0 or i == x[0] - 1 or j == x[1] - 1:
                print("#", end = '')
            else:
                 print(".", end ='')
        print("")
    print("")

Measured memory_bytes: 9044
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
#define sc(x) scanf("%d",&(x))
string mp[6];
bool check(int x)
{
  int t = 0;
  for(int i=0;i<n;i++){
    if((x>>i)&1)continue;
    for(int j=0;j<m;j++){
       if((x>>(j+n))&1)continue;
       if(mp[i][j] == '#')t++;
    }
  }
  return t == k;

}
int main()
{
  sc(n); sc(m); sc(k);
   for(int i=0;i<n;i++){
      cin>>mp[i];
   }
  int w = (1<<(n+m))-1;
  int ans = 0;
  //cout<<w<<endl;
  for(int i=0;i<=w;i++){
     if(check(i)){ans++;//cout<<i<<'\n';
     }
  }
  cout<<ans;
}


Measured memory_bytes: 3728
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
int N, Y;
int main(void) {
  cin >> N >> Y;
  int count = 0;
  for (int man = 0; man <= N; man++) {
    for (int gosen = 0; gosen <= N - man; gosen++) {
      int diff = Y - 10000 * man - 5000 * gosen;
      if (diff < 0) continue;
      int sen = N - man - gosen;
      if (diff == sen * 1000) {
        cout << man << ' ' << gosen << ' ' << sen << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i,n)cin >> b[i];
    int ans[110];
    int cnt = 0;
    int z = n;
    while(1){
        int x = cnt;
        for(int i = z;i >= 1;i--){
            if(b[i-1] == i){
                b.erase(b.begin()+i-1);
                ans[n-1-cnt] = i;
                cnt++;
                z--;
                break;
            }
        }
        if(cnt == n)break;
        if(cnt == x){
            cout << -1 << endl;
            return 0;
        }
    }
    rep(i,n)cout << ans[i] << endl;


    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d
// rm -r -f test;oj dl http://agc032.contest.atcoder.jp/tasks/agc032_a

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] p = new int[m];
        int[] y = new int[m];
        //Map<Integer, Integer> ymap = new HashMap<>();
        Map<Integer, Integer> map = new TreeMap<>();
        for(int i=0; i<m; i++) {
            p[i] = Integer.parseInt(sc.next());
            y[i] = Integer.parseInt(sc.next());
            //ymap.put(y[i], p[i]);
            map.put(y[i], i);
        }

        int[] num = new int[m];
        int[] parr = new int[n];
        /*
        for(int key : map.keySet()) {
            int pre = ymap.get(key);
            parr[pre-1]++;
            num[map.get(key)] = parr[pre-1];
        }
        */
        for(int key : map.keySet()) {
            int pre = p[map.get(key)];
            parr[pre-1]++;
            num[map.get(key)] = parr[pre-1];
        }
        
        for(int i=0; i<m; i++) {
            String s = String.format("%06d", p[i])+String.format("%06d", num[i]);
            System.out.println(s);
        }
    }
}

Measured memory_bytes: 134352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll> 
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

void print_vec(const lvector v) {
  for(auto i:v) cout << i << " ";
  cout << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w,k;cin>>h>>w>>k;
  string s;
  lvector yoko(w,0);vector<lvector> c(h,yoko);
  vector<lvector> ans(c);
  rep(i,h) {
    cin>>s;
    rep(j,w) if(s[j]=='#') c[i][j]=1;
  }
  ll num=1;
  for(ll tate=0;tate<h;tate++) {
    lvector yoko_=c[tate];
    ll sum_of_yoko=accumulate(ALL(yoko_),0);
    if(sum_of_yoko==0) continue;
    ll pos=0,pos_prev=0,yoko_cnt=0;
    while(pos<w) {
      ans[tate][pos]=num;
      if(yoko_[pos]==1&&yoko_cnt<sum_of_yoko-1) {num++;yoko_cnt++;}
      pos++;
    }
    num++;
  }
  ll cnt=0;
  for(ll i=0;i<h;++i) {
    if(accumulate(ALL(ans[i]),0)==0) cnt++;
    else {
      if(cnt>0) {
        for(ll tate=i-cnt;tate<i;++tate) rep(j,w) ans[tate][j]=ans[i][j];
        cnt=0;
      }
    }
  }
  if(cnt>0) for(ll tate=h-cnt;tate<h;++tate) rep(j,w) ans[tate][j]=ans[h-cnt-1][j];
  for(lvector i:ans) print_vec(i);
  return 0;
}

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

fn main(){
    let mut hm: HashMap<&str, u32> = HashMap::new();
    hm.insert("AC", 0);
    hm.insert("WA", 0);
    hm.insert("TLE", 0);
    hm.insert("RE", 0);
        
    let n: usize = read();
    let vs: Vec<String> = (0..n).map(|_| read()).collect();

    vs.iter().for_each(|s|{let x = hm.entry(s).or_insert(0); *x += 1;});
    
    for s in vec!["AC", "WA", "TLE", "RE"] {
        println!("{} x {}", s, hm[s]);
    }
    
}

#[allow(dead_code)]
fn read<T>() -> T
where T: std::str::FromStr,
      T::Err: std::fmt::Debug
{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).expect("failed to read");
    buf.trim().parse().unwrap()
}


Measured memory_bytes: 7560
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord
import Data.Maybe


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    [n,m] <- r' :: IO [Int]
    sc <- nub <$> replicateM m (r' >>= (\[s,c] -> return (s,c)))
    let r = tr $ sl (replicate n Nothing) sc
    print $ if length (show r) == n
        then r
        else if r /= -1 && lookup 1 sc /= Just 0 then r + 10^(n-1) else (-1)

sl :: [Maybe Int] -> [(Int,Int)] -> Maybe [Int]
sl xs [] = Just $ map (fromMaybe 0) xs
sl xs ((s,c):sc) = case xs!!(s-1) of
    Nothing -> sl (take (s-1) xs ++ Just c:drop s xs) sc
    Just _  -> Nothing
tr :: Maybe [Int] -> Int
tr Nothing = -1
tr (Just xs) = sum $ zipWith (*) [10^x | x<-[0..]] (reverse xs)



Measured memory_bytes: 380
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<vector>

using namespace std;

int main()
{
	int n;
	cin>>n;
	
	vector<int> a(n+1);
	
	for(int i=1;i<n+1;i++)
	{
		cin>>a[i];
	}
	
	vector< pair<int,int> > data[n+1];
	vector<int> dist(n+1,1000000000);
	
	dist[1]=0;
	
	for(int i=1;i<n-1;i++)
	{
		data[i].push_back({i+1,fabs(a[i+1]-a[i])});
		data[i].push_back({i+2,fabs(a[i+2]-a[i])});
	}
	
	data[n-1].push_back({n,fabs(a[n-1]-a[n])});
	
	multiset< pair<int,int> > s;
	
	s.insert({0,1});
	
	while(!s.empty())
	{
		pair<int,int> p=*s.begin();
		int ver=p.second;
		s.erase(s.begin());
		
		for(int i=0;i<data[ver].size();i++)
		{
			int v=data[ver][i].first;
			int d=data[ver][i].second;
			
			if(dist[ver]+d<dist[v])
			{
				dist[v]=d+dist[ver];
				s.insert({dist[v],v});
			}
		}
	}
	
	cout<<dist[n];
	
	return 0;
}


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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int n, r, k;
    cin >> n>>r;
    if(n >= 10)
        k = r;
    else
        k = r+(100*(10 - n));
    cout <<k <<endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,m,a,b;
    cin >> n >> m;
    int A[n][m];
    int B[m];
    int answer;
    
    for(int i = 0; i < n; i++){ //A行列に値を入れる
        for(int j=0 ; j < m; j++){
            cin >> a;
            A[i][j] = a;
        }
    }
    
    for(int k = 0; k < m; k++){//ｂ行列に要素を入れている。
        cin >> b;
        B[k] = b;
    }
    
    
    for(int l = 0; l < n; l++){
        
        for(int p = 0; p< m ; p++){
            answer += A[l][p] * B[p];
        }
        cout << answer << endl;
        answer = 0;
    }
    
    
    return 0;
}


Measured memory_bytes: 3144
#include<iostream>
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
using namespace std;
typedef long long ll;

ll gcd(ll m, ll n){
    if (n==0){
        return m;
    }
    else{
        return gcd(n, m%n);
    }
}

ll f(ll x, ll c, ll d){
    ll c_div=x/c;
    ll d_div=x/d;
    ll cd_div=x/((c*d)/gcd(c, d));
    return x-(c_div+d_div-cd_div);
}

int main(void){
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    ll ans=f(b, c, d)-f(a-1, c, d);
    cout<<ans<<endl;

}

Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString.Char8 as B
import Data.Attoparsec.ByteString.Char8

type Input = B.ByteString

input :: Parser B.ByteString
input = takeTill isSpace

main :: IO ()
main = B.interact
  $ B.pack . show . either (error "parse err") solve . parseOnly input

solve :: Input -> Int
solve xs = 2 * (ts `min` fs)
  where
    ts = B.length $ B.filter (== '1') xs
    fs = B.length $ B.filter (== '0') xs

Measured memory_bytes: 892
K, N = [int(x) for x in input().split()]
A_list = [int(x) for x in input().split()]

max_distance = 0
max_distance_idx = 0
for i in range(0, N-1):
  dist = A_list[i+1]-A_list[i]
  if max_distance < dist:
    max_distance = dist
    max_distance_idx = i

if max_distance <= (K-A_list[N-1]) + (A_list[0]):
  print(A_list[N-1] - A_list[0])
else:
  print((A_list[max_distance_idx]) + (K-A_list[max_distance_idx+1]))

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

int k, t;

int tab[1000007];

int gdz[1000007];

int wyn;

int main()
{
    scanf("%d%d", &k, &t);
    for (int i=1; i<=t; i++)
        scanf("%d", &tab[i]);
    sort(tab+1, tab+1+t);
    reverse(tab+1, tab+1+t);
    for (int i=1; tab[1] && i<=k; i+=2)
    {
        tab[1]--;
        gdz[i]=1;
    }
    if (k&1)
    {
        for (int i=2; tab[1] && i<=k; i+=2)
        {
            tab[1]--;
            gdz[i]=1;
        }
    }
    else
    {
        for (int i=k; tab[1] && i>0; i-=2)
        {
            tab[1]--;
            gdz[i]=1;
        }
    }
    for (int i=1; i<=k; i++)
        wyn+=gdz[i]*gdz[i-1];
    printf("%d\n", wyn);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2]) cout << "Yes" << endl;
    else if (s[1] == s[2] && s[2] == s[3]) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}


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

int main() {

  int a,b,c,x;
  cin >> a >> b >> c >> x;
  //cout << a << b << c << x<<endl;
  int count = 0;
  for(int i=0 ;i<=a && 500*i <= x ; i++){
    for(int j=0 ;j<=b && 500*i + 100*j <= x ; j++){
      for(int k=0 ;k<=c && 500*i + 100*j + 50*k <= x ; k++){
	if( 500*i + 100*j + 50*k == x){
	  //cout << "Record "<<i<<","<<j<<","<<k<<endl;
	  count++;
	}
      }
    }
  }

  cout << count << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K;
    cin >> K;
    cout << A[K-1] << "\n";
}


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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans;
int N;

void solve(){
    cout << 180 * (N - 2) << endl;
}

int main(){
    cin >> N;

    solve();
}


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

    int count = 0;
    int tmp = 1;
    while(count < N){
        tmp = a.at(tmp - 1);
        count++;
        if (tmp == 2){
            break;
        }
    }

    if(tmp == 2){
        cout << count << endl;
    }
    else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt(), m = scan.nextInt(), l = scan.nextInt();
        long[][] a = new long[n][m], b = new long[m][l], c = new long[n][l];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                a[i][j] = scan.nextInt();
            }
        }

        for (int i = 0; i < m; i++) {
            for (int j = 0; j < l; j++) {
                b[i][j] = scan.nextInt();
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                long sum = 0;
                for (int k = 0; k < m; k++) {
                    sum += a[i][k] * b[k][j];
                }
                c[i][j] = sum;
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                if (j == l -1) {
                    System.out.print(c[i][j]);
                } else {
                    System.out.print(c[i][j] + " ");
                }
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 53236
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const int MAX_N = 1e5 + 10;
ll dp[MAX_N];
ll h[MAX_N];

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    for(int i = 0; i < n; i ++) {
        cin >> h[i];
    }
    fill_n(dp, MAX_N, mod * mod);
    dp[0] = 0;
    for(int i = 1; i < n; i ++) {
        if(i > 1) {
            chkmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
        chkmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}




Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int d = in.nextInt();
		int g = in.nextInt();
		int[] p = new int[d];
		int[] c = new int[d];
		for(int i=0;i<d;i++) {
			p[i] = in.nextInt();
			c[i] = in.nextInt();
		}
		int[] pmax = new int[d];
		for(int i=0;i<d;i++) {
			pmax[i] = 100*(i+1)*p[i] + c[i];
		}
		
		int ans = Integer.MAX_VALUE;
		for(int i=0;i<(1<<d);i++) {
			int sump = 0;
			int sumpmax = 0;
			int highest = -1;
			int digit = 0;
			while(digit<d) {
				if(((i>>digit)&1)==1) {
					sump += p[digit];
					sumpmax += pmax[digit];
				}else {
					highest = digit;
				}
				digit++;
			}
			int plus = 0;
			while(sumpmax<g && plus<p[highest]-1) {
				plus++;
				sumpmax += 100*(highest+1);
			}
			if(sumpmax>=g) {
				ans = Math.min(ans, sump+plus);
			}
		}
		
		System.out.println(ans);
		
		
	}

}


Measured memory_bytes: 23764
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		int n = sc.nextInt();long sum = 0;
		for(int i = 1; i <= n; i++) {
			if(i % 3 == 0 || i % 5 == 0 || i % 15 == 0)
				continue;
			sum += i;
		}
		System.out.println(sum);
	}

	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}

}

Measured memory_bytes: 32880
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int Vmax = 8;

int graph[Vmax][Vmax];
bool visited[Vmax];

int dfs(int v, int N) {
    
    int all_visited = 1;
    rep(i, N) {
        if(!visited[i]) {
            all_visited = 0;
        }
    }

    if(all_visited) {
        return 1;
    }

    int cnt = 0;
    rep(i, N) {
        
        if(!graph[v][i] || visited[i]) {
            continue;
        }

        visited[i] = true;

        cnt += dfs(i, N);

        visited[i] = false;
    }

    return cnt;
}

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

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        graph[a][b] = graph[b][a] = 1;
    }

    rep(i, n) {
        visited[i] = false;
    }
    visited[0] = true;

    cout << dfs(0, n) << endl;
    return 0;
}

Measured memory_bytes: 256
// AOJ 1203
#include<iostream>
#include<string>
#include<sstream>
#include<set>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

const int LMAX = 1500;
int R[2 * LMAX];
string S;

string erase_space(string s, char target) {
  stringstream ss;
  for (char c : s)
    if (c != target)
      ss << c;
  return ss.str();
}

void init() {
  string T;
  for (char c : S) {
    if (isalpha(c)) {
      T.push_back('/');
      T.push_back(toupper(c));
    }
  }
  S = (T.empty() ? "" : T.substr(1));
  REP(i, S.size()) {
    R[i] = 0;
  }
}

void palindrome() {
  int i = 0, j = 0;
  while (i < S.size()) {
    while (i-j >= 0 && i+j < S.size() && S[i-j] == S[i+j]) ++j;
    R[i] = j;
    int k = 1;
    while (i-k >= 0 && i+k < S.size() && k+R[i-k] < j) 
      R[i+k] = R[i-k], ++k;
    i += k; j -= k;
  }
}

void show() {
  int n = S.size();
  set<string> ok, ng;
  stringstream ss;
  REP(i, n) {
    string s = erase_space(S.substr(i-R[i]+1,R[i]*2-1), '/');
    if (s.size() > 2) { ok.insert(s); }
    while (s.size() > 2) {
      s = s.substr(1,s.size()-2);
      ng.insert(s);
    }
  }
  for (string s : ok) {
    if (ng.find(s) == ng.end()) {
      ss << ' ' << s;
    }
  }
  string out = ss.str();
  cout << (out.empty() ? "" : out.substr(1)) << endl;
}

int main() {
  while (getline(cin,S)) {
    init();
    palindrome();
    show();
  }
}

Measured memory_bytes: 1248
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

int ans[200] ;
int a[200] ;
int n , m ;

int main ()
{
	int i , j ;
	scanf("%d",&n),m=n;
	for ( i=1 ; i<=n ; i++ ) scanf("%d",a+i);
	for ( i=1 ; i<=n ; i++ ) 
	{
		int flag=0 ;
		for ( j=n ; j>=1 ; j-- ) 
			if ( j==a[j] ) { flag=1; break; }
		if ( !flag ) { puts("-1"); return 0 ; }
		ans[i]=j;
		for ( j=j ; j<=n ; j++ ) a[j]=a[j+1];
	}
	for ( i=m ; i>=1 ; i-- ) printf("%d\n",ans[i]);
	return 0 ;
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

const int kFacMax = 2000000;

long long fac[kFacMax];
long long finv[kFacMax];
long long inv[kFacMax];

void combi_prepare(int mod)
{
  fac[0] = 1;
  fac[1] = 1;
  finv[0] = 1;
  finv[1] = 1;
  inv[1] = 1;

  for (int i = 2; i < kFacMax; i++)
  {
    fac[i] = fac[i - 1] * i % mod;
    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}

long long combi(long long n, long long k, long long mod)
{
  if (n < 0 || k < 0 || n < k)
    return 0;

  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

long long mod_pow(long long a, long long n, long long mod)
{
  long long pow = 1;

  while (n > 0)
  {
    if (n & 1)
      pow = pow * a % mod;

    a = a * a % mod;
    n = n >> 1;
  }

  return pow;
}

int main()
{
  const int MOD = 1000000007;

  combi_prepare(MOD);

  long long K;
  cin >> K;

  string S;
  cin >> S;

  long long sum = 0;
  for (long long i = 0; i <= K; i++)
  {
    long long left = combi(S.size() - 1 + i, S.size() - 1, MOD) * mod_pow(25, i, MOD) % MOD;
    long long right = mod_pow(26, K - i, MOD);
    sum += left * right % MOD;
    sum %= MOD;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 52196
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (ll)1e9+7
#define LLINF (ll)1e30
// #define int ll
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,dp[1010][1010]={};
    vector<string> a;
    cin>>h>>w;
    a.resize(h);
    rep(i,h) cin>>a[i];
    dp[0][0]=1;
    rep(i,h){
        rep(j,w){
            if(i+1<h && a[i][j]=='.'){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %=MOD;
            }
            if(j+1<w && a[i][j]=='.'){
                dp[i][j+1]  += dp[i][j];
                dp[i][j+1] %=MOD;
            }
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}

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

int main(){
    char m[1000];
    int s[1000];
    scanf("%s",m);
    for(int i=0;i<1000;i++){
        if(m[i]=='\0')break;
        if(m[i]=='A' || m[i]=='B' || m[i]=='C'){
            s[i]=m[i];
            s[i]+=26;
            m[i]=s[i];
        }
        s[i]=m[i];
        s[i]-=3;
        m[i]=s[i];
    }
    printf("%s\n",m);
    return 0;
}

Measured memory_bytes: 952
n,d = map(int,input().split())
x=[[0]*d]*n
for i in range(n):
    x[i] = [int(j) for j in input().split()]

squares=[i**2 for i in range(200)]
ans=0
for i in range(n):
    for j in range(i+1,n):
#        print(i,j)
        dist = sum((x[i][m]-x[j][m])**2 for m in range(d)) 
        if dist in squares: ans+=1
#        print(dist)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;



int main() {
    int n, count[100005] = {}, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a <= 100000) count[a]++;
        else ans++;
    }
    for (int i = 0; i <= 100000; i++) {
        if (count[i] > i) ans += count[i] - i;
        else if (count[i] < i) ans += count[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    char a;
    cin >> a;
    if (IN('A', 'Z' + 1, a)) cout << "A\n";
    else cout << "a\n";

    return 0;
}



Measured memory_bytes: 3600
# frozen_string_literal: true

# Builtin if ruby was 2.4 or above.
module Enumerable
  def sum(init = 0, &block)
    target = block_given? ? map(&block) : self
    target.reduce(init, :+)
  end
end

x, y, _a, _b, _c = gets.chomp.split(' ').map(&:to_i)
reds = gets.chomp.split(' ').map(&:to_i).sort.reverse
greens = gets.chomp.split(' ').map(&:to_i).sort.reverse
whites = gets.chomp.split(' ').map(&:to_i).sort.reverse

red_candidates = reds.take(x)
green_candidates = greens.take(y)
candidates = (red_candidates + green_candidates).sort.reverse

total = whites.reduce(candidates.sum) do |acm, white|
  popped = candidates.pop
  break acm if popped.nil? || white <= popped

  acm + white - popped
end

puts total


Measured memory_bytes: 30548
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, T;
	cin >> N >> T;

	Int ans = INF;

	Int c, t;
	for (Int i = 0; i < N; i++) {
		cin >> c >> t;
		if (t <= T) {
			ans = min(ans, c);
		}
	}

	if (ans == INF) {
		cout << "TLE" << "\n";
	}
	else {
		cout << ans << "\n";

	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef gp_hash_table<int, null_type,hash<int>, equal_to<int>, direct_mask_range_hashing<int>, linear_probe_fn<>,
    hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>,true>> hash_set;
typedef gp_hash_table<int,null_type> hash_map;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 100005

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

const ld PI = (ld)4*atanl(1);

mt19937 g1(chrono::steady_clock::now().time_since_epoch().count());

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int len,A[MAXN],B[MAXN];
deque<pii> v;

int main(){
    scanf("%d",&len);
    for(int i=1; i<=len; i++)
        scanf(" %d",&A[i]);
    for(int i=1; i<=len; i++){
        scanf(" %d",&B[i]);
        v.pb(mp(A[i]-B[i],i));
    }
    sort(all(v));
    ll ss = 0;
    for(int i=1; i<=len; i++) ss+=A[i];
    for(int i=1; i<=len; i++) ss-=B[i];
    if(ss < 0) return 0*printf("-1\n");
    bool lst = false;
    while(v.size() && v[0].first < 0){
        while(v[0].first < 0){
            int tk = min(-v[0].first,v.back().first);
            v[0].first+=tk, v.back().first-=tk;
            lst = true;
            if(v.back().first == 0){
                v.pop_back();
                lst = false;
            }
        }
        if(v.size()) v.pop_front();
    }
    if(lst) v.pop_back();
    printf("%d\n",len-(int)v.size());
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
//#include <math.h>
using namespace std;
int main(){
	int k,a,b,i;
	cin>>k>>a>>b;
	for (i=a; i<=b; ++i)
	{
		if(i%k==0)
		{
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
}

Measured memory_bytes: 3636
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;

#define ull unsigned long long
#define ll long long
#define PI 3.141592654

int module(int num){
	if(num > 0){
		return num%26;
	}	
	while(abs(num)>26)num +=26;
	return 26+num;
}

vector<string> that(string line){
	vector<string> word;
	int b = 0;
	string tmp = "";
	while(line[b] != 0){
		if(line[b] == ' '){
			word.push_back(tmp);
			tmp = "";
		}else{
			tmp += line[b];
		}
		b++;
	}

	if(tmp.size() > 0)word.push_back(tmp);
	vector<string> res;

	for(int x=0;x<word.size();++x){
		if(word[x].size()==4)res.push_back(word[x]);
	}
	return res;
}

int inv(int a){
	for(int x=1;x<26;++x){
		if((a*x)%26 == 1)return x;
	}
	return -1;
}

string solve(string org,int a,int b){
	string ret = "";
	for(int x=0;x<org.size();++x){
		if(org[x] == ' '){
			ret += " ";
		}else{
	//		cout<<a<<"#"<<inv(a)<<endl;
			ret += 'a' + (inv(a)*module(org[x]-b-'a'))%26;
		}
	}
	return ret;
}

int main(){
	int n;
	string line;
	while(getline(cin,line)){
		sscanf(line.c_str(),"%d",&n);
		for(int i=0;i<n;++i){
		 	getline(cin,line);
			vector<string> cand = that(line);
			bool flag = true;
			for(int c=0;c<cand.size() && flag;++c){
				for(int a=1;a<26 && flag;a+=2){
					int b = module(cand[c][0]-'a'-a*('t'-'a'));	
					string rta = solve(line,a,b);
	//				cout<<a<<":"<<b<<endl;
	//				cout<<rta<<endl;	
					if(rta.find("that")!=string::npos || rta.find("this")!=string::npos){
						cout<<rta<<endl;
						flag = false;
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1248
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll flag = 0;
    string S;
    in >> S;
    //vector<ll> X(N);

    REP(i, 50){
        
        if(S[2*i] == 'L'){
            flag = 1;
            break;
        }
        if(S[2*i+1] == 'R'){
            flag = 1;
            break;
        }
        
    }
    if(flag == 1){
        out << "No" << endl;
    }else{
        out << "Yes" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){

    string a;
    cin >> a ;
    long long sum = 0;
    
    for(int i = 0; i < a.size(); i++){
        sum += a.at(i) - '0';
    }

    if(sum % 9 == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 3720
#include<stdio.h>
int main(){
 int N[4][14]={0};
 char O[53];
 int A[53];
 int n,i,j,k;

 scanf("%d",&n);

 for(i=1;i<=n+1;i++){
   scanf("%c %d\n",&O[i],&A[i]);
 
  switch(O[i]){
   case 'S':
   N[0][A[i]]=A[i];
   break;

   case 'H':
   N[1][A[i]]=A[i];
   break;

   case 'C':
   N[2][A[i]]=A[i];
   break;

   case 'D':
   N[3][A[i]]=A[i];
   break;
  }
 }

  for(j=0;j<=3;j++){
  
   switch(j){
    case 0:
     for(k=1;k<=13;k++){
      if(N[j][k]==0){
      printf("%c %d\n",'S',k);
    }
   }
   break;

    case 1:
     for(k=1;k<=13;k++){
      if(N[j][k]==0){
      printf("%c %d\n",'H',k);
    }
   }
   break;

    case 2:
     for(k=1;k<=13;k++){
      if(N[j][k]==0){
      printf("%c %d\n",'C',k);
    }
   }
   break;

    case 3:
     for(k=1;k<=13;k++){
      if(N[j][k]==0){
      printf("%c %d\n",'D',k);
    }
   }
   break;

  }

}

return 0;
}

Measured memory_bytes: 600
N = int(input())
An = map(int, input().split())

total = 0
minim = 1000000000
num_negs = 0

for a in An:
    is_neg = int(a < 0)
    num_negs += is_neg
    a *= (is_neg * -2 + 1)
    total += a
    minim = minim if minim < a else a
    pass

if num_negs % 2:
    print(total - 2*minim)
else:
    print(total)
    pass


Measured memory_bytes: 11212
#include <iostream>
#include<math.h>
#include <algorithm>
#include<string>
using namespace std;

int main() {
        int N;
        int a[2][110];
        int Ans=0;

        cin >> N;
        for(int i=0; i<N; i++) cin >> a[0][i];
        for(int i=0; i<N; i++) cin >> a[1][i];

        for(int i=0; i<N; i++){
                int Sum = 0;
                for(int j=0; j<=i; j++) Sum+=a[0][j];
                for(int j=i; j<N; j++) Sum+=a[1][j];
                Ans=max(Ans,Sum);
        }
        cout << Ans << endl;
        return 0;
}

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

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

const int MAXN = 1e5 + 5;

struct edge {
	int a, b, c;
	void input() {
		scanf("%d%d%d", &a, &b, &c);
	}
	bool operator <(const edge &rhs) const {
		return c < rhs.c;
	}
};

int N, M;
set <pii> adj[MAXN];
int x[MAXN];
edge e[MAXN];
bool ok[MAXN], taken[MAXN];
int dad[MAXN], rnk[MAXN];
ll sum[MAXN];
bool bio[MAXN];

void load() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= N; i++)
		scanf("%d", x + i);
	for (int i = 0; i < M; i++)
		e[i].input();		
}

int find(int x) {
	return dad[x] == x ? x : dad[x] = find(dad[x]);
}

void join(int u, int v) {
	u = find(u);
	v = find(v);
	if (u == v)
		return;
	if (rnk[u] > rnk[v])
		swap(u, v);
	dad[u] = v;
	rnk[v] += rnk[u] == rnk[v];
	sum[v] += sum[u];
}

void dfs(int x) {
	bio[x] = true;
	for (auto it : adj[x]) {
		ok[it.second] = true;
		if (!bio[it.first]) 
			dfs(it.first);
	}
}

int solve() {
	sort(e, e + M);
	
	for (int i = 1; i <= N; i++) {
		dad[i] = i;
		sum[i] = x[i];
	}
	
	int ptr = 0;
	for (int i = 0; i < M; ) {
		for (; ptr < M && e[ptr].c == e[i].c; ptr++)
			join(e[ptr].a, e[ptr].b);
		for (int j = i; j < ptr; j++)
			taken[j] = sum[find(e[j].a)] < e[j].c;
		i = ptr;
	}
	
	for (int i = 0; i < M; i++) {
		adj[e[i].a].insert({e[i].b, i});
		adj[e[i].b].insert({e[i].a, i});
	}
	
	int sol = 0;
	for (int i = M - 1; i >= 0; i--) {
		if (ok[i])
			continue;
		if (taken[i]) {
			adj[e[i].a].erase({e[i].b, i});
			adj[e[i].b].erase({e[i].a, i});
			sol++;
			continue;
		}
		dfs(e[i].a);
	}
	
	return sol;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

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

using namespace std;

#define FOR(i,s,e) for(int i=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;
const int INF = 1e4;
const int H = 50;
const int W = 50;
int h, w;
int b[H][W], d[H][W];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main() {
  fscanf(stdin, "%d%d ", &h, &w);
  int res = h*w;
  REP(i,h) {
    string s; cin >> s;
    REP(j,w) {
      if (s[j] == '.') b[i][j] = 1;
      else res--;
    }
  }
  REP(i,h) REP(j,w) d[i][j] = INF;
  d[0][0] = 0;
  queue<tuple<int,int>> q;
  q.push(mt(0,0));
  while (q.size()) {
    tuple<int,int> t = q.front(); q.pop();
    int y = t0(t), x = t1(t);
    if (y == h-1 && x == w-1) break;
    REP(i,4) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny < 0 || ny >= h) continue;
      if (nx < 0 || nx >= w) continue;
      if (!b[ny][nx]) continue;
      if (d[ny][nx] <= d[y][x] + 1) continue;
      d[ny][nx] = d[y][x] + 1;
      q.push(mt(ny,nx));
    }
  }
  if (d[h-1][w-1] == INF)
    res = -1;
  else
    res -= d[h-1][w-1] + 1;
  fprintf(stdout, "%d\n", res);
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
avg = 0
for i in range(N):
	avg+=a[i]
avg=avg/len(a)
min = 100
ans = 0
for i in range(N):
	if min > abs(avg - a[i]):
		ans = i
		min = abs(avg - a[i])
print(ans)

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

/*** MOD CALCULATION ***/

const int MOD = 1e9+7;
// const int MOD = 998244353;
const int MAX = 2'000'005;

ll addM(ll a, ll b){
	return ((a % MOD) + (b % MOD)) % MOD;
}

ll mulM(ll a, ll b){
	return ((a % MOD) * (b % MOD)) % MOD;
}

ll powM(ll a, ll b){
	if(b == 0) return 1;
  	else if(b == 1) return a % MOD;
  	else if(b%2==0) return mulM(powM(a, b/2), powM(a, b/2));
  	else return mulM(a, mulM(powM(a, (b-1)/2), powM(a, (b-1)/2)));
}

// b^{-1} = b^{p-2} (mod p)
// a/b = a*b^{p-2} (mod p)
ll divM(ll a, ll b){ 
  	return mulM(a, powM(b, MOD-2));
}

// n!, (n!)^{-1} のテーブル作成
ll fac[MAX], finv[MAX], inv[MAX];
void COMBinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    rep3(i,2,MAX-1){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COMB(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

/*** MOD CALCULATION ここまで ***/

int n, k;
vvi to;
ll ans;

void dfs(int v = 0, int p = -1, int depth = 0){
    int color = k-1;
    if(depth >= 1) color--;
    for(auto u : to[v]){
        if(u == p) continue;
        ans = mulM(ans, color);
        // cout << p << "->" << v << ": " << color << " " << ans << endl;
        color--;
        dfs(u, v, depth+1);
    }
}

void Main(){
    cin >> n >> k;
    to.resize(n);
    rep(i, n-1){
        int a, b; cin >> a >> b; a--; b--;
        to[a].pb(b);
        to[b].pb(a);
    }
    ans = k;
    dfs();
    cout << ans << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 14448
while True:
    H, W = map(int, input().split())
    
    if H==0 and W==0 :
        break
    
    print('#'*W)
    for i in range(H-2):
        print('#',end='')
        print('.'*(W-2),end='')
        print('#')
    print('#'*W)
    print('')


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 600010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
vector<pi> G[MAX_N];
vector<int> id[MAX_N];
vector<int> color[MAX_N];
int A[MAX_N], B[MAX_N], C[MAX_N];

int d[MAX_N];

void solve() {
	cin >> N >> M;
	rep(i, 0, M) {
		cin >> A[i] >> B[i] >> C[i]; A[i]--; B[i]--;
		color[A[i]].pb(C[i]);
		color[B[i]].pb(C[i]);
	}
	int cid = N;
	rep(i, 0, N) {
		sort(all(color[i]));
		color[i].erase(unique(all(color[i])), color[i].end());
		id[i].resize(sz(color[i]));
		rep(j, 0, sz(color[i])) {
			id[i][j] = cid++;
		}
	}
	rep(i, 0, M) {
		int aat = lower_bound(all(color[A[i]]), C[i]) - color[A[i]].begin();
		int bat = lower_bound(all(color[B[i]]), C[i]) - color[B[i]].begin();
		int aid = id[A[i]][aat], bid = id[B[i]][bat];
		G[aid].pb(pi(bid, 0));
		G[bid].pb(pi(aid, 0));
	}
	rep(i, 0, N) {
		rep(j, 0, sz(id[i])) {
			int nid = id[i][j];
			G[nid].pb(pi(i, 0));
			G[i].pb(pi(nid, 1));
		}
	}
	priority_queue<pi, vector<pi>, greater<pi>> que;
	rep(i, 0, N + 2 * M) d[i] = inf;
	que.push(pi(0, 0));
	d[0] = 0;
	while(!que.empty()) {
		pi p = que.top(); que.pop();
		int v = p.sec;
		if(p.fst != d[v]) continue;
		rep(i, 0, sz(G[v])) {
			int n = G[v][i].fst, cost = G[v][i].sec;
			if(d[n] > d[v] + cost) {
				d[n] = d[v] + cost;
				que.push(pi(d[n], n));
			}
		}
	}
	if(d[N - 1] == inf) cout << -1 << "\n";
	else cout << d[N - 1] << "\n";
}


int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 79040
import java.util.*;

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

    String w = sc.next();

    String ans = "Yes";
    for (int i = 0; i < w.length(); i++) {
      String a = w.substring(i, i + 1);
      int cnt = 0;
      for (int j = 0; j < w.length(); j++) {
        String b = w.substring(j, j + 1);
        if (a.equals(b)) cnt++;
      }
      if (cnt % 2 != 0) {
        ans = "No";
        break;
      }
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 21460